curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [3/4] git commit: When performBackgroundOperation gets a retryable CuratorConnectionLossException, don't do it inline. Queue the background operation as usual
Date Tue, 24 Sep 2013 01:54:39 GMT
When performBackgroundOperation gets a retryable CuratorConnectionLossException, don't do it
inline. Queue the background operation as usual


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

Branch: refs/heads/master
Commit: 64a21a79c5c8bbb9f5b36dfdfd7adbec72795af3
Parents: a561f9a
Author: randgalt <randgalt@apache.org>
Authored: Sun Sep 22 17:53:53 2013 -0700
Committer: randgalt <randgalt@apache.org>
Committed: Sun Sep 22 17:53:53 2013 -0700

----------------------------------------------------------------------
 .../framework/imps/CuratorFrameworkImpl.java    | 43 ++++++++++----------
 1 file changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/64a21a79/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 3cccf45..87353bf 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
@@ -667,32 +667,33 @@ public class CuratorFrameworkImpl implements CuratorFramework
 
     private void performBackgroundOperation(OperationAndData<?> operationAndData)
     {
-        boolean isDone = false;
-        while ( !isDone )
+        try
         {
-            try
-            {
-                operationAndData.callPerformBackgroundOperation();
-                isDone = true;
-            }
-            catch ( Throwable e )
+            operationAndData.callPerformBackgroundOperation();
+        }
+        catch ( Throwable e )
+        {
+            /**
+             * Fix edge case reported as CURATOR-52. ConnectionState.checkTimeouts() throws
KeeperException.ConnectionLossException
+             * when the initial (or previously failed) connection cannot be re-established.
This needs to be run through the retry policy
+             * and callbacks need to get invoked, etc.
+             */
+            if ( e instanceof CuratorConnectionLossException )
             {
-                /**
-                 * Fix edge case reported as CURATOR-52. ConnectionState.checkTimeouts()
throws KeeperException.ConnectionLossException
-                 * when the initial (or previously failed) connection cannot be re-established.
This needs to be run through the retry policy
-                 * and callbacks need to get invoked, etc.
-                 */
-                if ( e instanceof CuratorConnectionLossException )
+                WatchedEvent watchedEvent = new WatchedEvent(Watcher.Event.EventType.None,
Watcher.Event.KeeperState.Disconnected, null);
+                CuratorEvent event = new CuratorEventImpl(this, CuratorEventType.WATCHED,
KeeperException.Code.CONNECTIONLOSS.intValue(), null, null, operationAndData.getContext(),
null, null, null, watchedEvent, null);
+                if ( checkBackgroundRetry(operationAndData, event) )
                 {
-                    WatchedEvent watchedEvent = new WatchedEvent(Watcher.Event.EventType.None,
Watcher.Event.KeeperState.Disconnected, null);
-                    CuratorEvent event = new CuratorEventImpl(this, CuratorEventType.WATCHED,
KeeperException.Code.CONNECTIONLOSS.intValue(), null, null, operationAndData.getContext(),
null, null, null, watchedEvent, null);
-                    if ( checkBackgroundRetry(operationAndData, event) )
-                    {
-                        continue;
-                    }
+                    queueOperation(operationAndData);
+                }
+                else
+                {
+                    handleBackgroundOperationException(operationAndData, e);
                 }
+            }
+            else
+            {
                 handleBackgroundOperationException(operationAndData, e);
-                isDone = true;
             }
         }
     }


Mime
View raw message