Search in sources :

Example 1 with Message

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

the class NotebookServer method broadcastSpellExecution.

private void broadcastSpellExecution(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
    final String paragraphId = (String) fromMessage.get("id");
    if (paragraphId == null) {
        return;
    }
    String noteId = getOpenNoteId(conn);
    if (!hasParagraphWriterPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, "write")) {
        return;
    }
    String text = (String) fromMessage.get("paragraph");
    String title = (String) fromMessage.get("title");
    Status status = Status.valueOf((String) fromMessage.get("status"));
    Map<String, Object> params = (Map<String, Object>) fromMessage.get("params");
    Map<String, Object> config = (Map<String, Object>) fromMessage.get("config");
    final Note note = notebook.getNote(noteId);
    Paragraph p = setParagraphUsingMessage(note, fromMessage, paragraphId, text, title, params, config);
    p.setResult(fromMessage.get("results"));
    p.setErrorMessage((String) fromMessage.get("errorMessage"));
    p.setStatusWithoutNotification(status);
    addNewParagraphIfLastParagraphIsExecuted(note, p);
    if (!persistNoteWithAuthInfo(conn, note, p)) {
        return;
    }
    // broadcast to other clients only
    broadcastExcept(note.getId(), new Message(OP.RUN_PARAGRAPH_USING_SPELL).put("paragraph", p), conn);
}
Also used : Status(org.apache.zeppelin.scheduler.Job.Status) 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) JsonObject(com.google.gson.JsonObject) AngularObject(org.apache.zeppelin.display.AngularObject) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Paragraph(org.apache.zeppelin.notebook.Paragraph)

Example 2 with Message

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

the class NotebookServer method checkpointNote.

private void checkpointNote(NotebookSocket conn, Notebook notebook, Message fromMessage) throws IOException {
    String noteId = (String) fromMessage.get("noteId");
    String commitMessage = (String) fromMessage.get("commitMessage");
    AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
    Revision revision = notebook.checkpointNote(noteId, commitMessage, subject);
    if (!Revision.isEmpty(revision)) {
        List<Revision> revisions = notebook.listRevisionHistory(noteId, subject);
        conn.send(serializeMessage(new Message(OP.LIST_REVISION_HISTORY).put("revisionList", revisions)));
    } else {
        conn.send(serializeMessage(new Message(OP.ERROR_INFO).put("info", "Couldn't checkpoint note revision: possibly storage doesn't support versioning. " + "Please check the logs for more details.")));
    }
}
Also used : Revision(org.apache.zeppelin.notebook.repo.NotebookRepo.Revision) InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) Message(org.apache.zeppelin.notebook.socket.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo)

Example 3 with Message

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

the class NotebookServer method listRevisionHistory.

private void listRevisionHistory(NotebookSocket conn, Notebook notebook, Message fromMessage) throws IOException {
    String noteId = (String) fromMessage.get("noteId");
    AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
    List<Revision> revisions = notebook.listRevisionHistory(noteId, subject);
    conn.send(serializeMessage(new Message(OP.LIST_REVISION_HISTORY).put("revisionList", revisions)));
}
Also used : Revision(org.apache.zeppelin.notebook.repo.NotebookRepo.Revision) InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) Message(org.apache.zeppelin.notebook.socket.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo)

Example 4 with Message

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

the class NotebookServer method removeAngularFromRemoteRegistry.

private void removeAngularFromRemoteRegistry(String noteId, String paragraphId, String varName, RemoteAngularObjectRegistry remoteRegistry, String interpreterGroupId, NotebookSocket conn) {
    final AngularObject ao = remoteRegistry.removeAndNotifyRemoteProcess(varName, noteId, paragraphId);
    this.broadcastExcept(noteId, new Message(OP.ANGULAR_OBJECT_REMOVE).put("angularObject", ao).put("interpreterGroupId", interpreterGroupId).put("noteId", noteId).put("paragraphId", paragraphId), conn);
}
Also used : InterpreterResultMessage(org.apache.zeppelin.interpreter.InterpreterResultMessage) Message(org.apache.zeppelin.notebook.socket.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage) AngularObject(org.apache.zeppelin.display.AngularObject)

Example 5 with Message

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

the class NotebookServer method setNoteRevision.

private void setNoteRevision(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
    String noteId = (String) fromMessage.get("noteId");
    String revisionId = (String) fromMessage.get("revisionId");
    AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
    if (!hasParagraphWriterPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, "update")) {
        return;
    }
    Note headNote = null;
    boolean setRevisionStatus;
    try {
        headNote = notebook.setNoteRevision(noteId, revisionId, subject);
        setRevisionStatus = headNote != null;
    } catch (Exception e) {
        setRevisionStatus = false;
        LOG.error("Failed to set given note revision", e);
    }
    if (setRevisionStatus) {
        notebook.loadNoteFromRepo(noteId, subject);
    }
    conn.send(serializeMessage(new Message(OP.SET_NOTE_REVISION).put("status", setRevisionStatus)));
    if (setRevisionStatus) {
        Note reloadedNote = notebook.getNote(headNote.getId());
        broadcastNote(reloadedNote);
    } else {
        conn.send(serializeMessage(new Message(OP.ERROR_INFO).put("info", "Couldn't set note to the given revision. " + "Please check the logs for more details.")));
    }
}
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) URISyntaxException(java.net.URISyntaxException) FileSystemException(org.apache.commons.vfs2.FileSystemException) ForbiddenException(org.apache.zeppelin.rest.exception.ForbiddenException) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

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