Search in sources :

Example 1 with RestartInterpreterRequest

use of org.apache.zeppelin.rest.message.RestartInterpreterRequest in project zeppelin by apache.

the class InterpreterRestApi method restartSetting.

/**
   * Restart interpreter setting
   */
@PUT
@Path("setting/restart/{settingId}")
@ZeppelinApi
public Response restartSetting(String message, @PathParam("settingId") String settingId) {
    logger.info("Restart interpreterSetting {}, msg={}", settingId, message);
    InterpreterSetting setting = interpreterSettingManager.get(settingId);
    try {
        RestartInterpreterRequest request = gson.fromJson(message, RestartInterpreterRequest.class);
        String noteId = request == null ? null : request.getNoteId();
        if (null == noteId) {
            interpreterSettingManager.close(setting);
        } else {
            interpreterSettingManager.restart(settingId, noteId, SecurityUtils.getPrincipal());
        }
        notebookServer.clearParagraphRuntimeInfo(setting);
    } catch (InterpreterException e) {
        logger.error("Exception in InterpreterRestApi while restartSetting ", e);
        return new JsonResponse<>(Status.NOT_FOUND, e.getMessage(), ExceptionUtils.getStackTrace(e)).build();
    }
    if (setting == null) {
        return new JsonResponse<>(Status.NOT_FOUND, "", settingId).build();
    }
    return new JsonResponse<>(Status.OK, "", setting).build();
}
Also used : RestartInterpreterRequest(org.apache.zeppelin.rest.message.RestartInterpreterRequest) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) JsonResponse(org.apache.zeppelin.server.JsonResponse) Path(javax.ws.rs.Path) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) PUT(javax.ws.rs.PUT)

Aggregations

PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 ZeppelinApi (org.apache.zeppelin.annotation.ZeppelinApi)1 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)1 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)1 RestartInterpreterRequest (org.apache.zeppelin.rest.message.RestartInterpreterRequest)1 JsonResponse (org.apache.zeppelin.server.JsonResponse)1