You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ma...@apache.org on 2015/05/26 17:21:14 UTC
[28/32] incubator-kylin git commit: KYLIN-697 refine zookeeperjoblock
KYLIN-697 refine zookeeperjoblock
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/cf26d3d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/cf26d3d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/cf26d3d0
Branch: refs/heads/0.8.0
Commit: cf26d3d06a43d6ff87d6ecc0edc0a79285ab27cf
Parents: d647d5a
Author: honma <ho...@ebay.com>
Authored: Tue May 26 23:03:57 2015 +0800
Committer: honma <ho...@ebay.com>
Committed: Tue May 26 23:21:28 2015 +0800
----------------------------------------------------------------------
.../org/apache/kylin/common/lock/ZookeeperJobLock.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/cf26d3d0/common/src/main/java/org/apache/kylin/common/lock/ZookeeperJobLock.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/kylin/common/lock/ZookeeperJobLock.java b/common/src/main/java/org/apache/kylin/common/lock/ZookeeperJobLock.java
index 7a755a3..78da480 100644
--- a/common/src/main/java/org/apache/kylin/common/lock/ZookeeperJobLock.java
+++ b/common/src/main/java/org/apache/kylin/common/lock/ZookeeperJobLock.java
@@ -23,11 +23,14 @@ public class ZookeeperJobLock implements JobLock {
private Logger logger = LoggerFactory.getLogger(ZookeeperJobLock.class);
private static final String ZOOKEEPER_LOCK_PATH = "/kylin/job_engine/lock";
+
+ private String scheduleID;
private InterProcessMutex sharedLock;
private CuratorFramework zkClient;
@Override
public boolean lock() {
+ this.scheduleID = schedulerId();
String ZKConnectString = getZKConnectString();
if (StringUtils.isEmpty(ZKConnectString)) {
throw new IllegalArgumentException("ZOOKEEPER_QUORUM is empty!");
@@ -36,7 +39,7 @@ public class ZookeeperJobLock implements JobLock {
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
this.zkClient = CuratorFrameworkFactory.newClient(ZKConnectString, retryPolicy);
this.zkClient.start();
- this.sharedLock = new InterProcessMutex(zkClient, schedulerId());
+ this.sharedLock = new InterProcessMutex(zkClient, this.scheduleID);
boolean hasLock = false;
try {
hasLock = sharedLock.acquire(3, TimeUnit.SECONDS);
@@ -65,12 +68,12 @@ public class ZookeeperJobLock implements JobLock {
try {
if (zkClient.getState().equals(CuratorFrameworkState.STARTED)) {
// client.setData().forPath(ZOOKEEPER_LOCK_PATH, null);
- if (zkClient.checkExists().forPath(schedulerId()) != null) {
- zkClient.delete().guaranteed().deletingChildrenIfNeeded().forPath(schedulerId());
+ if (zkClient.checkExists().forPath(scheduleID) != null) {
+ zkClient.delete().guaranteed().deletingChildrenIfNeeded().forPath(scheduleID);
}
}
} catch (Exception e) {
- logger.error("error release lock:" + schedulerId());
+ logger.error("error release lock:" + scheduleID);
throw new RuntimeException(e);
}
}