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);
}
}
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;
}
});
}
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));
}
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);
}
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);
}
}
}
Aggregations