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 2013/06/10 22:57:08 UTC
[1/5] git commit: Add myself as a developer
Updated Branches:
refs/heads/2.0.2-incubating e5c7755c9 -> e21321434
Add myself as a developer
Project: http://git-wip-us.apache.org/repos/asf/incubator-curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-curator/commit/79039812
Tree: http://git-wip-us.apache.org/repos/asf/incubator-curator/tree/79039812
Diff: http://git-wip-us.apache.org/repos/asf/incubator-curator/diff/79039812
Branch: refs/heads/2.0.2-incubating
Commit: 79039812bdecb7d48d998821ac0ac1fd63f6850c
Parents: 93fccc6
Author: cheddar <ch...@metamarkets.com>
Authored: Thu Jun 6 13:18:59 2013 -0700
Committer: cheddar <ch...@metamarkets.com>
Committed: Thu Jun 6 13:18:59 2013 -0700
----------------------------------------------------------------------
pom.xml | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/79039812/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index edea5a5..29770b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -142,6 +142,17 @@
</roles>
<url>https://people.apache.org/~zarfide</url>
</developer>
+
+ <developer>
+ <id>cheddar</id>
+ <name>Eric Tschetter</name>
+ <email>cheddar@apache.org</email>
+ <timezone>-6</timezone>
+ <roles>
+ <role>Committer</role>
+ <role>ChedHeader</role>
+ </roles>
+ </developer>
</developers>
<contributors>
[4/5] git commit: Added setData() method
Posted by ra...@apache.org.
Added setData() method
Project: http://git-wip-us.apache.org/repos/asf/incubator-curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-curator/commit/415ec2e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-curator/tree/415ec2e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-curator/diff/415ec2e8
Branch: refs/heads/2.0.2-incubating
Commit: 415ec2e8500e3a47ef1232c927e17f3e5cf2ef9a
Parents: f7e75e0
Author: randgalt <ra...@apache.org>
Authored: Mon Jun 10 13:56:43 2013 -0700
Committer: randgalt <ra...@apache.org>
Committed: Mon Jun 10 13:56:43 2013 -0700
----------------------------------------------------------------------
.../recipes/nodes/PersistentEphemeralNode.java | 22 ++++++--
.../nodes/TestPersistentEphemeralNode.java | 53 +++++++++++++++++++-
2 files changed, 71 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/415ec2e8/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
index d86af92..7e92bdf 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
@@ -47,7 +47,7 @@ public class PersistentEphemeralNode implements Closeable
private final AtomicReference<String> nodePath = new AtomicReference<String>(null);
private final String basePath;
private final Mode mode;
- private final byte[] data;
+ private final AtomicReference<byte[]> data = new AtomicReference<byte[]>();
private final AtomicReference<State> state = new AtomicReference<State>(State.LATENT);
private final AtomicBoolean isSuspended = new AtomicBoolean(false);
private final BackgroundCallback backgroundCallback;
@@ -227,7 +227,7 @@ public class PersistentEphemeralNode implements Closeable
};
createMethod = mode.isProtected() ? client.create().withProtection() : client.create();
- this.data = Arrays.copyOf(data, data.length);
+ this.data.set(Arrays.copyOf(data, data.length));
}
/**
@@ -281,6 +281,22 @@ public class PersistentEphemeralNode implements Closeable
return nodePath.get();
}
+ /**
+ * Set data that ephemeral node should set in ZK also writes the data to the node
+ *
+ * @param data new data value
+ * @throws Exception errors
+ */
+ public void setData(byte[] data) throws Exception
+ {
+ data = Preconditions.checkNotNull(data, "data cannot be null");
+ this.data.set(Arrays.copyOf(data, data.length));
+ if ( isActive() )
+ {
+ client.setData().inBackground().forPath(basePath, this.data.get());
+ }
+ }
+
private void deleteNode()
{
String localNodePath = nodePath.getAndSet(null);
@@ -313,7 +329,7 @@ public class PersistentEphemeralNode implements Closeable
String existingPath = nodePath.get();
String createPath = (existingPath != null) ? existingPath : basePath;
ensurePath.ensure(client.getZookeeperClient());
- createMethod.withMode(mode.getCreateMode(existingPath != null)).inBackground(backgroundCallback).forPath(createPath, data);
+ createMethod.withMode(mode.getCreateMode(existingPath != null)).inBackground(backgroundCallback).forPath(createPath, data.get());
}
catch ( Exception e )
{
http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/415ec2e8/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
index 033ec1f..84c1cf7 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java
@@ -12,12 +12,14 @@ import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.data.Stat;
+import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import static org.testng.Assert.*;
@@ -74,6 +76,54 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
}
@Test
+ public void testSettingData() throws Exception
+ {
+ PersistentEphemeralNode node = null;
+ Timing timing = new Timing();
+ CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
+ try
+ {
+ client.start();
+ node = new PersistentEphemeralNode(client, PersistentEphemeralNode.Mode.EPHEMERAL, PATH, "a".getBytes());
+ node.start();
+ Assert.assertTrue(node.waitForInitialCreate(5, TimeUnit.SECONDS));
+
+ Assert.assertEquals(node.getActualPath(), PATH);
+ Assert.assertEquals(client.getData().forPath(PATH), "a".getBytes());
+
+ final Semaphore semaphore = new Semaphore(0);
+ Watcher watcher = new Watcher()
+ {
+ @Override
+ public void process(WatchedEvent arg0)
+ {
+ semaphore.release();
+ }
+ };
+ client.checkExists().usingWatcher(watcher).forPath(PATH);
+ node.setData("b".getBytes());
+ Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ Assert.assertEquals(node.getActualPath(), PATH);
+ Assert.assertEquals(client.getData().usingWatcher(watcher).forPath(PATH), "b".getBytes());
+ node.setData("c".getBytes());
+ Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ Assert.assertEquals(node.getActualPath(), PATH);
+ Assert.assertEquals(client.getData().usingWatcher(watcher).forPath(PATH), "c".getBytes());
+ node.close();
+ Assert.assertTrue(timing.acquireSemaphore(semaphore));
+ Assert.assertTrue(client.checkExists().forPath(PATH) == null);
+ }
+ finally
+ {
+ if ( node != null )
+ {
+ node.close();
+ }
+ client.close();
+ }
+ }
+
+ @Test
public void testDeletesNodeWhenClosed() throws Exception
{
CuratorFramework curator = newCurator();
@@ -342,7 +392,8 @@ public class TestPersistentEphemeralNode extends BaseClassForTests
try
{
return latch.await(duration, unit);
- } catch ( InterruptedException e )
+ }
+ catch ( InterruptedException e )
{
throw Throwables.propagate(e);
}
[5/5] git commit: Merge branch 'CURATOR-25' into 2.0.2-incubating
Posted by ra...@apache.org.
Merge branch 'CURATOR-25' into 2.0.2-incubating
Project: http://git-wip-us.apache.org/repos/asf/incubator-curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-curator/commit/e2132143
Tree: http://git-wip-us.apache.org/repos/asf/incubator-curator/tree/e2132143
Diff: http://git-wip-us.apache.org/repos/asf/incubator-curator/diff/e2132143
Branch: refs/heads/2.0.2-incubating
Commit: e2132143432c089681e962413d1afc56eaada87a
Parents: e5c7755 415ec2e
Author: randgalt <ra...@apache.org>
Authored: Mon Jun 10 13:57:03 2013 -0700
Committer: randgalt <ra...@apache.org>
Committed: Mon Jun 10 13:57:03 2013 -0700
----------------------------------------------------------------------
.../recipes/nodes/PersistentEphemeralNode.java | 22 ++++++--
.../nodes/TestPersistentEphemeralNode.java | 53 +++++++++++++++++++-
pom.xml | 11 ++++
3 files changed, 82 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
[2/5] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-curator
Posted by ra...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-curator
Project: http://git-wip-us.apache.org/repos/asf/incubator-curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-curator/commit/b766eb76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-curator/tree/b766eb76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-curator/diff/b766eb76
Branch: refs/heads/2.0.2-incubating
Commit: b766eb76a551ee03920955b991f320aefc68adec
Parents: aec1cfd 7903981
Author: randgalt <ra...@apache.org>
Authored: Mon Jun 10 08:00:37 2013 -0700
Committer: randgalt <ra...@apache.org>
Committed: Mon Jun 10 08:00:37 2013 -0700
----------------------------------------------------------------------
pom.xml | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
[3/5] git commit: Merge branch 'master' into CURATOR-25
Posted by ra...@apache.org.
Merge branch 'master' into CURATOR-25
Project: http://git-wip-us.apache.org/repos/asf/incubator-curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-curator/commit/f7e75e00
Tree: http://git-wip-us.apache.org/repos/asf/incubator-curator/tree/f7e75e00
Diff: http://git-wip-us.apache.org/repos/asf/incubator-curator/diff/f7e75e00
Branch: refs/heads/2.0.2-incubating
Commit: f7e75e00e28b24bb5cce8fb84b494afddb7560ac
Parents: 53fd857 b766eb7
Author: randgalt <ra...@apache.org>
Authored: Mon Jun 10 13:26:26 2013 -0700
Committer: randgalt <ra...@apache.org>
Committed: Mon Jun 10 13:26:26 2013 -0700
----------------------------------------------------------------------
pom.xml | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------