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 3478017B75 for ; Tue, 4 Nov 2014 00:11:09 +0000 (UTC) Received: (qmail 37427 invoked by uid 500); 4 Nov 2014 00:11:09 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 37340 invoked by uid 500); 4 Nov 2014 00:11:09 -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 37325 invoked by uid 99); 4 Nov 2014 00:11:09 -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, 04 Nov 2014 00:11:09 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9DB7BA06817; Tue, 4 Nov 2014 00:11:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cammckenzie@apache.org To: commits@curator.apache.org Date: Tue, 04 Nov 2014 00:11:08 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/5] git commit: CURATOR-140: Allow InterProcessReadWriteLock consumer to set lock node data. Repository: curator Updated Branches: refs/heads/master 3e4626237 -> 1cd052245 CURATOR-140: Allow InterProcessReadWriteLock consumer to set lock node data. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/77a1afbc Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/77a1afbc Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/77a1afbc Branch: refs/heads/master Commit: 77a1afbcc074d9ef87ba3bfc7d3cb641ad2f727e Parents: 1e9b76e Author: Brien Wheeler Authored: Fri Oct 24 12:33:16 2014 -0400 Committer: Brien Wheeler Committed: Fri Oct 24 12:33:16 2014 -0400 ---------------------------------------------------------------------- .../locks/InterProcessReadWriteLock.java | 34 +++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/77a1afbc/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessReadWriteLock.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessReadWriteLock.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessReadWriteLock.java index d5b0036..3a0dc44 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessReadWriteLock.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessReadWriteLock.java @@ -22,6 +22,8 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import org.apache.curator.framework.CuratorFramework; + +import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -74,11 +76,13 @@ public class InterProcessReadWriteLock private static class InternalInterProcessMutex extends InterProcessMutex { private final String lockName; + private final byte[] lockData; - InternalInterProcessMutex(CuratorFramework client, String path, String lockName, int maxLeases, LockInternalsDriver driver) + InternalInterProcessMutex(CuratorFramework client, String path, String lockName, byte[] lockData, int maxLeases, LockInternalsDriver driver) { super(client, path, lockName, maxLeases, driver); this.lockName = lockName; + this.lockData = lockData; } @Override @@ -99,19 +103,38 @@ public class InterProcessReadWriteLock ); return ImmutableList.copyOf(filtered); } + + @Override + protected byte[] getLockNodeBytes() + { + return lockData; + } } - /** - * @param client the client - * @param basePath path to use for locking - */ + /** + * @param client the client + * @param basePath path to use for locking + */ public InterProcessReadWriteLock(CuratorFramework client, String basePath) { + this(client, basePath, null); + } + + /** + * @param client the client + * @param basePath path to use for locking + * @param lockData the data to store in the lock nodes + */ + public InterProcessReadWriteLock(CuratorFramework client, String basePath, byte[] lockData) + { + lockData = (lockData == null) ? null : Arrays.copyOf(lockData, lockData.length); + writeMutex = new InternalInterProcessMutex ( client, basePath, WRITE_LOCK_NAME, + lockData, 1, new SortingLockInternalsDriver() { @@ -128,6 +151,7 @@ public class InterProcessReadWriteLock client, basePath, READ_LOCK_NAME, + lockData, Integer.MAX_VALUE, new SortingLockInternalsDriver() {