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 2016/01/15 04:42:46 UTC

[1/7] curator git commit: Added an unhandled exception error handler

Repository: curator
Updated Branches:
  refs/heads/CURATOR-208 003acc602 -> 36a72d9c5


Added an unhandled exception error handler


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

Branch: refs/heads/CURATOR-208
Commit: 9951d4eceecdd97e73291c061ba04ec114ed9e53
Parents: 003acc6
Author: randgalt <ra...@apache.org>
Authored: Thu Jan 14 22:37:24 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Jan 14 22:37:24 2016 -0500

----------------------------------------------------------------------
 .../java/org/apache/curator/utils/ThreadUtils.java   | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/9951d4ec/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java b/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java
index 24efd50..74b4e40 100644
--- a/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java
+++ b/curator-client/src/main/java/org/apache/curator/utils/ThreadUtils.java
@@ -18,7 +18,10 @@
  */
 package org.apache.curator.utils;
 
+import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -26,6 +29,8 @@ import java.util.concurrent.ThreadFactory;
 
 public class ThreadUtils
 {
+    private static final Logger log = LoggerFactory.getLogger(ThreadUtils.class);
+
     public static void checkInterrupted(Throwable e)
     {
         if ( e instanceof InterruptedException )
@@ -61,9 +66,19 @@ public class ThreadUtils
 
     public static ThreadFactory newGenericThreadFactory(String processName)
     {
+        Thread.UncaughtExceptionHandler uncaughtExceptionHandler = new Thread.UncaughtExceptionHandler()
+        {
+            @Override
+            public void uncaughtException(Thread t, Throwable e)
+            {
+                log.error("Unexpected exception in thread: " + t, e);
+                Throwables.propagate(e);
+            }
+        };
         return new ThreadFactoryBuilder()
             .setNameFormat(processName + "-%d")
             .setDaemon(true)
+            .setUncaughtExceptionHandler(uncaughtExceptionHandler)
             .build();
     }
 


[7/7] curator git commit: Don't let thread interrupt status get reset. The only proper reason for these loops to exit if the instance is closed

Posted by ra...@apache.org.
Don't let thread interrupt status get reset. The only proper reason for these loops to exit if the instance is closed


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

Branch: refs/heads/CURATOR-208
Commit: 36a72d9c509a796d9e2bc112fab9356148a13f76
Parents: f73dc08
Author: randgalt <ra...@apache.org>
Authored: Thu Jan 14 22:42:24 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Jan 14 22:42:24 2016 -0500

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


http://git-wip-us.apache.org/repos/asf/curator/blob/36a72d9c/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 dddcfe4..442579d 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
@@ -22,6 +22,7 @@ package org.apache.curator.framework.imps;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
 import org.apache.curator.CuratorConnectionLossException;
 import org.apache.curator.CuratorZookeeperClient;
@@ -257,8 +258,7 @@ public class CuratorFrameworkImpl implements CuratorFramework
 
             client.start();
 
-            executorService = Executors.newFixedThreadPool(2, threadFactory);  // 1 for listeners, 1 for background ops
-
+            executorService = Executors.newSingleThreadScheduledExecutor(threadFactory);
             executorService.submit(new Callable<Object>()
             {
                 @Override
@@ -794,24 +794,31 @@ public class CuratorFrameworkImpl implements CuratorFramework
 
     private void backgroundOperationsLoop()
     {
-        while ( !Thread.currentThread().isInterrupted() )
+        try
         {
-            OperationAndData<?> operationAndData;
-            try
+            while ( state.get() == CuratorFrameworkState.STARTED )
             {
-                operationAndData = backgroundOperations.take();
-                if ( debugListener != null )
+                OperationAndData<?> operationAndData;
+                try
                 {
-                    debugListener.listen(operationAndData);
+                    operationAndData = backgroundOperations.take();
+                    if ( debugListener != null )
+                    {
+                        debugListener.listen(operationAndData);
+                    }
+                    performBackgroundOperation(operationAndData);
+                }
+                catch ( InterruptedException e )
+                {
+                    // swallow the interrupt as it's only possible from either a background
+                    // operation and, thus, doesn't apply to this loop or the instance
+                    // is being closed in which case the while test will get it
                 }
             }
-            catch ( InterruptedException e )
-            {
-                Thread.currentThread().interrupt();
-                break;
-            }
-
-            performBackgroundOperation(operationAndData);
+        }
+        finally
+        {
+            log.info("backgroundOperationsLoop exiting");
         }
     }
 


[2/7] curator git commit: ZK calls InetAddress.getLocalHost().getCanonicalHostName internally. On some systems this takes seconds. Pre-call it and use the elapsed time to set MAX_WAIT_MS so that tests don't fail in setup

Posted by ra...@apache.org.
ZK calls InetAddress.getLocalHost().getCanonicalHostName internally. On some systems this takes seconds. Pre-call it and use the elapsed time to set MAX_WAIT_MS so that tests don't fail in setup


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

Branch: refs/heads/CURATOR-208
Commit: eee4b03905e2ded72c32e3d113799644d8823d39
Parents: 9951d4e
Author: randgalt <ra...@apache.org>
Authored: Thu Jan 14 22:38:28 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Jan 14 22:38:28 2016 -0500

----------------------------------------------------------------------
 .../curator/test/TestingZooKeeperMain.java      | 31 ++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/eee4b039/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
index bb70da5..7487557 100644
--- a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
+++ b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
@@ -28,6 +28,8 @@ import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.nio.channels.ServerSocketChannel;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicReference;
@@ -37,7 +39,25 @@ public class TestingZooKeeperMain extends ZooKeeperServerMain implements ZooKeep
     private final CountDownLatch latch = new CountDownLatch(1);
     private final AtomicReference<Exception> startingException = new AtomicReference<Exception>(null);
 
-    private static final int MAX_WAIT_MS = 1000;
+    private static final int MAX_WAIT_MS;
+
+    static
+    {
+        long startMs = System.currentTimeMillis();
+        try
+        {
+            // this can take forever and fails tests - ZK calls it internally so there's nothing we can do
+            // pre flight it and use it to calculate max wait
+            //noinspection ResultOfMethodCallIgnored
+            InetAddress.getLocalHost().getCanonicalHostName();
+        }
+        catch ( UnknownHostException e )
+        {
+            // ignore
+        }
+        long elapsed = System.currentTimeMillis() - startMs;
+        MAX_WAIT_MS = Math.max((int)elapsed * 2, 1000);
+    }
 
     @Override
     public void kill()
@@ -119,7 +139,14 @@ public class TestingZooKeeperMain extends ZooKeeperServerMain implements ZooKeep
     @Override
     public void close() throws IOException
     {
-        shutdown();
+        try
+        {
+            shutdown();
+        }
+        catch ( Throwable e )
+        {
+            e.printStackTrace();    // just ignore - this class is only for testing
+        }
 
         try
         {


[6/7] curator git commit: rewrote for better stability

Posted by ra...@apache.org.
rewrote for better stability


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

Branch: refs/heads/CURATOR-208
Commit: f73dc08bd5ec292e09e5b86d08e02c318e24262d
Parents: 5a51b09
Author: randgalt <ra...@apache.org>
Authored: Thu Jan 14 22:41:59 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Jan 14 22:41:59 2016 -0500

----------------------------------------------------------------------
 ...estResetConnectionWithBackgroundFailure.java | 36 ++++++++++----------
 1 file changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/f73dc08b/curator-recipes/src/test/java/org/apache/curator/framework/client/TestResetConnectionWithBackgroundFailure.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/client/TestResetConnectionWithBackgroundFailure.java b/curator-recipes/src/test/java/org/apache/curator/framework/client/TestResetConnectionWithBackgroundFailure.java
index 7d2cb89..852d9aa 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/client/TestResetConnectionWithBackgroundFailure.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/client/TestResetConnectionWithBackgroundFailure.java
@@ -19,44 +19,41 @@
 
 package org.apache.curator.framework.client;
 
+import com.google.common.collect.Queues;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.imps.CuratorFrameworkImpl;
 import org.apache.curator.framework.recipes.leader.LeaderSelector;
 import org.apache.curator.framework.recipes.leader.LeaderSelectorListener;
 import org.apache.curator.framework.recipes.leader.LeaderSelectorListenerAdapter;
 import org.apache.curator.framework.state.ConnectionState;
 import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.retry.ExponentialBackoffRetry;
 import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.BaseClassForTests;
-import org.apache.curator.test.TestingServer;
 import org.apache.curator.test.Timing;
 import org.apache.curator.utils.CloseableUtils;
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.ZooDefs;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
 
 public class TestResetConnectionWithBackgroundFailure extends BaseClassForTests
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @BeforeMethod
-    @Override
-    public void setup() throws Exception
-    {
-        super.setup();
-    }
-
     @Test
     public void testConnectionStateListener() throws Exception
     {
         server.stop();
 
-        final StringBuilder listenerSequence = new StringBuilder();
         LeaderSelector selector = null;
         Timing timing = new Timing();
-        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(100));
+        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
         try
         {
             client.start();
@@ -74,33 +71,36 @@ public class TestResetConnectionWithBackgroundFailure extends BaseClassForTests
             selector.autoRequeue();
             selector.start();
 
+            final BlockingQueue<ConnectionState> listenerSequence = Queues.newLinkedBlockingQueue();
             ConnectionStateListener listener1 = new ConnectionStateListener()
             {
                 @Override
                 public void stateChanged(CuratorFramework client, ConnectionState newState)
                 {
-                    listenerSequence.append("-").append(newState);
+                    listenerSequence.add(newState);
                 }
             };
 
+            Timing forWaiting = timing.forWaiting();
+
             client.getConnectionStateListenable().addListener(listener1);
             log.debug("Starting ZK server");
             server.restart();
-            timing.forWaiting().sleepABit();
+            Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.CONNECTED);
 
             log.debug("Stopping ZK server");
             server.stop();
-            timing.forWaiting().sleepABit();
+            Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
+            Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
 
             log.debug("Starting ZK server");
             server.restart();
-            timing.forWaiting().sleepABit();
+            Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.RECONNECTED);
 
             log.debug("Stopping ZK server");
             server.close();
-            timing.forWaiting().sleepABit();
-
-            Assert.assertEquals(listenerSequence.toString(), "-CONNECTED-SUSPENDED-LOST-RECONNECTED-SUSPENDED-LOST");
+            Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.SUSPENDED);
+            Assert.assertEquals(listenerSequence.poll(forWaiting.milliseconds(), TimeUnit.MILLISECONDS), ConnectionState.LOST);
         }
         finally
         {


[5/7] curator git commit: Don't let thread interrupt status get reset. The only proper reason for these loops to exit if the instance is closed

Posted by ra...@apache.org.
Don't let thread interrupt status get reset. The only proper reason for these loops to exit if the instance is closed


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

Branch: refs/heads/CURATOR-208
Commit: 5a51b0939bbee46e1d22f30fbaacd35685cdd9f0
Parents: 737d2aa
Author: randgalt <ra...@apache.org>
Authored: Thu Jan 14 22:41:44 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Jan 14 22:41:44 2016 -0500

----------------------------------------------------------------------
 .../framework/state/ConnectionStateManager.java | 14 ++++---
 .../recipes/queue/DistributedQueue.java         | 39 +++++++++++---------
 .../framework/recipes/queue/QueueSharder.java   | 14 ++++---
 3 files changed, 38 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/5a51b093/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 67ff13d..8cc37aa 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
@@ -238,9 +238,9 @@ public class ConnectionStateManager implements Closeable
 
     private void processEvents()
     {
-        try
+        while ( state.get() == State.STARTED )
         {
-            while ( !Thread.currentThread().isInterrupted() )
+            try
             {
                 final ConnectionState newState = eventQueue.take();
 
@@ -262,10 +262,12 @@ public class ConnectionStateManager implements Closeable
                         }
                     );
             }
-        }
-        catch ( InterruptedException e )
-        {
-            Thread.currentThread().interrupt();
+            catch ( InterruptedException e )
+            {
+                // swallow the interrupt as it's only possible from either a background
+                // operation and, thus, doesn't apply to this loop or the instance
+                // is being closed in which case the while test will get it
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/5a51b093/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
index 43291e4..14d1266 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedQueue.java
@@ -545,34 +545,39 @@ public class DistributedQueue<T> implements QueueBase<T>
         long         maxWaitMs = -1;
         try
         {
-            while ( !Thread.currentThread().isInterrupted()  )
+            while ( state.get() == State.STARTED  )
             {
-                ChildrenCache.Data      data = (maxWaitMs > 0) ? childrenCache.blockingNextGetData(currentVersion, maxWaitMs, TimeUnit.MILLISECONDS) : childrenCache.blockingNextGetData(currentVersion);
-                currentVersion = data.version;
+                try
+                {
+                    ChildrenCache.Data      data = (maxWaitMs > 0) ? childrenCache.blockingNextGetData(currentVersion, maxWaitMs, TimeUnit.MILLISECONDS) : childrenCache.blockingNextGetData(currentVersion);
+                    currentVersion = data.version;
 
-                List<String>        children = Lists.newArrayList(data.children);
-                sortChildren(children); // makes sure items are processed in the correct order
+                    List<String>        children = Lists.newArrayList(data.children);
+                    sortChildren(children); // makes sure items are processed in the correct order
 
-                if ( children.size() > 0 )
-                {
-                    maxWaitMs = getDelay(children.get(0));
-                    if ( maxWaitMs > 0 )
+                    if ( children.size() > 0 )
+                    {
+                        maxWaitMs = getDelay(children.get(0));
+                        if ( maxWaitMs > 0 )
+                        {
+                            continue;
+                        }
+                    }
+                    else
                     {
                         continue;
                     }
+
+                    processChildren(children, currentVersion);
                 }
-                else
+                catch ( InterruptedException e )
                 {
-                    continue;
+                    // swallow the interrupt as it's only possible from either a background
+                    // operation and, thus, doesn't apply to this loop or the instance
+                    // is being closed in which case the while test will get it
                 }
-
-                processChildren(children, currentVersion);
             }
         }
-        catch ( InterruptedException ignore )
-        {
-            Thread.currentThread().interrupt();
-        }
         catch ( Exception e )
         {
             log.error("Exception caught in background handler", e);

http://git-wip-us.apache.org/repos/asf/curator/blob/5a51b093/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
index 24a56f8..3cd0cdb 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/QueueSharder.java
@@ -124,17 +124,19 @@ public class QueueSharder<U, T extends QueueBase<U>> implements Closeable
                 @Override
                 public Void call() throws Exception
                 {
-                    try
+                    while ( state.get() == State.STARTED )
                     {
-                        while ( !Thread.currentThread().isInterrupted() && (state.get() == State.STARTED) )
+                        try
                         {
                             Thread.sleep(policies.getThresholdCheckMs());
                             checkThreshold();
                         }
-                    }
-                    catch ( InterruptedException e )
-                    {
-                        Thread.currentThread().interrupt();
+                        catch ( InterruptedException e )
+                        {
+                            // swallow the interrupt as it's only possible from either a background
+                            // operation and, thus, doesn't apply to this loop or the instance
+                            // is being closed in which case the while test will get it
+                        }
                     }
                     return null;
                 }


[4/7] curator git commit: Turns out FindAndDeleteProtectedNodeInBackground was causing a stack overflow. Reset the retry count before requeueing

Posted by ra...@apache.org.
Turns out FindAndDeleteProtectedNodeInBackground was causing a stack overflow. Reset the retry count before requeueing


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

Branch: refs/heads/CURATOR-208
Commit: 737d2aa19f74a3988279c41068cbad28fc868f8a
Parents: 70846a6
Author: randgalt <ra...@apache.org>
Authored: Thu Jan 14 22:40:24 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Jan 14 22:40:24 2016 -0500

----------------------------------------------------------------------
 .../imps/FindAndDeleteProtectedNodeInBackground.java     |  1 +
 .../apache/curator/framework/imps/OperationAndData.java  | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/737d2aa1/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
index 2fbd9dd..5b0f47c 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
@@ -52,6 +52,7 @@ class FindAndDeleteProtectedNodeInBackground implements BackgroundOperation<Void
             @Override
             public void retriesExhausted(OperationAndData<Void> operationAndData)
             {
+                operationAndData.reset();
                 client.processBackgroundOperation(operationAndData, null);
             }
         };

http://git-wip-us.apache.org/repos/asf/curator/blob/737d2aa1/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java
index 38f59a0..279eece 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java
@@ -38,7 +38,7 @@ class OperationAndData<T> implements Delayed, RetrySleeper
     private final ErrorCallback<T> errorCallback;
     private final AtomicInteger retryCount = new AtomicInteger(0);
     private final AtomicLong sleepUntilTimeMs = new AtomicLong(0);
-    private final long ordinal = nextOrdinal.getAndIncrement();
+    private final AtomicLong ordinal = new AtomicLong();
     private final Object context;
 
     interface ErrorCallback<T>
@@ -53,6 +53,13 @@ class OperationAndData<T> implements Delayed, RetrySleeper
         this.callback = callback;
         this.errorCallback = errorCallback;
         this.context = context;
+        reset();
+    }
+
+    void reset()
+    {
+        retryCount.set(0);
+        ordinal.set(nextOrdinal.getAndIncrement());
     }
 
     Object getContext()
@@ -121,7 +128,7 @@ class OperationAndData<T> implements Delayed, RetrySleeper
         {
             if ( o instanceof OperationAndData )
             {
-                diff = ordinal - ((OperationAndData)o).ordinal;
+                diff = ordinal.get() - ((OperationAndData)o).ordinal.get();
             }
         }
 


[3/7] curator git commit: removed extra blank line

Posted by ra...@apache.org.
removed extra blank line


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

Branch: refs/heads/CURATOR-208
Commit: 70846a616f69c1836489ac1662eb39734ba7e9fe
Parents: eee4b03
Author: randgalt <ra...@apache.org>
Authored: Thu Jan 14 22:39:33 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Jan 14 22:39:33 2016 -0500

----------------------------------------------------------------------
 .../org/apache/curator/framework/imps/FailedDeleteManager.java    | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/70846a61/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
index ecf8fb3..4e6fcf3 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/FailedDeleteManager.java
@@ -46,8 +46,7 @@ class FailedDeleteManager
         {
             debugListener.pathAddedForDelete(path);
         }
-        
-        
+
         if ( client.getState() == CuratorFrameworkState.STARTED )
         {
             log.debug("Path being added to guaranteed delete set: " + path);