Repository: zeppelin
Updated Branches:
  refs/heads/master 582981677 -> 377dc4edf


[ZEPPELIN-1191] Supported legacy way to run paragraph with group name only

### What is this PR for?
Preserving legacy way to run paragraph when users use group name only

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

### Todos
* [x] - Added the way to find a interpreter with group name at last

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1191

### How should this be tested?

### Screenshots (if appropriate)

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

Author: Jongyoul Lee <[email protected]>

Closes #1200 from jongyoul/ZEPPELIN-1191 and squashes the following commits:

12a2424 [Jongyoul Lee] Supported old way to run paragraph with group name only


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

Branch: refs/heads/master
Commit: 377dc4edf7fca96bd1399d92c6e2e924b47796ac
Parents: 5829816
Author: Jongyoul Lee <[email protected]>
Authored: Mon Jul 18 17:30:01 2016 +0900
Committer: Jongyoul Lee <[email protected]>
Committed: Tue Aug 23 01:30:57 2016 +0900

----------------------------------------------------------------------
 .../interpreter/InterpreterFactory.java         | 25 +++++++++++++-------
 .../interpreter/InterpreterFactoryTest.java     |  1 +
 2 files changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/377dc4ed/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 4ec8fa0..30411d1 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
@@ -97,13 +97,13 @@ public class InterpreterFactory implements 
InterpreterGroupFactory {
    * This is only references with default settings, name and properties
    * key: InterpreterSetting.name
    */
-  private Map<String, InterpreterSetting> interpreterSettingsRef = new 
HashMap<>();
+  private final Map<String, InterpreterSetting> interpreterSettingsRef = new 
HashMap<>();
 
   /**
    * This is used by creating and running Interpreters
    * key: InterpreterSetting.id <- This is becuase backward compatibility
    */
-  private Map<String, InterpreterSetting> interpreterSettings = new 
HashMap<>();
+  private final Map<String, InterpreterSetting> interpreterSettings = new 
HashMap<>();
 
   private Map<String, List<String>> interpreterBindings = new HashMap<>();
   private List<RemoteRepository> interpreterRepositories;
@@ -175,7 +175,7 @@ public class InterpreterFactory implements 
InterpreterGroupFactory {
 
         registerInterpreterFromResource(cl, interpreterDirString, 
interpreterJson);
 
-        /**
+        /*
          * TODO(jongyoul)
          * - Remove these codes below because of legacy code
          * - Support ThreadInterpreter
@@ -468,8 +468,6 @@ public class InterpreterFactory implements 
InterpreterGroupFactory {
    * Return ordered interpreter setting list.
    * The list does not contain more than one setting from the same interpreter 
class.
    * Order by InterpreterClass (order defined by ZEPPELIN_INTERPRETERS), 
Interpreter setting name
-   *
-   * @return
    */
   public List<String> getDefaultInterpreterSettingList() {
     // this list will contain default interpreter setting list
@@ -529,8 +527,7 @@ public class InterpreterFactory implements 
InterpreterGroupFactory {
   }
 
   /**
-   * @param group    InterpreterSetting reference name
-   * @param properties
+   * @param group InterpreterSetting reference name
    * @return
    */
   public InterpreterSetting add(String group, ArrayList<InterpreterInfo> 
interpreterInfos,
@@ -579,8 +576,8 @@ public class InterpreterFactory implements 
InterpreterGroupFactory {
 
       } else {
         interpreterSetting =
-            new InterpreterSetting(group, null, interpreterInfos, properties, 
dependencies,
-                option, path);
+            new InterpreterSetting(group, null, interpreterInfos, properties, 
dependencies, option,
+                path);
         interpreterSettingsRef.put(group, interpreterSetting);
       }
     }
@@ -1176,6 +1173,16 @@ public class InterpreterFactory implements 
InterpreterGroupFactory {
           return interpreters.get(0);
         }
       }
+
+      // Support the legacy way to use it
+      for (InterpreterSetting s : settings) {
+        if (s.getGroup().equals(replName)) {
+          List<Interpreter> interpreters = createOrGetInterpreterList(noteId, 
s);
+          if (null != interpreters) {
+            return interpreters.get(0);
+          }
+        }
+      }
     }
 
     // dev interpreter

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/377dc4ed/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 e284164..c344082 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
@@ -155,5 +155,6 @@ public class InterpreterFactoryTest {
     }});
 
     assertEquals("className1", factory.getInterpreter("note", 
"test-group1").getClassName());
+    assertEquals("className1", factory.getInterpreter("note", 
"group1").getClassName());
   }
 }

Reply via email to