use of org.apache.zeppelin.common.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);
connectionManager.broadcast(noteId, msg);
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method angularObjectUpdated.
/**
* 1. When angular object updated from client.
* 2. Save AngularObject to note.
*
* @param conn the web socket.
* @param fromMessage the message.
*/
private void angularObjectUpdated(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
String noteId = (String) fromMessage.get("noteId");
String paragraphId = (String) fromMessage.get("paragraphId");
String interpreterGroupId = (String) fromMessage.get("interpreterGroupId");
String varName = (String) fromMessage.get("name");
Object varValue = fromMessage.get("value");
String user = fromMessage.principal;
getNotebookService().updateAngularObject(noteId, paragraphId, interpreterGroupId, varName, varValue, context, new WebSocketServiceCallback<AngularObject>(conn) {
@Override
public void onSuccess(AngularObject ao, ServiceContext context) throws IOException {
super.onSuccess(ao, context);
connectionManager.broadcastExcept(noteId, new Message(OP.ANGULAR_OBJECT_UPDATE).put("angularObject", ao).put("interpreterGroupId", interpreterGroupId).put("noteId", noteId).put("paragraphId", ao.getParagraphId()), conn);
getNotebook().processNote(noteId, note -> {
note.addOrUpdateAngularObject(interpreterGroupId, ao);
return null;
});
}
});
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class NotebookServer method getInterpreterBindings.
public void getInterpreterBindings(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
List<InterpreterSettingsList> settingList = new ArrayList<>();
String noteId = (String) fromMessage.data.get("noteId");
getNotebook().processNote(noteId, note -> {
if (note != null) {
List<InterpreterSetting> bindedSettings = note.getBindedInterpreterSettings(new ArrayList<>(context.getUserAndRoles()));
for (InterpreterSetting setting : bindedSettings) {
settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
}
}
conn.send(serializeMessage(new Message(OP.INTERPRETER_BINDINGS).put("interpreterBindings", settingList)));
return null;
});
}
use of org.apache.zeppelin.common.Message in project zeppelin by apache.
the class InterpreterRestApi method installInterpreter.
/**
* Install interpreter
*/
@POST
@Path("install")
@ZeppelinApi
public Response installInterpreter(@NotNull String message) {
LOGGER.info("Install interpreter: {}", message);
InterpreterInstallationRequest request = InterpreterInstallationRequest.fromJson(message);
try {
interpreterService.installInterpreter(request, new SimpleServiceCallback<String>() {
@Override
public void onStart(String message, ServiceContext context) {
Message m = new Message(OP.INTERPRETER_INSTALL_STARTED);
Map<String, Object> data = new HashMap<>();
data.put("result", "Starting");
data.put("message", message);
m.data = data;
notebookServer.broadcast(m);
}
@Override
public void onSuccess(String message, ServiceContext context) {
Message m = new Message(OP.INTERPRETER_INSTALL_RESULT);
Map<String, Object> data = new HashMap<>();
data.put("result", "Succeed");
data.put("message", message);
m.data = data;
notebookServer.broadcast(m);
}
@Override
public void onFailure(Exception ex, ServiceContext context) {
Message m = new Message(OP.INTERPRETER_INSTALL_RESULT);
Map<String, Object> data = new HashMap<>();
data.put("result", "Failed");
data.put("message", ex.getMessage());
m.data = data;
notebookServer.broadcast(m);
}
});
} catch (Throwable t) {
return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR, t.getMessage()).build();
}
return new JsonResponse<>(Status.OK).build();
}
Aggregations