zoukankan      html  css  js  c++  java
  • 关于修改zeppelin的代码显示

    最近我在修改zeppelin(0.7版本)的源码相关的知识,目前做的工作是修改zeppelin的代码,为了让zeppelin可以可以在页面中显示数据集,并且在其数据库中存储式真实的路径1.如果我们要运行paragraph的代码的时候,我们要修改

    我们要修改NotebookServer.setParagraphUsingMessage(Note note, Message fromMessage, String paragraphId, String text, String title, Map<String, Object> params, Map<String, Object> config)方法,
    目的让你在zeppelin上面写数据集但是存储在zeppelin的代码里面是真实路径
    代码:

    Paragraph p = note.getParagraph(paragraphId);
    //修改text的值
    if(text != null){
    if(text.contains("#mydata")){
    text = text.replaceAll("#mydata","/tmp/xjdx.txt");
    }
    }
    p.setText(text);
    p.setTitle(title);
    AuthenticationInfo subject =
    new AuthenticationInfo(fromMessage.principal, fromMessage.ticket);
    p.setAuthenticationInfo(subject);
    p.settings.setParams(params);
    p.setConfig(config);

    return p;

    -----------------------------------------------------------

    修改页面或者换其他的notebook

    private void updateParagraph(NotebookSocket conn, HashSet<String> userAndRoles,
    Notebook notebook, Message fromMessage) throws IOException {
    LOG.info("----------------------------------updateParagraph-------------------------------");
    String paragraphId = (String) fromMessage.get("id");
    if (paragraphId == null) {
    return;
    }

    Map<String, Object> params = (Map<String, Object>) fromMessage.get("params");
    Map<String, Object> config = (Map<String, Object>) fromMessage.get("config");
    String noteId = getOpenNoteId(conn);
    final Note note = notebook.getNote(noteId);
    NotebookAuthorization notebookAuthorization = notebook.getNotebookAuthorization();
    AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
    if (!notebookAuthorization.isWriter(noteId, userAndRoles)) {
    permissionError(conn, "write", fromMessage.principal, userAndRoles,
    notebookAuthorization.getWriters(noteId));
    return;
    }

    Paragraph p = note.getParagraph(paragraphId);

    if (note.isPersonalizedMode()) {
    p = p.getUserParagraphMap().get(subject.getUser());
    }

    p.settings.setParams(params);
    p.setConfig(config);
    p.setTitle((String) fromMessage.get("title"));

    // p.setText((String) fromMessage.get("paragraph"));
    //修改text的值
    String myText = (String) fromMessage.get("paragraph");
    if(myText != null){
    if(myText.contains("#mydata")){
    myText = myText.replaceAll("#mydata","/tmp/xjdx.txt");
    }
    }
    p.setText(myText);


    note.persist(subject);

    if (note.isPersonalizedMode()) {
    Map<String, Paragraph> userParagraphMap =
    note.getParagraph(paragraphId).getUserParagraphMap();
    broadcastParagraphs(userParagraphMap, p);
    } else {
    broadcastParagraph(note, p);
    }
    }

    ------------------------------------------------------------

    整体刷新页面或者是换notebook的显示模式

    private void sendNote(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook,
    Message fromMessage) throws IOException {

    LOG.info("New operation from {} : {} : {} : {} : {}", conn.getRequest().getRemoteAddr(),
    conn.getRequest().getRemotePort(), fromMessage.principal, fromMessage.op,
    fromMessage.get("id"));

    String noteId = (String) fromMessage.get("id");
    if (noteId == null) {
    return;
    }

    String user = fromMessage.principal;

    Note note = notebook.getNote(noteId);
    NotebookAuthorization notebookAuthorization = notebook.getNotebookAuthorization();
    if (note != null) {
    if (!notebookAuthorization.isReader(noteId, userAndRoles)) {
    permissionError(conn, "read", fromMessage.principal, userAndRoles,
    notebookAuthorization.getReaders(noteId));
    return;
    }
    addConnectionToNote(note.getId(), conn);

    if (note.isPersonalizedMode()) {
    note = note.getUserNote(user);
    }

    String msg2 = serializeMessage(new Message(OP.NOTE).put("note", note));
    Message message2 = deserializeMessage(msg2);

    Map note2 = message2.getType("note");
    if (note2 != null) {
    List<Map> paragraphs2 = (List<Map>)note2.get("paragraphs");
    for (Map m : paragraphs2) {
    String text2 = (String)m.get("text");
    if(text2 != null){
    if(text2.contains("/tmp/xjdx.txt")){
    text2 = text2.replaceAll("/tmp/xjdx.txt","#mydata");
    }
    }
    m.put("text", text2);
    }
    }
    conn.send(serializeMessage(message2));
    sendAllAngularObjects(note, user, conn);
    } else {
    conn.send(serializeMessage(new Message(OP.NOTE).put("note", null)));
    }
    }

    ------------------------------------------------------

    旁边的一些辅助功能以及run后面的访问流程,例如copy以及showline的方法

    public void broadcastParagraph(Note note, Paragraph p) {
    Paragraph p2 = p;
    if (p.settings != null) {
    //clone()方法
    p2 = p.cloneParagraphForUser(p.getId());

    String text = p2.getText();
    if (text != null) {
    if (text.contains("/tmp/xjdx.txt")) {
    text = text.replaceAll("/tmp/xjdx.txt", "#mydata");
    p2.setText(text);
    }
    }
    }
    if (note.isPersonalizedMode()) {
    broadcastParagraphs(p.getUserParagraphMap(), p2);
    } else {
    broadcast(note.getId(), new Message(OP.PARAGRAPH).put("paragraph", p2));
    }
    }

  • 相关阅读:
    docker 介绍,安装,镜像操作, docker换源
    go语言5 接口, 并发与并行, go协程, 信道, 缓冲信道, 异常处理, python进程线程
    [编织消息框架]目录
    2017总结
    赚钱方法[信息红利]
    面单 全单 单板 批发吉他民谣 知乎 百度知道 百度贴吧 吉他批发
    看第三部杀破狼感想
    海豚极货店 淘宝店开张啦
    我上头条了
    尤克里里 ukulele 单板 非kaka tom uma
  • 原文地址:https://www.cnblogs.com/wnbahmbb/p/6426458.html
Copyright © 2011-2022 走看看