zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject zeppelin git commit: [ZEPPELIN-1334] Environment variable defined in interpreter setting doesn't take effect
Date Sat, 10 Sep 2016 18:05:48 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.6 23162c5bc -> 074ce6f97


[ZEPPELIN-1334] Environment variable defined in interpreter setting doesn't take effect

I define SPAKR_HOME in interpreter setting, but it doesn't take effect. This PR is for bring
back the environment variable defined in interpreter setting.  The root cause is that we reset
the env after creating RemoteInterpreter.
```
         new RemoteInterpreter(property, noteId, className, conf.getInterpreterRemoteRunnerPath(),
             interpreterPath, localRepoPath, connectTimeout, maxPoolSize,
             remoteInterpreterProcessListener, appEventListener);
    remoteInterpreter.setEnv(env);
```

[Bug Fix]

* [ ] - Task

* https://issues.apache.org/jira/browse/ZEPPELIN-1334

Tested manually.  Create 2 spark interpreter setting, one for spark1 another is for spark2.
And define SPARK_HOME for each interpreter. Then I can run both spark1 and spark2 in one zeppelin
instance.

![image](https://cloud.githubusercontent.com/assets/164491/17696073/b64b1014-63de-11e6-88ab-d26b1c2fa75c.png)

* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Jeff Zhang <zjffdu@apache.org>

Closes #1333 from zjffdu/ZEPPELIN-1334 and squashes the following commits:

febbf3f [Jeff Zhang] fix unit test
dd59b35 [Jeff Zhang] fix code style
39c9140 [Jeff Zhang] add test case
32ae1a2 [Jeff Zhang] [ZEPPELIN-1334] Environment variable defined in interpreter setting doesn't
take effect

(cherry picked from commit db99ccb7056282033978244fe1ffb3f204c0aedd)
Signed-off-by: Lee moon soo <moon@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/074ce6f9
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/074ce6f9
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/074ce6f9

Branch: refs/heads/branch-0.6
Commit: 074ce6f972e0538b618a5b060ad131f576cf8a66
Parents: 23162c5
Author: Jeff Zhang <zjffdu@apache.org>
Authored: Thu Sep 8 13:40:06 2016 +0800
Committer: Lee moon soo <moon@apache.org>
Committed: Sat Sep 10 11:05:19 2016 -0700

----------------------------------------------------------------------
 .../interpreter/remote/RemoteInterpreter.java   | 15 ++++++++++
 zeppelin-zengine/pom.xml                        |  9 ++++++
 .../interpreter/InterpreterFactory.java         | 12 ++++----
 .../interpreter/InterpreterFactoryTest.java     | 31 +++++++++++++++++++-
 4 files changed, 61 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/074ce6f9/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java
index e18edbd..7e4c080 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java
@@ -462,4 +462,19 @@ public class RemoteInterpreter extends Interpreter {
       client.angularRegistryPush(gson.toJson(registry, registryType));
     }
   }
+
+  public Map<String, String> getEnv() {
+    return env;
+  }
+
+  public void setEnv(Map<String, String> env) {
+    this.env = env;
+  }
+
+  public void addEnv(Map<String, String> env) {
+    if (this.env == null) {
+      this.env = new HashMap<>();
+    }
+    this.env.putAll(env);
+  }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/074ce6f9/zeppelin-zengine/pom.xml
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/pom.xml b/zeppelin-zengine/pom.xml
index 0292e3b..897bb62 100644
--- a/zeppelin-zengine/pom.xml
+++ b/zeppelin-zengine/pom.xml
@@ -258,5 +258,14 @@
         <filtering>true</filtering>
       </resource>
     </resources>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.17</version>
+        <configuration combine.children="append">
+          <forkMode>always</forkMode>
+        </configuration>
+      </plugin>
+    </plugins>
   </build>
 </project>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/074ce6f9/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 9802275..715890a 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
@@ -890,11 +890,13 @@ public class InterpreterFactory implements InterpreterGroupFactory {
     String localRepoPath = conf.getInterpreterLocalRepoPath() + "/" + interpreterSettingId;
     int maxPoolSize = conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_MAX_POOL_SIZE);
 
-    LazyOpenInterpreter intp = new LazyOpenInterpreter(new RemoteInterpreter(
-        property, noteId, className, conf.getInterpreterRemoteRunnerPath(),
-        interpreterPath, localRepoPath, connectTimeout,
-        maxPoolSize, remoteInterpreterProcessListener));
-    return intp;
+    RemoteInterpreter remoteInterpreter =
+        new RemoteInterpreter(property, noteId, className, conf.getInterpreterRemoteRunnerPath(),
+            interpreterPath, localRepoPath, connectTimeout, maxPoolSize,
+            remoteInterpreterProcessListener);
+    remoteInterpreter.addEnv(env);
+
+    return new LazyOpenInterpreter(remoteInterpreter);
   }
 
   private URL[] recursiveBuildLibList(File path) throws MalformedURLException {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/074ce6f9/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 3d9ee6f..ce74914 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
@@ -20,6 +20,8 @@ package org.apache.zeppelin.interpreter;
 import java.io.*;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
 import java.util.Properties;
 
 import org.apache.commons.lang.NullArgumentException;
@@ -29,6 +31,7 @@ import org.apache.zeppelin.dep.Dependency;
 import org.apache.zeppelin.dep.DependencyResolver;
 import org.apache.zeppelin.interpreter.mock.MockInterpreter1;
 import org.apache.zeppelin.interpreter.mock.MockInterpreter2;
+import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -50,7 +53,10 @@ public class InterpreterFactoryTest {
     tmpDir.mkdirs();
     new File(tmpDir, "conf").mkdirs();
 
-    MockInterpreter1.register("mock1", "org.apache.zeppelin.interpreter.mock.MockInterpreter1");
+    Map<String, InterpreterProperty> propertiesMockInterpreter1 = new HashMap<String,
InterpreterProperty>();
+    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());
@@ -99,6 +105,29 @@ public class InterpreterFactoryTest {
   }
 
   @Test
+  public void testRemoteRepl() throws Exception {
+    factory = new InterpreterFactory(conf, new InterpreterOption(true), null, null, null,
depResolver);
+    List<InterpreterSetting> all = factory.get();
+    InterpreterSetting mock1Setting = null;
+    for (InterpreterSetting setting : all) {
+      if (setting.getName().equals("mock1")) {
+        mock1Setting = setting;
+        break;
+      }
+    }
+    InterpreterGroup interpreterGroup = mock1Setting.getInterpreterGroup("sharedProcess");
+    factory.createInterpretersForNote(mock1Setting, "sharedProcess", "session");
+    // get interpreter
+    assertNotNull("get Interpreter", interpreterGroup.get("session").get(0));
+    assertTrue(interpreterGroup.get("session").get(0) instanceof LazyOpenInterpreter);
+    LazyOpenInterpreter lazyInterpreter = (LazyOpenInterpreter)(interpreterGroup.get("session").get(0));
+    assertTrue(lazyInterpreter.getInnerInterpreter() instanceof RemoteInterpreter);
+    RemoteInterpreter remoteInterpreter = (RemoteInterpreter) lazyInterpreter.getInnerInterpreter();
+    assertEquals("VALUE_1", remoteInterpreter.getEnv().get("PROPERTY_1"));
+    assertEquals("value_2", remoteInterpreter.getProperty("property_2"));
+  }
+
+  @Test
   public void testFactoryDefaultList() throws IOException, RepositoryException {
     // get default settings
     List<String> all = factory.getDefaultInterpreterSettingList();


Mime
View raw message