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:51:42 UTC
[1/2] 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-329 [created] 8f281eb5b
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-329
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);
+ }
+ }
}
[2/2] 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-329
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(-)
----------------------------------------------------------------------