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/08/19 04:39:29 UTC

zeppelin git commit: [ZEPPELIN-913] Apply new mechanism to HbaseInterpreter

Repository: zeppelin
Updated Branches:
  refs/heads/master bba6ddd24 -> 49b3df666


[ZEPPELIN-913] Apply new mechanism to HbaseInterpreter

### What is this PR for?
This PR applies the new interpreter registration mechanism to Hbase interpreter.

### What type of PR is it?
(minor) Improvement

### Todos
* [ ] - Task

### What is the Jira issue?
[ZEPPELIN-913]

### How should this be tested?
1. apply this patch
3. build source
4. bin/zeppelin-daemon.sh start
5.Run a paragraph with hbase commands

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? => no
* Is there breaking changes for older versions? => well it's not compatible with older static interpreter declaration
* Does this needs documentation? => no

Author: gdupont <ge...@gmail.com>

Closes #1310 from ggdupont/ZEPPELIN-913 and squashes the following commits:

be29b38 [gdupont] fixing unused code and styling
ca0f36c [gdupont] Apply new mechanism to HbaseInterpreter


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

Branch: refs/heads/master
Commit: 49b3df666c562ae29a58833c9284b61b44b63a1d
Parents: bba6ddd
Author: gdupont <ge...@gmail.com>
Authored: Tue Aug 9 23:24:55 2016 +0200
Committer: Jongyoul Lee <jo...@apache.org>
Committed: Fri Aug 19 13:39:25 2016 +0900

----------------------------------------------------------------------
 .../apache/zeppelin/hbase/HbaseInterpreter.java | 24 +++++++------------
 .../src/main/resources/interpreter-setting.json | 25 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/49b3df66/hbase/src/main/java/org/apache/zeppelin/hbase/HbaseInterpreter.java
----------------------------------------------------------------------
diff --git a/hbase/src/main/java/org/apache/zeppelin/hbase/HbaseInterpreter.java b/hbase/src/main/java/org/apache/zeppelin/hbase/HbaseInterpreter.java
index 289579f..6c2460d 100644
--- a/hbase/src/main/java/org/apache/zeppelin/hbase/HbaseInterpreter.java
+++ b/hbase/src/main/java/org/apache/zeppelin/hbase/HbaseInterpreter.java
@@ -54,23 +54,15 @@ import java.util.Properties;
  * zeppelin.hbase.test.mode: (Testing only) Disable checks for unit and manual tests. Default: false
  */
 public class HbaseInterpreter extends Interpreter {
+  public static final String HBASE_HOME = "hbase.home";
+  public static final String HBASE_RUBY_SRC = "hbase.ruby.sources";
+  public static final String HBASE_TEST_MODE = "zeppelin.hbase.test.mode";
+
   private Logger logger = LoggerFactory.getLogger(HbaseInterpreter.class);
   private ScriptingContainer scriptingContainer;
 
   private StringWriter writer;
 
-  static {
-    Interpreter.register("hbase", "hbase", HbaseInterpreter.class.getName(),
-        new InterpreterPropertyBuilder()
-            .add("hbase.home",
-              getSystemDefault("HBASE_HOME", "hbase.home", "/usr/lib/hbase/"),
-              "Installation directory of HBase")
-            .add("hbase.ruby.sources", "lib/ruby",
-                "Path to Ruby scripts relative to 'hbase.home'")
-            .add("zeppelin.hbase.test.mode", "false", "Disable checks for unit and manual tests")
-          .build());
-  }
-
   public HbaseInterpreter(Properties property) {
     super(property);
   }
@@ -81,9 +73,9 @@ public class HbaseInterpreter extends Interpreter {
     this.writer = new StringWriter();
     scriptingContainer.setOutput(this.writer);
 
-    if (!Boolean.parseBoolean(getProperty("zeppelin.hbase.test.mode"))) {
-      String hbase_home = getProperty("hbase.home");
-      String ruby_src = getProperty("hbase.ruby.sources");
+    if (!Boolean.parseBoolean(getProperty(HBASE_TEST_MODE))) {
+      String hbase_home = getProperty(HBASE_HOME);
+      String ruby_src = getProperty(HBASE_RUBY_SRC);
       Path abs_ruby_src = Paths.get(hbase_home, ruby_src).toAbsolutePath();
 
       logger.info("Home:" + hbase_home);
@@ -98,7 +90,7 @@ public class HbaseInterpreter extends Interpreter {
       logger.info("Absolute Ruby Source:" + abs_ruby_src.toString());
       // hirb.rb:41 requires the following system property to be set.
       Properties sysProps = System.getProperties();
-      sysProps.setProperty("hbase.ruby.sources", abs_ruby_src.toString());
+      sysProps.setProperty(HBASE_RUBY_SRC, abs_ruby_src.toString());
 
       Path abs_hirb_path = Paths.get(hbase_home, "bin/hirb.rb");
       try {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/49b3df66/hbase/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/hbase/src/main/resources/interpreter-setting.json b/hbase/src/main/resources/interpreter-setting.json
new file mode 100644
index 0000000..be2f01a
--- /dev/null
+++ b/hbase/src/main/resources/interpreter-setting.json
@@ -0,0 +1,25 @@
+[
+  {
+    "group": "hbase",
+    "name": "hbase",
+    "className": "org.apache.zeppelin.hbase.HbaseInterpreter",
+    "properties": {
+      "hbase.home": {
+        "envName": "HBASE_HOME",
+        "propertyName": "hbase.home",
+        "defaultValue": "/usr/lib/hbase/",
+        "description": "Installation directory of HBase"
+      },
+      "hbase.ruby.sources": {
+        "propertyName": "hbase.ruby.sources",
+        "defaultValue": "lib/ruby",
+        "description": "Path to Ruby scripts relative to 'hbase.home'"
+      },
+      "zeppelin.hbase.test.mode": {
+        "propertyName": "zeppelin.hbase.test.mode",
+        "defaultValue": "false",
+        "description": "Disable checks for unit and manual tests"
+      }
+    }
+  }
+]