curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject git commit: When the message was requeued, the wrong node name was being used causing a node name length leak - increasingly long node names
Date Mon, 23 Sep 2013 01:28:26 GMT
Updated Branches:
  refs/heads/CURATOR-56 [created] 38a29687f


When the message was requeued, the wrong node name was being used causing a node name length
leak - increasingly long node names


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

Branch: refs/heads/CURATOR-56
Commit: 38a29687f140bf5c8ff27d6d2ff591bdcc172cba
Parents: b9500dc
Author: randgalt <randgalt@apache.org>
Authored: Sun Sep 22 18:29:37 2013 -0700
Committer: randgalt <randgalt@apache.org>
Committed: Sun Sep 22 18:29:37 2013 -0700

----------------------------------------------------------------------
 .../recipes/queue/DistributedQueue.java         |  2 +-
 .../recipes/queue/TestDistributedQueue.java     | 62 ++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/38a29687/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 dc7d2d3..6e74579 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
@@ -748,7 +748,7 @@ public class DistributedQueue<T> implements QueueBase<T>
                 client.inTransaction()
                     .delete().forPath(itemPath)
                     .and()
-                    .create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(itemPath,
bytes)
+                    .create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(makeItemPath(),
bytes)
                     .and()
                     .commit();
             }

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/38a29687/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedQueue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedQueue.java
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedQueue.java
index c6f4b6a..0e33b80 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedQueue.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedQueue.java
@@ -37,6 +37,7 @@ import org.apache.zookeeper.CreateMode;
 import org.mockito.Mockito;
 import org.testng.Assert;
 import org.testng.annotations.Test;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Callable;
@@ -57,6 +58,67 @@ public class TestDistributedQueue extends BaseClassForTests
     private static final QueueSerializer<TestQueueItem>  serializer = new QueueItemSerializer();
 
     @Test
+    public void testRetryAfterFailure_Curator56() throws Exception
+    {
+        /*
+            https://issues.apache.org/jira/browse/CURATOR-56
+
+            This tests against ever growing node name bug
+         */
+
+        DistributedQueue<TestQueueItem> queue = null;
+        final CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(),
new RetryOneTime(1));
+        client.start();
+        try
+        {
+            final int RETRY_COUNT = 1;
+            final CountDownLatch retryCounter = new CountDownLatch(RETRY_COUNT + 1);
+            final List<String> names = new ArrayList<String>();
+
+            QueueConsumer<TestQueueItem> consumer = new QueueConsumer<TestQueueItem>()
+            {
+                @Override
+                public void consumeMessage(TestQueueItem messsage) throws Exception
+                {
+                    List<String> queueItems = client.getChildren().forPath(QUEUE_PATH);
+                    names.add(queueItems.get(0));
+
+                    if (retryCounter.getCount() > 1)
+                    {
+                        retryCounter.countDown();
+                        throw new Exception("Something went wrong");
+                    }
+                    else
+                    {
+                        retryCounter.countDown();
+                    }
+                }
+
+                @Override
+                public void stateChanged(CuratorFramework client, ConnectionState newState)
+                {
+                }
+            };
+
+            queue = QueueBuilder.builder(client, consumer, serializer, QUEUE_PATH)
+                .lockPath("/lock")
+                .buildQueue();
+            queue.start();
+            queue.put(new TestQueueItem("test"));
+
+            retryCounter.await(10, TimeUnit.SECONDS);
+            Assert.assertEquals(retryCounter.getCount(), 0, "Queue item was not consumed.
Retry counter is " + retryCounter.getCount());
+            Assert.assertEquals(names.size(), 2);
+            Assert.assertEquals(names.get(0).length(), names.get(1).length());
+        }
+        finally
+        {
+            Closeables.closeQuietly(queue);
+            Closeables.closeQuietly(client);
+        }
+    }
+
+    @Test
     public void     testCustomExecutor() throws Exception
     {
         final int       ITERATIONS = 1000;


Mime
View raw message