use of org.apache.zeppelin.service.ServiceContext 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