Search in sources :

Example 36 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class ConnectionManager method unicastParagraph.

public void unicastParagraph(Note note, Paragraph p, String user, String msgId) {
    if (!note.isPersonalizedMode() || p == null || user == null) {
        return;
    }
    if (!userSocketMap.containsKey(user)) {
        LOGGER.warn("Failed to send unicast. user {} that is not in connections map", user);
        return;
    }
    for (NotebookSocket conn : userSocketMap.get(user)) {
        Message m = new Message(Message.OP.PARAGRAPH).withMsgId(msgId).put("paragraph", p);
        unicast(m, conn);
    }
}
Also used : Message(org.apache.zeppelin.common.Message) WatcherMessage(org.apache.zeppelin.notebook.socket.WatcherMessage)

Example 37 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class NotebookServer method convertNote.

protected void convertNote(NotebookSocket conn, Message fromMessage) throws IOException {
    String noteId = fromMessage.get("noteId").toString();
    getNotebook().processNote(noteId, note -> {
        if (note == null) {
            throw new IOException("No such note: " + noteId);
        } else {
            Message resp = new Message(OP.CONVERTED_NOTE_NBFORMAT).put("nbformat", new JupyterUtil().getNbformat(note.toJson())).put("noteName", fromMessage.get("noteName"));
            conn.send(serializeMessage(resp));
            return null;
        }
    });
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message) JupyterUtil(org.apache.zeppelin.jupyter.JupyterUtil) IOException(java.io.IOException)

Example 38 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class NotebookServer method broadcastNoteForms.

private void broadcastNoteForms(Note note) {
    GUI formsSettings = new GUI();
    formsSettings.setForms(note.getNoteForms());
    formsSettings.setParams(note.getNoteParams());
    connectionManager.broadcast(note.getId(), new Message(OP.SAVE_NOTE_FORMS).put("formsData", formsSettings));
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message) GUI(org.apache.zeppelin.display.GUI)

Example 39 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class NotebookServer method inlineBroadcastNote.

private void inlineBroadcastNote(Note note) {
    Message message = new Message(OP.NOTE).put("note", note);
    connectionManager.broadcast(note.getId(), message);
}
Also used : OnMessage(javax.websocket.OnMessage) ClusterMessage(org.apache.zeppelin.cluster.event.ClusterMessage) Message(org.apache.zeppelin.common.Message)

Example 40 with Message

use of org.apache.zeppelin.common.Message in project zeppelin by apache.

the class NotebookServerTest method testImportNotebook.

@Test
public void testImportNotebook() throws IOException {
    String msg = "{\"op\":\"IMPORT_NOTE\",\"data\":" + "{\"note\":{\"paragraphs\": [{\"text\": \"Test " + "paragraphs import\"," + "\"progressUpdateIntervalMs\":500," + "\"config\":{},\"settings\":{}}]," + "\"name\": \"Test Zeppelin notebook import\",\"config\": " + "{}}}}";
    Message messageReceived = notebookServer.deserializeMessage(msg);
    String noteId = null;
    ServiceContext context = new ServiceContext(AuthenticationInfo.ANONYMOUS, new HashSet<>());
    try {
        try {
            noteId = notebookServer.importNote(null, context, messageReceived);
        } catch (NullPointerException e) {
            // broadcastNoteList(); failed nothing to worry.
            LOG.error("Exception in NotebookServerTest while testImportNotebook, failed nothing to " + "worry ", e);
        }
        notebook.processNote(noteId, note -> {
            assertNotNull(note);
            assertEquals("Test Zeppelin notebook import", note.getName());
            assertEquals("Test paragraphs import", note.getParagraphs().get(0).getText());
            return null;
        });
    } finally {
        if (noteId != null) {
            notebook.removeNote(noteId, anonymous);
        }
    }
}
Also used : Message(org.apache.zeppelin.common.Message) ServiceContext(org.apache.zeppelin.service.ServiceContext) Mockito.anyString(org.mockito.Mockito.anyString) Test(org.junit.Test)

Aggregations

Message (org.apache.zeppelin.common.Message)49 OnMessage (javax.websocket.OnMessage)31 ClusterMessage (org.apache.zeppelin.cluster.event.ClusterMessage)31 IOException (java.io.IOException)18 ServiceContext (org.apache.zeppelin.service.ServiceContext)18 Paragraph (org.apache.zeppelin.notebook.Paragraph)12 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 AngularObject (org.apache.zeppelin.display.AngularObject)10 Test (org.junit.Test)10 Mockito.anyString (org.mockito.Mockito.anyString)10 UnknownHostException (java.net.UnknownHostException)8 TException (org.apache.thrift.TException)8 ServiceException (org.apache.zeppelin.interpreter.thrift.ServiceException)8 Note (org.apache.zeppelin.notebook.Note)8 RemoteAngularObjectRegistry (org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry)7 HashMap (java.util.HashMap)6 List (java.util.List)6 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)6