Return-Path: X-Original-To: apmail-kylin-commits-archive@minotaur.apache.org Delivered-To: apmail-kylin-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 970E818EAA for ; Sun, 6 Sep 2015 11:58:07 +0000 (UTC) Received: (qmail 28156 invoked by uid 500); 6 Sep 2015 11:58:07 -0000 Delivered-To: apmail-kylin-commits-archive@kylin.apache.org Received: (qmail 28127 invoked by uid 500); 6 Sep 2015 11:58:07 -0000 Mailing-List: contact commits-help@kylin.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kylin.incubator.apache.org Delivered-To: mailing list commits@kylin.incubator.apache.org Received: (qmail 28118 invoked by uid 99); 6 Sep 2015 11:58:07 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Sep 2015 11:58:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id E1AF0C0257 for ; Sun, 6 Sep 2015 11:58:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.774 X-Spam-Level: * X-Spam-Status: No, score=1.774 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.006] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 0DpOi9uUZD-g for ; Sun, 6 Sep 2015 11:58:05 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 7820842BC8 for ; Sun, 6 Sep 2015 11:58:05 +0000 (UTC) Received: (qmail 28115 invoked by uid 99); 6 Sep 2015 11:58:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Sep 2015 11:58:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CE861DFC63; Sun, 6 Sep 2015 11:58:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: qhzhou@apache.org To: commits@kylin.incubator.apache.org Message-Id: <616ba03c7bcb471b9934e981d12a45b6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-kylin git commit: KYLIN-1005 Date: Sun, 6 Sep 2015 11:58:04 +0000 (UTC) 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 Authored: Sun Sep 6 19:56:37 2015 +0800 Committer: qianhao.zhou 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() { + @Nullable + @Override + public String apply(String input) { + return input + ":" + port; + } + }), ","); } private void releaseLock() {