Search in sources :

Example 11 with Message

use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.

the class NotebookServer method broadcastUpdateNoteJobInfo.

public void broadcastUpdateNoteJobInfo(long lastUpdateUnixTime) throws IOException {
    List<Map<String, Object>> noteJobs = new LinkedList<>();
    Notebook notebookObject = notebook();
    List<Map<String, Object>> jobNotes = null;
    if (notebookObject != null) {
        jobNotes = notebook().getJobListByUnixTime(false, lastUpdateUnixTime, null);
        noteJobs = jobNotes == null ? noteJobs : jobNotes;
    }
    Map<String, Object> response = new HashMap<>();
    response.put("lastResponseUnixTime", System.currentTimeMillis());
    response.put("jobs", noteJobs != null ? noteJobs : new LinkedList<>());
    broadcast(JOB_MANAGER_SERVICE.JOB_MANAGER_PAGE.getKey(), new Message(OP.LIST_UPDATE_NOTE_JOBS).put("noteRunningJobs", response));
}
Also used : Notebook(org.apache.zeppelin.notebook.Notebook) InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) Message(org.apache.zeppelin.notebook.socket.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) AngularObject(org.apache.zeppelin.display.AngularObject) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedList(java.util.LinkedList)

Example 12 with Message

use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.

the class NotebookServer method permissionError.

void permissionError(NotebookSocket conn, String op, String userName, Set<String> userAndRoles, Set<String> allowed) throws IOException {
    LOG.info("Cannot {}. Connection readers {}. Allowed readers {}", op, userAndRoles, allowed);
    conn.send(serializeMessage(new Message(OP.AUTH_INFO).put("info", "Insufficient privileges to " + op + " note.\n\n" + "Allowed users or roles: " + allowed.toString() + "\n\n" + "But the user " + userName + " belongs to: " + userAndRoles.toString())));
}
Also used : InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) Message(org.apache.zeppelin.notebook.socket.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage)

Example 13 with Message

use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.

the class NotebookServer method moveParagraph.

private void moveParagraph(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
    final String paragraphId = (String) fromMessage.get("id");
    if (paragraphId == null) {
        return;
    }
    final int newIndex = (int) Double.parseDouble(fromMessage.get("index").toString());
    String noteId = getOpenNoteId(conn);
    final Note note = notebook.getNote(noteId);
    if (!hasParagraphWriterPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, "write")) {
        return;
    }
    AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
    note.moveParagraph(paragraphId, newIndex);
    note.persist(subject);
    broadcast(note.getId(), new Message(OP.PARAGRAPH_MOVED).put("id", paragraphId).put("index", newIndex));
}
Also used : InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) Message(org.apache.zeppelin.notebook.socket.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage) Note(org.apache.zeppelin.notebook.Note) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo)

Example 14 with Message

use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.

the class NotebookServer method onParaInfosReceived.

@Override
public void onParaInfosReceived(String noteId, String paragraphId, String interpreterSettingId, Map<String, String> metaInfos) {
    Note note = notebook().getNote(noteId);
    if (note != null) {
        Paragraph paragraph = note.getParagraph(paragraphId);
        if (paragraph != null) {
            InterpreterSetting setting = notebook().getInterpreterSettingManager().get(interpreterSettingId);
            setting.addNoteToPara(noteId, paragraphId);
            String label = metaInfos.get("label");
            String tooltip = metaInfos.get("tooltip");
            List<String> keysToRemove = Arrays.asList("noteId", "paraId", "label", "tooltip");
            for (String removeKey : keysToRemove) {
                metaInfos.remove(removeKey);
            }
            paragraph.updateRuntimeInfos(label, tooltip, metaInfos, setting.getGroup(), setting.getId());
            broadcast(note.getId(), new Message(OP.PARAS_INFO).put("id", paragraphId).put("infos", paragraph.getRuntimeInfos()));
        }
    }
}
Also used : InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) Message(org.apache.zeppelin.notebook.socket.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage) Note(org.apache.zeppelin.notebook.Note) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) Paragraph(org.apache.zeppelin.notebook.Paragraph)

Example 15 with Message

use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.

the class NotebookServer method onStatusChange.

@Override
public void onStatusChange(String noteId, String paragraphId, String appId, String status) {
    Message msg = new Message(OP.APP_STATUS_CHANGE).put("noteId", noteId).put("paragraphId", paragraphId).put("appId", appId).put("status", status);
    broadcast(noteId, msg);
}
Also used : InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) Message(org.apache.zeppelin.notebook.socket.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage)

Aggregations

Message (org.apache.zeppelin.notebook.socket.Message)51 InterpreterResultMessage (org.apache.zeppelin.interpreter.InterpreterResultMessage)38 WatcherMessage (org.apache.zeppelin.notebook.socket.WatcherMessage)38 Note (org.apache.zeppelin.notebook.Note)24 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)14 AngularObject (org.apache.zeppelin.display.AngularObject)9 Paragraph (org.apache.zeppelin.notebook.Paragraph)9 Test (org.junit.Test)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)8 Notebook (org.apache.zeppelin.notebook.Notebook)8 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)7 RemoteAngularObjectRegistry (org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry)6 JsonObject (com.google.gson.JsonObject)5 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)5 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)4 ZeppelinhubMessage (org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.protocol.ZeppelinhubMessage)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)3 WebSocketClient (org.eclipse.jetty.websocket.client.WebSocketClient)3