use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.
the class NotebookServer method completion.
private void completion(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
String paragraphId = (String) fromMessage.get("id");
String buffer = (String) fromMessage.get("buf");
int cursor = (int) Double.parseDouble(fromMessage.get("cursor").toString());
Message resp = new Message(OP.COMPLETION_LIST).put("id", paragraphId);
if (paragraphId == null) {
conn.send(serializeMessage(resp));
return;
}
final Note note = notebook.getNote(getOpenNoteId(conn));
List<InterpreterCompletion> candidates = note.completion(paragraphId, buffer, cursor);
resp.put("completions", candidates);
conn.send(serializeMessage(resp));
}
use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.
the class NotebookServer method onRemove.
@Override
public void onRemove(String interpreterGroupId, String name, String noteId, String paragraphId) {
Notebook notebook = notebook();
List<Note> notes = notebook.getAllNotes();
for (Note note : notes) {
if (noteId != null && !note.getId().equals(noteId)) {
continue;
}
List<String> settingIds = notebook.getInterpreterSettingManager().getInterpreters(note.getId());
for (String id : settingIds) {
if (interpreterGroupId.contains(id)) {
broadcast(note.getId(), new Message(OP.ANGULAR_OBJECT_REMOVE).put("name", name).put("noteId", noteId).put("paragraphId", paragraphId));
break;
}
}
}
}
use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.
the class NotebookServer method clearParagraphRuntimeInfo.
public void clearParagraphRuntimeInfo(InterpreterSetting setting) {
Map<String, Set<String>> noteIdAndParaMap = setting.getNoteIdAndParaMap();
if (noteIdAndParaMap != null && !noteIdAndParaMap.isEmpty()) {
for (String noteId : noteIdAndParaMap.keySet()) {
Set<String> paraIdSet = noteIdAndParaMap.get(noteId);
if (paraIdSet != null && !paraIdSet.isEmpty()) {
for (String paraId : paraIdSet) {
Note note = notebook().getNote(noteId);
if (note != null) {
Paragraph paragraph = note.getParagraph(paraId);
if (paragraph != null) {
paragraph.clearRuntimeInfo(setting.getId());
broadcast(noteId, new Message(OP.PARAGRAPH).put("paragraph", paragraph));
}
}
}
}
}
}
setting.clearNoteIdAndParaMap();
}
use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.
the class NotebookServer method onLoad.
@Override
public void onLoad(String noteId, String paragraphId, String appId, HeliumPackage pkg) {
Message msg = new Message(OP.APP_LOAD).put("noteId", noteId).put("paragraphId", paragraphId).put("appId", appId).put("pkg", pkg);
broadcast(noteId, msg);
}
use of org.apache.zeppelin.notebook.socket.Message in project zeppelin by apache.
the class NotebookServer method broadcastReloadedNoteList.
public void broadcastReloadedNoteList(AuthenticationInfo subject, HashSet userAndRoles) {
if (subject == null) {
subject = new AuthenticationInfo(StringUtils.EMPTY);
}
//reload and reply first to requesting user
List<Map<String, String>> notesInfo = generateNotesInfo(true, subject, userAndRoles);
multicastToUser(subject.getUser(), new Message(OP.NOTES_INFO).put("notes", notesInfo));
//to others afterwards
broadcastNoteListExcept(notesInfo, subject);
}
Aggregations