From 744a1b5165b9dbb77aba2759ded6c0423e50d7af Mon Sep 17 00:00:00 2001 From: liningrui Date: Mon, 14 Jan 2019 12:00:25 +0800 Subject: [PATCH] Add config hbase.zookeeper.znode.parent for hbase backend Implement #107 Change-Id: Ic57fe5aaeedc1af91b05399097a4170a2b159f2e --- hugegraph-dist/src/assembly/travis/hbase-site.xml | 4 ++++ .../baidu/hugegraph/backend/store/hbase/HbaseOptions.java | 8 ++++++++ .../hugegraph/backend/store/hbase/HbaseSessions.java | 7 +++++-- hugegraph-test/src/main/resources/hugegraph.properties | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/hugegraph-dist/src/assembly/travis/hbase-site.xml b/hugegraph-dist/src/assembly/travis/hbase-site.xml index ffb28d10ad..012c28f813 100644 --- a/hugegraph-dist/src/assembly/travis/hbase-site.xml +++ b/hugegraph-dist/src/assembly/travis/hbase-site.xml @@ -17,6 +17,10 @@ zookeeper.session.timeout 1200000 + + zookeeper.znode.parent + /hbase + hbase.zookeeper.property.tickTime 6000 diff --git a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseOptions.java b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseOptions.java index 96cfb8deab..ff1f95eff9 100644 --- a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseOptions.java +++ b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseOptions.java @@ -57,6 +57,14 @@ public static synchronized HbaseOptions instance() { 2181 ); + public static final ConfigOption HBASE_ZNODE_PARENT = + new ConfigOption<>( + "hbase.znode_parent", + "The znode parent path of HBase zookeeper.", + disallowEmpty(), + "/hbase" + ); + public static final ConfigOption HBASE_THREADS_MAX = new ConfigOption<>( "hbase.threads_max", diff --git a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java index 937645cc6f..f93555d279 100644 --- a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java +++ b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java @@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.CellScanner; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.RegionMetrics; import org.apache.hadoop.hbase.ServerName; @@ -93,10 +94,12 @@ private Table table(String table) throws IOException { public synchronized void open(HugeConfig conf) throws IOException { String hosts = conf.get(HbaseOptions.HBASE_HOSTS); int port = conf.get(HbaseOptions.HBASE_PORT); + String znodeParent = conf.get(HbaseOptions.HBASE_ZNODE_PARENT); Configuration config = HBaseConfiguration.create(); - config.set("hbase.zookeeper.quorum", hosts); - config.set("hbase.zookeeper.property.clientPort", String.valueOf(port)); + config.set(HConstants.ZOOKEEPER_QUORUM, hosts); + config.set(HConstants.ZOOKEEPER_CLIENT_PORT, String.valueOf(port)); + config.set(HConstants.ZOOKEEPER_ZNODE_PARENT, znodeParent); // Set hbase.hconnection.threads.max 64 to avoid OOM(default value: 256) config.setInt("hbase.hconnection.threads.max", conf.get(HbaseOptions.HBASE_THREADS_MAX)); diff --git a/hugegraph-test/src/main/resources/hugegraph.properties b/hugegraph-test/src/main/resources/hugegraph.properties index 54d5b14850..19fd6f94da 100644 --- a/hugegraph-test/src/main/resources/hugegraph.properties +++ b/hugegraph-test/src/main/resources/hugegraph.properties @@ -26,6 +26,7 @@ cassandra.read_timeout=120 # hbase backend config hbase.hosts=localhost hbase.port=2181 +hbase.znode_parent=/hbase # mysql backend config jdbc.driver=com.mysql.jdbc.Driver