zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jongy...@apache.org
Subject zeppelin git commit: Search for interpreter-settings in several jars in folder
Date Wed, 01 Feb 2017 15:02:16 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master 42be8396c -> 019df1f6b


Search for interpreter-settings in several jars in folder

### What is this PR for?
`InterpreterFactory` searches for single `interpreter-settings.json` in some jar in folder.
This PR allows us to have `interpreter-settings.json` in several jar in one interpreter folder.

For example, we can have `zeppelin-spark.jar` and `zeppelin-zrinterpreter.jar` in interpreter/spark
folder, both with interpreter-settings.json. Zeppelin will load R settings only when `zeppelin-zrinterpreter.jar`
exists.

### What type of PR is it?
[Improvement]

### What is the Jira issue?
* Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/
* Put link here, and add [ZEPPELIN-*Jira number*] in PR title, eg. [ZEPPELIN-533]

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

Author: Igor Drozdov <igor_drozdov@epam.com>

Closes #1937 from DrIgor/multiply-interpreter-settings and squashes the following commits:

b1dd6a3 [Igor Drozdov] Search for interpreter-settings in several jars in folder


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

Branch: refs/heads/master
Commit: 019df1f6bc4875bd8592d2cb77164b1c9756ac1c
Parents: 42be839
Author: Igor Drozdov <igor_drozdov@epam.com>
Authored: Mon Jan 23 14:20:38 2017 +0300
Committer: Jongyoul Lee <jongyoul@apache.org>
Committed: Thu Feb 2 00:02:06 2017 +0900

----------------------------------------------------------------------
 .../interpreter/InterpreterFactory.java         | 22 ++++++++++++--------
 1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/019df1f6/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 bb43fa4..633a9b1 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
@@ -42,6 +42,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -312,16 +313,19 @@ public class InterpreterFactory implements InterpreterGroupFactory {
     URL[] urls = recursiveBuildLibList(new File(interpreterDir));
     ClassLoader tempClassLoader = new URLClassLoader(urls, cl);
 
-    InputStream inputStream = tempClassLoader.getResourceAsStream(interpreterJson);
-
-    if (null != inputStream) {
-      logger.debug("Reading {} from resources in {}", interpreterJson, interpreterDir);
-      List<RegisteredInterpreter> registeredInterpreterList =
-          getInterpreterListFromJson(inputStream);
-      registerInterpreters(registeredInterpreterList, interpreterDir);
-      return true;
+    Enumeration<URL> interpreterSettings = tempClassLoader.getResources(interpreterJson);
+    if (!interpreterSettings.hasMoreElements()) {
+      return false;
     }
-    return false;
+    for (URL url : Collections.list(interpreterSettings)) {
+      try (InputStream inputStream = url.openStream()) {
+        logger.debug("Reading {} from {}", interpreterJson, url);
+        List<RegisteredInterpreter> registeredInterpreterList =
+            getInterpreterListFromJson(inputStream);
+        registerInterpreters(registeredInterpreterList, interpreterDir);
+      }
+    }
+    return true;
   }
 
   private boolean registerInterpreterFromPath(String interpreterDir, String interpreterJson)


Mime
View raw message