[11/12] git commit: Merge branch 'master' into CURATOR-72
Merge branch 'master' into CURATOR-72 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/777a5f13 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/777a5f13 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/777a5f13 Branch: refs/heads/master Commit: 777a5f13ca1055849d4ffa9c3811c0e3283b2168 Parents: 5238d5f 863eaee Author: randgalt Authored: Mon Feb 3 13:57:36 2014 -0500 Committer: randgalt Committed: Mon Feb 3 13:57:36 2014 -0500 -- .../org/apache/curator/ConnectionState.java | 4 +- .../exhibitor/DefaultExhibitorRestClient.java | 4 +- .../apache/curator/utils/CloseableUtils.java| 70 .../curator/TestSessionFailRetryLoop.java | 10 +-- .../TestExhibitorEnsembleProvider.java | 6 +- .../src/main/java/cache/PathCacheExample.java | 10 +-- .../main/java/discovery/DiscoveryExample.java | 16 ++--- .../src/main/java/discovery/ExampleServer.java | 4 +- .../main/java/leader/LeaderSelectorExample.java | 8 +-- .../src/main/java/locking/LockingExample.java | 6 +- .../imps/CuratorTempFrameworkImpl.java | 4 +- .../curator/framework/imps/TestCompression.java | 8 +-- .../framework/imps/TestFailedDeleteManager.java | 10 +-- .../curator/framework/imps/TestFramework.java | 6 +- .../framework/imps/TestFrameworkBackground.java | 8 +-- .../framework/imps/TestFrameworkEdges.java | 22 +++--- .../curator/framework/imps/TestMultiClient.java | 6 +- .../framework/imps/TestNamespaceFacade.java | 12 ++-- .../framework/imps/TestNeverConnected.java | 4 +- .../curator/framework/imps/TestReadOnly.java| 6 +- .../framework/imps/TestTempFramework.java | 6 +- .../framework/imps/TestWatcherIdentity.java | 10 +-- .../curator/framework/imps/TestWithCluster.java | 10 +-- .../framework/recipes/leader/LeaderLatch.java | 2 +- .../framework/recipes/locks/ChildReaper.java| 4 +- .../recipes/locks/InterProcessSemaphore.java| 6 +- .../recipes/locks/InterProcessSemaphoreV2.java | 6 +- .../recipes/queue/DistributedQueue.java | 4 +- .../framework/recipes/queue/QueueSharder.java | 4 +- .../barriers/TestDistributedBarrier.java| 10 +-- .../barriers/TestDistributedDoubleBarrier.java | 8 +-- .../framework/recipes/cache/TestNodeCache.java | 18 ++--- .../recipes/cache/TestPathChildrenCache.java| 24 +++ .../cache/TestPathChildrenCacheInCluster.java | 8 +-- .../recipes/leader/TestLeaderLatch.java | 28 .../recipes/leader/TestLeaderLatchCluster.java | 8 +-- .../recipes/leader/TestLeaderSelector.java | 22 +++--- .../leader/TestLeaderSelectorCluster.java | 10 +-- .../leader/TestLeaderSelectorParticipants.java | 10 +-- .../leader/TestLeaderSelectorWithExecutor.java | 6 +- .../recipes/locks/SemaphoreClient.java | 4 +- .../recipes/locks/TestChildReaper.java | 14 ++-- .../locks/TestInterProcessMutexBase.java| 8 +-- .../locks/TestInterProcessReadWriteLock.java| 12 ++-- .../locks/TestInterProcessSemaphore.java| 10 +-- .../locks/TestInterProcessSemaphoreCluster.java | 14 ++-- .../framework/recipes/locks/TestLockACLs.java | 6 +- .../locks/TestLockCleanlinessWithFaults.java| 4 +- .../framework/recipes/locks/TestReaper.java | 38 +-- .../nodes/TestPersistentEphemeralNode.java | 8 +-- .../queue/TestBoundedDistributedQueue.java | 12 ++-- .../queue/TestDistributedDelayQueue.java| 14 ++-- .../recipes/queue/TestDistributedIdQueue.java | 10 +-- .../queue/TestDistributedPriorityQueue.java | 18 ++--- .../recipes/queue/TestDistributedQueue.java | 50 +++--- .../recipes/queue/TestQueueSharder.java | 16 ++--- .../queue/TestSimpleDistributedQueue.java | 4 +- .../recipes/shared/TestSharedCount.java | 4 +- .../discovery/server/rest/InstanceCleanup.java | 2 +- .../src/site/confluence/index.confluence| 8 +-- .../x/discovery/details/ServiceCacheImpl.java | 4 +- .../discovery/details/ServiceDiscoveryImpl.java | 6 +- .../curator/x/discovery/TestServiceCache.java | 10 +-- .../x/discovery/TestServiceDiscovery.java | 12 ++-- 64 files changed, 393 insertions(+), 323 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/777a5f13/curator-client/src/main/java/org/apache/curator/ConnectionState.java --
[02/12] git commit: Continued re-work on the connection state transitions involving background/async APIs.
Continued re-work on the connection state transitions involving background/async APIs. ConnectionStateManager now uses synchronization. This shouldn't hurt performance but rationalizes state changes from foreground/background ops. Background errors now go through same code as foreground errors. Transition to LOST is handled specifically instead of generally in logError(). Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/75acb0d9 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/75acb0d9 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/75acb0d9 Branch: refs/heads/master Commit: 75acb0d9222c3a54c9e15edff319acedcb26bbf5 Parents: a937dfa Author: randgalt Authored: Tue Dec 24 17:54:55 2013 -0500 Committer: randgalt Committed: Tue Dec 24 17:54:55 2013 -0500 -- .../java/org/apache/curator/HandleHolder.java | 2 +- .../curator/framework/imps/Backgrounding.java | 5 + .../framework/imps/CuratorFrameworkImpl.java| 128 +++-- .../framework/state/ConnectionStateManager.java | 44 +- .../framework/client/TestBackgroundStates.java | 142 +++ 5 files changed, 268 insertions(+), 53 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/75acb0d9/curator-client/src/main/java/org/apache/curator/HandleHolder.java -- diff --git a/curator-client/src/main/java/org/apache/curator/HandleHolder.java b/curator-client/src/main/java/org/apache/curator/HandleHolder.java index 4922688..1f7cd91 100644 --- a/curator-client/src/main/java/org/apache/curator/HandleHolder.java +++ b/curator-client/src/main/java/org/apache/curator/HandleHolder.java @@ -52,7 +52,7 @@ class HandleHolder ZooKeeper getZooKeeper() throws Exception { -return helper.getZooKeeper(); +return (helper != null) ? helper.getZooKeeper() : null; } String getConnectionString() http://git-wip-us.apache.org/repos/asf/curator/blob/75acb0d9/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java index 6ae9151..262b2a8 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/Backgrounding.java @@ -21,6 +21,7 @@ package org.apache.curator.framework.imps; import org.apache.curator.framework.api.BackgroundCallback; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.framework.CuratorFramework; +import org.apache.zookeeper.KeeperException; import java.util.concurrent.Executor; class Backgrounding @@ -109,6 +110,10 @@ class Backgrounding } catch ( Exception e ) { +if ( e instanceof KeeperException ) +{ + client.validateConnection(client.codeToState(((KeeperException)e).code())); +} client.logError("Background operation result handling threw exception", e); } } http://git-wip-us.apache.org/repos/asf/curator/blob/75acb0d9/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 3aa1097..1b0ef3f 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -512,24 +512,19 @@ public class CuratorFrameworkImpl implements CuratorFramework log.error(reason, e); } -if ( e instanceof KeeperException.ConnectionLossException ) -{ -handleKeeperStateDisconnected(); -} - final StringlocalReason = reason; unhandledErrorListeners.forEach -( -new Function() -{ -@Override -public Void apply(UnhandledErrorListener listener) +( +new Function() { -listener.unhandledError(localReason, e); -
[04/12] git commit: Another edge case found by Evaristo. When the SUSPEND is set, a background sync is executed to detect LOST. If the ZK connection is reset while this command is processing an incorr
Another edge case found by Evaristo. When the SUSPEND is set, a background sync is executed to detect LOST. If the ZK connection is reset while this command is processing an incorrect LOST might get set. Instead, keep track of ZooKeeper instance reset. If there is a reset ignore the background sync failure and re-submit the sync to test again. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0359bc5a Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0359bc5a Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0359bc5a Branch: refs/heads/master Commit: 0359bc5ab683285f44523d1445ef2eb8116380c4 Parents: 75acb0d Author: randgalt Authored: Sun Jan 12 16:53:03 2014 -0500 Committer: randgalt Committed: Sun Jan 12 16:54:17 2014 -0500 -- .../org/apache/curator/ConnectionState.java | 9 ++ .../apache/curator/CuratorZookeeperClient.java | 11 ++ .../framework/imps/CuratorFrameworkImpl.java| 17 ++- ...estResetConnectionWithBackgroundFailure.java | 104 +++ 4 files changed, 139 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/0359bc5a/curator-client/src/main/java/org/apache/curator/ConnectionState.java -- diff --git a/curator-client/src/main/java/org/apache/curator/ConnectionState.java b/curator-client/src/main/java/org/apache/curator/ConnectionState.java index e02ee88..4978c3f 100644 --- a/curator-client/src/main/java/org/apache/curator/ConnectionState.java +++ b/curator-client/src/main/java/org/apache/curator/ConnectionState.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; class ConnectionState implements Watcher, Closeable @@ -49,6 +50,7 @@ class ConnectionState implements Watcher, Closeable private final AtomicReference tracer; private final Queue backgroundExceptions = new ConcurrentLinkedQueue(); private final Queue parentWatchers = new ConcurrentLinkedQueue(); +private final AtomicLong instanceIndex = new AtomicLong(); private volatile long connectionStartMs = 0; ConnectionState(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher parentWatcher, AtomicReference tracer, boolean canBeReadOnly) @@ -131,6 +133,11 @@ class ConnectionState implements Watcher, Closeable parentWatchers.remove(watcher); } +long getInstanceIndex() +{ +return instanceIndex.get(); +} + @Override public void process(WatchedEvent event) { @@ -204,6 +211,8 @@ class ConnectionState implements Watcher, Closeable { log.debug("reset"); +instanceIndex.incrementAndGet(); + isConnected.set(false); connectionStartMs = System.currentTimeMillis(); zooKeeper.closeAndReset(); http://git-wip-us.apache.org/repos/asf/curator/blob/0359bc5a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java -- diff --git a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java index f4e56f9..f0a4ab3 100644 --- a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java +++ b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java @@ -279,6 +279,17 @@ public class CuratorZookeeperClient implements Closeable return connectionTimeoutMs; } +/** + * Every time a new {@link ZooKeeper} instance is allocated, the "instance index" + * is incremented. + * + * @return the current instance index + */ +public long getInstanceIndex() +{ +return state.getInstanceIndex(); +} + voidaddParentWatcher(Watcher watcher) { state.addParentWatcher(watcher); http://git-wip-us.apache.org/repos/asf/curator/blob/0359bc5a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 1b0ef3f..f1258ea 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFra
[08/12] git commit: if doSyncForSuspendedConnection repeatedly fails there may be an infinite loop of connection resets. So, after the first reset (signaled by getInstanceIndex value changing) give up
if doSyncForSuspendedConnection repeatedly fails there may be an infinite loop of connection resets. So, after the first reset (signaled by getInstanceIndex value changing) give up and mark the connection LOST Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/c40afd96 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/c40afd96 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/c40afd96 Branch: refs/heads/master Commit: c40afd96a0121ac45b340679174320f7b4f02d26 Parents: f0fc51f Author: randgalt Authored: Mon Feb 3 13:46:28 2014 -0500 Committer: randgalt Committed: Mon Feb 3 13:46:28 2014 -0500 -- .../org/apache/curator/framework/imps/CuratorFrameworkImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/c40afd96/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 3a2a48f..b480d9b 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -624,14 +624,15 @@ public class CuratorFrameworkImpl implements CuratorFramework // if instanceIndex != newInstanceIndex, the ZooKeeper instance was reset/reallocated // so the pending background sync is no longer valid long newInstanceIndex = client.getInstanceIndex(); -if ( instanceIndex == newInstanceIndex ) +if ( (instanceIndex < 0) || (instanceIndex == newInstanceIndex) ) { connectionStateManager.addStateChange(ConnectionState.LOST); } else { log.debug("suspendConnection() failure ignored as the ZooKeeper instance was reset. Retrying."); -doSyncForSuspendedConnection(newInstanceIndex); +// send -1 to signal that if it happens again, punt and mark the connection lost +doSyncForSuspendedConnection(-1); } } };
[06/12] git commit: Previous version was incorrectly re-using the instanceIndex. Need to use latest value
Previous version was incorrectly re-using the instanceIndex. Need to use latest value Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/8fbe4b7d Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8fbe4b7d Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8fbe4b7d Branch: refs/heads/master Commit: 8fbe4b7db66d157c951268f1ce07e08cf176bd77 Parents: 4f47e7b Author: randgalt Authored: Mon Jan 13 17:59:37 2014 -0500 Committer: randgalt Committed: Mon Jan 13 17:59:37 2014 -0500 -- .../apache/curator/framework/imps/CuratorFrameworkImpl.java | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/8fbe4b7d/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index f1258ea..d516f48 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -606,8 +606,11 @@ public class CuratorFrameworkImpl implements CuratorFramework { connectionStateManager.setToSuspended(); -final long instanceIndex = client.getInstanceIndex(); +doSyncForSuspendedConnection(client.getInstanceIndex()); +} +private void doSyncForSuspendedConnection(final long instanceIndex) +{ // we appear to have disconnected, force a new ZK event and see if we can connect to another server final BackgroundOperation operation = new BackgroundSyncImpl(this, null); OperationAndData.ErrorCallback errorCallback = new OperationAndData.ErrorCallback() @@ -625,7 +628,7 @@ public class CuratorFrameworkImpl implements CuratorFramework else { log.debug("suspendConnection() failure ignored as the ZooKeeper instance was reset. Retrying."); -performBackgroundOperation(new OperationAndData(operation, "/", null, this, null)); +doSyncForSuspendedConnection(newInstanceIndex); } } };
[01/12] git commit: Background connection errors would go straight to LOST which is different than foreground connection errors. Changed so that background connection errors go to SUSPENDED first just
Updated Branches: refs/heads/master 09f04e9c9 -> 0a82f4eaa Background connection errors would go straight to LOST which is different than foreground connection errors. Changed so that background connection errors go to SUSPENDED first just like foreground connection errors. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/a937dfac Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/a937dfac Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/a937dfac Branch: refs/heads/master Commit: a937dfacf68869b1f6a860ffd02993108da99382 Parents: 262d57e Author: randgalt Authored: Sun Nov 17 12:46:55 2013 -0800 Committer: randgalt Committed: Sun Nov 17 12:46:55 2013 -0800 -- .../framework/imps/CuratorFrameworkImpl.java| 11 ++- .../TestPersistentEphemeralNodeListener.java| 94 2 files changed, 102 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/a937dfac/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index d56c9a4..3aa1097 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -514,7 +514,7 @@ public class CuratorFrameworkImpl implements CuratorFramework if ( e instanceof KeeperException.ConnectionLossException ) { -connectionStateManager.addStateChange(ConnectionState.LOST); +handleKeeperStateDisconnected(); } final StringlocalReason = reason; @@ -745,8 +745,7 @@ public class CuratorFrameworkImpl implements CuratorFramework { if ( curatorEvent.getWatchedEvent().getState() == Watcher.Event.KeeperState.Disconnected ) { - connectionStateManager.addStateChange(ConnectionState.SUSPENDED); -internalSync(this, "/", null); // we appear to have disconnected, force a new ZK event and see if we can connect to another server +handleKeeperStateDisconnected(); } else if ( curatorEvent.getWatchedEvent().getState() == Watcher.Event.KeeperState.Expired ) { @@ -762,4 +761,10 @@ public class CuratorFrameworkImpl implements CuratorFramework } } } + +private void handleKeeperStateDisconnected() +{ +connectionStateManager.addStateChange(ConnectionState.SUSPENDED); +internalSync(this, "/", null); // we appear to have disconnected, force a new ZK event and see if we can connect to another server +} } http://git-wip-us.apache.org/repos/asf/curator/blob/a937dfac/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNodeListener.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNodeListener.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNodeListener.java new file mode 100644 index 000..b97ba41 --- /dev/null +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNodeListener.java @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.curator.framework.recipes.nodes; + +import com.google.common.collect.Lists; +import com.google.common.io.Closeables; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.framework.recipes.BaseClassForTests; +import org.apache.curator.fra
[09/12] git commit: don't need to hoist value anymore
don't need to hoist value anymore Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/22659054 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/22659054 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/22659054 Branch: refs/heads/master Commit: 226590541f07ce4a611f71d389a43762d118397d Parents: c40afd9 Author: randgalt Authored: Mon Feb 3 13:49:45 2014 -0500 Committer: randgalt Committed: Mon Feb 3 13:49:45 2014 -0500 -- .../org/apache/curator/framework/imps/CuratorFrameworkImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/22659054/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index b480d9b..0f98495 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -623,8 +623,7 @@ public class CuratorFrameworkImpl implements CuratorFramework { // if instanceIndex != newInstanceIndex, the ZooKeeper instance was reset/reallocated // so the pending background sync is no longer valid -long newInstanceIndex = client.getInstanceIndex(); -if ( (instanceIndex < 0) || (instanceIndex == newInstanceIndex) ) +if ( (instanceIndex < 0) || (instanceIndex == client.getInstanceIndex()) ) { connectionStateManager.addStateChange(ConnectionState.LOST); }
[12/12] git commit: Merge branch 'CURATOR-72'
Merge branch 'CURATOR-72' Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0a82f4ea Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0a82f4ea Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0a82f4ea Branch: refs/heads/master Commit: 0a82f4eaa518ae41097fefdce332099dd2983286 Parents: 09f04e9 777a5f1 Author: randgalt Authored: Wed Feb 5 13:41:33 2014 -0500 Committer: randgalt Committed: Wed Feb 5 13:41:33 2014 -0500 -- .../org/apache/curator/ConnectionState.java | 9 ++ .../apache/curator/CuratorZookeeperClient.java | 11 ++ .../java/org/apache/curator/HandleHolder.java | 2 +- .../curator/framework/imps/Backgrounding.java | 5 + .../framework/imps/CuratorFrameworkImpl.java| 145 +-- .../framework/state/ConnectionStateManager.java | 47 +- .../framework/client/TestBackgroundStates.java | 142 ++ ...estResetConnectionWithBackgroundFailure.java | 104 + .../TestPersistentEphemeralNodeListener.java| 94 9 files changed, 510 insertions(+), 49 deletions(-) --
[03/12] git commit: Another edge case found Evaristo. When the SUSPEND is set, a background sync is executed to detect LOST. If the ZK connection is reset while this command is processing an incorrect
Another edge case found Evaristo. When the SUSPEND is set, a background sync is executed to detect LOST. If the ZK connection is reset while this command is processing an incorrect LOST might get set. Instead, keep track of ZooKeeper instance reset. If there is a reset ignore the background sync failure and re-submit the sync to test again. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/332c20b3 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/332c20b3 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/332c20b3 Branch: refs/heads/master Commit: 332c20b375510b81bbc2a15fcccfacb7d57ec93d Parents: 75acb0d Author: randgalt Authored: Sun Jan 12 16:53:03 2014 -0500 Committer: randgalt Committed: Sun Jan 12 16:53:03 2014 -0500 -- .../org/apache/curator/ConnectionState.java | 9 ++ .../apache/curator/CuratorZookeeperClient.java | 11 ++ .../framework/imps/CuratorFrameworkImpl.java| 17 ++- ...estResetConnectionWithBackgroundFailure.java | 104 +++ 4 files changed, 139 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/332c20b3/curator-client/src/main/java/org/apache/curator/ConnectionState.java -- diff --git a/curator-client/src/main/java/org/apache/curator/ConnectionState.java b/curator-client/src/main/java/org/apache/curator/ConnectionState.java index e02ee88..4978c3f 100644 --- a/curator-client/src/main/java/org/apache/curator/ConnectionState.java +++ b/curator-client/src/main/java/org/apache/curator/ConnectionState.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; class ConnectionState implements Watcher, Closeable @@ -49,6 +50,7 @@ class ConnectionState implements Watcher, Closeable private final AtomicReference tracer; private final Queue backgroundExceptions = new ConcurrentLinkedQueue(); private final Queue parentWatchers = new ConcurrentLinkedQueue(); +private final AtomicLong instanceIndex = new AtomicLong(); private volatile long connectionStartMs = 0; ConnectionState(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher parentWatcher, AtomicReference tracer, boolean canBeReadOnly) @@ -131,6 +133,11 @@ class ConnectionState implements Watcher, Closeable parentWatchers.remove(watcher); } +long getInstanceIndex() +{ +return instanceIndex.get(); +} + @Override public void process(WatchedEvent event) { @@ -204,6 +211,8 @@ class ConnectionState implements Watcher, Closeable { log.debug("reset"); +instanceIndex.incrementAndGet(); + isConnected.set(false); connectionStartMs = System.currentTimeMillis(); zooKeeper.closeAndReset(); http://git-wip-us.apache.org/repos/asf/curator/blob/332c20b3/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java -- diff --git a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java index f4e56f9..f0a4ab3 100644 --- a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java +++ b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java @@ -279,6 +279,17 @@ public class CuratorZookeeperClient implements Closeable return connectionTimeoutMs; } +/** + * Every time a new {@link ZooKeeper} instance is allocated, the "instance index" + * is incremented. + * + * @return the current instance index + */ +public long getInstanceIndex() +{ +return state.getInstanceIndex(); +} + voidaddParentWatcher(Watcher watcher) { state.addParentWatcher(watcher); http://git-wip-us.apache.org/repos/asf/curator/blob/332c20b3/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 1b0ef3f..f1258ea 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFramew
[10/12] git commit: added a comment
added a comment Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5238d5f0 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5238d5f0 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5238d5f0 Branch: refs/heads/master Commit: 5238d5f083f0c5b9c28e4c73d834873737dab936 Parents: 2265905 Author: randgalt Authored: Mon Feb 3 13:50:25 2014 -0500 Committer: randgalt Committed: Mon Feb 3 13:50:25 2014 -0500 -- .../org/apache/curator/framework/imps/CuratorFrameworkImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/5238d5f0/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 0f98495..7854308 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -622,7 +622,8 @@ public class CuratorFrameworkImpl implements CuratorFramework public void retriesExhausted(OperationAndData operationAndData) { // if instanceIndex != newInstanceIndex, the ZooKeeper instance was reset/reallocated -// so the pending background sync is no longer valid +// so the pending background sync is no longer valid. +// if instanceIndex is -1, this is the second try to sync - punt and mark the connection lost if ( (instanceIndex < 0) || (instanceIndex == client.getInstanceIndex()) ) { connectionStateManager.addStateChange(ConnectionState.LOST);
[05/12] git commit: Merge branch 'CURATOR-72' of https://git-wip-us.apache.org/repos/asf/curator into CURATOR-72
Merge branch 'CURATOR-72' of https://git-wip-us.apache.org/repos/asf/curator into CURATOR-72 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/4f47e7b1 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/4f47e7b1 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/4f47e7b1 Branch: refs/heads/master Commit: 4f47e7b11cfcbd6b2ae80d51c1130e1752b40318 Parents: 0359bc5 332c20b Author: randgalt Authored: Sun Jan 12 16:54:39 2014 -0500 Committer: randgalt Committed: Sun Jan 12 16:54:39 2014 -0500 -- --
[07/12] git commit: patch from Evaristo to possibly finalize this change
patch from Evaristo to possibly finalize this change Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f0fc51f7 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f0fc51f7 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f0fc51f7 Branch: refs/heads/master Commit: f0fc51f766f608bbb0df7ac506f592407eb9be83 Parents: 8fbe4b7 Author: randgalt Authored: Mon Feb 3 09:23:03 2014 -0500 Committer: randgalt Committed: Mon Feb 3 09:23:03 2014 -0500 -- .../apache/curator/framework/imps/CuratorFrameworkImpl.java | 7 +-- .../curator/framework/state/ConnectionStateManager.java | 9 ++--- 2 files changed, 11 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/f0fc51f7/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index d516f48..3a2a48f 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -604,7 +604,10 @@ public class CuratorFrameworkImpl implements CuratorFramework private void suspendConnection() { -connectionStateManager.setToSuspended(); +if ( !connectionStateManager.setToSuspended() ) +{ +return; +} doSyncForSuspendedConnection(client.getInstanceIndex()); } @@ -782,7 +785,7 @@ public class CuratorFrameworkImpl implements CuratorFramework } else { -handleBackgroundOperationException(operationAndData, e); + logError("Background retry gave up", e); } } else http://git-wip-us.apache.org/repos/asf/curator/blob/f0fc51f7/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java index a2cfa60..42804b8 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java @@ -136,21 +136,24 @@ public class ConnectionStateManager implements Closeable /** * Change to {@link ConnectionState#SUSPENDED} only if not already suspended and not lost + * + * @return true if connection is set to SUSPENDED */ -public synchronized void setToSuspended() +public synchronized boolean setToSuspended() { if ( state.get() != State.STARTED ) { -return; +return false; } if ( (currentConnectionState == ConnectionState.LOST) || (currentConnectionState == ConnectionState.SUSPENDED) ) { -return; +return false; } currentConnectionState = ConnectionState.SUSPENDED; postState(ConnectionState.SUSPENDED); +return true; } /**
git commit: [maven-release-plugin] prepare for next development iteration
Updated Branches: refs/heads/master b12d55e81 -> f5384e5be [maven-release-plugin] prepare for next development iteration Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f5384e5b Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f5384e5b Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f5384e5b Branch: refs/heads/master Commit: f5384e5bef9ca18d01fd9c269cb6062daf232274 Parents: b12d55e Author: randgalt Authored: Wed Feb 5 13:54:14 2014 -0500 Committer: randgalt Committed: Wed Feb 5 13:54:14 2014 -0500 -- curator-client/pom.xml | 4 ++-- curator-examples/pom.xml | 2 +- curator-framework/pom.xml | 4 ++-- curator-recipes/pom.xml| 4 ++-- curator-test/pom.xml | 4 ++-- curator-x-discovery-server/pom.xml | 4 ++-- curator-x-discovery/pom.xml| 4 ++-- pom.xml| 16 8 files changed, 21 insertions(+), 21 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/f5384e5b/curator-client/pom.xml -- diff --git a/curator-client/pom.xml b/curator-client/pom.xml index c4db7a2..e66f2ae 100644 --- a/curator-client/pom.xml +++ b/curator-client/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.4.0 +2.4.1-SNAPSHOT org.apache.curator curator-client -2.4.0 +2.4.1-SNAPSHOT bundle Curator Client http://git-wip-us.apache.org/repos/asf/curator/blob/f5384e5b/curator-examples/pom.xml -- diff --git a/curator-examples/pom.xml b/curator-examples/pom.xml index c16a4a9..06b2694 100644 --- a/curator-examples/pom.xml +++ b/curator-examples/pom.xml @@ -24,7 +24,7 @@ org.apache.curator apache-curator -2.4.0 +2.4.1-SNAPSHOT curator-examples http://git-wip-us.apache.org/repos/asf/curator/blob/f5384e5b/curator-framework/pom.xml -- diff --git a/curator-framework/pom.xml b/curator-framework/pom.xml index fcc6841..17c10e6 100644 --- a/curator-framework/pom.xml +++ b/curator-framework/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.4.0 +2.4.1-SNAPSHOT org.apache.curator curator-framework -2.4.0 +2.4.1-SNAPSHOT bundle Curator Framework http://git-wip-us.apache.org/repos/asf/curator/blob/f5384e5b/curator-recipes/pom.xml -- diff --git a/curator-recipes/pom.xml b/curator-recipes/pom.xml index 1ada19d..56ac0c8 100644 --- a/curator-recipes/pom.xml +++ b/curator-recipes/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.4.0 +2.4.1-SNAPSHOT org.apache.curator curator-recipes -2.4.0 +2.4.1-SNAPSHOT bundle Curator Recipes http://git-wip-us.apache.org/repos/asf/curator/blob/f5384e5b/curator-test/pom.xml -- diff --git a/curator-test/pom.xml b/curator-test/pom.xml index 591d462..98fc0c2 100644 --- a/curator-test/pom.xml +++ b/curator-test/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.4.0 +2.4.1-SNAPSHOT org.apache.curator curator-test -2.4.0 +2.4.1-SNAPSHOT Curator Testing Unit testing utilities. http://git-wip-us.apache.org/repos/asf/curator/blob/f5384e5b/curator-x-discovery-server/pom.xml -- diff --git a/curator-x-discovery-server/pom.xml b/curator-x-discovery-server/pom.xml index 4fa3c98..2901abf 100644 --- a/curator-x-discovery-server/pom.xml +++ b/curator-x-discovery-server/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.4.0 +2.4.1-SNAPSHOT org.apache.curator curator-x-discovery-server -2.4.0 +2.4.1-SNAPSHOT bundle Curator Service Discovery Server http://git-wip-us.apache.org/repos/asf/curator/blob/f5384e5b/curator-x-discovery/pom.xml -- diff --git a/curator-x-discovery/pom.xml b/curator-x-discovery/pom.xml index 43dfba0..d40b225 100644 --- a/curator-x-discovery/pom.xml +++ b/curator-x-discovery/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.4.0 +2.4.1-SNAPSHOT org.apache.curator curator-x-discovery -2.4.0 +2.4.1-SNAPSHOT
git commit: [maven-release-plugin] prepare release 2.4.0
Updated Branches: refs/heads/master 0a82f4eaa -> b12d55e81 [maven-release-plugin] prepare release 2.4.0 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b12d55e8 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b12d55e8 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b12d55e8 Branch: refs/heads/master Commit: b12d55e8150d56bbe8564c5edcb22efde0c14dd1 Parents: 0a82f4e Author: randgalt Authored: Wed Feb 5 13:53:49 2014 -0500 Committer: randgalt Committed: Wed Feb 5 13:53:49 2014 -0500 -- curator-client/pom.xml | 4 ++-- curator-examples/pom.xml | 2 +- curator-framework/pom.xml | 4 ++-- curator-recipes/pom.xml| 4 ++-- curator-test/pom.xml | 4 ++-- curator-x-discovery-server/pom.xml | 4 ++-- curator-x-discovery/pom.xml| 4 ++-- pom.xml| 16 8 files changed, 21 insertions(+), 21 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/b12d55e8/curator-client/pom.xml -- diff --git a/curator-client/pom.xml b/curator-client/pom.xml index a2015bb..c4db7a2 100644 --- a/curator-client/pom.xml +++ b/curator-client/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.3.2-SNAPSHOT +2.4.0 org.apache.curator curator-client -2.3.2-SNAPSHOT +2.4.0 bundle Curator Client http://git-wip-us.apache.org/repos/asf/curator/blob/b12d55e8/curator-examples/pom.xml -- diff --git a/curator-examples/pom.xml b/curator-examples/pom.xml index fb60edb..c16a4a9 100644 --- a/curator-examples/pom.xml +++ b/curator-examples/pom.xml @@ -24,7 +24,7 @@ org.apache.curator apache-curator -2.3.2-SNAPSHOT +2.4.0 curator-examples http://git-wip-us.apache.org/repos/asf/curator/blob/b12d55e8/curator-framework/pom.xml -- diff --git a/curator-framework/pom.xml b/curator-framework/pom.xml index 30ae1bf..fcc6841 100644 --- a/curator-framework/pom.xml +++ b/curator-framework/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.3.2-SNAPSHOT +2.4.0 org.apache.curator curator-framework -2.3.2-SNAPSHOT +2.4.0 bundle Curator Framework http://git-wip-us.apache.org/repos/asf/curator/blob/b12d55e8/curator-recipes/pom.xml -- diff --git a/curator-recipes/pom.xml b/curator-recipes/pom.xml index 94791f0..1ada19d 100644 --- a/curator-recipes/pom.xml +++ b/curator-recipes/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.3.2-SNAPSHOT +2.4.0 org.apache.curator curator-recipes -2.3.2-SNAPSHOT +2.4.0 bundle Curator Recipes http://git-wip-us.apache.org/repos/asf/curator/blob/b12d55e8/curator-test/pom.xml -- diff --git a/curator-test/pom.xml b/curator-test/pom.xml index 838c8a1..591d462 100644 --- a/curator-test/pom.xml +++ b/curator-test/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.3.2-SNAPSHOT +2.4.0 org.apache.curator curator-test -2.3.2-SNAPSHOT +2.4.0 Curator Testing Unit testing utilities. http://git-wip-us.apache.org/repos/asf/curator/blob/b12d55e8/curator-x-discovery-server/pom.xml -- diff --git a/curator-x-discovery-server/pom.xml b/curator-x-discovery-server/pom.xml index a01e17f..4fa3c98 100644 --- a/curator-x-discovery-server/pom.xml +++ b/curator-x-discovery-server/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.3.2-SNAPSHOT +2.4.0 org.apache.curator curator-x-discovery-server -2.3.2-SNAPSHOT +2.4.0 bundle Curator Service Discovery Server http://git-wip-us.apache.org/repos/asf/curator/blob/b12d55e8/curator-x-discovery/pom.xml -- diff --git a/curator-x-discovery/pom.xml b/curator-x-discovery/pom.xml index 65ac0c2..43dfba0 100644 --- a/curator-x-discovery/pom.xml +++ b/curator-x-discovery/pom.xml @@ -24,12 +24,12 @@ org.apache.curator apache-curator -2.3.2-SNAPSHOT +2.4.0 org.apache.curator curator-x-discovery -2.3.2-SNAPSHOT +2.4.0 bundle Cu
Git Push Summary
Updated Tags: refs/tags/2.4.0 [created] 7abaf963f