use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method inlineBroadcastParagraphs.
private void inlineBroadcastParagraphs(Map<String, Paragraph> userParagraphMap, String msgId) {
if (null != userParagraphMap) {
for (String user : userParagraphMap.keySet()) {
Message message = new Message(OP.PARAGRAPH).withMsgId(msgId).put("paragraph", userParagraphMap.get(user));
connectionManager.multicastToUser(user, message);
}
}
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method sendMessage.
@ManagedOperation
public void sendMessage(String message) {
Message m = new Message(OP.NOTICE);
m.data.put("notice", message);
connectionManager.broadcast(m);
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method broadcastSpellExecution.
private void broadcastSpellExecution(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
String noteId = connectionManager.getAssociatedNoteId(conn);
getNotebookService().spell(noteId, fromMessage, context, new WebSocketServiceCallback<Paragraph>(conn) {
@Override
public void onSuccess(Paragraph p, ServiceContext context) throws IOException {
super.onSuccess(p, context);
// broadcast to other clients only
connectionManager.broadcastExcept(p.getNote().getId(), new Message(OP.RUN_PARAGRAPH_USING_SPELL).put("paragraph", p), conn);
}
});
}
use of org.apache.zeppelin.common.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) {
try {
getNotebook().processNote(noteId, note -> {
if (note != null) {
Paragraph paragraph = note.getParagraph(paragraphId);
if (paragraph != null) {
InterpreterSetting setting = getNotebook().getInterpreterSettingManager().get(interpreterSettingId);
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());
getNotebook().saveNote(note, AuthenticationInfo.ANONYMOUS);
connectionManager.broadcast(note.getId(), new Message(OP.PARAS_INFO).put("id", paragraphId).put("infos", paragraph.getRuntimeInfos()));
}
}
return null;
});
} catch (IOException e) {
LOG.warn("Fail to call onParaInfosReceived", e);
}
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method updateNote.
private void updateNote(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
String noteId = (String) fromMessage.get("id");
String name = (String) fromMessage.get("name");
Map<String, Object> config = (Map<String, Object>) fromMessage.get("config");
if (noteId == null) {
return;
}
if (config == null) {
return;
}
getNotebookService().updateNote(noteId, name, config, context, new WebSocketServiceCallback<Note>(conn) {
@Override
public void onSuccess(Note note, ServiceContext context) throws IOException {
connectionManager.broadcast(note.getId(), new Message(OP.NOTE_UPDATED).put("name", name).put("config", config).put("info", note.getInfo()));
broadcastNoteList(context.getAutheInfo(), context.getUserAndRoles());
}
});
}
Aggregations