You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2014/08/26 19:58:48 UTC

[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 <ka...@opower.com>
Authored: Sat Aug 16 13:11:54 2014 -0400
Committer: Karthik Kumar <ka...@opower.com>
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<InterProce
      */
     public InterProcessMutex(CuratorFramework client, String path)
     {
-        this(client, path, LOCK_NAME, 1, new StandardLockInternalsDriver());
+        this(client, path, new StandardLockInternalsDriver());
+    }
+
+    /**
+     * @param client client
+     * @param path the path to lock
+     * @param driver lock driver
+     */
+    public InterProcessMutex(CuratorFramework client, String path, LockInternalsDriver driver)
+    {
+        this(client, path, LOCK_NAME, 1, driver);
     }
 
     /**
@@ -201,6 +211,11 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
         return null;
     }
 
+    protected String getLockPath() {
+        LockData    lockData = threadData.get(Thread.currentThread());
+        return lockData != null ? lockData.lockPath : null;
+    }
+
     private boolean internalLock(long time, TimeUnit unit) throws Exception
     {
         /*

http://git-wip-us.apache.org/repos/asf/curator/blob/882f5410/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
index 706b242..74022e0 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
@@ -214,14 +214,7 @@ public class LockInternals
 
             try
             {
-                if ( localLockNodeBytes != null )
-                {
-                    ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path, localLockNodeBytes);
-                }
-                else
-                {
-                    ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path);
-                }
+                ourPath = driver.createsTheLock(client, path, localLockNodeBytes);
                 hasTheLock = internalLockLoop(startMillis, millisToWait, ourPath);
             }
             catch ( KeeperException.NoNodeException e )

http://git-wip-us.apache.org/repos/asf/curator/blob/882f5410/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java
index 1570eed..69e3ce6 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java
@@ -21,7 +21,9 @@ package org.apache.curator.framework.recipes.locks;
 import org.apache.curator.framework.CuratorFramework;
 import java.util.List;
 
-interface LockInternalsDriver extends LockInternalsSorter
+public interface LockInternalsDriver extends LockInternalsSorter
 {
     public PredicateResults getsTheLock(CuratorFramework client, List<String> 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);


[3/7] git commit: CURATOR-84 More flexibility for InterProcessMutex extensions

Posted by ra...@apache.org.
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/6ecfd791
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6ecfd791
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6ecfd791

Branch: refs/heads/master
Commit: 6ecfd791b47410b0d6d1ddae92eb0cffe406d85b
Parents: d2c37d0
Author: Karthik Kumar <ka...@opower.com>
Authored: Sat Aug 16 13:11:54 2014 -0400
Committer: Karthik Kumar <ka...@opower.com>
Committed: Wed Aug 20 09:17:08 2014 -0400

----------------------------------------------------------------------
 .../recipes/locks/InterProcessMutex.java        | 17 +++++++-
 .../framework/recipes/locks/LockInternals.java  |  9 +---
 .../recipes/locks/LockInternalsDriver.java      |  4 +-
 .../recipes/locks/PredicateResults.java         |  8 ++--
 .../locks/StandardLockInternalsDriver.java      | 17 ++++++++
 .../recipes/locks/TestInterProcessMutex.java    | 43 ++++++++++++++++++++
 6 files changed, 84 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/6ecfd791/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<InterProce
      */
     public InterProcessMutex(CuratorFramework client, String path)
     {
-        this(client, path, LOCK_NAME, 1, new StandardLockInternalsDriver());
+        this(client, path, new StandardLockInternalsDriver());
+    }
+
+    /**
+     * @param client client
+     * @param path the path to lock
+     * @param driver lock driver
+     */
+    public InterProcessMutex(CuratorFramework client, String path, LockInternalsDriver driver)
+    {
+        this(client, path, LOCK_NAME, 1, driver);
     }
 
     /**
@@ -201,6 +211,11 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
         return null;
     }
 
+    protected String getLockPath() {
+        LockData    lockData = threadData.get(Thread.currentThread());
+        return lockData != null ? lockData.lockPath : null;
+    }
+
     private boolean internalLock(long time, TimeUnit unit) throws Exception
     {
         /*

http://git-wip-us.apache.org/repos/asf/curator/blob/6ecfd791/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
index 706b242..74022e0 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
@@ -214,14 +214,7 @@ public class LockInternals
 
             try
             {
-                if ( localLockNodeBytes != null )
-                {
-                    ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path, localLockNodeBytes);
-                }
-                else
-                {
-                    ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path);
-                }
+                ourPath = driver.createsTheLock(client, path, localLockNodeBytes);
                 hasTheLock = internalLockLoop(startMillis, millisToWait, ourPath);
             }
             catch ( KeeperException.NoNodeException e )

http://git-wip-us.apache.org/repos/asf/curator/blob/6ecfd791/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java
index 1570eed..69e3ce6 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java
@@ -21,7 +21,9 @@ package org.apache.curator.framework.recipes.locks;
 import org.apache.curator.framework.CuratorFramework;
 import java.util.List;
 
-interface LockInternalsDriver extends LockInternalsSorter
+public interface LockInternalsDriver extends LockInternalsSorter
 {
     public PredicateResults getsTheLock(CuratorFramework client, List<String> 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/6ecfd791/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/6ecfd791/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);

http://git-wip-us.apache.org/repos/asf/curator/blob/6ecfd791/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
index bbc3466..c116a50 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
@@ -21,6 +21,8 @@ package org.apache.curator.framework.recipes.locks;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
 import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.KillSession;
+import org.apache.zookeeper.CreateMode;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 import java.util.Collection;
@@ -107,4 +109,45 @@ public class TestInterProcessMutex extends TestInterProcessMutexBase
             client.close();
         }
     }
+
+    @Test
+    public void testPersistentLock() throws Exception {
+        final CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+        client.start();
+
+        try {
+            final InterProcessMutex lock = new InterProcessMutex(client, LOCK_PATH, new StandardLockInternalsDriver() {
+                @Override
+                public String createsTheLock(CuratorFramework client, String path, byte[] lockNodeBytes) throws Exception {
+                    String ourPath;
+                    if ( lockNodeBytes != null )
+                    {
+                        ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.PERSISTENT).forPath(path, lockNodeBytes);
+                    }
+                    else
+                    {
+                        ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.PERSISTENT).forPath(path);
+                    }
+                    return ourPath;
+                }
+            });
+
+            // Get a persistent lock
+            lock.acquire(10, TimeUnit.SECONDS);
+            Assert.assertTrue(lock.isAcquiredInThisProcess());
+
+            // Kill the session, check that lock node still exists
+            KillSession.kill(client.getZookeeperClient().getZooKeeper(), server.getConnectString());
+            Assert.assertNotNull(client.checkExists().forPath(LOCK_PATH));
+
+            // Release the lock and verify that the actual lock node created no longer exists
+            String actualLockPath = lock.getLockPath();
+            lock.release();
+            Assert.assertNull(client.checkExists().forPath(actualLockPath));
+        }
+        finally {
+            client.close();
+        }
+
+    }
 }


[5/7] git commit: CURATOR-84 - Fixed up formatting

Posted by ra...@apache.org.
CURATOR-84 - Fixed up formatting


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

Branch: refs/heads/master
Commit: d5f55177f4c7a4bd1e95d1e872d65463909a6d35
Parents: 6b19fe2
Author: Cam McKenzie <ca...@apache.org>
Authored: Thu Aug 21 07:47:00 2014 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Thu Aug 21 07:47:00 2014 +1000

----------------------------------------------------------------------
 .../recipes/locks/TestInterProcessMutex.java        | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/d5f55177/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
index c116a50..453de33 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java
@@ -111,14 +111,18 @@ public class TestInterProcessMutex extends TestInterProcessMutexBase
     }
 
     @Test
-    public void testPersistentLock() throws Exception {
+    public void testPersistentLock() throws Exception
+    {
         final CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
         client.start();
 
-        try {
-            final InterProcessMutex lock = new InterProcessMutex(client, LOCK_PATH, new StandardLockInternalsDriver() {
+        try
+        {
+            final InterProcessMutex lock = new InterProcessMutex(client, LOCK_PATH, new StandardLockInternalsDriver()
+            {
                 @Override
-                public String createsTheLock(CuratorFramework client, String path, byte[] lockNodeBytes) throws Exception {
+                public String createsTheLock(CuratorFramework client, String path, byte[] lockNodeBytes) throws Exception
+                {
                     String ourPath;
                     if ( lockNodeBytes != null )
                     {
@@ -145,9 +149,9 @@ public class TestInterProcessMutex extends TestInterProcessMutexBase
             lock.release();
             Assert.assertNull(client.checkExists().forPath(actualLockPath));
         }
-        finally {
+        finally
+        {
             client.close();
         }
-
     }
 }


[7/7] git commit: Merge branch 'master' into CURATOR-84

Posted by ra...@apache.org.
Merge branch 'master' into CURATOR-84

Conflicts:
	curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java
	curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java


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

Branch: refs/heads/master
Commit: f9c69199bf0ff81c49554e55133f319e1d880287
Parents: 942e23d 7d30d3d
Author: randgalt <ra...@apache.org>
Authored: Tue Aug 26 12:58:26 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Tue Aug 26 12:58:26 2014 -0500

----------------------------------------------------------------------
 .../org/apache/curator/utils/PathUtils.java     |  7 ++-
 .../framework/imps/CreateBuilderImpl.java       | 11 +++--
 .../framework/imps/CuratorFrameworkImpl.java    |  6 ++-
 .../curator/framework/imps/NamespaceFacade.java | 12 -----
 .../framework/imps/TestNamespaceFacade.java     | 46 ++++++++++++++++++++
 .../recipes/atomic/DistributedAtomicValue.java  |  4 +-
 .../recipes/atomic/PromotedToLock.java          |  3 +-
 .../recipes/barriers/DistributedBarrier.java    |  3 +-
 .../barriers/DistributedDoubleBarrier.java      |  3 +-
 .../framework/recipes/cache/ChildData.java      |  3 +-
 .../recipes/cache/GetDataOperation.java         |  4 +-
 .../framework/recipes/cache/NodeCache.java      |  3 +-
 .../recipes/cache/PathChildrenCache.java        |  3 +-
 .../framework/recipes/cache/TreeCache.java      |  3 +-
 .../framework/recipes/leader/LeaderLatch.java   |  5 ++-
 .../recipes/leader/LeaderSelector.java          |  3 +-
 .../framework/recipes/locks/ChildReaper.java    |  3 +-
 .../recipes/locks/InterProcessMultiLock.java    |  1 +
 .../recipes/locks/InterProcessMutex.java        |  3 +-
 .../recipes/locks/InterProcessSemaphore.java    |  1 +
 .../recipes/locks/InterProcessSemaphoreV2.java  |  2 +
 .../framework/recipes/locks/LockInternals.java  |  3 +-
 .../recipes/nodes/PersistentEphemeralNode.java  |  3 +-
 .../framework/recipes/queue/ChildrenCache.java  |  3 +-
 .../recipes/queue/DistributedQueue.java         |  6 +--
 .../framework/recipes/queue/QueueBuilder.java   |  5 ++-
 .../framework/recipes/queue/QueueSafety.java    |  5 ++-
 .../recipes/queue/SimpleDistributedQueue.java   |  3 +-
 .../framework/recipes/shared/SharedValue.java   |  3 +-
 .../recipes/leader/TestLeaderLatch.java         |  8 ++++
 pom.xml                                         |  4 +-
 31 files changed, 125 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/f9c69199/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/curator/blob/f9c69199/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
----------------------------------------------------------------------


[6/7] git commit: minor re-format

Posted by ra...@apache.org.
minor re-format


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/942e23d4
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/942e23d4
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/942e23d4

Branch: refs/heads/master
Commit: 942e23d4ded3e7d687a1c818aacb69c0e7f8ba3d
Parents: d5f5517
Author: randgalt <ra...@apache.org>
Authored: Tue Aug 26 12:55:31 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Tue Aug 26 12:55:31 2014 -0500

----------------------------------------------------------------------
 .../recipes/locks/InterProcessMutex.java        | 57 +++++++++-----------
 1 file changed, 26 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/942e23d4/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 02a3d1f..c8032a8 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
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.curator.framework.recipes.locks;
 
 import com.google.common.collect.Maps;
@@ -35,15 +36,15 @@ import java.util.concurrent.atomic.AtomicInteger;
  */
 public class InterProcessMutex implements InterProcessLock, Revocable<InterProcessMutex>
 {
-    private final LockInternals         internals;
-    private final String                basePath;
+    private final LockInternals internals;
+    private final String basePath;
 
-    private final ConcurrentMap<Thread, LockData>   threadData = Maps.newConcurrentMap();
+    private final ConcurrentMap<Thread, LockData> threadData = Maps.newConcurrentMap();
 
     private static class LockData
     {
-        final Thread        owningThread;
-        final String        lockPath;
+        final Thread owningThread;
+        final String lockPath;
         final AtomicInteger lockCount = new AtomicInteger(1);
 
         private LockData(Thread owningThread, String lockPath)
@@ -57,7 +58,7 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
 
     /**
      * @param client client
-     * @param path the path to lock
+     * @param path   the path to lock
      */
     public InterProcessMutex(CuratorFramework client, String path)
     {
@@ -66,7 +67,7 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
 
     /**
      * @param client client
-     * @param path the path to lock
+     * @param path   the path to lock
      * @param driver lock driver
      */
     public InterProcessMutex(CuratorFramework client, String path, LockInternalsDriver driver)
@@ -131,8 +132,8 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
             can be only acted on by a single thread so locking isn't necessary
          */
 
-        Thread      currentThread = Thread.currentThread();
-        LockData    lockData = threadData.get(currentThread);
+        Thread currentThread = Thread.currentThread();
+        LockData lockData = threadData.get(currentThread);
         if ( lockData == null )
         {
             throw new IllegalMonitorStateException("You do not own the lock: " + basePath);
@@ -163,7 +164,7 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
      * @return list of nodes
      * @throws Exception ZK errors, interruptions, etc.
      */
-    public Collection<String>   getParticipantNodes() throws Exception
+    public Collection<String> getParticipantNodes() throws Exception
     {
         return LockInternals.getParticipantNodes(internals.getClient(), basePath, internals.getLockName(), internals.getDriver());
     }
@@ -177,21 +178,14 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
     @Override
     public void makeRevocable(final RevocationListener<InterProcessMutex> listener, Executor executor)
     {
-        internals.makeRevocable
-        (
-            new RevocationSpec
-            (
-                executor,
-                new Runnable()
+        internals.makeRevocable(new RevocationSpec(executor, new Runnable()
+            {
+                @Override
+                public void run()
                 {
-                    @Override
-                    public void run()
-                    {
-                        listener.revocationRequested(InterProcessMutex.this);
-                    }
+                    listener.revocationRequested(InterProcessMutex.this);
                 }
-            )
-        );
+            }));
     }
 
     InterProcessMutex(CuratorFramework client, String path, String lockName, int maxLeases, LockInternalsDriver driver)
@@ -200,19 +194,20 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
         internals = new LockInternals(client, driver, path, lockName, maxLeases);
     }
 
-    boolean      isOwnedByCurrentThread()
+    boolean isOwnedByCurrentThread()
     {
-        LockData    lockData = threadData.get(Thread.currentThread());
+        LockData lockData = threadData.get(Thread.currentThread());
         return (lockData != null) && (lockData.lockCount.get() > 0);
     }
 
-    protected byte[]        getLockNodeBytes()
+    protected byte[] getLockNodeBytes()
     {
         return null;
     }
 
-    protected String getLockPath() {
-        LockData    lockData = threadData.get(Thread.currentThread());
+    protected String getLockPath()
+    {
+        LockData lockData = threadData.get(Thread.currentThread());
         return lockData != null ? lockData.lockPath : null;
     }
 
@@ -223,9 +218,9 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
            can be only acted on by a single thread so locking isn't necessary
         */
 
-        Thread          currentThread = Thread.currentThread();
+        Thread currentThread = Thread.currentThread();
 
-        LockData        lockData = threadData.get(currentThread);
+        LockData lockData = threadData.get(currentThread);
         if ( lockData != null )
         {
             // re-entering
@@ -236,7 +231,7 @@ public class InterProcessMutex implements InterProcessLock, Revocable<InterProce
         String lockPath = internals.attemptLock(time, unit, getLockNodeBytes());
         if ( lockPath != null )
         {
-            LockData        newLockData = new LockData(currentThread, lockPath);
+            LockData newLockData = new LockData(currentThread, lockPath);
             threadData.put(currentThread, newLockData);
             return true;
         }


[4/7] git commit: Merge branch 'CURATOR-84' of https://github.com/karkum/curator into CURATOR-84

Posted by ra...@apache.org.
Merge branch 'CURATOR-84' of https://github.com/karkum/curator into CURATOR-84


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6b19fe2b
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6b19fe2b
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6b19fe2b

Branch: refs/heads/master
Commit: 6b19fe2b1906f656712c9f5c1da7083870a3e8ac
Parents: 475a3b0 6ecfd79
Author: Cam McKenzie <ca...@apache.org>
Authored: Thu Aug 21 07:40:57 2014 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Thu Aug 21 07:40:57 2014 +1000

----------------------------------------------------------------------
 .../recipes/locks/TestInterProcessMutex.java    | 43 ++++++++++++++++++++
 1 file changed, 43 insertions(+)
----------------------------------------------------------------------



[2/7] git commit: Merge branch 'CURATOR-84' of https://github.com/karkum/curator into CURATOR-84

Posted by ra...@apache.org.
Merge branch 'CURATOR-84' of https://github.com/karkum/curator into CURATOR-84


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/475a3b00
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/475a3b00
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/475a3b00

Branch: refs/heads/master
Commit: 475a3b00a08dab6b5b6beb192ebe91039277a443
Parents: 0d1397a 882f541
Author: Cam McKenzie <ca...@apache.org>
Authored: Wed Aug 20 16:49:16 2014 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Wed Aug 20 16:49:16 2014 +1000

----------------------------------------------------------------------
 .../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(-)
----------------------------------------------------------------------