curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cammcken...@apache.org
Subject [3/3] curator git commit: Merge branch 'master' into CURATOR-3.0
Date Tue, 24 May 2016 22:53:03 GMT
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 <cammckenzie@apache.org>
Authored: Wed May 25 08:52:44 2016 +1000
Committer: Cam McKenzie <cammckenzie@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);
+         }
+     }
  }


Mime
View raw message