Return-Path: X-Original-To: apmail-curator-commits-archive@minotaur.apache.org Delivered-To: apmail-curator-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 306AC11FAB for ; Tue, 26 Aug 2014 17:58:50 +0000 (UTC) Received: (qmail 43793 invoked by uid 500); 26 Aug 2014 17:58:50 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 43760 invoked by uid 500); 26 Aug 2014 17:58:50 -0000 Mailing-List: contact commits-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list commits@curator.apache.org Received: (qmail 43751 invoked by uid 99); 26 Aug 2014 17:58:50 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Aug 2014 17:58:50 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9F9689CE70E; Tue, 26 Aug 2014 17:58:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: randgalt@apache.org To: commits@curator.apache.org Date: Tue, 26 Aug 2014 17:58:48 -0000 Message-Id: <10baabe015d54fde843e2476a985cc05@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/7] git commit: CURATOR-84 More flexibility for InterProcessMutex extensions Repository: curator Updated Branches: refs/heads/master 7d30d3d19 -> f9c69199b CURATOR-84 More flexibility for InterProcessMutex extensions Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/882f5410 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/882f5410 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/882f5410 Branch: refs/heads/master Commit: 882f5410033e55c41fdc8db95e0fb2a2ecff7026 Parents: d2c37d0 Author: Karthik Kumar Authored: Sat Aug 16 13:11:54 2014 -0400 Committer: Karthik Kumar Committed: Tue Aug 19 09:31:41 2014 -0400 ---------------------------------------------------------------------- .../framework/recipes/locks/InterProcessMutex.java | 17 ++++++++++++++++- .../framework/recipes/locks/LockInternals.java | 9 +-------- .../recipes/locks/LockInternalsDriver.java | 4 +++- .../framework/recipes/locks/PredicateResults.java | 8 ++++---- .../recipes/locks/StandardLockInternalsDriver.java | 17 +++++++++++++++++ 5 files changed, 41 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/882f5410/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java index ffdeb70..02a3d1f 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java @@ -61,7 +61,17 @@ public class InterProcessMutex implements InterProcessLock, Revocable children, String sequenceNodeName, int maxLeases) throws Exception; + + public String createsTheLock(CuratorFramework client, String path, byte[] lockNodeBytes) throws Exception; } http://git-wip-us.apache.org/repos/asf/curator/blob/882f5410/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java index 0f098ea..b032d98 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java @@ -18,23 +18,23 @@ */ package org.apache.curator.framework.recipes.locks; -class PredicateResults +public class PredicateResults { private final boolean getsTheLock; private final String pathToWatch; - PredicateResults(String pathToWatch, boolean getsTheLock) + public PredicateResults(String pathToWatch, boolean getsTheLock) { this.pathToWatch = pathToWatch; this.getsTheLock = getsTheLock; } - String getPathToWatch() + public String getPathToWatch() { return pathToWatch; } - boolean getsTheLock() + public boolean getsTheLock() { return getsTheLock; } http://git-wip-us.apache.org/repos/asf/curator/blob/882f5410/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/StandardLockInternalsDriver.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/StandardLockInternalsDriver.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/StandardLockInternalsDriver.java index 25f07b8..0c9b6de 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/StandardLockInternalsDriver.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/StandardLockInternalsDriver.java @@ -19,6 +19,7 @@ package org.apache.curator.framework.recipes.locks; import org.apache.curator.framework.CuratorFramework; +import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,6 +42,22 @@ public class StandardLockInternalsDriver implements LockInternalsDriver } @Override + public String createsTheLock(CuratorFramework client, String path, byte[] lockNodeBytes) throws Exception + { + String ourPath; + if ( lockNodeBytes != null ) + { + ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path, lockNodeBytes); + } + else + { + ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path); + } + return ourPath; + } + + + @Override public String fixForSorting(String str, String lockName) { return standardFixForSorting(str, lockName);