You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by jo...@apache.org on 2017/02/24 09:01:56 UTC
zeppelin git commit: [WIP][MINOR][ZEPPELIN-804] Remove static method
for static initialization
Repository: zeppelin
Updated Branches:
refs/heads/master 88637eaa4 -> 8d3482aeb
[WIP][MINOR][ZEPPELIN-804] Remove static method for static initialization
### What is this PR for?
This is one of steps of ZEPPELIN-804 to change the way of registration of interpreter. This PR removes some static method and replace those code to use new mechanism
### What type of PR is it?
[Refactoring]
### Todos
* [x] - Remove `public static void register(...)`
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-804
### How should this be tested?
N/A
### Screenshots (if appropriate)
N/A
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: Jongyoul Lee <jo...@gmail.com>
Closes #1794 from jongyoul/minor/remove-interpreter-register and squashes the following commits:
8f844c4 [Jongyoul Lee] Fixed some tests
53abb6a [Jongyoul Lee] Fixed some tests
d0ea3b3 [Jongyoul Lee] Fixed Test cases
cba3e02 [Jongyoul Lee] Fixed test cases
e9dcf3a [Jongyoul Lee] Marked as deprecated in all Interpreter.register methods
eb2c828 [Jongyoul Lee] Removed static initialization code for all mock interpreters
c505a78 [Jongyoul Lee] Removed static logic from DevInterpreter in helium-dev
06147a7 [Jongyoul Lee] Fixed interpreterOption to pass some tests
875e869 [Jongyoul Lee] Removed `register(String name, String group, String className, boolean defaultInterpreter)` Removed `register(String name, String group, String className)`
67321c6 [Jongyoul Lee] Remove commented code
71a2377 [Jongyoul Lee] Removed `public static void register(String name, String className)`
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/8d3482ae
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/8d3482ae
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/8d3482ae
Branch: refs/heads/master
Commit: 8d3482aeb8f21afc1d149fd1f0ffbd0b2ec77114
Parents: 88637ea
Author: Jongyoul Lee <jo...@gmail.com>
Authored: Thu Feb 23 03:24:25 2017 +0900
Committer: Jongyoul Lee <jo...@apache.org>
Committed: Fri Feb 24 18:01:49 2017 +0900
----------------------------------------------------------------------
.../apache/zeppelin/helium/DevInterpreter.java | 7 ---
.../zeppelin/interpreter/Interpreter.java | 16 +-----
.../zeppelin/interpreter/InterpreterTest.java | 21 ++-----
.../remote/mock/MockInterpreterA.java | 9 ---
.../remote/mock/MockInterpreterAngular.java | 9 ---
.../remote/mock/MockInterpreterB.java | 8 ---
.../remote/mock/MockInterpreterEnv.java | 9 ---
.../mock/MockInterpreterOutputStream.java | 9 ---
.../mock/MockInterpreterResourcePool.java | 9 ---
.../zeppelin/interpreter/InterpreterInfo.java | 2 +-
.../helium/HeliumApplicationFactoryTest.java | 21 +++++--
.../interpreter/InterpreterFactoryTest.java | 58 ++++++++++++++++----
.../notebook/NoteInterpreterLoaderTest.java | 33 +++++++----
.../apache/zeppelin/notebook/NotebookTest.java | 19 +++++--
.../notebook/repo/GitNotebookRepoTest.java | 4 --
.../notebook/repo/NotebookRepoSyncTest.java | 9 ---
.../notebook/repo/VFSNotebookRepoTest.java | 16 +++++-
17 files changed, 121 insertions(+), 138 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/helium-dev/src/main/java/org/apache/zeppelin/helium/DevInterpreter.java
----------------------------------------------------------------------
diff --git a/helium-dev/src/main/java/org/apache/zeppelin/helium/DevInterpreter.java b/helium-dev/src/main/java/org/apache/zeppelin/helium/DevInterpreter.java
index d1007c4..07b6326 100644
--- a/helium-dev/src/main/java/org/apache/zeppelin/helium/DevInterpreter.java
+++ b/helium-dev/src/main/java/org/apache/zeppelin/helium/DevInterpreter.java
@@ -33,13 +33,6 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
* Dummy interpreter to support development mode for Zeppelin app
*/
public class DevInterpreter extends Interpreter {
- static {
- Interpreter.register(
- "dev",
- "dev",
- DevInterpreter.class.getName(),
- new InterpreterPropertyBuilder().build());
- }
private InterpreterEvent interpreterEvent;
private InterpreterContext context;
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/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 6a9cc2c..7114f31 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
@@ -394,25 +394,12 @@ public abstract class Interpreter {
public static Map<String, RegisteredInterpreter> registeredInterpreters = Collections
.synchronizedMap(new HashMap<String, RegisteredInterpreter>());
- public static void register(String name, String className) {
- register(name, name, className);
- }
-
- public static void register(String name, String group, String className) {
- register(name, group, className, false, new HashMap<String, InterpreterProperty>());
- }
-
+ @Deprecated
public static void register(String name, String group, String className,
Map<String, InterpreterProperty> properties) {
register(name, group, className, false, properties);
}
- public static void register(String name, String group, String className,
- boolean defaultInterpreter) {
- register(name, group, className, defaultInterpreter,
- new HashMap<String, InterpreterProperty>());
- }
-
@Deprecated
public static void register(String name, String group, String className,
boolean defaultInterpreter, Map<String, InterpreterProperty> properties) {
@@ -422,6 +409,7 @@ public abstract class Interpreter {
register(new RegisteredInterpreter(name, group, className, defaultInterpreter, properties));
}
+ @Deprecated
public static void register(RegisteredInterpreter registeredInterpreter) {
String interpreterKey = registeredInterpreter.getInterpreterKey();
if (!registeredInterpreters.containsKey(interpreterKey)) {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java
index e10bb32..9eb7932 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java
@@ -29,6 +29,7 @@ public class InterpreterTest {
@Test
public void testDefaultProperty() {
Properties p = new Properties();
+ p.put("p1", "v1");
MockInterpreterA intp = new MockInterpreterA(p);
assertEquals(1, intp.getProperty().size());
@@ -37,27 +38,17 @@ public class InterpreterTest {
}
@Test
- public void testOverridedProperty() {
+ public void testOverriddenProperty() {
Properties p = new Properties();
- p.put("p1", "v2");
+ p.put("p1", "v1");
MockInterpreterA intp = new MockInterpreterA(p);
+ Properties overriddenProperty = new Properties();
+ overriddenProperty.put("p1", "v2");
+ intp.setProperty(overriddenProperty);
assertEquals(1, intp.getProperty().size());
assertEquals("v2", intp.getProperty().get("p1"));
assertEquals("v2", intp.getProperty("p1"));
}
- @Test
- public void testAdditionalProperty() {
- Properties p = new Properties();
- p.put("p2", "v2");
- MockInterpreterA intp = new MockInterpreterA(p);
-
- assertEquals(2, intp.getProperty().size());
- assertEquals("v1", intp.getProperty().get("p1"));
- assertEquals("v1", intp.getProperty("p1"));
- assertEquals("v2", intp.getProperty().get("p2"));
- assertEquals("v2", intp.getProperty("p2"));
- }
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java
index cb367ca..aef3a00 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterA.java
@@ -31,15 +31,6 @@ import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.scheduler.SchedulerFactory;
public class MockInterpreterA extends Interpreter {
- static {
- Interpreter.register(
- "interpreterA",
- "group1",
- MockInterpreterA.class.getName(),
- new InterpreterPropertyBuilder()
- .add("p1", "v1", "property1").build());
-
- }
private String lastSt;
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java
index 76b2925..6805da2 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterAngular.java
@@ -31,15 +31,6 @@ import org.apache.zeppelin.interpreter.InterpreterResult.Code;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
public class MockInterpreterAngular extends Interpreter {
- static {
- Interpreter.register(
- "angularTest",
- "angular",
- MockInterpreterA.class.getName(),
- new InterpreterPropertyBuilder()
- .add("p1", "v1", "property1").build());
-
- }
AtomicInteger numWatch = new AtomicInteger(0);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterB.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterB.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterB.java
index d31a549..4262500 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterB.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterB.java
@@ -32,15 +32,7 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;
public class MockInterpreterB extends Interpreter {
- static {
- Interpreter.register(
- "interpreterB",
- "group1",
- MockInterpreterA.class.getName(),
- new InterpreterPropertyBuilder()
- .add("p1", "v1", "property1").build());
- }
public MockInterpreterB(Properties property) {
super(property);
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterEnv.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterEnv.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterEnv.java
index 10146b8..2bd7893 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterEnv.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterEnv.java
@@ -26,15 +26,6 @@ import java.util.Properties;
public class MockInterpreterEnv extends Interpreter {
- static {
- Interpreter.register(
- "interpreterA",
- "group1",
- MockInterpreterA.class.getName(),
- new InterpreterPropertyBuilder().build());
-
- }
-
public MockInterpreterEnv(Properties property) {
super(property);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java
index 85a8444..8181df1 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterOutputStream.java
@@ -29,15 +29,6 @@ import java.util.Properties;
* MockInterpreter to test outputstream
*/
public class MockInterpreterOutputStream extends Interpreter {
- static {
- Interpreter.register(
- "interpreterOutputStream",
- "group1",
- MockInterpreterA.class.getName(),
- new InterpreterPropertyBuilder().build());
-
- }
-
private String lastSt;
public MockInterpreterOutputStream(Properties property) {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
index be746bd..4321e22 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/mock/MockInterpreterResourcePool.java
@@ -34,15 +34,6 @@ import org.apache.zeppelin.resource.Resource;
import org.apache.zeppelin.resource.ResourcePool;
public class MockInterpreterResourcePool extends Interpreter {
- static {
- Interpreter.register(
- "resourcePoolTest",
- "resourcePool",
- MockInterpreterA.class.getName(),
- new InterpreterPropertyBuilder()
- .add("p1", "v1", "property1").build());
-
- }
AtomicInteger numWatch = new AtomicInteger(0);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterInfo.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterInfo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterInfo.java
index e9088e9..fd632ce 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterInfo.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterInfo.java
@@ -31,7 +31,7 @@ public class InterpreterInfo {
private boolean defaultInterpreter = false;
private Map<String, Object> editor;
- InterpreterInfo(String className, String name, boolean defaultInterpreter,
+ public InterpreterInfo(String className, String name, boolean defaultInterpreter,
Map<String, Object> editor) {
this.className = className;
this.name = name;
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/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 c220019..f91126f 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
@@ -16,8 +16,10 @@
*/
package org.apache.zeppelin.helium;
+import com.google.common.collect.Maps;
import org.apache.commons.io.FileUtils;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.apache.zeppelin.dep.Dependency;
import org.apache.zeppelin.dep.DependencyResolver;
import org.apache.zeppelin.interpreter.*;
import org.apache.zeppelin.interpreter.mock.MockInterpreter1;
@@ -35,9 +37,11 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
+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;
@@ -73,16 +77,11 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME.getVarName(), home.getAbsolutePath());
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_CONF_DIR.getVarName(), tmpDir.getAbsolutePath() + "/conf");
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
- System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETERS.getVarName(), "org.apache.zeppelin.interpreter.mock.MockInterpreter1,org.apache.zeppelin.interpreter.mock.MockInterpreter2");
conf = new ZeppelinConfiguration();
this.schedulerFactory = new SchedulerFactory();
- MockInterpreter1.register("mock1", "org.apache.zeppelin.interpreter.mock.MockInterpreter1");
- MockInterpreter2.register("mock2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");
-
-
heliumAppFactory = new HeliumApplicationFactory();
depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
@@ -91,6 +90,18 @@ public class HeliumApplicationFactoryTest implements JobListenerFactory {
env.put("ZEPPELIN_CLASSPATH", new File("./target/test-classes").getAbsolutePath());
factory.setEnv(env);
+ 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());
+
+ 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());
+
SearchService search = mock(SearchService.class);
notebookRepo = new VFSNotebookRepo(conf);
NotebookAuthorization notebookAuthorization = NotebookAuthorization.init(conf);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/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 a8da7d3..70c7a6b 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
@@ -30,6 +30,7 @@ import java.util.Map;
import java.util.HashMap;
import java.util.Properties;
+import com.google.common.collect.Maps;
import com.google.gson.Gson;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.NullArgumentException;
@@ -87,17 +88,7 @@ public class InterpreterFactoryTest {
new File(tmpDir, "conf").mkdirs();
FileUtils.copyDirectory(new File("src/test/resources/interpreter"), new File(tmpDir, "interpreter"));
- Map<String, InterpreterProperty> propertiesMockInterpreter1 = new HashMap<>();
- propertiesMockInterpreter1.put("PROPERTY_1", new InterpreterProperty("PROPERTY_1", "", "VALUE_1", "desc"));
- propertiesMockInterpreter1.put("property_2", new InterpreterProperty("", "property_2", "value_2", "desc"));
- MockInterpreter1.register("mock1", "mock1", "org.apache.zeppelin.interpreter.mock.MockInterpreter1", propertiesMockInterpreter1);
- MockInterpreter2.register("mock2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");
-
System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), tmpDir.getAbsolutePath());
- System.setProperty(ConfVars.ZEPPELIN_INTERPRETERS.getVarName(),
- "org.apache.zeppelin.interpreter.mock.MockInterpreter1," +
- "org.apache.zeppelin.interpreter.mock.MockInterpreter2," +
- "org.apache.zeppelin.interpreter.mock.MockInterpreter11");
System.setProperty(ConfVars.ZEPPELIN_INTERPRETER_GROUP_ORDER.getVarName(),
"mock1,mock2,mock11,dev");
conf = new ZeppelinConfiguration();
@@ -107,6 +98,21 @@ public class InterpreterFactoryTest {
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
context = new InterpreterContext("note", "id", null, "title", "text", null, null, null, null, null, null, null);
+ 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");
+ 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());
+
SearchService search = mock(SearchService.class);
notebookRepo = new VFSNotebookRepo(conf);
notebookAuthorization = NotebookAuthorization.init(conf);
@@ -149,6 +155,14 @@ public class InterpreterFactoryTest {
@Test
public void testRemoteRepl() throws Exception {
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
+ 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");
+ 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();
InterpreterSetting mock1Setting = null;
@@ -178,6 +192,14 @@ public class InterpreterFactoryTest {
@Test
public void testRestartInterpreterInScopedMode() throws Exception {
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
+ 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");
+ 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();
InterpreterSetting mock1Setting = null;
@@ -215,6 +237,14 @@ public class InterpreterFactoryTest {
@Test
public void testRestartInterpreterInIsolatedMode() throws Exception {
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
+ 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");
+ 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();
InterpreterSetting mock1Setting = null;
@@ -282,7 +312,13 @@ public class InterpreterFactoryTest {
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
- assertEquals(numInterpreters + 1, interpreterSettingManager.get().size());
+ /*
+ Current situation, if InterpreterSettinfRef doesn't have the key of InterpreterSetting, it would be ignored.
+ Thus even though interpreter.json have several interpreterSetting in that file, it would be ignored and would not be initialized from loadFromFile.
+ In this case, only "mock11" would be referenced from file under interpreter/mock, and "mock11" group would be initialized.
+ */
+ // TODO(jl): Decide how to handle the know referenced interpreterSetting.
+ assertEquals(1, interpreterSettingManager.get().size());
}
@Test
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/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 fc8c8bc..9c1096d 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
@@ -18,29 +18,30 @@ package org.apache.zeppelin.notebook;
import java.io.File;
import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
+import java.util.ArrayList;
+import java.util.Properties;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
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;
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.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;
import org.apache.zeppelin.interpreter.mock.MockInterpreter11;
import org.apache.zeppelin.interpreter.mock.MockInterpreter2;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
-import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcess;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static java.lang.Thread.sleep;
import static org.junit.Assert.*;
public class NoteInterpreterLoaderTest {
@@ -61,15 +62,23 @@ public class NoteInterpreterLoaderTest {
conf = ZeppelinConfiguration.create();
- Interpreter.registeredInterpreters = Collections
- .synchronizedMap(new HashMap<String, Interpreter.RegisteredInterpreter>());
- MockInterpreter1.register("mock1", "group1", "org.apache.zeppelin.interpreter.mock.MockInterpreter1", true);
- MockInterpreter11.register("mock11", "group1", "org.apache.zeppelin.interpreter.mock.MockInterpreter11");
- MockInterpreter2.register("mock2", "group2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");
-
depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
+
+ ArrayList<InterpreterInfo> interpreterInfos = new ArrayList<>();
+ interpreterInfos.add(new InterpreterInfo(MockInterpreter1.class.getName(), "mock1", true, Maps.<String, Object>newHashMap()));
+ interpreterInfos.add(new InterpreterInfo(MockInterpreter11.class.getName(), "mock11", false, Maps.<String, Object>newHashMap()));
+ 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.createNewSetting("group1", "group1", Lists.<Dependency>newArrayList(), new InterpreterOption(), new Properties());
+ interpreterSettingManager.createNewSetting("group2", "group2", Lists.<Dependency>newArrayList(), new InterpreterOption(), new Properties());
+
+
}
@After
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/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 f62315c..50775c0 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
@@ -20,6 +20,7 @@ package org.apache.zeppelin.notebook;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
+import com.google.common.collect.Maps;
import java.io.File;
import java.io.IOException;
import java.util.*;
@@ -31,6 +32,7 @@ import com.google.common.collect.Sets;
import org.apache.commons.io.FileUtils;
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;
import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.interpreter.*;
@@ -83,19 +85,28 @@ public class NotebookTest implements JobListenerFactory{
System.setProperty(ConfVars.ZEPPELIN_CONF_DIR.getVarName(), tmpDir.toString() + "/conf");
System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), tmpDir.getAbsolutePath());
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
- System.setProperty(ConfVars.ZEPPELIN_INTERPRETERS.getVarName(), "org.apache.zeppelin.interpreter.mock.MockInterpreter1,org.apache.zeppelin.interpreter.mock.MockInterpreter2");
conf = ZeppelinConfiguration.create();
this.schedulerFactory = new SchedulerFactory();
- MockInterpreter1.register("mock1", "org.apache.zeppelin.interpreter.mock.MockInterpreter1");
- MockInterpreter2.register("mock2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");
-
depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(false));
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
+ 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());
+
+ 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());
+
+
SearchService search = mock(SearchService.class);
notebookRepo = new VFSNotebookRepo(conf);
notebookAuthorization = NotebookAuthorization.init(conf);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/GitNotebookRepoTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/GitNotebookRepoTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/GitNotebookRepoTest.java
index 4fe3dfd..6249dfa 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/GitNotebookRepoTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/GitNotebookRepoTest.java
@@ -78,12 +78,8 @@ public class GitNotebookRepoTest {
System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), zeppelinDir.getAbsolutePath());
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
- System.setProperty(ConfVars.ZEPPELIN_INTERPRETERS.getVarName(), "org.apache.zeppelin.interpreter.mock.MockInterpreter1,org.apache.zeppelin.interpreter.mock.MockInterpreter2");
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), "org.apache.zeppelin.notebook.repo.GitNotebookRepo");
- MockInterpreter1.register("mock1", "org.apache.zeppelin.interpreter.mock.MockInterpreter1");
- MockInterpreter2.register("mock2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");
-
conf = ZeppelinConfiguration.create();
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java
index a77b646..de1575a 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java
@@ -35,18 +35,13 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
import org.apache.zeppelin.dep.DependencyResolver;
import org.apache.zeppelin.interpreter.InterpreterFactory;
import org.apache.zeppelin.interpreter.InterpreterOption;
-import org.apache.zeppelin.interpreter.InterpreterOutput;
import org.apache.zeppelin.interpreter.InterpreterResultMessage;
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
-import org.apache.zeppelin.interpreter.mock.MockInterpreter1;
-import org.apache.zeppelin.interpreter.mock.MockInterpreter2;
import org.apache.zeppelin.notebook.*;
import org.apache.zeppelin.scheduler.Job;
import org.apache.zeppelin.scheduler.Job.Status;
-import org.apache.zeppelin.scheduler.JobListener;
import org.apache.zeppelin.scheduler.SchedulerFactory;
import org.apache.zeppelin.search.SearchService;
-import org.apache.zeppelin.search.LuceneSearch;
import org.apache.zeppelin.user.AuthenticationInfo;
import org.apache.zeppelin.user.Credentials;
import org.junit.After;
@@ -90,7 +85,6 @@ public class NotebookRepoSyncTest implements JobListenerFactory {
System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), mainZepDir.getAbsolutePath());
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), mainNotebookDir.getAbsolutePath());
- System.setProperty(ConfVars.ZEPPELIN_INTERPRETERS.getVarName(), "org.apache.zeppelin.interpreter.mock.MockInterpreter1,org.apache.zeppelin.interpreter.mock.MockInterpreter2");
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), "org.apache.zeppelin.notebook.repo.VFSNotebookRepo,org.apache.zeppelin.notebook.repo.mock.VFSNotebookRepoMock");
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_ONE_WAY_SYNC.getVarName(), "false");
LOG.info("main Note dir : " + mainNotePath);
@@ -99,9 +93,6 @@ public class NotebookRepoSyncTest implements JobListenerFactory {
this.schedulerFactory = new SchedulerFactory();
- MockInterpreter1.register("mock1", "org.apache.zeppelin.interpreter.mock.MockInterpreter1");
- MockInterpreter2.register("mock2", "org.apache.zeppelin.interpreter.mock.MockInterpreter2");
-
depResolver = new DependencyResolver(mainZepDir.getAbsolutePath() + "/local-repo");
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8d3482ae/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 6db85fe..18f5fe9 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
@@ -22,15 +22,22 @@ import static org.mockito.Mockito.mock;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
+import com.google.common.collect.Maps;
import org.apache.commons.io.FileUtils;
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;
import org.apache.zeppelin.interpreter.InterpreterFactory;
+import org.apache.zeppelin.interpreter.InterpreterInfo;
import org.apache.zeppelin.interpreter.InterpreterOption;
+import org.apache.zeppelin.interpreter.InterpreterProperty;
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
import org.apache.zeppelin.interpreter.mock.MockInterpreter1;
import org.apache.zeppelin.notebook.JobListenerFactory;
@@ -76,19 +83,22 @@ public class VFSNotebookRepoTest implements JobListenerFactory {
System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), mainZepDir.getAbsolutePath());
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), mainNotebookDir.getAbsolutePath());
- System.setProperty(ConfVars.ZEPPELIN_INTERPRETERS.getVarName(), "org.apache.zeppelin.interpreter.mock.MockInterpreter1");
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE.getVarName(), "org.apache.zeppelin.notebook.repo.VFSNotebookRepo");
conf = ZeppelinConfiguration.create();
this.schedulerFactory = new SchedulerFactory();
- MockInterpreter1.register("mock1", "org.apache.zeppelin.interpreter.mock.MockInterpreter1");
-
this.schedulerFactory = new SchedulerFactory();
depResolver = new DependencyResolver(mainZepDir.getAbsolutePath() + "/local-repo");
interpreterSettingManager = new InterpreterSettingManager(conf, depResolver, new InterpreterOption(true));
factory = new InterpreterFactory(conf, null, null, null, depResolver, false, interpreterSettingManager);
+ 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());
+
SearchService search = mock(SearchService.class);
notebookRepo = new VFSNotebookRepo(conf);
notebookAuthorization = NotebookAuthorization.init(conf);