use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method saveInterpreterBindings.
public void saveInterpreterBindings(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
List<InterpreterSettingsList> settingList = new ArrayList<>();
String noteId = (String) fromMessage.data.get("noteId");
// use write lock, because defaultInterpreterGroup is overwritten
getNotebook().processNote(noteId, note -> {
if (note != null) {
List<String> settingIdList = gson.fromJson(String.valueOf(fromMessage.data.get("selectedSettingIds")), new TypeToken<ArrayList<String>>() {
}.getType());
if (!settingIdList.isEmpty()) {
note.setDefaultInterpreterGroup(settingIdList.get(0));
getNotebook().saveNote(note, context.getAutheInfo());
}
List<InterpreterSetting> bindedSettings = note.getBindedInterpreterSettings(new ArrayList<>(context.getUserAndRoles()));
for (InterpreterSetting setting : bindedSettings) {
settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
}
}
return null;
});
conn.send(serializeMessage(new Message(OP.INTERPRETER_BINDINGS).put("interpreterBindings", settingList)));
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method updateNoteAngularObject.
private void updateNoteAngularObject(String noteId, AngularObject angularObject, String interpreterGroupId) throws IOException {
List<InterpreterSetting> intpSettings = getNotebook().processNote(noteId, note -> note.getBindedInterpreterSettings(new ArrayList<>(authorizationService.getOwners(note.getId()))));
if (intpSettings.isEmpty()) {
return;
}
connectionManager.broadcast(noteId, new Message(OP.ANGULAR_OBJECT_UPDATE).put("angularObject", angularObject).put("interpreterGroupId", interpreterGroupId).put("noteId", noteId).put("paragraphId", angularObject.getParagraphId()));
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method removeParagraph.
private void removeParagraph(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
final String paragraphId = (String) fromMessage.get("id");
String noteId = connectionManager.getAssociatedNoteId(conn);
getNotebookService().removeParagraph(noteId, paragraphId, context, new WebSocketServiceCallback<Paragraph>(conn) {
@Override
public void onSuccess(Paragraph p, ServiceContext context) throws IOException {
super.onSuccess(p, context);
connectionManager.broadcast(p.getNote().getId(), new Message(OP.PARAGRAPH_REMOVED).put("id", p.getId()));
}
});
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method moveParagraph.
private void moveParagraph(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
final String paragraphId = (String) fromMessage.get("id");
final int newIndex = (int) Double.parseDouble(fromMessage.get("index").toString());
String noteId = connectionManager.getAssociatedNoteId(conn);
getNotebookService().moveParagraph(noteId, paragraphId, newIndex, context, new WebSocketServiceCallback<Paragraph>(conn) {
@Override
public void onSuccess(Paragraph result, ServiceContext context) throws IOException {
super.onSuccess(result, context);
connectionManager.broadcast(result.getNote().getId(), new Message(OP.PARAGRAPH_MOVED).put("id", paragraphId).put("index", newIndex));
}
});
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method broadcastUpdateNoteJobInfo.
public void broadcastUpdateNoteJobInfo(Note note, long lastUpdateUnixTime) throws IOException {
ServiceContext context = new ServiceContext(new AuthenticationInfo(), authorizationService.getOwners(note.getId()));
getJobManagerService().getNoteJobInfoByUnixTime(lastUpdateUnixTime, context, new WebSocketServiceCallback<List<JobManagerService.NoteJobInfo>>(null) {
@Override
public void onSuccess(List<JobManagerService.NoteJobInfo> notesJobInfo, ServiceContext context) throws IOException {
super.onSuccess(notesJobInfo, context);
Map<String, Object> response = new HashMap<>();
response.put("lastResponseUnixTime", System.currentTimeMillis());
response.put("jobs", notesJobInfo);
connectionManager.broadcast(JobManagerServiceType.JOB_MANAGER_PAGE.getKey(), new Message(OP.LIST_UPDATE_NOTE_JOBS).put("noteRunningJobs", response));
}
@Override
public void onFailure(Exception ex, ServiceContext context) throws IOException {
LOG.warn(ex.getMessage());
}
});
}
Aggregations