You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by ji...@apache.org on 2015/01/20 14:04:21 UTC

[3/5] tajo git commit: TAJO-1307: HBaseStorageManager need to support for users to use hbase-site.xml file. (jaehwa)

TAJO-1307: HBaseStorageManager need to support for users to use hbase-site.xml file. (jaehwa)

Closes #350


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/6f07cefd
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/6f07cefd
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/6f07cefd

Branch: refs/heads/index_support
Commit: 6f07cefd224c8da420ec7ec37974917993a05fc5
Parents: 9d749d6
Author: JaeHwa Jung <bl...@apache.org>
Authored: Mon Jan 19 17:50:26 2015 +0900
Committer: JaeHwa Jung <bl...@apache.org>
Committed: Mon Jan 19 17:50:26 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |  5 +++-
 .../tajo/engine/query/TestHBaseTable.java       | 20 +++++++++++++++
 tajo-dist/src/main/bin/tajo                     | 26 ++++++++++++++++++++
 tajo-dist/src/main/conf/tajo-env.sh             |  5 +++-
 .../tajo/storage/hbase/HBaseStorageManager.java |  9 ++++++-
 5 files changed, 62 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/6f07cefd/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 1be019a..8acd4e5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,7 @@
 Tajo Change Log 
 
 
-Release 0.9.1 - unreleased
+Release 0.10.0 - unreleased
 
   NEW FEATURES
 
@@ -27,6 +27,9 @@ Release 0.9.1 - unreleased
 
   IMPROVEMENT
 
+    TAJO-1307: HBaseStorageManager need to support for users to use
+    hbase-site.xml file. (jaehwa)
+
     TAJO-1290: Add HBase Storage Integration Documentation. (jaehwa)
 
     TAJO-1293: Tajo have to accept hostname beginning with digits.

http://git-wip-us.apache.org/repos/asf/tajo/blob/6f07cefd/tajo-core/src/test/java/org/apache/tajo/engine/query/TestHBaseTable.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestHBaseTable.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestHBaseTable.java
index 520c9f6..741a807 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestHBaseTable.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestHBaseTable.java
@@ -111,6 +111,26 @@ public class TestHBaseTable extends QueryTestCaseBase {
     }
   }
 
+
+  @Test
+  public void testVerifyCreateHBaseTableWithHBaseConfiguration() throws Exception {
+    String hostName = InetAddress.getLocalHost().getHostName();
+    String zkPort = testingCluster.getHBaseUtil().getConf().get(HConstants.ZOOKEEPER_CLIENT_PORT);
+    assertNotNull(zkPort);
+
+    try {
+      testingCluster.getHBaseUtil().getConf().set(HConstants.ZOOKEEPER_QUORUM, hostName);
+
+      executeString("CREATE TABLE hbase_mapped_table3 (col1 text, col2 text) " +
+        "USING hbase " +
+        "WITH ('table'='hbase_mapped_table3', 'columns'='col1:,col2:')").close();
+
+      testingCluster.getHBaseUtil().getConf().set(HConstants.ZOOKEEPER_QUORUM, null);
+    } catch (Exception e) {
+      assertFalse(e.getMessage().indexOf("HBase mapped table") >= 0);
+    }
+  }
+
   @Test
   public void testCreateHBaseTable() throws Exception {
     String hostName = InetAddress.getLocalHost().getHostName();

http://git-wip-us.apache.org/repos/asf/tajo/blob/6f07cefd/tajo-dist/src/main/bin/tajo
----------------------------------------------------------------------
diff --git a/tajo-dist/src/main/bin/tajo b/tajo-dist/src/main/bin/tajo
index e73c6b2..f10f393 100755
--- a/tajo-dist/src/main/bin/tajo
+++ b/tajo-dist/src/main/bin/tajo
@@ -287,6 +287,32 @@ fi
 # Hive Home Configuration End
 ##############################################################################
 
+
+##############################################################################
+# Find and Set HBase CLASSPATH
+##############################################################################
+
+HBASE_CONF=$HBASE_HOME/conf/hbase-site.xml
+
+if [ -d ${HBASE_CONF} ]; then
+  CLASSPATH=${HBASE_CONF}:${CLASSPATH}
+fi
+
+
+HBASE_LIB=$HBASE_HOME/lib
+
+if [ -d ${HBASE_LIB} ]; then
+
+  for f in ${HBASE_LIB}/hbase-common-*.jar; do
+    CLASSPATH=${CLASSPATH}:$f;
+  done
+fi
+
+##############################################################################
+# Find and Set HBase CLASSPATH
+##############################################################################
+
+
 ##############################################################################
 # Find and Set Tajo CLASSPATH
 ##############################################################################

http://git-wip-us.apache.org/repos/asf/tajo/blob/6f07cefd/tajo-dist/src/main/conf/tajo-env.sh
----------------------------------------------------------------------
diff --git a/tajo-dist/src/main/conf/tajo-env.sh b/tajo-dist/src/main/conf/tajo-env.sh
index 064a82f..4a8e2b2 100755
--- a/tajo-dist/src/main/conf/tajo-env.sh
+++ b/tajo-dist/src/main/conf/tajo-env.sh
@@ -80,4 +80,7 @@ export TAJO_WORKER_STANDBY_MODE=true
 # export HIVE_JDBC_DRIVER_DIR=
 
 # Tajo PullServer mode. the default mode is standalone mode
-# export TAJO_PULLSERVER_STANDALONE=false
\ No newline at end of file
+# export TAJO_PULLSERVER_STANDALONE=false
+
+# It must be required to use HBase
+# export HBASE_HOME=

http://git-wip-us.apache.org/repos/asf/tajo/blob/6f07cefd/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseStorageManager.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseStorageManager.java b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseStorageManager.java
index c606e88..c51e31c 100644
--- a/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseStorageManager.java
+++ b/tajo-storage/tajo-storage-hbase/src/main/java/org/apache/tajo/storage/hbase/HBaseStorageManager.java
@@ -299,7 +299,14 @@ public class HBaseStorageManager extends StorageManager {
    * @throws java.io.IOException
    */
   public static Configuration getHBaseConfiguration(Configuration conf, TableMeta tableMeta) throws IOException {
-    String zkQuorum = tableMeta.getOption(HBaseStorageConstants.META_ZK_QUORUM_KEY, "");
+    boolean hasZkQuorum = tableMeta.containsOption(HBaseStorageConstants.META_ZK_QUORUM_KEY);
+    String zkQuorum = null;
+    if (hasZkQuorum) {
+      zkQuorum = tableMeta.getOption(HBaseStorageConstants.META_ZK_QUORUM_KEY, "");
+    } else {
+      zkQuorum = conf.get(HBaseStorageConstants.META_ZK_QUORUM_KEY, "");
+    }
+
     if (zkQuorum == null || zkQuorum.trim().isEmpty()) {
       throw new IOException("HBase mapped table is required a '" +
           HBaseStorageConstants.META_ZK_QUORUM_KEY + "' attribute.");