Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
import javax.ws.rs.core.Response.Status;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterException;
import org.apache.zeppelin.interpreter.InterpreterFactory;
import org.apache.zeppelin.interpreter.InterpreterSetting;
import org.apache.zeppelin.interpreter.*;
import org.apache.zeppelin.interpreter.Interpreter.RegisteredInterpreter;
import org.apache.zeppelin.rest.message.NewInterpreterSettingRequest;
import org.apache.zeppelin.rest.message.UpdateInterpreterSettingRequest;
Expand Down Expand Up @@ -102,8 +99,12 @@ public Response newSettings(String message) throws InterpreterException, IOExcep
NewInterpreterSettingRequest.class);
Properties p = new Properties();
p.putAll(request.getProperties());
interpreterFactory.add(request.getName(), request.getGroup(), request.getOption(), p);
return new JsonResponse(Status.CREATED, "").build();
// Option is deprecated from API, always use remote = true
InterpreterGroup interpreterGroup = interpreterFactory.add(request.getName(),
request.getGroup(), new InterpreterOption(true), p);
InterpreterSetting setting = interpreterFactory.get(interpreterGroup.getId());
logger.info("new setting created with " + setting.id());
return new JsonResponse(Status.CREATED, "", setting ).build();
}

@PUT
Expand All @@ -114,7 +115,9 @@ public Response updateSetting(String message, @PathParam("settingId") String set
try {
UpdateInterpreterSettingRequest p = gson.fromJson(message,
UpdateInterpreterSettingRequest.class);
interpreterFactory.setPropertyAndRestart(settingId, p.getOption(), p.getProperties());
// Option is deprecated from API, always use remote = true
interpreterFactory.setPropertyAndRestart(settingId,
new InterpreterOption(true), p.getProperties());
} catch (InterpreterException e) {
return new JsonResponse(
Status.NOT_FOUND, e.getMessage(), ExceptionUtils.getStackTrace(e)).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class NewInterpreterSettingRequest {
String name;
String group;
InterpreterOption option;
// option was deprecated
Map<String, String> properties;

public NewInterpreterSettingRequest() {
Expand All @@ -47,7 +47,4 @@ public Map<String, String> getProperties() {
return properties;
}

public InterpreterOption getOption() {
return option;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@
*
*/
public class UpdateInterpreterSettingRequest {
InterpreterOption option;

// option was deprecated
Properties properties;

public UpdateInterpreterSettingRequest(InterpreterOption option,
Properties properties) {
super();
this.option = option;
this.properties = properties;
}
public InterpreterOption getOption() {
return option;
}

public Properties getProperties() {
return properties;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.zeppelin.server;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import org.apache.zeppelin.interpreter.InterpreterOption;

/**
* Created by eranw on 8/30/15.
* Omit InterpreterOption from serialization
*/
public class JsonExclusionStrategy implements ExclusionStrategy {

public boolean shouldSkipClass(Class<?> arg0) {
//exclude only InterpreterOption
return InterpreterOption.class.equals(arg0);
}

public boolean shouldSkipField(FieldAttributes f) {

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public String toString() {
if (pretty) {
gsonBuilder.setPrettyPrinting();
}
gsonBuilder.setExclusionStrategies(new JsonExclusionStrategy());
Gson gson = gsonBuilder.create();
return gson.toJson(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,4 @@ public void testInterpreterRestart() throws IOException, InterruptedException {
assertEquals("<p>markdown restarted</p>\n", p.getResult().message());
}
}

2 changes: 0 additions & 2 deletions zeppelin-web/src/app/interpreter/interpreter.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope,
var index = _.findIndex($scope.interpreterSettings, { 'id': settingId });

var request = {
option : angular.copy($scope.interpreterSettings[index].option),
properties : angular.copy($scope.interpreterSettings[index].properties),
};

Expand Down Expand Up @@ -169,7 +168,6 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope,
$scope.newInterpreterSetting = {
name : undefined,
group : undefined,
option : { remote : true },
properties : {}
};
emptyNewProperty($scope.newInterpreterSetting);
Expand Down