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 2016/10/24 05:45:29 UTC
zeppelin git commit: [ZEPPELIN-912] Apply new mechanism to
GeodeOqlInterpreter
Repository: zeppelin
Updated Branches:
refs/heads/master 575467055 -> 89392a3f2
[ZEPPELIN-912] Apply new mechanism to GeodeOqlInterpreter
### What is this PR for?
This PR applies the new interpreter registration mechanism to Geode Oql interpreter.
### What type of PR is it?
Improvement
### Todos
Added `interpreter-setting.json`
### What is the Jira issue?
Jira: https://issues.apache.org/jira/browse/ZEPPELIN-912
### How should this be tested?
Test locally.
### 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: Kai Jiang <ji...@gmail.com>
Closes #1550 from vectorijk/zeppelin-912 and squashes the following commits:
5dfad61 [Kai Jiang] Apply new mechanism to GeodeOqlInterpreter
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/89392a3f
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/89392a3f
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/89392a3f
Branch: refs/heads/master
Commit: 89392a3f20b8e447bb9ee54f23716001686d971e
Parents: 5754670
Author: Kai Jiang <ji...@gmail.com>
Authored: Sat Oct 22 06:13:11 2016 -0700
Committer: Jongyoul Lee <jo...@apache.org>
Committed: Mon Oct 24 12:36:42 2016 +0900
----------------------------------------------------------------------
.../zeppelin/geode/GeodeOqlInterpreter.java | 27 +++---------------
.../src/main/resources/interpreter-setting.json | 30 ++++++++++++++++++++
.../zeppelin/geode/GeodeOqlInterpreterTest.java | 6 ++--
3 files changed, 37 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/89392a3f/geode/src/main/java/org/apache/zeppelin/geode/GeodeOqlInterpreter.java
----------------------------------------------------------------------
diff --git a/geode/src/main/java/org/apache/zeppelin/geode/GeodeOqlInterpreter.java b/geode/src/main/java/org/apache/zeppelin/geode/GeodeOqlInterpreter.java
index 12297b6..c677e45 100644
--- a/geode/src/main/java/org/apache/zeppelin/geode/GeodeOqlInterpreter.java
+++ b/geode/src/main/java/org/apache/zeppelin/geode/GeodeOqlInterpreter.java
@@ -21,7 +21,6 @@ import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterPropertyBuilder;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
@@ -38,7 +37,7 @@ import com.gemstone.gemfire.cache.query.Struct;
import com.gemstone.gemfire.pdx.PdxInstance;
/**
- * Apache Geode OQL Interpreter (http://geode.incubator.apache.org)
+ * Apache Geode OQL Interpreter (http://geode.apache.org)
*
* <ul>
* <li>{@code geode.locator.host} - The Geode Locator {@code <HOST>} to connect to.</li>
@@ -87,30 +86,12 @@ public class GeodeOqlInterpreter extends Interpreter {
private Logger logger = LoggerFactory.getLogger(GeodeOqlInterpreter.class);
- public static final String DEFAULT_PORT = "10334";
- public static final String DEFAULT_HOST = "localhost";
- public static final String DEFAULT_MAX_RESULT = "1000";
-
private static final char NEWLINE = '\n';
private static final char TAB = '\t';
private static final char WHITESPACE = ' ';
private static final String TABLE_MAGIC_TAG = "%table ";
- public static final String LOCATOR_HOST = "geode.locator.host";
- public static final String LOCATOR_PORT = "geode.locator.port";
- public static final String MAX_RESULT = "geode.max.result";
-
- static {
- Interpreter.register(
- "oql",
- "geode",
- GeodeOqlInterpreter.class.getName(),
- new InterpreterPropertyBuilder().add(LOCATOR_HOST, DEFAULT_HOST, "The Geode Locator Host.")
- .add(LOCATOR_PORT, DEFAULT_PORT, "The Geode Locator Port")
- .add(MAX_RESULT, DEFAULT_MAX_RESULT, "Max number of OQL result to display.").build());
- }
-
private ClientCache clientCache = null;
private QueryService queryService = null;
private Exception exceptionOnConnect;
@@ -122,8 +103,8 @@ public class GeodeOqlInterpreter extends Interpreter {
protected ClientCache getClientCache() {
- String locatorHost = getProperty(LOCATOR_HOST);
- int locatorPort = Integer.valueOf(getProperty(LOCATOR_PORT));
+ String locatorHost = getProperty("geode.locator.host");
+ int locatorPort = Integer.valueOf(getProperty("geode.locator.port"));
ClientCache clientCache =
new ClientCacheFactory().addPoolLocator(locatorHost, locatorPort).create();
@@ -139,7 +120,7 @@ public class GeodeOqlInterpreter extends Interpreter {
close();
try {
- maxResult = Integer.valueOf(getProperty(MAX_RESULT));
+ maxResult = Integer.valueOf(getProperty("geode.max.result"));
clientCache = getClientCache();
queryService = clientCache.getQueryService();
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/89392a3f/geode/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/geode/src/main/resources/interpreter-setting.json b/geode/src/main/resources/interpreter-setting.json
new file mode 100644
index 0000000..f67cfef
--- /dev/null
+++ b/geode/src/main/resources/interpreter-setting.json
@@ -0,0 +1,30 @@
+[
+ {
+ "group": "geode",
+ "name": "oql",
+ "className": "org.apache.zeppelin.geode.GeodeOqlInterpreter",
+ "properties": {
+ "geode.locator.host": {
+ "envName": null,
+ "propertyName": "geode.locator.host",
+ "defaultValue": "localhost",
+ "description": "The Geode Locator Host."
+ },
+ "geode.locator.port": {
+ "envName": null,
+ "propertyName": "geode.locator.port",
+ "defaultValue": "10334",
+ "description": "The Geode Locator Port."
+ },
+ "geode.max.result": {
+ "envName": null,
+ "propertyName": "geode.max.result",
+ "defaultValue": "1000",
+ "description": "Max number of OQL result to display."
+ }
+ },
+ "editor": {
+ "language": "sql"
+ }
+ }
+]
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/89392a3f/geode/src/test/java/org/apache/zeppelin/geode/GeodeOqlInterpreterTest.java
----------------------------------------------------------------------
diff --git a/geode/src/test/java/org/apache/zeppelin/geode/GeodeOqlInterpreterTest.java b/geode/src/test/java/org/apache/zeppelin/geode/GeodeOqlInterpreterTest.java
index 78755eb..0b23caa 100644
--- a/geode/src/test/java/org/apache/zeppelin/geode/GeodeOqlInterpreterTest.java
+++ b/geode/src/test/java/org/apache/zeppelin/geode/GeodeOqlInterpreterTest.java
@@ -58,9 +58,9 @@ public class GeodeOqlInterpreterTest {
public void testOpenCommandIndempotency() {
Properties properties = new Properties();
- properties.put(LOCATOR_HOST, DEFAULT_HOST);
- properties.put(LOCATOR_PORT, DEFAULT_PORT);
- properties.put(MAX_RESULT, DEFAULT_MAX_RESULT);
+ properties.put("geode.locator.host", "localhost");
+ properties.put("geode.locator.port", "10334");
+ properties.put("geode.max.result", "1000");
GeodeOqlInterpreter spyGeodeOqlInterpreter = spy(new GeodeOqlInterpreter(properties));