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 2017/07/10 17:09:07 UTC

[2/2] curator git commit: fixed some merge problems from CURATOR-311 merge

fixed some merge problems from CURATOR-311 merge


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

Branch: refs/heads/CURATOR-2.0
Commit: 6af5f367efd238c7e61f0b9ea341d69c7fdaa736
Parents: 3e159bd
Author: randgalt <ra...@apache.org>
Authored: Mon Jul 10 12:09:01 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Jul 10 12:09:01 2017 -0500

----------------------------------------------------------------------
 .../framework/recipes/shared/SharedCount.java      |  5 +++++
 .../framework/recipes/shared/TestSharedCount.java  | 17 ++++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/6af5f367/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java
index 87fffdd..bdfa844 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java
@@ -49,6 +49,11 @@ public class SharedCount implements Closeable, SharedCountReader, Listenable<Sha
         sharedValue = new SharedValue(client, path, toBytes(seedValue));
     }
 
+    protected SharedCount(CuratorFramework client, String path, SharedValue sv)
+    {
+        sharedValue = sv;
+    }
+
     @Override
     public int getCount()
     {

http://git-wip-us.apache.org/repos/asf/curator/blob/6af5f367/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
index a6a32e9..2ef93eb 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
@@ -77,6 +77,7 @@ public class TestSharedCount extends BaseClassForTests
                                 CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
                                 clients.add(client);
                                 client.start();
+                                client.checkExists().forPath("/");  // clear initial connect event
 
                                 SharedCount count = new SharedCount(client, "/count", 10);
                                 counts.add(count);
@@ -120,6 +121,7 @@ public class TestSharedCount extends BaseClassForTests
             CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
             clients.add(client);
             client.start();
+            client.checkExists().forPath("/");  // clear initial connect event
 
             Assert.assertTrue(startLatch.await(10, TimeUnit.SECONDS));
 
@@ -436,13 +438,14 @@ public class TestSharedCount extends BaseClassForTests
     @Test
     public void testDisconnectReconnectWithMultipleClients() throws Exception
     {
+        Timing timing = new Timing();
         CuratorFramework curatorFramework1 = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryNTimes(10, 500));
         CuratorFramework curatorFramework2 = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryNTimes(10, 500));
 
         curatorFramework1.start();
-        curatorFramework1.blockUntilConnected();
+        curatorFramework1.checkExists().forPath("/");   // clear initial connect events
         curatorFramework2.start();
-        curatorFramework2.blockUntilConnected();
+        curatorFramework2.checkExists().forPath("/");   // clear initial connect events
 
         final String sharedCountPath = "/count";
         final int initialCount = 10;
@@ -468,7 +471,7 @@ public class TestSharedCount extends BaseClassForTests
             {
                 if (newState == ConnectionState.SUSPENDED) {
                     gotSuspendEvent.arrive();
-                } else if (newState.isConnected()) {
+                } else if (newState == ConnectionState.RECONNECTED) {
                     getReconnectEvent.arrive();
                 }
             }
@@ -483,7 +486,7 @@ public class TestSharedCount extends BaseClassForTests
         try
         {
             sharedCount1.setCount(12);
-            Assert.assertEquals(listener1.gotChangeEvent.awaitAdvanceInterruptibly(0, 2, TimeUnit.SECONDS), 1);
+            Assert.assertEquals(listener1.gotChangeEvent.awaitAdvanceInterruptibly(0, timing.forWaiting().seconds(), TimeUnit.SECONDS), 1);
             Assert.assertEquals(sharedCount1.getCount(), 12);
 
             Assert.assertEquals(sharedCountWithFaultyWatcher.getCount(), 10);
@@ -496,10 +499,10 @@ public class TestSharedCount extends BaseClassForTests
 
                 server.restart();
 
-                Assert.assertEquals(listener2.getReconnectEvent.awaitAdvanceInterruptibly(i, 2, TimeUnit.SECONDS), i + 1);
+                Assert.assertEquals(listener2.getReconnectEvent.awaitAdvanceInterruptibly(i, timing.forWaiting().seconds(), TimeUnit.SECONDS), i + 1);
                 // CURATOR-311 introduces to Curator's client reading server's shared count value
                 // when client's state gets ConnectionState.RECONNECTED. Following tests ensures that.
-                Assert.assertEquals(listener2.gotChangeEvent.awaitAdvanceInterruptibly(i, 2, TimeUnit.SECONDS), i + 1);
+                Assert.assertEquals(listener2.gotChangeEvent.awaitAdvanceInterruptibly(i, timing.forWaiting().seconds(), TimeUnit.SECONDS), i + 1);
                 Assert.assertEquals(sharedCountWithFaultyWatcher.getCount(), 13 + i);
             }
         }
@@ -530,7 +533,7 @@ public class TestSharedCount extends BaseClassForTests
         final SharedValue faultySharedValue = new FaultySharedValue(curatorFramework, path, SharedCount.toBytes(val));
         class FaultySharedCount extends SharedCount {
             public FaultySharedCount(CuratorFramework client, String path, int val) {
-                super(client, path, val);
+                super(client, path, faultySharedValue);
             }
         };
         return new FaultySharedCount(curatorFramework, path, val);