You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2016/05/24 22:53:01 UTC

[1/3] curator git commit: Fixed CURATOR-329 - SharedValue.start() method does not update to current value if version of value currently stored in zookeeper is 0

Repository: curator
Updated Branches:
  refs/heads/CURATOR-3.0 20c6955b1 -> 5ff8aaae8


Fixed CURATOR-329 - SharedValue.start() method does not update to current value if version of value currently stored in zookeeper is 0


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

Branch: refs/heads/CURATOR-3.0
Commit: f12f35d0f78198e1f9f89a8cf3dafc7b07404220
Parents: d63e06e
Author: Algirdas Rascius <ar...@kayak.com>
Authored: Tue May 24 16:45:45 2016 +0300
Committer: Algirdas Rascius <ar...@kayak.com>
Committed: Tue May 24 16:45:45 2016 +0300

----------------------------------------------------------------------
 .../framework/recipes/shared/SharedValue.java   |  4 ++-
 .../recipes/shared/TestSharedCount.java         | 27 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/f12f35d0/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
index 17a2943..dddc471 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
@@ -44,6 +44,8 @@ import java.util.concurrent.atomic.AtomicReference;
  */
 public class SharedValue implements Closeable, SharedValueReader
 {
+	private static final int UNINITIALIZED_VERSION = -1;
+
     private final Logger log = LoggerFactory.getLogger(getClass());
     private final ListenerContainer<SharedValueListener> listeners = new ListenerContainer<SharedValueListener>();
     private final CuratorFramework client;
@@ -91,7 +93,7 @@ public class SharedValue implements Closeable, SharedValueReader
         this.client = client;
         this.path = PathUtils.validatePath(path);
         this.seedValue = Arrays.copyOf(seedValue, seedValue.length);
-        currentValue = new AtomicReference<VersionedValue<byte[]>>(new VersionedValue<byte[]>(0, Arrays.copyOf(seedValue, seedValue.length)));
+        currentValue = new AtomicReference<VersionedValue<byte[]>>(new VersionedValue<byte[]>(UNINITIALIZED_VERSION, Arrays.copyOf(seedValue, seedValue.length)));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/curator/blob/f12f35d0/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 659154a..a1f4d8c 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
@@ -256,4 +256,31 @@ public class TestSharedCount extends BaseClassForTests
             CloseableUtils.closeQuietly(client1);
         }
     }
+
+
+    @Test
+    public void testMultiClientDifferentSeed() throws Exception
+    {
+        CuratorFramework client1 = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+        CuratorFramework client2 = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+        SharedCount count1 = new SharedCount(client1, "/count", 10);
+        SharedCount count2 = new SharedCount(client2, "/count", 20);
+        try
+        {
+            client1.start();
+            client2.start();
+            count1.start();
+            count2.start();
+
+            Assert.assertEquals(count1.getCount(), 10);
+            Assert.assertEquals(count2.getCount(), 10);
+        }
+        finally
+        {
+            CloseableUtils.closeQuietly(count2);
+            CloseableUtils.closeQuietly(count1);
+            CloseableUtils.closeQuietly(client2);
+            CloseableUtils.closeQuietly(client1);
+        }
+    }
 }


[3/3] curator git commit: Merge branch 'master' into CURATOR-3.0

Posted by ca...@apache.org.
Merge branch 'master' into CURATOR-3.0


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

Branch: refs/heads/CURATOR-3.0
Commit: 5ff8aaae89f911316c3e4c2082cc5e780c8480ef
Parents: 20c6955 8f281eb
Author: Cam McKenzie <ca...@apache.org>
Authored: Wed May 25 08:52:44 2016 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Wed May 25 08:52:44 2016 +1000

----------------------------------------------------------------------
 .../framework/recipes/shared/SharedValue.java   |  4 ++-
 .../recipes/shared/TestSharedCount.java         | 27 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/5ff8aaae/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
----------------------------------------------------------------------
diff --cc curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
index e27f455,dddc471..7c2febd
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
@@@ -45,9 -44,11 +45,11 @@@ import java.util.concurrent.atomic.Atom
   */
  public class SharedValue implements Closeable, SharedValueReader
  {
+ 	private static final int UNINITIALIZED_VERSION = -1;
+ 
      private final Logger log = LoggerFactory.getLogger(getClass());
      private final ListenerContainer<SharedValueListener> listeners = new ListenerContainer<SharedValueListener>();
 -    private final CuratorFramework client;
 +    private final WatcherRemoveCuratorFramework client;
      private final String path;
      private final byte[] seedValue;
      private final AtomicReference<State> state = new AtomicReference<State>(State.LATENT);
@@@ -89,10 -90,10 +91,10 @@@
       */
      public SharedValue(CuratorFramework client, String path, byte[] seedValue)
      {
 -        this.client = client;
 +        this.client = client.newWatcherRemoveCuratorFramework();
          this.path = PathUtils.validatePath(path);
          this.seedValue = Arrays.copyOf(seedValue, seedValue.length);
-         currentValue = new AtomicReference<VersionedValue<byte[]>>(new VersionedValue<byte[]>(0, Arrays.copyOf(seedValue, seedValue.length)));
+         currentValue = new AtomicReference<VersionedValue<byte[]>>(new VersionedValue<byte[]>(UNINITIALIZED_VERSION, Arrays.copyOf(seedValue, seedValue.length)));
      }
  
      @Override

http://git-wip-us.apache.org/repos/asf/curator/blob/5ff8aaae/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
----------------------------------------------------------------------
diff --cc curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
index 2bdd278,a1f4d8c..16134ed
--- 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
@@@ -253,8 -252,35 +253,35 @@@ public class TestSharedCount extends Ba
          {
              CloseableUtils.closeQuietly(count2);
              CloseableUtils.closeQuietly(count1);
 -            CloseableUtils.closeQuietly(client2);
 -            CloseableUtils.closeQuietly(client1);
 +            TestCleanState.closeAndTestClean(client2);
 +            TestCleanState.closeAndTestClean(client1);
          }
      }
+ 
+ 
+     @Test
+     public void testMultiClientDifferentSeed() throws Exception
+     {
+         CuratorFramework client1 = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+         CuratorFramework client2 = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+         SharedCount count1 = new SharedCount(client1, "/count", 10);
+         SharedCount count2 = new SharedCount(client2, "/count", 20);
+         try
+         {
+             client1.start();
+             client2.start();
+             count1.start();
+             count2.start();
+ 
+             Assert.assertEquals(count1.getCount(), 10);
+             Assert.assertEquals(count2.getCount(), 10);
+         }
+         finally
+         {
+             CloseableUtils.closeQuietly(count2);
+             CloseableUtils.closeQuietly(count1);
+             CloseableUtils.closeQuietly(client2);
+             CloseableUtils.closeQuietly(client1);
+         }
+     }
  }


[2/3] curator git commit: Merge branch 'CURATOR-329' of https://github.com/ARascius/curator into CURATOR-329

Posted by ca...@apache.org.
Merge branch 'CURATOR-329' of https://github.com/ARascius/curator into CURATOR-329


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

Branch: refs/heads/CURATOR-3.0
Commit: 8f281eb5bf2d3d65f1c9c3dd1ea8d04188210f90
Parents: 6ae3f85 f12f35d
Author: Cam McKenzie <ca...@apache.org>
Authored: Wed May 25 08:38:25 2016 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Wed May 25 08:38:25 2016 +1000

----------------------------------------------------------------------
 .../framework/recipes/shared/SharedValue.java   |  4 ++-
 .../recipes/shared/TestSharedCount.java         | 27 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------