Repository: zeppelin Updated Branches: refs/heads/master 2842251b7 -> 155a55b56
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/DefaultInterpreterProperty.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/DefaultInterpreterProperty.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/DefaultInterpreterProperty.java new file mode 100644 index 0000000..f11cbc3 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/DefaultInterpreterProperty.java @@ -0,0 +1,128 @@ +/* + * 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.interpreter; + +/** + * Property for registered interpreter + */ +public class DefaultInterpreterProperty { + private String envName; + private String propertyName; + private Object defaultValue; + private String description; + private String type; + + public DefaultInterpreterProperty(String envName, String propertyName, Object defaultValue, + String description, String type) { + this.envName = envName; + this.propertyName = propertyName; + this.defaultValue = defaultValue; + this.description = description; + this.type = type; + } + + public DefaultInterpreterProperty(Object defaultValue, String description, String type) { + this(null, null, defaultValue, description, type); + } + + public DefaultInterpreterProperty(Object defaultValue, String description) { + this(null, null, defaultValue, description, InterpreterPropertyType.TEXTAREA.getValue()); + } + + public DefaultInterpreterProperty(String envName, String propertyName, String defaultValue) { + this(envName, propertyName, defaultValue, null, InterpreterPropertyType.TEXTAREA.getValue()); + } + + public DefaultInterpreterProperty(String envName, String propertyName, String defaultValue, + String description) { + this(envName, propertyName, defaultValue, description, + InterpreterPropertyType.TEXTAREA.getValue()); + } + + public String getEnvName() { + return envName; + } + + public void setEnvName(String envName) { + this.envName = envName; + } + + public String getPropertyName() { + return propertyName; + } + + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + + public Object getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(Object defaultValue) { + this.defaultValue = defaultValue; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int hashCode() { + return this.toString().hashCode(); + } + + public boolean equals(Object o) { + if (o == null) return false; + return this.toString().equals(o.toString()); + } + + public Object getValue() { + if (envName != null && !envName.isEmpty()) { + String envValue = System.getenv().get(envName); + if (envValue != null) { + return envValue; + } + } + + if (propertyName != null && !propertyName.isEmpty()) { + String propValue = System.getProperty(propertyName); + if (propValue != null) { + return propValue; + } + } + return defaultValue; + } + + @Override + public String toString() { + return String.format("{envName=%s, propertyName=%s, defaultValue=%s, description=%20s, " + + "type=%s}", envName, propertyName, defaultValue, description, type); + } +} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java index e426d94..74506dd 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Interpreter.java @@ -165,12 +165,13 @@ public abstract class Interpreter { RegisteredInterpreter registeredInterpreter = Interpreter.findRegisteredInterpreterByClassName( getClassName()); if (null != registeredInterpreter) { - Map<String, InterpreterProperty> defaultProperties = registeredInterpreter.getProperties(); + Map<String, DefaultInterpreterProperty> defaultProperties = + registeredInterpreter.getProperties(); for (String k : defaultProperties.keySet()) { if (!p.containsKey(k)) { - String value = defaultProperties.get(k).getValue(); + Object value = defaultProperties.get(k).getValue(); if (value != null) { - p.put(k, defaultProperties.get(k).getValue()); + p.put(k, defaultProperties.get(k).getValue().toString()); } } } @@ -369,19 +370,19 @@ public abstract class Interpreter { private String name; private String className; private boolean defaultInterpreter; - private Map<String, InterpreterProperty> properties; + private Map<String, DefaultInterpreterProperty> properties; private Map<String, Object> editor; private String path; private InterpreterOption option; private InterpreterRunner runner; public RegisteredInterpreter(String name, String group, String className, - Map<String, InterpreterProperty> properties) { + Map<String, DefaultInterpreterProperty> properties) { this(name, group, className, false, properties); } public RegisteredInterpreter(String name, String group, String className, - boolean defaultInterpreter, Map<String, InterpreterProperty> properties) { + boolean defaultInterpreter, Map<String, DefaultInterpreterProperty> properties) { super(); this.name = name; this.group = group; @@ -411,7 +412,7 @@ public abstract class Interpreter { this.defaultInterpreter = defaultInterpreter; } - public Map<String, InterpreterProperty> getProperties() { + public Map<String, DefaultInterpreterProperty> getProperties() { return properties; } @@ -452,13 +453,13 @@ public abstract class Interpreter { @Deprecated public static void register(String name, String group, String className, - Map<String, InterpreterProperty> properties) { + Map<String, DefaultInterpreterProperty> properties) { register(name, group, className, false, properties); } @Deprecated public static void register(String name, String group, String className, - boolean defaultInterpreter, Map<String, InterpreterProperty> properties) { + boolean defaultInterpreter, Map<String, DefaultInterpreterProperty> properties) { logger.warn("Static initialization is deprecated for interpreter {}, You should change it " + "to use interpreter-setting.json in your jar or " + "interpreter/{interpreter}/interpreter-setting.json", name); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterProperty.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterProperty.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterProperty.java index 92a23d6..0bb3d42 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterProperty.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterProperty.java @@ -18,87 +18,50 @@ package org.apache.zeppelin.interpreter; /** - * Represent property of interpreter + * Property for instance of interpreter */ public class InterpreterProperty { - String envName; - String propertyName; - String defaultValue; - String description; - - public InterpreterProperty(String envName, String propertyName, String defaultValue, - String description) { - this.envName = envName; - this.propertyName = propertyName; - this.defaultValue = defaultValue; - this.description = description; - } - - public InterpreterProperty(String defaultValue, String description) { - this(null, null, defaultValue, description); - } - - public String getEnvName() { - return envName; - } - - public void setEnvName(String envName) { - this.envName = envName; - } - - public String getPropertyName() { - return propertyName; + private String name; + private Object value; + private String type; + + public InterpreterProperty(String name, Object value, String type) { + this.name = name; + this.value = value; + this.type = type; } - public void setPropertyName(String propertyName) { - this.propertyName = propertyName; + public InterpreterProperty(String name, Object value) { + this.name = name; + this.value = value; } - public String getDefaultValue() { - return defaultValue; + public String getName() { + return name; } - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; + public void setName(String name) { + this.name = name; } - public String getDescription() { - return description; + public Object getValue() { + return value; } - public void setDescription(String description) { - this.description = description; + public void setValue(Object value) { + this.value = value; } - public int hashCode() { - return this.toString().hashCode(); + public String getType() { + return type; } - public boolean equals(Object o) { - if (o == null) return false; - return this.toString().equals(o.toString()); - } - - public String getValue() { - if (envName != null && !envName.isEmpty()) { - String envValue = System.getenv().get(envName); - if (envValue != null) { - return envValue; - } - } - - if (propertyName != null && !propertyName.isEmpty()) { - String propValue = System.getProperty(propertyName); - if (propValue != null) { - return propValue; - } - } - return defaultValue; + public void setType(String type) { + this.type = type; } @Override public String toString() { - return String.format("{envName=%s, propertyName=%s, defaultValue=%s, description=%20s}", - envName, propertyName, defaultValue, description); + return String.format("{name=%s, value=%s, type=%s}", name, value, type); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterPropertyBuilder.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterPropertyBuilder.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterPropertyBuilder.java index d375a32..aa1a0b2 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterPropertyBuilder.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterPropertyBuilder.java @@ -24,21 +24,22 @@ import java.util.Map; * InterpreterPropertyBuilder */ public class InterpreterPropertyBuilder { - Map<String, InterpreterProperty> properties = new HashMap<>(); + Map<String, DefaultInterpreterProperty> properties = new HashMap<>(); public InterpreterPropertyBuilder add(String name, String defaultValue, String description){ - properties.put(name, new InterpreterProperty(defaultValue, description)); + properties.put(name, + new DefaultInterpreterProperty(defaultValue, description)); return this; } public InterpreterPropertyBuilder add(String name, String envName, String propertyName, String defaultValue, String description){ properties.put(name, - new InterpreterProperty(envName, propertyName, defaultValue, description)); + new DefaultInterpreterProperty(envName, propertyName, defaultValue, description)); return this; } - public Map<String, InterpreterProperty> build(){ + public Map<String, DefaultInterpreterProperty> build(){ return properties; } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterPropertyType.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterPropertyType.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterPropertyType.java new file mode 100644 index 0000000..6bbc39d --- /dev/null +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/InterpreterPropertyType.java @@ -0,0 +1,62 @@ +/* + * 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.interpreter; + +import java.util.ArrayList; +import java.util.List; + +/** + * Types of interpreter properties + */ +public enum InterpreterPropertyType { + + TEXTAREA("textarea"), + STRING("string"), + NUMBER("number"), + URL("url"), + PASSWORD("password"), + CHECKBOX("checkbox"); + + private String value; + + InterpreterPropertyType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static InterpreterPropertyType byValue(String value) { + for (InterpreterPropertyType e : values()) { + if (e.getValue().equals(value)) { + return e; + } + } + return null; + } + + public static List<String> getTypes() { + List<String> types = new ArrayList<>(); + InterpreterPropertyType[] values = values(); + for (InterpreterPropertyType interpreterPropertyType : values) { + types.add(interpreterPropertyType.getValue()); + } + return types; + } +} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java index 8824d90..17c4027 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Properties; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.DELETE; @@ -36,21 +35,21 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.zeppelin.interpreter.InterpreterSettingManager; -import org.apache.zeppelin.rest.message.RestartInterpreterRequest; -import org.apache.zeppelin.utils.SecurityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sonatype.aether.repository.RemoteRepository; - import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.dep.Repository; import org.apache.zeppelin.interpreter.InterpreterException; +import org.apache.zeppelin.interpreter.InterpreterPropertyType; import org.apache.zeppelin.interpreter.InterpreterSetting; +import org.apache.zeppelin.interpreter.InterpreterSettingManager; import org.apache.zeppelin.rest.message.NewInterpreterSettingRequest; +import org.apache.zeppelin.rest.message.RestartInterpreterRequest; import org.apache.zeppelin.rest.message.UpdateInterpreterSettingRequest; import org.apache.zeppelin.server.JsonResponse; import org.apache.zeppelin.socket.NotebookServer; +import org.apache.zeppelin.utils.SecurityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.sonatype.aether.repository.RemoteRepository; /** * Interpreter Rest API @@ -118,11 +117,10 @@ public class InterpreterRestApi { if (request == null) { return new JsonResponse<>(Status.BAD_REQUEST).build(); } - Properties p = new Properties(); - p.putAll(request.getProperties()); + InterpreterSetting interpreterSetting = interpreterSettingManager .createNewSetting(request.getName(), request.getGroup(), request.getDependencies(), - request.getOption(), p); + request.getOption(), request.getProperties()); logger.info("new setting created with {}", interpreterSetting.getId()); return new JsonResponse<>(Status.OK, "", interpreterSetting).build(); } catch (InterpreterException | IOException e) { @@ -253,7 +251,7 @@ public class InterpreterRestApi { @GET @Path("getmetainfos/{settingId}") public Response getMetaInfo(@Context HttpServletRequest req, - @PathParam("settingId") String settingId) { + @PathParam("settingId") String settingId) { String propName = req.getParameter("propName"); if (propName == null) { return new JsonResponse<>(Status.BAD_REQUEST).build(); @@ -291,4 +289,14 @@ public class InterpreterRestApi { } return new JsonResponse(Status.OK).build(); } + + /** + * Get available types for property + */ + @GET + @Path("property/types") + public Response listInterpreterPropertyTypes() { + return new JsonResponse<>(Status.OK, InterpreterPropertyType.getTypes()).build(); + } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java index feaa303..848a2bf 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java @@ -24,6 +24,7 @@ import com.google.gson.Gson; import org.apache.zeppelin.common.JsonSerializable; import org.apache.zeppelin.dep.Dependency; import org.apache.zeppelin.interpreter.InterpreterOption; +import org.apache.zeppelin.interpreter.InterpreterProperty; /** * NewInterpreterSetting rest api request message @@ -33,7 +34,7 @@ public class NewInterpreterSettingRequest implements JsonSerializable { private String name; private String group; - private Map<String, String> properties; + private Map<String, InterpreterProperty> properties; private List<Dependency> dependencies; private InterpreterOption option; @@ -49,7 +50,7 @@ public class NewInterpreterSettingRequest implements JsonSerializable { return group; } - public Map<String, String> getProperties() { + public Map<String, InterpreterProperty> getProperties() { return properties; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java index 8764e8b..a5d113f 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/UpdateInterpreterSettingRequest.java @@ -18,12 +18,13 @@ package org.apache.zeppelin.rest.message; import java.util.List; -import java.util.Properties; +import java.util.Map; import com.google.gson.Gson; import org.apache.zeppelin.common.JsonSerializable; import org.apache.zeppelin.dep.Dependency; import org.apache.zeppelin.interpreter.InterpreterOption; +import org.apache.zeppelin.interpreter.InterpreterProperty; /** * UpdateInterpreterSetting rest api request message @@ -31,18 +32,18 @@ import org.apache.zeppelin.interpreter.InterpreterOption; public class UpdateInterpreterSettingRequest implements JsonSerializable { private static final Gson gson = new Gson(); - Properties properties; + Map<String, InterpreterProperty> properties; List<Dependency> dependencies; InterpreterOption option; - public UpdateInterpreterSettingRequest(Properties properties, + public UpdateInterpreterSettingRequest(Map<String, InterpreterProperty> properties, List<Dependency> dependencies, InterpreterOption option) { this.properties = properties; this.dependencies = dependencies; this.option = option; } - public Properties getProperties() { + public Map<String, InterpreterProperty> getProperties() { return properties; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-server/src/test/java/org/apache/zeppelin/integration/InterpreterIT.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/InterpreterIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/InterpreterIT.java index 9587cd6..6adc1f7 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/InterpreterIT.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/InterpreterIT.java @@ -72,7 +72,7 @@ public class InterpreterIT extends AbstractZeppelinIT { select.selectByVisibleText("spark"); collector.checkThat("description of interpreter property is displayed", - driver.findElement(By.xpath("//tr/td[contains(text(), 'spark.app.name')]/following-sibling::td[2]")).getText(), + driver.findElement(By.xpath("//tr/td[contains(text(), 'spark.app.name')]/following-sibling::td[3]")).getText(), CoreMatchers.equalTo("The name of spark application.")); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java index ac991f5..ae0911c 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java @@ -23,7 +23,7 @@ import java.lang.ref.WeakReference; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.List; -import java.util.Properties; +import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.regex.Pattern; @@ -44,6 +44,8 @@ import org.apache.commons.httpclient.methods.RequestEntity; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.interpreter.InterpreterProperty; +import org.apache.zeppelin.interpreter.InterpreterPropertyType; import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.server.ZeppelinServer; import org.hamcrest.Description; @@ -194,16 +196,21 @@ public abstract class AbstractTestRestApi { } } - Properties sparkProperties = (Properties) sparkIntpSetting.getProperties(); + Map<String, InterpreterProperty> sparkProperties = + (Map<String, InterpreterProperty>) sparkIntpSetting.getProperties(); // ci environment runs spark cluster for testing // so configure zeppelin use spark cluster if ("true".equals(System.getenv("CI"))) { // set spark master and other properties - sparkProperties.setProperty("master", "local[2]"); - sparkProperties.setProperty("spark.cores.max", "2"); - sparkProperties.setProperty("zeppelin.spark.useHiveContext", "false"); + sparkProperties.put("master", + new InterpreterProperty("master", "local[2]", InterpreterPropertyType.TEXTAREA.getValue())); + sparkProperties.put("spark.cores.max", + new InterpreterProperty("spark.cores.max", "2", InterpreterPropertyType.TEXTAREA.getValue())); + sparkProperties.put("zeppelin.spark.useHiveContext", + new InterpreterProperty("zeppelin.spark.useHiveContext", false, InterpreterPropertyType.CHECKBOX.getValue())); // set spark home for pyspark - sparkProperties.setProperty("spark.home", getSparkHome()); + sparkProperties.put("spark.home", + new InterpreterProperty("spark.home", getSparkHome(), InterpreterPropertyType.TEXTAREA.getValue())); sparkIntpSetting.setProperties(sparkProperties); pySpark = true; @@ -213,14 +220,19 @@ public abstract class AbstractTestRestApi { String sparkHome = getSparkHome(); if (sparkHome != null) { if (System.getenv("SPARK_MASTER") != null) { - sparkProperties.setProperty("master", System.getenv("SPARK_MASTER")); + sparkProperties.put("master", + new InterpreterProperty("master", System.getenv("SPARK_MASTER"), InterpreterPropertyType.TEXTAREA.getValue())); } else { - sparkProperties.setProperty("master", "local[2]"); + sparkProperties.put("master", + new InterpreterProperty("master", "local[2]", InterpreterPropertyType.TEXTAREA.getValue())); } - sparkProperties.setProperty("spark.cores.max", "2"); + sparkProperties.put("spark.cores.max", + new InterpreterProperty("spark.cores.max", "2", InterpreterPropertyType.TEXTAREA.getValue())); // set spark home for pyspark - sparkProperties.setProperty("spark.home", sparkHome); - sparkProperties.setProperty("zeppelin.spark.useHiveContext", "false"); + sparkProperties.put("spark.home", + new InterpreterProperty("spark.home", sparkHome, InterpreterPropertyType.TEXTAREA.getValue())); + sparkProperties.put("zeppelin.spark.useHiveContext", + new InterpreterProperty("zeppelin.spark.useHiveContext", false, InterpreterPropertyType.CHECKBOX.getValue())); pySpark = true; sparkR = true; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java index 6849167..5333385 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java @@ -110,7 +110,8 @@ public class InterpreterRestApiTest extends AbstractTestRestApi { @Test public void testSettingsCRUD() throws IOException { // when: call create setting API - String rawRequest = "{\"name\":\"md2\",\"group\":\"md\",\"properties\":{\"propname\":\"propvalue\"}," + + String rawRequest = "{\"name\":\"md2\",\"group\":\"md\"," + + "\"properties\":{\"propname\": {\"value\": \"propvalue\", \"name\": \"propname\", \"type\": \"textarea\"}}," + "\"interpreterGroup\":[{\"class\":\"org.apache.zeppelin.markdown.Markdown\",\"name\":\"md\"}]," + "\"dependencies\":[]," + "\"option\": { \"remote\": true, \"session\": false }}"; @@ -135,7 +136,11 @@ public class InterpreterRestApiTest extends AbstractTestRestApi { get.releaseConnection(); // when: call update setting API - jsonRequest.getAsJsonObject("properties").addProperty("propname2", "this is new prop"); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("name", "propname2"); + jsonObject.addProperty("value", "this is new prop"); + jsonObject.addProperty("type", "textarea"); + jsonRequest.getAsJsonObject("properties").add("propname2", jsonObject); PutMethod put = httpPut("/interpreter/setting/" + newSettingId, jsonRequest.toString()); LOG.info("testSettingCRUD update response\n" + put.getResponseBodyAsString()); // then: call update setting API @@ -160,7 +165,8 @@ public class InterpreterRestApiTest extends AbstractTestRestApi { String md1Dep = "org.apache.drill.exec:drill-jdbc:jar:1.7.0"; String md2Dep = "org.apache.drill.exec:drill-jdbc:jar:1.6.0"; - String reqBody1 = "{\"name\":\"" + md1Name + "\",\"group\":\"md\",\"properties\":{\"propname\":\"propvalue\"}," + + String reqBody1 = "{\"name\":\"" + md1Name + "\",\"group\":\"md\"," + + "\"properties\":{\"propname\": {\"value\": \"propvalue\", \"name\": \"propname\", \"type\": \"textarea\"}}," + "\"interpreterGroup\":[{\"class\":\"org.apache.zeppelin.markdown.Markdown\",\"name\":\"md\"}]," + "\"dependencies\":[ {\n" + " \"groupArtifactVersion\": \"" + md1Dep + "\",\n" + @@ -171,7 +177,8 @@ public class InterpreterRestApiTest extends AbstractTestRestApi { assertThat("test create method:", post, isAllowed()); post.releaseConnection(); - String reqBody2 = "{\"name\":\"" + md2Name + "\",\"group\":\"md\",\"properties\":{\"propname\":\"propvalue\"}," + + String reqBody2 = "{\"name\":\"" + md2Name + "\",\"group\":\"md\"," + + "\"properties\": {\"propname\": {\"value\": \"propvalue\", \"name\": \"propname\", \"type\": \"textarea\"}}," + "\"interpreterGroup\":[{\"class\":\"org.apache.zeppelin.markdown.Markdown\",\"name\":\"md\"}]," + "\"dependencies\":[ {\n" + " \"groupArtifactVersion\": \"" + md2Dep + "\",\n" + http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-web/package.json ---------------------------------------------------------------------- diff --git a/zeppelin-web/package.json b/zeppelin-web/package.json index ec62003..3d0f391 100644 --- a/zeppelin-web/package.json +++ b/zeppelin-web/package.json @@ -42,7 +42,7 @@ "css-loader": "^0.26.1", "eslint": "^3.19.0", "eslint-config-google": "^0.7.1", - "eslint-config-standard": "^10.2.0", + "eslint-config-standard": "^10.2.1", "eslint-plugin-import": "^2.2.0", "eslint-plugin-node": "^4.2.2", "eslint-plugin-promise": "^3.5.0", http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html b/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html index ab86a0d..1fa60f8 100644 --- a/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html +++ b/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html @@ -272,30 +272,55 @@ limitations under the License. <tr> <th>name</th> <th>value</th> - <th>description</th> <th>action</th> + <th>description</th> </tr> <tr ng-repeat="key in newInterpreterSetting.properties | sortByKey"> <td>{{key}}</td> - <td><textarea msd-elastic ng-model="newInterpreterSetting.properties[key].value"></textarea></td> - <td>{{newInterpreterSetting.properties[key].description}}</td> - <td> + <td style="vertical-align: middle;"> + <textarea ng-if="newInterpreterSetting.properties[key].type === 'textarea'" + msd-elastic ng-model="newInterpreterSetting.properties[key].value"></textarea> + <input ng-if="newInterpreterSetting.properties[key].type === 'string'" + type="text" msd-elastic ng-model="newInterpreterSetting.properties[key].value" /> + <input ng-if="newInterpreterSetting.properties[key].type === 'number'" + type="text" widget-number msd-elastic ng-model="newInterpreterSetting.properties[key].value" /> + <input ng-if="newInterpreterSetting.properties[key].type === 'url'" + type="text" msd-elastic ng-model="newInterpreterSetting.properties[key].value" /> + <input ng-if="newInterpreterSetting.properties[key].type === 'password'" + type="password" msd-elastic ng-model="newInterpreterSetting.properties[key].value" /> + <input ng-if="newInterpreterSetting.properties[key].type === 'boolean'" + type="checkbox" msd-elastic ng-model="newInterpreterSetting.properties[key].value" /> + </td> + <td style="vertical-align: middle;"> <button class="btn btn-default btn-sm fa fa-remove" ng-click="removeInterpreterProperty(key)"> </button> </td> + <td style="vertical-align: middle;"> + {{newInterpreterSetting.properties[key].description}} + </td> </tr> <tr> - <td> + <td style="vertical-align: middle;"> <input pu-elastic-input pu-elastic-input-minwidth="180px" ng-model="newInterpreterSetting.propertyKey" /> </td> - <td><textarea msd-elastic ng-model="newInterpreterSetting.propertyValue"></textarea></td> - <td></td> - <td> + <td style="vertical-align: middle;" ng-switch on="newInterpreterSetting.propertyType"> + <textarea ng-switch-default msd-elastic ng-model="newInterpreterSetting.propertyValue"></textarea> + <input ng-switch-when="string" type="text" msd-elastic ng-model="newInterpreterSetting.propertyValue" /> + <input ng-switch-when="number" type="text" widget-number msd-elastic ng-model="newInterpreterSetting.propertyValue" /> + <input ng-switch-when="url" type="text" msd-elastic ng-model="newInterpreterSetting.propertyValue" /> + <input ng-switch-when="password" type="password" msd-elastic ng-model="newInterpreterSetting.propertyValue" /> + <input ng-switch-when="checkbox" type="checkbox" msd-elastic ng-model="newInterpreterSetting.propertyValue" /> + </td> + <td style="vertical-align: middle;"> + <select msd-elastic ng-model="newInterpreterSetting.propertyType" ng-init="newInterpreterSetting.propertyType=interpreterPropertyTypes[0]" + ng-options="item for item in interpreterPropertyTypes" ng-change="defaultValueByType(newInterpreterSetting)"> + </select> <button class="btn btn-default btn-sm fa fa-plus" ng-click="addNewInterpreterProperty()"> </button> </td> + <td></td> </tr> </table> </div> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-web/src/app/interpreter/interpreter.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/interpreter/interpreter.controller.js b/zeppelin-web/src/app/interpreter/interpreter.controller.js index df2b216..e75740f 100644 --- a/zeppelin-web/src/app/interpreter/interpreter.controller.js +++ b/zeppelin-web/src/app/interpreter/interpreter.controller.js @@ -16,7 +16,7 @@ import { ParagraphStatus, } from '../notebook/paragraph/paragraph.status' angular.module('zeppelinWebApp').controller('InterpreterCtrl', InterpreterCtrl) -function InterpreterCtrl ($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeout, $route) { +function InterpreterCtrl($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeout, $route) { 'ngInject' let interpreterSettingsTmp = [] @@ -26,6 +26,7 @@ function InterpreterCtrl ($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeo $scope.showRepositoryInfo = false $scope.searchInterpreter = '' $scope._ = _ + $scope.interpreterPropertyTypes = [] ngToast.dismiss() $scope.openPermissions = function () { @@ -161,8 +162,17 @@ function InterpreterCtrl ($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeo }) } - let emptyNewProperty = function (object) { - angular.extend(object, {propertyValue: '', propertyKey: ''}) + let getAvailableInterpreterPropertyWidgets = function () { + $http.get(baseUrlSrv.getRestApiBase() + '/interpreter/property/types') + .success(function (data, status, headers, config) { + $scope.interpreterPropertyTypes = data.body + }).error(function (data, status, headers, config) { + console.log('Error %o %o', status, data.message) + }) + } + + let emptyNewProperty = function(object) { + angular.extend(object, {propertyValue: '', propertyKey: '', propertyType: $scope.interpreterPropertyTypes[0]}) } let emptyNewDependency = function (object) { @@ -203,6 +213,15 @@ function InterpreterCtrl ($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeo } } + $scope.defaultValueByType = function (setting) { + if (setting.propertyType === 'checkbox') { + setting.propertyValue = false + return + } + + setting.propertyValue = '' + } + $scope.setPerUserOption = function (settingId, sessionOption) { let option if (settingId === undefined) { @@ -428,7 +447,8 @@ function InterpreterCtrl ($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeo for (let key in intpInfo) { properties[key] = { value: intpInfo[key].defaultValue, - description: intpInfo[key].description + description: intpInfo[key].description, + type: intpInfo[key].type } } } @@ -503,9 +523,15 @@ function InterpreterCtrl ($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeo // Change properties to proper request format let newProperties = {} + for (let p in newSetting.properties) { - newProperties[p] = newSetting.properties[p].value + newProperties[p] = { + value: newSetting.properties[p].value, + type: newSetting.properties[p].type, + name: p + } } + request.properties = newProperties $http.post(baseUrlSrv.getRestApiBase() + '/interpreter/setting', request) @@ -573,9 +599,9 @@ function InterpreterCtrl ($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeo if (!$scope.newInterpreterSetting.propertyKey || $scope.newInterpreterSetting.propertyKey === '') { return } - $scope.newInterpreterSetting.properties[$scope.newInterpreterSetting.propertyKey] = { - value: $scope.newInterpreterSetting.propertyValue + value: $scope.newInterpreterSetting.propertyValue, + type: $scope.newInterpreterSetting.propertyType } emptyNewProperty($scope.newInterpreterSetting) } else { @@ -586,7 +612,10 @@ function InterpreterCtrl ($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeo if (!setting.propertyKey || setting.propertyKey === '') { return } - setting.properties[setting.propertyKey] = setting.propertyValue + + setting.properties[setting.propertyKey] = + {value: setting.propertyValue, type: setting.propertyType} + emptyNewProperty(setting) } } @@ -713,7 +742,9 @@ function InterpreterCtrl ($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeo }) } - let init = function () { + let init = function() { + getAvailableInterpreterPropertyWidgets() + $scope.resetNewInterpreterSetting() $scope.resetNewRepositorySetting() http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-web/src/app/interpreter/interpreter.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/interpreter/interpreter.html b/zeppelin-web/src/app/interpreter/interpreter.html index f9d4252..617ce38 100644 --- a/zeppelin-web/src/app/interpreter/interpreter.html +++ b/zeppelin-web/src/app/interpreter/interpreter.html @@ -403,8 +403,29 @@ limitations under the License. <tr ng-repeat="key in setting.properties | sortByKey" > <td style="vertical-align: middle;">{{key}}</td> <td style="vertical-align: middle;"> - <span editable-textarea="setting.properties[key]" e-form="valueform" e-msd-elastic> - {{setting.properties[key] | breakFilter}} + <span ng-if="setting.properties[key].type === 'textarea'" + editable-textarea="setting.properties[key].value" e-form="valueform" e-msd-elastic> + {{setting.properties[key].value | breakFilter}} + </span> + <span ng-if="setting.properties[key].type === 'string'" + editable-text="setting.properties[key].value" e-form="valueform" e-msd-elastic> + {{setting.properties[key].value}} + </span> + <span ng-if="setting.properties[key].type === 'number'" + editable-text="setting.properties[key].value" e-widget-number e-form="valueform" e-msd-elastic> + {{setting.properties[key].value}} + </span> + <span ng-if="setting.properties[key].type === 'url'" + editable-text="setting.properties[key].value" e-form="valueform" e-msd-elastic> + <a ng-href="{{setting.properties[key].value}}">{{setting.properties[key].value}}</a> + </span> + <span ng-if="setting.properties[key].type === 'password'" + editable-password="setting.properties[key].value" e-form="valueform" e-msd-elastic> + {{setting.properties[key].value ? '***' : ''}} + </span> + <span ng-if="setting.properties[key].type === 'checkbox'" + editable-checkbox="setting.properties[key].value" e-form="valueform" e-msd-elastic> + {{setting.properties[key].value}} </span> </td> <td style="vertical-align: middle;" ng-if="valueform.$visible"> @@ -418,12 +439,22 @@ limitations under the License. <input ng-model="setting.propertyKey" pu-elastic-input pu-elastic-input-minwidth="180px" /> </td> - <td style="vertical-align: middle;"> - <textarea msd-elastic ng-model="setting.propertyValue"></textarea> + + <td style="vertical-align: middle;" ng-switch on="setting.propertyType"> + <textarea ng-switch-default msd-elastic ng-model="setting.propertyValue"></textarea> + <input ng-switch-when="string" type="text" msd-elastic ng-model="setting.propertyValue"/> + <input ng-switch-when="number" type="text" msd-elastic ng-model="setting.propertyValue" widget-number /> + <input ng-switch-when="url" type="text" msd-elastic ng-model="setting.propertyValue" /> + <input ng-switch-when="password" type="password" msd-elastic ng-model="setting.propertyValue" /> + <input ng-switch-when="checkbox" type="checkbox" msd-elastic ng-model="setting.propertyValue" /> </td> <td style="vertical-align: middle;"> + <select ng-model="setting.propertyType" ng-init="setting.propertyType=interpreterPropertyTypes[0]" + ng-options="item for item in interpreterPropertyTypes" ng-change="defaultValueByType(setting)"> + </select> + <button class="btn btn-default btn-sm fa fa-plus" - ng-click="addNewInterpreterProperty(setting.id)"> + ng-click="addNewInterpreterProperty(setting.id)"> </button> </td> </tr> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-web/src/components/interpreter/widget/widget.number.directive.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/interpreter/widget/widget.number.directive.js b/zeppelin-web/src/components/interpreter/widget/widget.number.directive.js new file mode 100644 index 0000000..5d66cd1 --- /dev/null +++ b/zeppelin-web/src/components/interpreter/widget/widget.number.directive.js @@ -0,0 +1,31 @@ +/* + * Licensed 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. + */ + +angular.module('zeppelinWebApp').directive('widgetNumber', numericOnly) + +function numericOnly() { + return { + require: 'ngModel', + link: function (scope, element, attrs, modelCtrl) { + modelCtrl.$parsers.push(function (inputValue) { + let transformedInput = inputValue ? inputValue.replace(/[^\d.-]/g, '') : null + if (transformedInput !== inputValue) { + modelCtrl.$setViewValue(transformedInput) + modelCtrl.$render() + } + return transformedInput + }) + } + } +} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-web/src/index.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/index.js b/zeppelin-web/src/index.js index 5304225..de77686 100644 --- a/zeppelin-web/src/index.js +++ b/zeppelin-web/src/index.js @@ -52,6 +52,7 @@ import './components/clipboard/clipboard.controller.js' import './components/navbar/navbar.controller.js' import './components/ngescape/ngescape.directive.js' import './components/interpreter/interpreter.directive.js' +import './components/interpreter/widget/widget.number.directive.js' import './components/expandCollapse/expandCollapse.directive.js' import './components/noteName-create/notename.controller.js' import './components/noteName-import/notenameImport.controller.js' http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java index bbc2b3b..9403b4f 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java @@ -122,7 +122,7 @@ public class InterpreterFactory implements InterpreterGroupFactory { String noteId, String interpreterSessionKey) { InterpreterGroup interpreterGroup = interpreterSetting.getInterpreterGroup(user, noteId); InterpreterOption option = interpreterSetting.getOption(); - Properties properties = (Properties) interpreterSetting.getProperties(); + Properties properties = interpreterSetting.getFlatProperties(); // if interpreters are already there, wait until they're being removed synchronized (interpreterGroup) { long interpreterRemovalWaitStart = System.nanoTime(); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java index 7155112..752b4e2 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java @@ -36,6 +36,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.annotations.SerializedName; +import com.google.gson.internal.StringMap; import static org.apache.zeppelin.notebook.utility.IdHashes.generateId; @@ -57,14 +58,14 @@ public class InterpreterSetting { private transient Map<String, Set<String>> runtimeInfosToBeCleared; /** - * properties can be either Properties or Map<String, InterpreterProperty> + * properties can be either Map<String, DefaultInterpreterProperty> or + * Map<String, InterpreterProperty> * properties should be: - * - Properties when Interpreter instances are saved to `conf/interpreter.json` file - * - Map<String, InterpreterProperty> when Interpreters are registered + * - Map<String, InterpreterProperty> when Interpreter instances are saved to + * `conf/interpreter.json` file + * - Map<String, DefaultInterpreterProperty> when Interpreters are registered * : this is needed after https://github.com/apache/zeppelin/pull/1145 * which changed the way of getting default interpreter setting AKA interpreterSettingsRef - * Note(mina): In order to simplify the implementation, I chose to change properties - * from Properties to Object instead of creating new classes. */ private Object properties; private Status status; @@ -277,6 +278,19 @@ public class InterpreterSetting { return properties; } + public Properties getFlatProperties() { + Properties p = new Properties(); + if (properties != null) { + Map<String, InterpreterProperty> propertyMap = (Map<String, InterpreterProperty>) properties; + for (String key : propertyMap.keySet()) { + InterpreterProperty tmp = propertyMap.get(key); + p.put(tmp.getName() != null ? tmp.getName() : key, + tmp.getValue() != null ? tmp.getValue().toString() : null); + } + } + return p; + } + public List<Dependency> getDependencies() { if (dependencies == null) { return new LinkedList<>(); @@ -328,7 +342,7 @@ public class InterpreterSetting { this.option = interpreterOption; } - public void setProperties(Properties p) { + public void setProperties(Map<String, InterpreterProperty> p) { this.properties = p; } @@ -418,4 +432,28 @@ public class InterpreterSetting { } } } + + // For backward compatibility of interpreter.json format after ZEPPELIN-2403 + public void convertFlatPropertiesToPropertiesWithWidgets() { + StringMap newProperties = new StringMap(); + if (properties != null && properties instanceof StringMap) { + StringMap p = (StringMap) properties; + + for (Object o : p.entrySet()) { + Map.Entry entry = (Map.Entry) o; + if (!(entry.getValue() instanceof StringMap)) { + StringMap newProperty = new StringMap(); + newProperty.put("name", entry.getKey()); + newProperty.put("value", entry.getValue()); + newProperty.put("type", InterpreterPropertyType.TEXTAREA.getValue()); + newProperties.put(entry.getKey().toString(), newProperty); + } else { + // already converted + return; + } + } + + this.properties = newProperties; + } + } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java index 1327e09..12545d6 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java @@ -17,18 +17,6 @@ package org.apache.zeppelin.interpreter; -import static java.nio.file.attribute.PosixFilePermission.OWNER_READ; -import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.internal.StringMap; -import com.google.gson.reflect.TypeToken; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -47,7 +35,6 @@ import java.nio.file.DirectoryStream.Filter; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; - import java.nio.file.attribute.PosixFilePermission; import java.util.ArrayList; import java.util.Collection; @@ -60,12 +47,13 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.Set; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; +import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; import org.apache.zeppelin.dep.Dependency; import org.apache.zeppelin.dep.DependencyResolver; @@ -74,13 +62,24 @@ import org.apache.zeppelin.scheduler.Job; import org.apache.zeppelin.scheduler.Job.Status; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.sonatype.aether.RepositoryException; import org.sonatype.aether.repository.Authentication; import org.sonatype.aether.repository.Proxy; import org.sonatype.aether.repository.RemoteRepository; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.internal.StringMap; +import com.google.gson.reflect.TypeToken; + +import static java.nio.file.attribute.PosixFilePermission.OWNER_READ; +import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE; + /** * TBD */ @@ -157,7 +156,7 @@ public class InterpreterSettingManager { /** * Remember this method doesn't keep current connections after being called */ - private void loadFromFile() { + private void loadFromFile() { if (!Files.exists(interpreterBindingPath)) { // nothing to read return; @@ -171,13 +170,24 @@ public class InterpreterSettingManager { for (String k : infoSaving.interpreterSettings.keySet()) { InterpreterSetting setting = infoSaving.interpreterSettings.get(k); + + setting.convertFlatPropertiesToPropertiesWithWidgets(); + List<InterpreterInfo> infos = setting.getInterpreterInfos(); // Convert json StringMap to Properties - StringMap<String> p = (StringMap<String>) setting.getProperties(); - Properties properties = new Properties(); + StringMap<StringMap> p = (StringMap<StringMap>) setting.getProperties(); + Map<String, InterpreterProperty> properties = new HashMap(); for (String key : p.keySet()) { - properties.put(key, p.get(key)); + StringMap<String> fields = (StringMap<String>) p.get(key); + String type = InterpreterPropertyType.TEXTAREA.getValue(); + try { + type = InterpreterPropertyType.byValue(fields.get("type")).getValue(); + } catch (Exception e) { + logger.warn("Incorrect type of property {} in settings {}", key, + setting.getId()); + } + properties.put(key, new InterpreterProperty(key, fields.get("value"), type)); } setting.setProperties(properties); @@ -250,7 +260,7 @@ public class InterpreterSettingManager { } catch (UnsupportedOperationException e) { // File system does not support Posix file permissions (likely windows) - continue anyway. logger.warn("unable to setPosixFilePermissions on '{}'.", interpreterBindingPath); - }; + } } FileOutputStream fos = new FileOutputStream(interpreterBindingPath.toFile(), false); @@ -487,8 +497,8 @@ public class InterpreterSettingManager { new ArrayList<InterpreterInfo>() : new ArrayList<>(o.getInterpreterInfos()); List<Dependency> deps = (null == o.getDependencies()) ? new ArrayList<Dependency>() : new ArrayList<>(o.getDependencies()); - Properties props = - convertInterpreterProperties((Map<String, InterpreterProperty>) o.getProperties()); + Map<String, InterpreterProperty> props = + convertInterpreterProperties((Map<String, DefaultInterpreterProperty>) o.getProperties()); InterpreterOption option = InterpreterOption.fromInterpreterOption(o.getOption()); InterpreterSetting setting = new InterpreterSetting(o.getName(), o.getName(), @@ -497,10 +507,14 @@ public class InterpreterSettingManager { return setting; } - private Properties convertInterpreterProperties(Map<String, InterpreterProperty> p) { - Properties properties = new Properties(); - for (String key : p.keySet()) { - properties.put(key, p.get(key).getValue()); + private Map<String, InterpreterProperty> convertInterpreterProperties( + Map<String, DefaultInterpreterProperty> defaultProperties) { + Map<String, InterpreterProperty> properties = new HashMap<>(); + + for (String key : defaultProperties.keySet()) { + DefaultInterpreterProperty defaultInterpreterProperty = defaultProperties.get(key); + properties.put(key, new InterpreterProperty(key, defaultInterpreterProperty.getValue(), + defaultInterpreterProperty.getType())); } return properties; } @@ -686,7 +700,8 @@ public class InterpreterSettingManager { } public InterpreterSetting createNewSetting(String name, String group, - List<Dependency> dependencies, InterpreterOption option, Properties p) throws IOException { + List<Dependency> dependencies, InterpreterOption option, Map<String, InterpreterProperty> p) + throws IOException { if (name.indexOf(".") >= 0) { throw new IOException("'.' is invalid for InterpreterSetting name."); } @@ -704,8 +719,8 @@ public class InterpreterSettingManager { } private InterpreterSetting add(String group, InterpreterInfo interpreterInfo, - Map<String, InterpreterProperty> interpreterProperties, InterpreterOption option, String path, - InterpreterRunner runner) + Map<String, DefaultInterpreterProperty> interpreterProperties, InterpreterOption option, + String path, InterpreterRunner runner) throws InterpreterException, IOException, RepositoryException { ArrayList<InterpreterInfo> infos = new ArrayList<>(); infos.add(interpreterInfo); @@ -718,7 +733,7 @@ public class InterpreterSettingManager { */ public InterpreterSetting add(String group, ArrayList<InterpreterInfo> interpreterInfos, List<Dependency> dependencies, InterpreterOption option, - Map<String, InterpreterProperty> interpreterProperties, String path, + Map<String, DefaultInterpreterProperty> interpreterProperties, String path, InterpreterRunner runner) { Preconditions.checkNotNull(group, "name should not be null"); Preconditions.checkNotNull(interpreterInfos, "interpreterInfos should not be null"); @@ -755,8 +770,8 @@ public class InterpreterSettingManager { } // Append properties - Map<String, InterpreterProperty> properties = - (Map<String, InterpreterProperty>) interpreterSetting.getProperties(); + Map<String, DefaultInterpreterProperty> properties = + (Map<String, DefaultInterpreterProperty>) interpreterSetting.getProperties(); for (String key : interpreterProperties.keySet()) { if (!properties.containsKey(key)) { properties.put(key, interpreterProperties.get(key)); @@ -914,7 +929,8 @@ public class InterpreterSettingManager { /** * Change interpreter property and restart */ - public void setPropertyAndRestart(String id, InterpreterOption option, Properties properties, + public void setPropertyAndRestart(String id, InterpreterOption option, + Map<String, InterpreterProperty> properties, List<Dependency> dependencies) throws IOException { synchronized (interpreterSettings) { InterpreterSetting intpSetting = interpreterSettings.get(id); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java index 2eef06d..305258a 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java @@ -41,7 +41,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; @@ -93,14 +92,14 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory { ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>(); interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock1", interpreterInfos, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock1", null); - interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(true), new Properties()); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock1", null); + interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(true), new HashMap<String, InterpreterProperty>()); ArrayList<InterpreterInfo> interpreterInfos2 = new ArrayList<>(); interpreterInfos2.add(new InterpreterInfo(MockInterpreter2.class.getName(), "mock2", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock2", interpreterInfos2, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock2", null); - interpreterSettingManager.createNewSetting("mock2", "mock2", new ArrayList<Dependency>(), new InterpreterOption(), new Properties()); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock2", null); + interpreterSettingManager.createNewSetting("mock2", "mock2", new ArrayList<Dependency>(), new InterpreterOption(), new HashMap<String, InterpreterProperty>()); SearchService search = mock(SearchService.class); notebookRepo = new VFSNotebookRepo(conf); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java index 2e3812c..aaa8864 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java @@ -17,8 +17,18 @@ package org.apache.zeppelin.interpreter; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; + import org.apache.commons.io.FileUtils; import org.apache.commons.lang.NullArgumentException; import org.apache.zeppelin.conf.ZeppelinConfiguration; @@ -44,14 +54,22 @@ import org.mockito.Mock; import org.quartz.SchedulerException; import org.sonatype.aether.RepositoryException; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.*; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class InterpreterFactoryTest { @@ -88,17 +106,19 @@ public class InterpreterFactoryTest { ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>(); interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock1", interpreterInfos, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock1", null); - Properties intp1Properties = new Properties(); - intp1Properties.put("PROPERTY_1", "VALUE_1"); - intp1Properties.put("property_2", "value_2"); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock1", null); + Map<String, InterpreterProperty> intp1Properties = new HashMap<String, InterpreterProperty>(); + intp1Properties.put("PROPERTY_1", + new InterpreterProperty("PROPERTY_1", "VALUE_1")); + intp1Properties.put("property_2", + new InterpreterProperty("property_2", "value_2")); interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(true), intp1Properties); ArrayList<InterpreterInfo> interpreterInfos2 = new ArrayList<>(); interpreterInfos2.add(new InterpreterInfo(MockInterpreter2.class.getName(), "mock2", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock2", interpreterInfos2, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock2", null); - interpreterSettingManager.createNewSetting("mock2", "mock2", new ArrayList<Dependency>(), new InterpreterOption(), new Properties()); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock2", null); + interpreterSettingManager.createNewSetting("mock2", "mock2", new ArrayList<Dependency>(), new InterpreterOption(), new HashMap<String, InterpreterProperty>()); SearchService search = mock(SearchService.class); notebookRepo = new VFSNotebookRepo(conf); @@ -145,10 +165,11 @@ public class InterpreterFactoryTest { ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>(); interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock1", interpreterInfos, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock1", null); - Properties intp1Properties = new Properties(); - intp1Properties.put("PROPERTY_1", "VALUE_1"); - intp1Properties.put("property_2", "value_2"); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock1", null); + Map<String, InterpreterProperty> intp1Properties = new HashMap<String, InterpreterProperty>(); + intp1Properties.put("PROPERTY_1", + new InterpreterProperty("PROPERTY_1", "VALUE_1")); + intp1Properties.put("property_2", new InterpreterProperty("property_2", "value_2")); interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(true), intp1Properties); factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager); List<InterpreterSetting> all = interpreterSettingManager.get(); @@ -182,10 +203,12 @@ public class InterpreterFactoryTest { ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>(); interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock1", interpreterInfos, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock1", null); - Properties intp1Properties = new Properties(); - intp1Properties.put("PROPERTY_1", "VALUE_1"); - intp1Properties.put("property_2", "value_2"); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock1", null); + Map<String, InterpreterProperty> intp1Properties = new HashMap<String, InterpreterProperty>(); + intp1Properties.put("PROPERTY_1", + new InterpreterProperty("PROPERTY_1", "VALUE_1")); + intp1Properties.put("property_2", + new InterpreterProperty("property_2", "value_2")); interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(true), intp1Properties); factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager); List<InterpreterSetting> all = interpreterSettingManager.get(); @@ -227,10 +250,12 @@ public class InterpreterFactoryTest { ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>(); interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock1", interpreterInfos, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock1", null); - Properties intp1Properties = new Properties(); - intp1Properties.put("PROPERTY_1", "VALUE_1"); - intp1Properties.put("property_2", "value_2"); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock1", null); + Map<String, InterpreterProperty> intp1Properties = new HashMap<String, InterpreterProperty>(); + intp1Properties.put("PROPERTY_1", + new InterpreterProperty("PROPERTY_1", "VALUE_1")); + intp1Properties.put("property_2", + new InterpreterProperty("property_2", "value_2")); interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(true), intp1Properties); factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager); List<InterpreterSetting> all = interpreterSettingManager.get(); @@ -294,7 +319,7 @@ public class InterpreterFactoryTest { // check if file saved assertTrue(new File(conf.getInterpreterSettingPath()).exists()); - interpreterSettingManager.createNewSetting("new-mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new Properties()); + interpreterSettingManager.createNewSetting("new-mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new HashMap<String, InterpreterProperty>()); assertEquals(numInterpreters + 1, interpreterSettingManager.get().size()); interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true)); @@ -313,14 +338,14 @@ public class InterpreterFactoryTest { // check if default interpreter reference's property type is map Map<String, InterpreterSetting> interpreterSettingRefs = interpreterSettingManager.getAvailableInterpreterSettings(); InterpreterSetting intpSetting = interpreterSettingRefs.get("mock1"); - Map<String, InterpreterProperty> intpProperties = - (Map<String, InterpreterProperty>) intpSetting.getProperties(); + Map<String, DefaultInterpreterProperty> intpProperties = + (Map<String, DefaultInterpreterProperty>) intpSetting.getProperties(); assertTrue(intpProperties instanceof Map); // check if interpreter instance is saved as Properties in conf/interpreter.json file - Properties properties = new Properties(); - properties.put("key1", "value1"); - properties.put("key2", "value2"); + Map<String, InterpreterProperty> properties = new HashMap<String, InterpreterProperty>(); + properties.put("key1", new InterpreterProperty("key1", "value1", "type1")); + properties.put("key2", new InterpreterProperty("key2", "value2", "type2")); interpreterSettingManager.createNewSetting("newMock", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), properties); @@ -351,8 +376,8 @@ public class InterpreterFactoryTest { add(info2); }}, new ArrayList<Dependency>(), new InterpreterOption(true), Collections.EMPTY_MAP, "/path2", null); - final InterpreterSetting setting1 = interpreterSettingManager.createNewSetting("test-group1", "group1", new ArrayList<Dependency>(), new InterpreterOption(true), new Properties()); - final InterpreterSetting setting2 = interpreterSettingManager.createNewSetting("test-group2", "group1", new ArrayList<Dependency>(), new InterpreterOption(true), new Properties()); + final InterpreterSetting setting1 = interpreterSettingManager.createNewSetting("test-group1", "group1", new ArrayList<Dependency>(), new InterpreterOption(true), new HashMap<String, InterpreterProperty>()); + final InterpreterSetting setting2 = interpreterSettingManager.createNewSetting("test-group2", "group1", new ArrayList<Dependency>(), new InterpreterOption(true), new HashMap<String, InterpreterProperty>()); interpreterSettingManager.setInterpreters("user", "note", new ArrayList<String>() {{ add(setting1.getId()); @@ -373,7 +398,7 @@ public class InterpreterFactoryTest { }}, new ArrayList<Dependency>(), new InterpreterOption(true), Collections.EMPTY_MAP, "/path1", null); InterpreterOption perUserInterpreterOption = new InterpreterOption(true, InterpreterOption.ISOLATED, InterpreterOption.SHARED); - final InterpreterSetting setting1 = interpreterSettingManager.createNewSetting("test-group1", "group1", new ArrayList<Dependency>(), perUserInterpreterOption, new Properties()); + final InterpreterSetting setting1 = interpreterSettingManager.createNewSetting("test-group1", "group1", new ArrayList<Dependency>(), perUserInterpreterOption, new HashMap<String, InterpreterProperty>()); interpreterSettingManager.setInterpreters("user1", "note", new ArrayList<String>() {{ add(setting1.getId()); @@ -390,7 +415,7 @@ public class InterpreterFactoryTest { @Test public void testInvalidInterpreterSettingName() { try { - interpreterSettingManager.createNewSetting("new.mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new Properties()); + interpreterSettingManager.createNewSetting("new.mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new HashMap<String, InterpreterProperty>()); fail("expect fail because of invalid InterpreterSetting Name"); } catch (IOException e) { assertEquals("'.' is invalid for InterpreterSetting name.", e.getMessage()); @@ -432,9 +457,9 @@ public class InterpreterFactoryTest { ArrayList<InterpreterInfo> interpreterInfos1 = new ArrayList<>(); interpreterInfos1.add(new InterpreterInfo("name1.class", "name1", true, Maps.<String, Object>newHashMap())); - spyInterpreterSettingManager.add("normalGroup1", interpreterInfos1, Lists.<Dependency>newArrayList(), new InterpreterOption(true), Maps.<String, InterpreterProperty>newHashMap(), "/normalGroup1", null); + spyInterpreterSettingManager.add("normalGroup1", interpreterInfos1, Lists.<Dependency>newArrayList(), new InterpreterOption(true), Maps.<String, DefaultInterpreterProperty>newHashMap(), "/normalGroup1", null); - spyInterpreterSettingManager.createNewSetting("normalGroup1", "normalGroup1", Lists.<Dependency>newArrayList(), new InterpreterOption(true), new Properties()); + spyInterpreterSettingManager.createNewSetting("normalGroup1", "normalGroup1", Lists.<Dependency>newArrayList(), new InterpreterOption(true), new HashMap<String, InterpreterProperty>()); ArrayList<InterpreterInfo> interpreterInfos2 = new ArrayList<>(); interpreterInfos2.add(new InterpreterInfo("name1.class", "name1", true, Maps.<String, Object>newHashMap())); @@ -443,9 +468,9 @@ public class InterpreterFactoryTest { when(mockInterpreterRunner.getPath()).thenReturn("custom-linux-path.sh"); - spyInterpreterSettingManager.add("customGroup1", interpreterInfos2, Lists.<Dependency>newArrayList(), new InterpreterOption(true), Maps.<String, InterpreterProperty>newHashMap(), "/customGroup1", mockInterpreterRunner); + spyInterpreterSettingManager.add("customGroup1", interpreterInfos2, Lists.<Dependency>newArrayList(), new InterpreterOption(true), Maps.<String, DefaultInterpreterProperty>newHashMap(), "/customGroup1", mockInterpreterRunner); - spyInterpreterSettingManager.createNewSetting("customGroup1", "customGroup1", Lists.<Dependency>newArrayList(), new InterpreterOption(true), new Properties()); + spyInterpreterSettingManager.createNewSetting("customGroup1", "customGroup1", Lists.<Dependency>newArrayList(), new InterpreterOption(true), new HashMap<String, InterpreterProperty>()); spyInterpreterSettingManager.setInterpreters("anonymous", "noteCustome", spyInterpreterSettingManager.getDefaultInterpreterSettingList()); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteInterpreterLoaderTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteInterpreterLoaderTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteInterpreterLoaderTest.java index 9c1096d..5632513 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteInterpreterLoaderTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteInterpreterLoaderTest.java @@ -19,7 +19,7 @@ package org.apache.zeppelin.notebook; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Properties; +import java.util.HashMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -31,8 +31,8 @@ import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.InterpreterFactory; import org.apache.zeppelin.interpreter.InterpreterInfo; import org.apache.zeppelin.interpreter.InterpreterOption; +import org.apache.zeppelin.interpreter.DefaultInterpreterProperty; import org.apache.zeppelin.interpreter.InterpreterProperty; -import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.interpreter.InterpreterSettingManager; import org.apache.zeppelin.interpreter.LazyOpenInterpreter; import org.apache.zeppelin.interpreter.mock.MockInterpreter1; @@ -72,11 +72,11 @@ public class NoteInterpreterLoaderTest { ArrayList<InterpreterInfo> interpreterInfos2 = new ArrayList<>(); interpreterInfos2.add(new InterpreterInfo(MockInterpreter2.class.getName(), "mock2", true, Maps.<String, Object>newHashMap())); - interpreterSettingManager.add("group1", interpreterInfos, Lists.<Dependency>newArrayList(), new InterpreterOption(), Maps.<String, InterpreterProperty>newHashMap(), "mock", null); - interpreterSettingManager.add("group2", interpreterInfos2, Lists.<Dependency>newArrayList(), new InterpreterOption(), Maps.<String, InterpreterProperty>newHashMap(), "mock", null); + interpreterSettingManager.add("group1", interpreterInfos, Lists.<Dependency>newArrayList(), new InterpreterOption(), Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock", null); + interpreterSettingManager.add("group2", interpreterInfos2, Lists.<Dependency>newArrayList(), new InterpreterOption(), Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock", null); - interpreterSettingManager.createNewSetting("group1", "group1", Lists.<Dependency>newArrayList(), new InterpreterOption(), new Properties()); - interpreterSettingManager.createNewSetting("group2", "group2", Lists.<Dependency>newArrayList(), new InterpreterOption(), new Properties()); + interpreterSettingManager.createNewSetting("group1", "group1", Lists.<Dependency>newArrayList(), new InterpreterOption(), new HashMap<String, InterpreterProperty>()); + interpreterSettingManager.createNewSetting("group2", "group2", Lists.<Dependency>newArrayList(), new InterpreterOption(), new HashMap<String, InterpreterProperty>()); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java index 495e17b..e1a20b5 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java @@ -97,14 +97,14 @@ public class NotebookTest implements JobListenerFactory{ ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>(); interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock1", interpreterInfos, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock1", null); - interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(), new Properties()); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock1", null); + interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(), new HashMap<String, InterpreterProperty>()); ArrayList<InterpreterInfo> interpreterInfos2 = new ArrayList<>(); interpreterInfos2.add(new InterpreterInfo(MockInterpreter2.class.getName(), "mock2", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock2", interpreterInfos2, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock2", null); - interpreterSettingManager.createNewSetting("mock2", "mock2", new ArrayList<Dependency>(), new InterpreterOption(), new Properties()); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock2", null); + interpreterSettingManager.createNewSetting("mock2", "mock2", new ArrayList<Dependency>(), new InterpreterOption(), new HashMap<String, InterpreterProperty>()); SearchService search = mock(SearchService.class); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/155a55b5/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepoTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepoTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepoTest.java index c361713..6f85bf6 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepoTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepoTest.java @@ -37,6 +37,7 @@ import org.apache.zeppelin.dep.DependencyResolver; import org.apache.zeppelin.interpreter.InterpreterFactory; import org.apache.zeppelin.interpreter.InterpreterInfo; import org.apache.zeppelin.interpreter.InterpreterOption; +import org.apache.zeppelin.interpreter.DefaultInterpreterProperty; import org.apache.zeppelin.interpreter.InterpreterProperty; import org.apache.zeppelin.interpreter.InterpreterSettingManager; import org.apache.zeppelin.interpreter.mock.MockInterpreter1; @@ -96,8 +97,8 @@ public class VFSNotebookRepoTest implements JobListenerFactory { ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>(); interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, new HashMap<String, Object>())); interpreterSettingManager.add("mock1", interpreterInfos, new ArrayList<Dependency>(), new InterpreterOption(), - Maps.<String, InterpreterProperty>newHashMap(), "mock1", null); - interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(), new Properties()); + Maps.<String, DefaultInterpreterProperty>newHashMap(), "mock1", null); + interpreterSettingManager.createNewSetting("mock1", "mock1", new ArrayList<Dependency>(), new InterpreterOption(), new HashMap<String, InterpreterProperty>()); SearchService search = mock(SearchService.class); notebookRepo = new VFSNotebookRepo(conf);
