kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qhz...@apache.org
Subject incubator-kylin git commit: KYLIN-1005
Date Sun, 06 Sep 2015 11:58:04 GMT
Repository: incubator-kylin
Updated Branches:
  refs/heads/0.8 c7990735c -> ec9bbb96e


KYLIN-1005


Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/ec9bbb96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/ec9bbb96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/ec9bbb96

Branch: refs/heads/0.8
Commit: ec9bbb96ea0bef73f19f12f2419144037a5e47c5
Parents: c799073
Author: qianhao.zhou <qianzhou@ebay.com>
Authored: Sun Sep 6 19:56:37 2015 +0800
Committer: qianhao.zhou <qianzhou@ebay.com>
Committed: Sun Sep 6 19:57:04 2015 +0800

----------------------------------------------------------------------
 .../storage/hbase/util/ZookeeperJobLock.java    | 23 ++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/ec9bbb96/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/util/ZookeeperJobLock.java
----------------------------------------------------------------------
diff --git a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/util/ZookeeperJobLock.java
b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/util/ZookeeperJobLock.java
index a96f639..ab15b72 100644
--- a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/util/ZookeeperJobLock.java
+++ b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/util/ZookeeperJobLock.java
@@ -1,7 +1,10 @@
 package org.apache.kylin.storage.hbase.util;
 
+import java.util.Arrays;
 import java.util.concurrent.TimeUnit;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
 import org.apache.commons.lang.StringUtils;
 import org.apache.curator.RetryPolicy;
 import org.apache.curator.framework.CuratorFramework;
@@ -17,6 +20,8 @@ import org.apache.kylin.storage.hbase.steps.HBaseConnection;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Nullable;
+
 /**
  */
 public class ZookeeperJobLock implements JobLock {
@@ -31,13 +36,15 @@ public class ZookeeperJobLock implements JobLock {
     @Override
     public boolean lock() {
         this.scheduleID = schedulerId();
-        String ZKConnectString = getZKConnectString();
-        if (StringUtils.isEmpty(ZKConnectString)) {
+        String zkConnectString = getZKConnectString();
+        logger.info("zk connection string:" + zkConnectString);
+        logger.info("schedulerId:" + scheduleID);
+        if (StringUtils.isEmpty(zkConnectString)) {
             throw new IllegalArgumentException("ZOOKEEPER_QUORUM is empty!");
         }
 
         RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
-        this.zkClient = CuratorFrameworkFactory.newClient(ZKConnectString, retryPolicy);
+        this.zkClient = CuratorFrameworkFactory.newClient(zkConnectString, retryPolicy);
         this.zkClient.start();
         this.sharedLock = new InterProcessMutex(zkClient, this.scheduleID);
         boolean hasLock = false;
@@ -61,7 +68,15 @@ public class ZookeeperJobLock implements JobLock {
 
     private String getZKConnectString() {
         Configuration conf = HBaseConnection.newHBaseConfiguration(KylinConfig.getInstanceFromEnv().getStorageUrl());
-        return conf.get(HConstants.ZOOKEEPER_QUORUM) + ":" + conf.get(HConstants.ZOOKEEPER_CLIENT_PORT);
+        final String serverList = conf.get(HConstants.ZOOKEEPER_QUORUM);
+        final String port = conf.get(HConstants.ZOOKEEPER_CLIENT_PORT);
+        return org.apache.commons.lang3.StringUtils.join(Iterables.transform(Arrays.asList(serverList.split(",")),
new Function<String, String>() {
+            @Nullable
+            @Override
+            public String apply(String input) {
+                return input + ":" + port;
+            }
+        }), ",");
     }
 
     private void releaseLock() {


Mime
View raw message