Repository: zeppelin
Updated Branches:
  refs/heads/master 201d60122 -> 58cdba2a8


[ZEPPELIN-916] Apply new mechanism to KylinInterpreter

### What is this PR for?
Applying for new registration mechanism for Apache Kylin

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

### Todos
* [x] - Added interpreter-setting.json

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

### 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 <jongy...@gmail.com>

Closes #1515 from jongyoul/ZEPPELIN-916 and squashes the following commits:

5e23043 [Jongyoul Lee] Added interpreter-setting.json Fixed test environments


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

Branch: refs/heads/master
Commit: 58cdba2a8c52386aed780355bca9c54599bf4e86
Parents: 201d601
Author: Jongyoul Lee <jongy...@gmail.com>
Authored: Fri Oct 14 12:08:21 2016 +0900
Committer: Jongyoul Lee <jongy...@apache.org>
Committed: Mon Oct 17 21:56:58 2016 +0900

----------------------------------------------------------------------
 .../apache/zeppelin/kylin/KylinInterpreter.java | 18 -------
 .../src/main/resources/interpreter-setting.json | 54 ++++++++++++++++++++
 kylin/src/test/java/KylinInterpreterTest.java   | 23 +++++----
 3 files changed, 67 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/58cdba2a/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java
----------------------------------------------------------------------
diff --git 
a/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java 
b/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java
index 72fad1a..8523e49 100755
--- a/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java
+++ b/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java
@@ -56,24 +56,6 @@ public class KylinInterpreter extends Interpreter {
   static final Pattern KYLIN_TABLE_FORMAT_REGEX_LABEL = 
Pattern.compile("\"label\":\"(.*?)\"");
   static final Pattern KYLIN_TABLE_FORMAT_REGEX = 
Pattern.compile("\"results\":\\[\\[\"(.*?)\"]]");
 
-  static {
-    Interpreter.register(
-        "kylin",
-        "kylin",
-        KylinInterpreter.class.getName(),
-        new InterpreterPropertyBuilder()
-            .add(KYLIN_USERNAME, "ADMIN", "username for kylin user")
-            .add(KYLIN_PASSWORD, "KYLIN", "password for kylin user")
-            .add(KYLIN_QUERY_API_URL, "http://<host>:<port>/kylin/api/query", 
"Kylin API.")
-            .add(KYLIN_QUERY_PROJECT, "default", "kylin project name")
-            .add(KYLIN_QUERY_OFFSET, "0", "kylin query offset")
-            .add(KYLIN_QUERY_LIMIT, "5000", "kylin query limit")
-            .add(KYLIN_QUERY_ACCEPT_PARTIAL, "true", "The kylin query partial 
flag").build());
-  }
-
-
-
-
   public KylinInterpreter(Properties property) {
     super(property);
   }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/58cdba2a/kylin/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/kylin/src/main/resources/interpreter-setting.json 
b/kylin/src/main/resources/interpreter-setting.json
new file mode 100644
index 0000000..b804da0
--- /dev/null
+++ b/kylin/src/main/resources/interpreter-setting.json
@@ -0,0 +1,54 @@
+[
+  {
+    "group": "kylin",
+    "name": "kylin",
+    "className": "org.apache.zeppelin.kylin.KylinInterpreter",
+    "properties": {
+      "kylin.api.url": {
+        "envName": null,
+        "propertyName": "kylin.api.url",
+        "defaultValue": "http://localhost:7070/kylin/api/query";,
+        "description": "Kylin API"
+      },
+      "kylin.api.user": {
+        "envName": null,
+        "propertyName": "kylin.api.user",
+        "defaultValue": "ADMIN",
+        "description": "username for kylin user"
+      },
+      "kylin.api.password": {
+        "envName": null,
+        "propertyName": "kylin.api.password",
+        "defaultValue": "KYLIN",
+        "description": "password for kylin user"
+      },
+      "kylin.query.project": {
+        "envName": null,
+        "propertyName": "kylin.query.project",
+        "defaultValue": "default",
+        "description": "kylin project name"
+      },
+      "kylin.query.offset": {
+        "envName": null,
+        "propertyName": "kylin.query.offset",
+        "defaultValue": "0",
+        "description": "kylin query offset"
+      },
+      "kylin.query.limit": {
+        "envName": null,
+        "propertyName": "kylin.query.limit",
+        "defaultValue": "5000",
+        "description": "kylin query limit"
+      },
+      "kylin.query.ispartial": {
+        "envName": null,
+        "propertyName": "kylin.query.ispartial",
+        "defaultValue": "true",
+        "description": "The kylin query partial flag"
+      }
+    },
+    "editor": {
+      "language": "sql"
+    }
+  }
+]

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/58cdba2a/kylin/src/test/java/KylinInterpreterTest.java
----------------------------------------------------------------------
diff --git a/kylin/src/test/java/KylinInterpreterTest.java 
b/kylin/src/test/java/KylinInterpreterTest.java
index 1df20f6..6f756da 100755
--- a/kylin/src/test/java/KylinInterpreterTest.java
+++ b/kylin/src/test/java/KylinInterpreterTest.java
@@ -20,8 +20,7 @@ import org.apache.http.client.methods.HttpPost;
 import org.apache.http.message.AbstractHttpMessage;
 import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.kylin.KylinInterpreter;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.io.ByteArrayInputStream;
@@ -33,19 +32,23 @@ import java.util.Properties;
 
 import static org.junit.Assert.assertEquals;
 
-
 public class KylinInterpreterTest {
-  @Before
-  public void setUp() throws Exception {
-  }
+  static final Properties kylinProperties = new Properties();
 
-  @After
-  public void tearDown() throws Exception {
+  @BeforeClass
+  public static void setUpClass() {
+    kylinProperties.put("kylin.api.url", 
"http://localhost:7070/kylin/api/query";);
+    kylinProperties.put("kylin.api.user", "ADMIN");
+    kylinProperties.put("kylin.api.password", "KYLIN");
+    kylinProperties.put("kylin.query.project", "default");
+    kylinProperties.put("kylin.query.offset", "0");
+    kylinProperties.put("kylin.query.limit", "5000");
+    kylinProperties.put("kylin.query.ispartial", "true");
   }
 
   @Test
   public void test(){
-    KylinInterpreter t = new MockKylinInterpreter(new Properties());
+    KylinInterpreter t = new MockKylinInterpreter(kylinProperties);
     InterpreterResult result = t.interpret(
         "select a.date,sum(b.measure) as measure from kylin_fact_table a " +
             "inner join kylin_lookup_table b on a.date=b.date group by 
a.date", null);
@@ -198,4 +201,4 @@ class MockEntity implements HttpEntity{
   public void consumeContent() throws IOException {
 
   }
-}
\ No newline at end of file
+}

Reply via email to