change argument string to boolean

This commit is contained in:
astroshim 2016-08-15 01:01:36 +09:00
parent 439b3613d9
commit 4dbe05ae1c
4 changed files with 25 additions and 17 deletions

View file

@ -155,19 +155,9 @@ public class InterpreterRestApi {
logger.info("Restart interpreterSetting {}, msg={}", settingId, message);
try {
RestartInterpreterRequest request =
gson.fromJson(message, RestartInterpreterRequest.class);
InterpreterSetting setting = interpreterFactory.get(settingId);
if (setting != null && request.getType().trim().equals("self")) {
if ((setting.getOption().isPerNoteProcess() |
setting.getOption().isPerNoteSession()) == false) {
return new JsonResponse<>(Status.FORBIDDEN,
"Can't restart shared interpreter process.").build();
}
}
interpreterFactory.restart(settingId);
RestartInterpreterRequest request = gson.fromJson(message, RestartInterpreterRequest.class);
boolean shouldBeCheckedIntpMode = request == null ? false : request.getCheckIntpCondition();
interpreterFactory.restart(settingId, shouldBeCheckedIntpMode);
} catch (InterpreterException e) {
logger.error("Exception in InterpreterRestApi while restartSetting ", e);
return new JsonResponse<>(Status.NOT_FOUND, e.getMessage(), ExceptionUtils.getStackTrace(e))

View file

@ -21,13 +21,13 @@ package org.apache.zeppelin.rest.message;
* RestartInterpreter rest api request message
*/
public class RestartInterpreterRequest {
String type;
boolean checkIntpCondition;
public RestartInterpreterRequest() {
}
public String getType() {
return type;
public boolean getCheckIntpCondition() {
return checkIntpCondition;
}
}

View file

@ -651,7 +651,7 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
callback: function(result) {
if (result) {
var payload = {
'type': 'self'
'checkIntpCondition': 'true'
};
$http.put(baseUrlSrv.getRestApiBase() + '/interpreter/setting/restart/' + interpeter.id, payload)
.success(function(data, status, headers, config) {

View file

@ -848,6 +848,24 @@ public class InterpreterFactory implements InterpreterGroupFactory {
}
}
private boolean isSharedInterpreter(InterpreterSetting setting) {
if (setting != null &&
setting.getOption().isPerNoteProcess() == false &&
setting.getOption().isPerNoteSession() == false){
return true;
}
return false;
}
public void restart(String settingId, boolean shouldBeCheckedIntpMode) {
InterpreterSetting setting = interpreterSettings.get(settingId);
if (shouldBeCheckedIntpMode && isSharedInterpreter(setting)) {
throw new InterpreterException("Can't restart shared interpreter process.");
}
restart(settingId);
}
public void restart(String id) {
synchronized (interpreterSettings) {
InterpreterSetting intpsetting = interpreterSettings.get(id);