Repository: incubator-zeppelin Updated Branches: refs/heads/master ea03e84d6 -> 1940388e3
HBase Shell Interpreter Support for Hbase Shell. All the commands documented here https://wiki.apache.org/hadoop/Hbase/Shell is supported. Requirements: Hbase Shell should be installed on the same machine. To be more specific, the following dir. should be available: https://github.com/apache/hbase/tree/master/hbase-shell/src/main/ruby Hbase Shell should be able to connect to the Hbase cluster from terminal. This makes sure that the client is configured properly. The interpreter takes 3 config parameters: hbase.home: Root dir. where hbase is installed. Default is /usr/lib/hbase/ hbase.ruby.sources: Dir where shell ruby code is installed. Path is relative to hbase.home. Default: lib/ruby hbase.irb.load: (Testing only) Default is true. Whether to load irb in the interpreter. Author: Rajat Venkatesh <[email protected]> Closes #278 from vrajat/incubator_hbase and squashes the following commits: caf87f3 [Rajat Venkatesh] Fix Protobuf version number c17db3b [Rajat Venkatesh] Fix typo in ZeppelinConfiguration 3efc892 [Rajat Venkatesh] Do not use ruby 1.9 and do not bother setting paths 9924784 [Rajat Venkatesh] Log absolute path of ruby source 69755ad [Rajat Venkatesh] Set hbase.ruby.sources in system properties 57ebad8 [Rajat Venkatesh] Fix hirb path 39dddb8 [Rajat Venkatesh] Address minor review comments b4ad18d [Rajat Venkatesh] Load hirb 49b5b27 [Rajat Venkatesh] Merge from master 320bfd5 [Rajat Venkatesh] Add information about licenses 7078a35 [Rajat Venkatesh] Add a doc for HBase shell interpreter 0fdcfe6 [Rajat Venkatesh] Merge from master be1bde7 [Rajat Venkatesh] Use Paths and Path instead of Strings to manipulate file system paths e21539b [Rajat Venkatesh] Remove hirb. Add a property for testing which disables all checks 7e9dffb [Rajat Venkatesh] Minor review comments 4f6bd04 [Rajat Venkatesh] Merge from master 72306b7 [Rajat Venkatesh] Merge from master ca64931 [Rajat Venkatesh] Review comments 255d0d9 [Rajat Venkatesh] Add more info in javadoc b598b70 [Rajat Venkatesh] Fix javadoc in unit tests 19f137e [Rajat Venkatesh] Terminate jruby c160787 [Rajat Venkatesh] Explicitly add private keyword. Improve javadoc feacd89 [Rajat Venkatesh] Fix tab in pom.xml b8b52ba [Rajat Venkatesh] Missed a couple of resolved conflicts afd50bc [Rajat Venkatesh] Merge master 9a23a21 [Rajat Venkatesh] Add an explicit dependency for mapreduce-client-core b7b06cd [Rajat Venkatesh] Fix version to add incubating string bc03f79 [Rajat Venkatesh] Merge remote branch 'upstream/master' into incubator_hbase b9a407c [Rajat Venkatesh] Specify relative path b2ff198 [Rajat Venkatesh] More fixes - sigh 032a2a4 [Rajat Venkatesh] More fixes for version config vars 63a2d89 [Rajat Venkatesh] Add a new config for hbase version for interpreter cd41ec2 [Rajat Venkatesh] Add a profile for Hbase-1.0 03e1b7a [Rajat Venkatesh] Fix test setup bdba5b2 [Rajat Venkatesh] Hbase Interpreter Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/1940388e Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/1940388e Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/1940388e Branch: refs/heads/master Commit: 1940388e3422b86a322fc82a0e7868ff25126804 Parents: ea03e84 Author: Rajat Venkatesh <[email protected]> Authored: Mon Feb 1 16:26:35 2016 +0530 Committer: Felix Cheung <[email protected]> Committed: Tue Feb 2 20:22:15 2016 -0800 ---------------------------------------------------------------------- conf/zeppelin-site.xml.template | 2 +- docs/_includes/themes/zeppelin/_navigation.html | 1 + docs/interpreter/hbase.md | 57 ++++++ hbase/pom.xml | 176 +++++++++++++++++++ .../apache/zeppelin/hbase/HbaseInterpreter.java | 158 +++++++++++++++++ .../zeppelin/hbase/HbaseInterpreterTest.java | 75 ++++++++ pom.xml | 1 + zeppelin-distribution/src/bin_license/LICENSE | 5 + .../zeppelin/conf/ZeppelinConfiguration.java | 3 +- 9 files changed, 476 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1940388e/conf/zeppelin-site.xml.template ---------------------------------------------------------------------- diff --git a/conf/zeppelin-site.xml.template b/conf/zeppelin-site.xml.template index 1d085ec..a55f6ae 100755 --- a/conf/zeppelin-site.xml.template +++ b/conf/zeppelin-site.xml.template @@ -111,7 +111,7 @@ <property> <name>zeppelin.interpreters</name> - <value>org.apache.zeppelin.spark.SparkInterpreter,org.apache.zeppelin.spark.PySparkInterpreter,org.apache.zeppelin.spark.SparkSqlInterpreter,org.apache.zeppelin.spark.DepInterpreter,org.apache.zeppelin.markdown.Markdown,org.apache.zeppelin.angular.AngularInterpreter,org.apache.zeppelin.shell.ShellInterpreter,org.apache.zeppelin.hive.HiveInterpreter,org.apache.zeppelin.tajo.TajoInterpreter,org.apache.zeppelin.flink.FlinkInterpreter,org.apache.zeppelin.lens.LensInterpreter,org.apache.zeppelin.ignite.IgniteInterpreter,org.apache.zeppelin.ignite.IgniteSqlInterpreter,org.apache.zeppelin.cassandra.CassandraInterpreter,org.apache.zeppelin.geode.GeodeOqlInterpreter,org.apache.zeppelin.postgresql.PostgreSqlInterpreter,org.apache.zeppelin.jdbc.JDBCInterpreter,org.apache.zeppelin.phoenix.PhoenixInterpreter,org.apache.zeppelin.kylin.KylinInterpreter,org.apache.zeppelin.elasticsearch.ElasticsearchInterpreter,org.apache.zeppelin.scalding.ScaldingInterpreter,org.apache.zeppelin.tachyon.TachyonIn terpreter</value> + <value>org.apache.zeppelin.spark.SparkInterpreter,org.apache.zeppelin.spark.PySparkInterpreter,org.apache.zeppelin.spark.SparkSqlInterpreter,org.apache.zeppelin.spark.DepInterpreter,org.apache.zeppelin.markdown.Markdown,org.apache.zeppelin.angular.AngularInterpreter,org.apache.zeppelin.shell.ShellInterpreter,org.apache.zeppelin.hive.HiveInterpreter,org.apache.zeppelin.tajo.TajoInterpreter,org.apache.zeppelin.flink.FlinkInterpreter,org.apache.zeppelin.lens.LensInterpreter,org.apache.zeppelin.ignite.IgniteInterpreter,org.apache.zeppelin.ignite.IgniteSqlInterpreter,org.apache.zeppelin.cassandra.CassandraInterpreter,org.apache.zeppelin.geode.GeodeOqlInterpreter,org.apache.zeppelin.postgresql.PostgreSqlInterpreter,org.apache.zeppelin.jdbc.JDBCInterpreter,org.apache.zeppelin.phoenix.PhoenixInterpreter,org.apache.zeppelin.kylin.KylinInterpreter,org.apache.zeppelin.elasticsearch.ElasticsearchInterpreter,org.apache.zeppelin.scalding.ScaldingInterpreter,org.apache.zeppelin.tachyon.TachyonIn terpreter,org.apache.zeppelin.hbase.HbaseInterpreter</value> <description>Comma separated interpreter configurations. First interpreter become a default</description> </property> http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1940388e/docs/_includes/themes/zeppelin/_navigation.html ---------------------------------------------------------------------- diff --git a/docs/_includes/themes/zeppelin/_navigation.html b/docs/_includes/themes/zeppelin/_navigation.html index 7a73365..ed54336 100644 --- a/docs/_includes/themes/zeppelin/_navigation.html +++ b/docs/_includes/themes/zeppelin/_navigation.html @@ -42,6 +42,7 @@ <li><a href="{{BASE_PATH}}/interpreter/elasticsearch.html">Elasticsearch</a></li> <li><a href="{{BASE_PATH}}/interpreter/flink.html">Flink</a></li> <li><a href="{{BASE_PATH}}/interpreter/geode.html">Geode</a></li> + <li><a href="{{BASE_PATH}}/interpreter/hbase.html">HBase</a></li> <li><a href="{{BASE_PATH}}/interpreter/hive.html">Hive</a></li> <li><a href="{{BASE_PATH}}/interpreter/ignite.html">Ignite</a></li> <li><a href="{{BASE_PATH}}/interpreter/lens.html">Lens</a></li> http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1940388e/docs/interpreter/hbase.md ---------------------------------------------------------------------- diff --git a/docs/interpreter/hbase.md b/docs/interpreter/hbase.md new file mode 100644 index 0000000..30cec44 --- /dev/null +++ b/docs/interpreter/hbase.md @@ -0,0 +1,57 @@ +--- +layout: page +title: "HBase Shell Interpreter" +description: "" +group: manual +--- +{% include JB/setup %} + + +## HBase Shell Interpreter for Apache Zeppelin +[HBase Shell](http://hbase.apache.org/book.html#shell) is a JRuby IRB client for Apache HBase. +This interpreter provides all capabilities of Apache HBase shell within Apache Zeppelin. The +interpreter assumes that Apache HBase client software has been installed and its possible to +connect to the Apache HBase cluster from the machine on where Apache Zeppelin is installed. + +<br /> +## 1. Configuration + +<table class="table-configuration"> + <tr> + <th>Property</th> + <th>Default</th> + <th>Description</th> + </tr> + <tr> + <td>hbase.home</td> + <td>/usr/lib/hbase</td> + <td>Installation directory of Hbase</td> + </tr> + <tr> + <td>hbase.ruby.sources</td> + <td>lib/ruby</td> + <td>Path to Ruby scripts relative to 'hbase.home'</td> + </tr> + <tr> + <td>hbase.test.mode</td> + <td>false</td> + <td>Disable checks for unit and manual tests</td> + </tr> +</table> + +## 2. Enabling the HBase Shell Interpreter + +In a notebook, to enable the **HBase Shell** interpreter, click the **Gear** icon and select +**HBase Shell**. + +## 3. Using the HBase Shell Interpreter + +In a paragraph, use `%hbase` to select the **HBase Shell** interpreter and then input all commands. + To get the list of available commands, use `help`. + +```bash +| %hbase +| help +``` + +For more information on all commands available, refer to [HBase Shell Documentation](http://hbase.apache.org/book.html#shell) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1940388e/hbase/pom.xml ---------------------------------------------------------------------- diff --git a/hbase/pom.xml b/hbase/pom.xml new file mode 100644 index 0000000..f70ef88 --- /dev/null +++ b/hbase/pom.xml @@ -0,0 +1,176 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>zeppelin</artifactId> + <groupId>org.apache.zeppelin</groupId> + <version>0.6.0-incubating-SNAPSHOT</version> + </parent> + + <groupId>org.apache.zeppelin</groupId> + <artifactId>zeppelin-hbase</artifactId> + <packaging>jar</packaging> + <version>0.6.0-incubating-SNAPSHOT</version> + <name>Zeppelin: HBase interpreter</name> + <url>http://www.apache.org</url> + + <properties> + <hbase.hbase.version>1.0.0</hbase.hbase.version> + <hbase.hadoop.version>2.6.0</hbase.hadoop.version> + <jruby.version>1.6.8</jruby.version> + <protobuf.version>2.5.0</protobuf.version> + </properties> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>zeppelin-interpreter</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-exec</artifactId> + <version>1.1</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <version>1.3</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jruby</groupId> + <artifactId>jruby-complete</artifactId> + <version>${jruby.version}</version> + </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-yarn-common</artifactId> + <version>${hbase.hadoop.version}</version> + </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-yarn-api</artifactId> + <version>${hbase.hadoop.version}</version> + </dependency> + <dependency> + <groupId>org.apache.hbase</groupId> + <artifactId>hbase-client</artifactId> + <version>${hbase.hbase.version}</version> + </dependency> + <dependency> + <groupId>org.apache.hbase</groupId> + <artifactId>hbase-annotations</artifactId> + <version>${hbase.hbase.version}</version> + </dependency> + <dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java</artifactId> + <version>${protobuf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.hbase</groupId> + <artifactId>hbase-server</artifactId> + <version>${hbase.hbase.version}</version> + </dependency> + <dependency> + <groupId>jline</groupId> + <artifactId>jline</artifactId> + <version>2.12.1</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>2.7</version> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + + <plugin> + <artifactId>maven-enforcer-plugin</artifactId> + <version>1.3.1</version> + <executions> + <execution> + <id>enforce</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.8</version> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/../../interpreter/hbase</outputDirectory> + <overWriteReleases>false</overWriteReleases> + <overWriteSnapshots>false</overWriteSnapshots> + <overWriteIfNewer>true</overWriteIfNewer> + <includeScope>runtime</includeScope> + </configuration> + </execution> + <execution> + <id>copy-artifact</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/../../interpreter/hbase</outputDirectory> + <overWriteReleases>false</overWriteReleases> + <overWriteSnapshots>false</overWriteSnapshots> + <overWriteIfNewer>true</overWriteIfNewer> + <includeScope>runtime</includeScope> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + <type>${project.packaging}</type> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1940388e/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 new file mode 100644 index 0000000..dbcb33d --- /dev/null +++ b/hbase/src/main/java/org/apache/zeppelin/hbase/HbaseInterpreter.java @@ -0,0 +1,158 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.zeppelin.hbase; + +import org.apache.zeppelin.interpreter.*; +import org.apache.zeppelin.scheduler.Scheduler; +import org.apache.zeppelin.scheduler.SchedulerFactory; +import org.jruby.embed.LocalContextScope; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jruby.embed.ScriptingContainer; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.io.IOException; +import java.io.StringWriter; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; + +/** + * Support for Hbase Shell. All the commands documented here + * http://hbase.apache.org/book.html#shell is supported. + * + * Requirements: + * Hbase Shell should be installed on the same machine. To be more specific, the following dir. + * should be available: https://github.com/apache/hbase/tree/master/hbase-shell/src/main/ruby + * Hbase Shell should be able to connect to the Hbase cluster from terminal. This makes sure + * that the client is configured properly. + * + * The interpreter takes 3 config parameters: + * hbase.home: Root dir. where hbase is installed. Default is /usr/lib/hbase/ + * hbase.ruby.sources: Dir where shell ruby code is installed. + * Path is relative to hbase.home. Default: lib/ruby + * hbase.irb.load: (Testing only) Default is true. + * Whether to load irb in the interpreter. + */ +public class HbaseInterpreter extends Interpreter { + 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", "/usr/lib/hbase/", "Installation dir. of Hbase") + .add("hbase.ruby.sources", "lib/ruby", + "Path to Ruby scripts relative to 'hbase.home'") + .add("hbase.test.mode", "false", "Disable checks for unit and manual tests") + .build()); + } + + public HbaseInterpreter(Properties property) { + super(property); + } + + @Override + public void open() { + this.scriptingContainer = new ScriptingContainer(LocalContextScope.SINGLETON); + this.writer = new StringWriter(); + scriptingContainer.setOutput(this.writer); + + if (!Boolean.parseBoolean(getProperty("hbase.test.mode"))) { + String hbase_home = getProperty("hbase.home"); + String ruby_src = getProperty("hbase.ruby.sources"); + Path abs_ruby_src = Paths.get(hbase_home, ruby_src).toAbsolutePath(); + + logger.info("Home:" + hbase_home); + logger.info("Ruby Src:" + ruby_src); + + File f = abs_ruby_src.toFile(); + if (!f.exists() || !f.isDirectory()) { + throw new InterpreterException("hbase ruby sources is not available at '" + abs_ruby_src + + "'"); + } + + 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()); + + Path abs_hirb_path = Paths.get(hbase_home, "bin/hirb.rb"); + try { + FileInputStream fis = new FileInputStream(abs_hirb_path.toFile()); + this.scriptingContainer.runScriptlet(fis, "hirb.rb"); + fis.close(); + } catch (IOException e) { + throw new InterpreterException(e.getCause()); + } + } + } + + @Override + public void close() { + if (this.scriptingContainer != null) { + this.scriptingContainer.terminate(); + } + } + + @Override + public InterpreterResult interpret(String cmd, InterpreterContext interpreterContext) { + try { + logger.info(cmd); + this.writer.getBuffer().setLength(0); + this.scriptingContainer.runScriptlet(cmd); + this.writer.flush(); + logger.debug(writer.toString()); + return new InterpreterResult(InterpreterResult.Code.SUCCESS, writer.getBuffer().toString()); + } catch (Throwable t) { + logger.error("Can not run '" + cmd + "'", t); + return new InterpreterResult(InterpreterResult.Code.ERROR, t.getMessage()); + } + } + + @Override + public void cancel(InterpreterContext context) {} + + @Override + public FormType getFormType() { + return FormType.SIMPLE; + } + + @Override + public int getProgress(InterpreterContext context) { + return 0; + } + + @Override + public Scheduler getScheduler() { + return SchedulerFactory.singleton().createOrGetFIFOScheduler( + HbaseInterpreter.class.getName() + this.hashCode()); + } + + @Override + public List<String> completion(String buf, int cursor) { + return null; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1940388e/hbase/src/test/java/org/apache/zeppelin/hbase/HbaseInterpreterTest.java ---------------------------------------------------------------------- diff --git a/hbase/src/test/java/org/apache/zeppelin/hbase/HbaseInterpreterTest.java b/hbase/src/test/java/org/apache/zeppelin/hbase/HbaseInterpreterTest.java new file mode 100644 index 0000000..e218070 --- /dev/null +++ b/hbase/src/test/java/org/apache/zeppelin/hbase/HbaseInterpreterTest.java @@ -0,0 +1,75 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.zeppelin.hbase; + +import org.apache.log4j.BasicConfigurator; +import org.apache.zeppelin.interpreter.InterpreterResult; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Properties; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertEquals; + +/** + * Tests for HBase Interpreter + */ +public class HbaseInterpreterTest { + private static Logger logger = LoggerFactory.getLogger(HbaseInterpreterTest.class); + private static HbaseInterpreter hbaseInterpreter; + + @BeforeClass + public static void setUp() throws NullPointerException { + BasicConfigurator.configure(); + Properties properties = new Properties(); + properties.put("hbase.home", ""); + properties.put("hbase.ruby.sources", ""); + properties.put("hbase.test.mode", "true"); + + hbaseInterpreter = new HbaseInterpreter(properties); + hbaseInterpreter.open(); + } + + @Test + public void newObject() { + assertThat(hbaseInterpreter, notNullValue()); + } + + @Test + public void putsTest() { + InterpreterResult result = hbaseInterpreter.interpret("puts \"Hello World\"", null); + assertEquals(InterpreterResult.Code.SUCCESS, result.code()); + assertEquals(result.type(), InterpreterResult.Type.TEXT); + assertEquals("Hello World\n", result.message()); + } + + public void putsLoadPath() { + InterpreterResult result = hbaseInterpreter.interpret("require 'two_power'; puts twoToThePowerOf(4)", null); + assertEquals(InterpreterResult.Code.SUCCESS, result.code()); + assertEquals(result.type(), InterpreterResult.Type.TEXT); + assertEquals("16\n", result.message()); + } + + @Test + public void testException() { + InterpreterResult result = hbaseInterpreter.interpret("plot practical joke", null); + assertEquals(InterpreterResult.Code.ERROR, result.code()); + assertEquals("(NameError) undefined local variable or method `joke' for main:Object", result.message()); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1940388e/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 9d46c0d..28260cf 100755 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,7 @@ <module>angular</module> <module>shell</module> <module>hive</module> + <module>hbase</module> <module>phoenix</module> <module>postgresql</module> <module>jdbc</module> http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1940388e/zeppelin-distribution/src/bin_license/LICENSE ---------------------------------------------------------------------- diff --git a/zeppelin-distribution/src/bin_license/LICENSE b/zeppelin-distribution/src/bin_license/LICENSE index 36e9836..a12b9c4 100644 --- a/zeppelin-distribution/src/bin_license/LICENSE +++ b/zeppelin-distribution/src/bin_license/LICENSE @@ -37,6 +37,7 @@ The following components are provided under Apache License. (Apache 2.0) Apache Cassandra (http://cassandra.apache.org/) (Apache 2.0) Apache CXF (http://cxf.apache.org/) (Apache 2.0) Apache Hive (http://hive.apache.org/) + (Apache 2.0) Apache HBase (http://hbase.apache.org/) (Apache 2.0) Apache Ignite (http://ignite.apache.org/) (Apache 2.0) Apache Kylin (http://kylin.apache.org/) (Apache 2.0) Apache Lens (http://lens.apache.org/) @@ -94,6 +95,7 @@ The following components are provided under Apache License. (Apache 2.0) Shiro Core (org.apache.shiro:shiro-core:1.2.3 - https://shiro.apache.org) (Apache 2.0) Shiro Web (org.apache.shiro:shiro-web:1.2.3 - https://shiro.apache.org) (Apache 2.0) SnakeYAML (org.yaml:snakeyaml:1.15 - http://www.snakeyaml.org) + (Apache 2.0) Protocol Buffers (com.google.protobuf:protobuf-java:2.4.1 - https://github.com/google/protobuf/releases) (Apache 2.0) Tachyon Shell (org.tachyonproject:tachyon-shell:0.8.2 - http://tachyon-project.org) (Apache 2.0) Tachyon Servers (org.tachyonproject:tachyon-servers:0.8.2 - http://tachyon-project.org) (Apache 2.0) Tachyon Minicluster (org.tachyonproject:tachyon-minicluster:0.8.2 - http://tachyon-project.org) @@ -154,6 +156,8 @@ The text of each license is also included at licenses/LICENSE-[project]-[version (BSD Style) dom4j v1.6.1 (http://www.dom4j.org) - https://github.com/dom4j/dom4j/blob/dom4j_1_6_1/LICENSE.txt (BSD Style) JSch v0.1.53 (http://www.jcraft.com) - http://www.jcraft.com/jsch/LICENSE.txt (BSD 3 Clause) highlightjs v8.4.0 (https://highlightjs.org/) - https://github.com/isagalaev/highlight.js/blob/8.4/LICENSE + (BSD 3 Clause) hamcrest v1.3 (http://hamcrest.org/JavaHamcrest/) - http://opensource.org/licenses/BSD-3-Clause + (BSD Style) JLine v2.12.1 (https://github.com/jline/jline2) - https://github.com/jline/jline2/blob/master/LICENSE.txt @@ -194,6 +198,7 @@ The following components are provided under the EPL License. (EPL 1.0) Aether (org.sonatype.aether - http://www.eclipse.org/aether/) (EPL 1.0) JDT Annotations For Enhanced Null Analysis (org.eclipse.jdt:org.eclipse.jdt.annotation:1.1.0 - https://repo.eclipse.org/content/repositories/eclipse-releases/org/eclipse/jdt/org.eclipse.jdt.annotation) + (EPL 1.0) JRuby (org.jruby.jruby-complete:v1.6.8 - http://www.jruby.org/) ======================================================================== http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/1940388e/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java index 421b3d4..687e622 100755 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java @@ -458,7 +458,8 @@ public class ZeppelinConfiguration extends XMLConfiguration { + "org.apache.zeppelin.kylin.KylinInterpreter," + "org.apache.zeppelin.elasticsearch.ElasticsearchInterpreter," + "org.apache.zeppelin.scalding.ScaldingInterpreter," - + "org.apache.zeppelin.jdbc.JDBCInterpreter"), + + "org.apache.zeppelin.jdbc.JDBCInterpreter," + + "org.apache.zeppelin.hbase.HbaseInterpreter"), ZEPPELIN_INTERPRETER_DIR("zeppelin.interpreter.dir", "interpreter"), ZEPPELIN_INTERPRETER_LOCALREPO("zeppelin.interpreter.localRepo", "local-repo"), ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT("zeppelin.interpreter.connect.timeout", 30000),
