You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by dr...@apache.org on 2015/08/19 01:18:36 UTC
[20/31] curator git commit: Merge branch 'CURATOR-161' into
CURATOR-217
Merge branch 'CURATOR-161' into CURATOR-217
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/fb274b1c
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/fb274b1c
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/fb274b1c
Branch: refs/heads/CURATOR-3.0
Commit: fb274b1c8d56eeae97c50966ba69e6b98fd71274
Parents: 43afca7 a47c036
Author: randgalt <ra...@apache.org>
Authored: Tue May 19 17:52:58 2015 -0700
Committer: randgalt <ra...@apache.org>
Committed: Tue May 19 17:52:58 2015 -0700
----------------------------------------------------------------------
.../curator/framework/CuratorFramework.java | 4 +
.../curator/framework/api/DeleteBuilder.java | 2 +-
.../curator/framework/api/Guaranteeable.java | 20 +-
.../framework/api/GuaranteeableDelete.java | 39 ++
.../framework/api/RemoveWatchesLocal.java | 4 +-
.../framework/api/RemoveWatchesType.java | 2 +-
.../framework/imps/CuratorFrameworkImpl.java | 10 +-
.../framework/imps/DeleteBuilderImpl.java | 4 +-
.../framework/imps/FailedDeleteManager.java | 39 +-
.../framework/imps/FailedOperationManager.java | 65 +++
.../imps/FailedRemoveWatchManager.java | 56 +++
.../framework/imps/NamespaceWatcherMap.java | 8 +
.../framework/imps/OperationAndData.java | 16 +-
.../imps/RemoveWatchesBuilderImpl.java | 126 ++++--
.../framework/imps/TestFailedDeleteManager.java | 9 +-
.../framework/imps/TestRemoveWatches.java | 407 +++++++++++++++----
16 files changed, 635 insertions(+), 176 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/fb274b1c/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/fb274b1c/curator-framework/src/main/java/org/apache/curator/framework/api/RemoveWatchesLocal.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/fb274b1c/curator-framework/src/main/java/org/apache/curator/framework/api/RemoveWatchesType.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/fb274b1c/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/fb274b1c/curator-framework/src/main/java/org/apache/curator/framework/imps/RemoveWatchesBuilderImpl.java
----------------------------------------------------------------------
diff --cc curator-framework/src/main/java/org/apache/curator/framework/imps/RemoveWatchesBuilderImpl.java
index 10d58d0,932706b..4b1b029
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/RemoveWatchesBuilderImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/RemoveWatchesBuilderImpl.java
@@@ -169,44 -164,87 +190,87 @@@ public class RemoveWatchesBuilderImpl i
return null;
}
- private void pathInBackground(String path)
+ private void pathInBackground(final String path)
{
- OperationAndData.ErrorCallback<String> errorCallback = null;
- client.processBackgroundOperation(new OperationAndData<String>(this, path, backgrounding.getCallback(), errorCallback, backgrounding.getContext()), null);
+ OperationAndData.ErrorCallback<String> errorCallback = null;
+
+ //Only need an error callback if we're in guaranteed mode
+ if(guaranteed)
+ {
+ errorCallback = new OperationAndData.ErrorCallback<String>()
+ {
+ @Override
+ public void retriesExhausted(OperationAndData<String> operationAndData)
+ {
+ client.getFailedRemoveWatcherManager().addFailedOperation(new FailedRemoveWatchManager.FailedRemoveWatchDetails(path, watcher));
+ }
+ };
+ }
+
+ client.processBackgroundOperation(new OperationAndData<String>(this, path, backgrounding.getCallback(),
+ errorCallback, backgrounding.getContext(), !local), null);
}
- private void pathInForeground(final String path) throws Exception
+ void pathInForeground(final String path) throws Exception
{
- RetryLoop.callWithRetry(client.getZookeeperClient(),
- new Callable<Void>()
- {
- @Override
- public Void call() throws Exception
+ //For the local case we don't want to use the normal retry loop and we don't want to block until a connection is available.
+ //We just execute the removeWatch, and if it fails, ZK will just remove local watches.
+ if(local)
+ {
+ ZooKeeper zkClient = client.getZooKeeper();
+ if(watcher == null)
+ {
+ zkClient.removeAllWatches(path, watcherType, local);
+ }
+ else
+ {
+ zkClient.removeWatches(path, watcher, watcherType, local);
+ }
+ }
+ else
+ {
+ RetryLoop.callWithRetry(client.getZookeeperClient(),
+ new Callable<Void>()
{
- try
+ @Override
+ public Void call() throws Exception
{
- ZooKeeper zkClient = client.getZooKeeper();
- if(watcher == null)
- {
- zkClient.removeAllWatches(path, watcherType, local);
- }
- else
+ try
{
- zkClient.removeWatches(path, watcher, watcherType, local);
+ ZooKeeper zkClient = client.getZookeeperClient().getZooKeeper();
+
+ if(watcher == null)
+ {
+ zkClient.removeAllWatches(path, watcherType, local);
+ }
+ else
+ {
+ zkClient.removeWatches(path, watcher, watcherType, local);
+ }
}
- }
- catch(KeeperException.NoWatcherException e)
- {
- //Swallow this exception if the quietly flag is set, otherwise rethrow.
- if(!quietly)
+ catch(Exception e)
{
- throw e;
+ if( RetryLoop.isRetryException(e) && guaranteed )
+ {
+ //Setup the guaranteed handler
+ client.getFailedRemoveWatcherManager().addFailedOperation(new FailedRemoveWatchManager.FailedRemoveWatchDetails(path, watcher));
+ throw e;
+ }
+ else if(e instanceof KeeperException.NoWatcherException && quietly)
+ {
+ //Ignore
+ }
+ else
+ {
+ //Rethrow
+ throw e;
+ }
}
- }
- return null;
- }
- });
+ return null;
+ }
+ });
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/curator/blob/fb274b1c/curator-framework/src/test/java/org/apache/curator/framework/imps/TestRemoveWatches.java
----------------------------------------------------------------------