You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2016/06/06 00:48:13 UTC
[13/13] curator git commit: Merge branch 'master' into CURATOR-3.0
Merge branch 'master' into CURATOR-3.0
Conflicts:
curator-client/pom.xml
curator-examples/pom.xml
curator-framework/pom.xml
curator-recipes/pom.xml
curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java
curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
curator-test/pom.xml
curator-x-discovery-server/pom.xml
curator-x-discovery/pom.xml
curator-x-rpc/pom.xml
pom.xml
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/d27a70c2
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/d27a70c2
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/d27a70c2
Branch: refs/heads/CURATOR-3.0
Commit: d27a70c283cfd2829b96147c8670a1e7dd59659e
Parents: a0dd0c9 8dc0283
Author: Cam McKenzie <ca...@apache.org>
Authored: Mon Jun 6 10:47:39 2016 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Mon Jun 6 10:47:39 2016 +1000
----------------------------------------------------------------------
.../recipes/locks/InterProcessSemaphoreV2.java | 28 ++-
.../locks/TestInterProcessSemaphore.java | 186 ++++++++++++++++++-
2 files changed, 204 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/d27a70c2/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java
----------------------------------------------------------------------
diff --cc curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java
index d967b98,2b9d48d..f343207
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessSemaphoreV2.java
@@@ -46,7 -44,9 +46,8 @@@ import java.util.Arrays
import java.util.Collection;
import java.util.List;
import java.util.Set;
+ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.apache.curator.utils.PathUtils;
/**
* <p>
@@@ -357,38 -360,53 +361,56 @@@ public class InterProcessSemaphoreV
String nodeName = ZKPaths.getNodeFromPath(path);
lease = makeLease(path);
+ if ( debugAcquireLatch != null )
+ {
+ debugAcquireLatch.await();
+ }
+
- synchronized(this)
+ try
{
- for(;;)
+ synchronized(this)
{
- List<String> children;
- try
- {
- children = client.getChildren().usingWatcher(watcher).forPath(leasesPath);
- }
- catch ( Exception e )
- {
- if ( debugFailedGetChildrenLatch != null )
+ for(;;)
- {
- List<String> children = client.getChildren().usingWatcher(watcher).forPath(leasesPath);
++ {
++ List<String> children;
++ try
+ {
- debugFailedGetChildrenLatch.countDown();
++ children = client.getChildren().usingWatcher(watcher).forPath(leasesPath);
+ }
- returnLease(lease); // otherwise the just created ZNode will be orphaned causing a dead lock
- throw e;
- }
- if ( !children.contains(nodeName) )
- {
- log.error("Sequential path not found: " + path);
- returnLease(lease);
- return InternalAcquireResult.RETRY_DUE_TO_MISSING_NODE;
- }
-
- if ( children.size() <= maxLeases )
- {
- break;
- }
- if ( hasWait )
- {
- long thisWaitMs = getThisWaitMs(startMs, waitMs);
- if ( thisWaitMs <= 0 )
++ catch ( Exception e )
+ {
++ if ( debugFailedGetChildrenLatch != null )
++ {
++ debugFailedGetChildrenLatch.countDown();
++ }
++ returnLease(lease); // otherwise the just created ZNode will be orphaned causing a dead lock
++ throw e;
++ }
+ if ( !children.contains(nodeName) )
+ {
+ log.error("Sequential path not found: " + path);
returnLease(lease);
- return InternalAcquireResult.RETURN_NULL;
+ return InternalAcquireResult.RETRY_DUE_TO_MISSING_NODE;
+ }
-
++
+ if ( children.size() <= maxLeases )
+ {
+ break;
+ }
+ if ( hasWait )
+ {
+ long thisWaitMs = getThisWaitMs(startMs, waitMs);
+ if ( thisWaitMs <= 0 )
+ {
+ returnLease(lease);
+ return InternalAcquireResult.RETURN_NULL;
+ }
+ wait(thisWaitMs);
+ }
+ else
+ {
+ wait();
}
- wait(thisWaitMs);
- }
- else
- {
- wait();
}
}
}
http://git-wip-us.apache.org/repos/asf/curator/blob/d27a70c2/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
----------------------------------------------------------------------
diff --cc curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
index 802290e,216c2a2..7e821d0
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
@@@ -23,8 -24,10 +24,11 @@@ import com.google.common.collect.Queues
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.api.CuratorWatcher;
+import org.apache.curator.framework.imps.TestCleanState;
import org.apache.curator.framework.recipes.shared.SharedCount;
+ import org.apache.curator.framework.state.ConnectionState;
+ import org.apache.curator.framework.state.ConnectionStateListener;
+ import org.apache.curator.retry.RetryNTimes;
import org.apache.curator.retry.RetryOneTime;
import org.apache.curator.test.BaseClassForTests;
import org.apache.curator.test.Timing;