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 2015/10/16 20:45:46 UTC
[1/8] curator git commit: First pass implementation of group
membership
Repository: curator
Updated Branches:
refs/heads/CURATOR-3.0 1a240520f -> ac5c13268
First pass implementation of group membership
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/3029856c
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/3029856c
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/3029856c
Branch: refs/heads/CURATOR-3.0
Commit: 3029856c894a72ed2c5762e0c6acd2c0a8cd3937
Parents: f8f05be
Author: randgalt <ra...@apache.org>
Authored: Sun Sep 27 16:59:48 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Sep 27 16:59:48 2015 -0500
----------------------------------------------------------------------
.../framework/CuratorFrameworkFactory.java | 31 ++--
.../framework/recipes/nodes/GroupMember.java | 140 +++++++++++++++++++
.../src/site/confluence/group-member.confluence | 42 ++++++
.../src/site/confluence/index.confluence | 3 +-
.../recipes/nodes/TestGroupMember.java | 79 +++++++++++
5 files changed, 281 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/3029856c/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
index dcb2ee6..41ff9cd 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
@@ -100,6 +100,24 @@ public class CuratorFrameworkFactory
build();
}
+ /**
+ * Return the local address as bytes that can be used as a node payload
+ *
+ * @return local address bytes
+ */
+ public static byte[] getLocalAddress()
+ {
+ try
+ {
+ return InetAddress.getLocalHost().getHostAddress().getBytes();
+ }
+ catch ( UnknownHostException ignore )
+ {
+ // ignore
+ }
+ return new byte[0];
+ }
+
public static class Builder
{
private EnsembleProvider ensembleProvider;
@@ -465,19 +483,6 @@ public class CuratorFrameworkFactory
}
}
- private static byte[] getLocalAddress()
- {
- try
- {
- return InetAddress.getLocalHost().getHostAddress().getBytes();
- }
- catch ( UnknownHostException ignore )
- {
- // ignore
- }
- return new byte[0];
- }
-
private CuratorFrameworkFactory()
{
}
http://git-wip-us.apache.org/repos/asf/curator/blob/3029856c/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
new file mode 100644
index 0000000..5aa8ca2
--- /dev/null
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
@@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.curator.framework.recipes.nodes;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableMap;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.recipes.cache.ChildData;
+import org.apache.curator.framework.recipes.cache.PathChildrenCache;
+import org.apache.curator.utils.CloseableUtils;
+import org.apache.curator.utils.ZKPaths;
+import java.io.Closeable;
+import java.util.Arrays;
+import java.util.Map;
+
+/**
+ * Group membership management. Adds this instance into a group and
+ * keeps a cache of members in the group
+ */
+public class GroupMember implements Closeable
+{
+ private final PersistentEphemeralNode pen;
+ private final PathChildrenCache cache;
+ private final String thisId;
+ private final byte[] payload;
+
+ /**
+ * @param client client
+ * @param membershipPath the path to use for membership
+ * @param thisId ID of this group member. MUST be unique for the group
+ */
+ public GroupMember(CuratorFramework client, String membershipPath, String thisId)
+ {
+ this(client, membershipPath, thisId, CuratorFrameworkFactory.getLocalAddress());
+ }
+
+ /**
+ * @param client client
+ * @param membershipPath the path to use for membership
+ * @param thisId ID of this group member. MUST be unique for the group
+ * @param payload the payload to write in our member node
+ */
+ public GroupMember(CuratorFramework client, String membershipPath, String thisId, byte[] payload)
+ {
+ this.thisId = Preconditions.checkNotNull(thisId, "thisId cannot be null");
+ this.payload = Arrays.copyOf(payload, payload.length);
+
+ cache = newPathChildrenCache(client, membershipPath);
+ pen = newPersistentEphemeralNode(client, membershipPath, thisId, payload);
+ }
+
+ /**
+ * Start the group membership. Register thisId as a member and begin
+ * caching all members
+ */
+ public void start()
+ {
+ pen.start();
+ try
+ {
+ cache.start();
+ }
+ catch ( Exception e )
+ {
+ Throwables.propagate(e);
+ }
+ }
+
+ /**
+ * Have thisId leave the group and stop caching membership
+ */
+ @Override
+ public void close()
+ {
+ CloseableUtils.closeQuietly(cache);
+ CloseableUtils.closeQuietly(pen);
+ }
+
+ /**
+ * Return the current view of membership. The keys are the IDs
+ * of the members. The values are each member's payload
+ *
+ * @return membership
+ */
+ public Map<String, byte[]> getCurrentMembers()
+ {
+ ImmutableMap.Builder<String, byte[]> builder = ImmutableMap.builder();
+ boolean thisIdAdded = false;
+ for ( ChildData data : cache.getCurrentData() )
+ {
+ String id = idFromPath(data.getPath());
+ thisIdAdded = thisIdAdded || id.equals(thisId);
+ builder.put(id, data.getData());
+ }
+ if ( !thisIdAdded )
+ {
+ builder.put(thisId, payload); // this instance is always a member
+ }
+ return builder.build();
+ }
+
+ /**
+ * Given a full ZNode path, return the member ID
+ *
+ * @param path full ZNode path
+ * @return id
+ */
+ public String idFromPath(String path)
+ {
+ return ZKPaths.getNodeFromPath(path);
+ }
+
+ protected PersistentEphemeralNode newPersistentEphemeralNode(CuratorFramework client, String membershipPath, String thisId, byte[] payload)
+ {
+ return new PersistentEphemeralNode(client, PersistentEphemeralNode.Mode.EPHEMERAL, ZKPaths.makePath(membershipPath, thisId), payload);
+ }
+
+ protected PathChildrenCache newPathChildrenCache(CuratorFramework client, String membershipPath)
+ {
+ return new PathChildrenCache(client, membershipPath, true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/curator/blob/3029856c/curator-recipes/src/site/confluence/group-member.confluence
----------------------------------------------------------------------
diff --git a/curator-recipes/src/site/confluence/group-member.confluence b/curator-recipes/src/site/confluence/group-member.confluence
new file mode 100644
index 0000000..dcb27b3
--- /dev/null
+++ b/curator-recipes/src/site/confluence/group-member.confluence
@@ -0,0 +1,42 @@
+h1. Group Member
+
+h2. Description
+Group membership management. Adds this instance into a group and keeps a cache of members in the group.
+
+h2. Participating Classes
+* GroupMember
+
+h2. Usage
+h3. Creating a GroupMember
+{code}
+public GroupMember(CuratorFramework client,
+ String membershipPath,
+ String thisId,
+ byte[] payload)
+Parameters:
+client - client instance
+membershipPath - the path to use for membership
+thisId - ID of this group member. MUST be unique for the group
+payload - the payload to write in our member node
+{code}
+
+h3. General Usage
+GroupMember must be started:
+{code}
+group.start();
+{code}
+
+When you are through with the GroupMember instance, you should call close:
+{code}
+group.close();
+{code}
+
+NOTE: this will remove the instance from the group
+
+You can get a current view of the members by calling:
+{code}
+group.getCurrentMembers();
+{code}
+
+h2. Error Handling
+GroupMember instances internally handle all error states recreating the node as necessary.
http://git-wip-us.apache.org/repos/asf/curator/blob/3029856c/curator-recipes/src/site/confluence/index.confluence
----------------------------------------------------------------------
diff --git a/curator-recipes/src/site/confluence/index.confluence b/curator-recipes/src/site/confluence/index.confluence
index 4f3a032..71de8df 100644
--- a/curator-recipes/src/site/confluence/index.confluence
+++ b/curator-recipes/src/site/confluence/index.confluence
@@ -29,7 +29,8 @@ regarding "Curator Recipes Own Their ZNode/Paths".
|[[Tree Cache|tree-cache.html]] \- A utility that attempts to keep all data from all children of a ZK path locally cached. This class will watch the ZK path, respond to update/create/delete events, pull down the data, etc. You can register a listener that will get notified when changes occur.|
||Nodes||
-|[[Persistent Ephemeral Node|persistent-ephemeral-node.html]] \- An ephemeral node that attempts to stay present in ZooKeeper, even through connection and session interruptions..|
+|[[Persistent Ephemeral Node|persistent-ephemeral-node.html]] \- An ephemeral node that attempts to stay present in ZooKeeper, even through connection and session interruptions.|
+|[Group Member|group-member-node.html]] \- Group membership management. Adds this instance into a group and keeps a cache of members in the group.|
||Queues||
|[[Distributed Queue|distributed-queue.html]] \- An implementation of the Distributed Queue ZK recipe. Items put into the queue are guaranteed to be ordered (by means of ZK's PERSISTENT_SEQUENTIAL node). If a single consumer takes items out of the queue, they will be ordered FIFO. If ordering is important, use a LeaderSelector to nominate a single consumer.|
http://git-wip-us.apache.org/repos/asf/curator/blob/3029856c/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
new file mode 100644
index 0000000..3d4b951
--- /dev/null
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.curator.framework.recipes.nodes;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.BaseClassForTests;
+import org.apache.curator.test.Timing;
+import org.apache.curator.utils.CloseableUtils;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import java.util.Map;
+
+public class TestGroupMember extends BaseClassForTests
+{
+ // NOTE - don't need many tests as this class is just a wrapper around two existing recipes
+
+ @Test
+ public void testBasic() throws Exception
+ {
+ Timing timing = new Timing();
+ GroupMember groupMember1 = null;
+ GroupMember groupMember2 = null;
+ CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+ try
+ {
+ client.start();
+
+ groupMember1 = new GroupMember(client, "/member", "1");
+ Assert.assertTrue(groupMember1.getCurrentMembers().containsKey("1"));
+ groupMember1.start();
+
+ groupMember2 = new GroupMember(client, "/member", "2");
+ groupMember2.start();
+
+ timing.sleepABit();
+
+ Map<String, byte[]> currentMembers1 = groupMember1.getCurrentMembers();
+ Map<String, byte[]> currentMembers2 = groupMember2.getCurrentMembers();
+ Assert.assertEquals(currentMembers1.size(), 2);
+ Assert.assertEquals(currentMembers2.size(), 2);
+ Assert.assertEquals(currentMembers1, currentMembers2);
+ Assert.assertTrue(currentMembers1.containsKey("1"));
+ Assert.assertTrue(currentMembers1.containsKey("2"));
+
+ groupMember2.close();
+
+ timing.sleepABit();
+
+ currentMembers1 = groupMember1.getCurrentMembers();
+ Assert.assertEquals(currentMembers1.size(), 1);
+ Assert.assertTrue(currentMembers1.containsKey("1"));
+ Assert.assertFalse(currentMembers1.containsKey("2"));
+ }
+ finally
+ {
+ CloseableUtils.closeQuietly(groupMember1);
+ CloseableUtils.closeQuietly(groupMember2);
+ CloseableUtils.closeQuietly(client);
+ }
+ }
+}
[5/8] curator git commit: [maven-release-plugin] prepare for next
development iteration
Posted by ra...@apache.org.
[maven-release-plugin] prepare for next development iteration
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0e9c90f6
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0e9c90f6
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0e9c90f6
Branch: refs/heads/CURATOR-3.0
Commit: 0e9c90f648e886301f240acdc0eb770fe8cc3c8d
Parents: b58b5c2
Author: randgalt <ra...@apache.org>
Authored: Mon Oct 12 00:28:41 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Oct 12 00:28:41 2015 -0500
----------------------------------------------------------------------
curator-client/pom.xml | 4 ++--
curator-examples/pom.xml | 2 +-
curator-framework/pom.xml | 4 ++--
curator-recipes/pom.xml | 4 ++--
curator-test/pom.xml | 4 ++--
curator-x-discovery-server/pom.xml | 4 ++--
curator-x-discovery/pom.xml | 4 ++--
curator-x-rpc/pom.xml | 4 ++--
pom.xml | 4 ++--
9 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/0e9c90f6/curator-client/pom.xml
----------------------------------------------------------------------
diff --git a/curator-client/pom.xml b/curator-client/pom.xml
index 226ad4a..ec2c504 100644
--- a/curator-client/pom.xml
+++ b/curator-client/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>curator-client</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Curator Client</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/0e9c90f6/curator-examples/pom.xml
----------------------------------------------------------------------
diff --git a/curator-examples/pom.xml b/curator-examples/pom.xml
index f99b171..9ec9ccc 100644
--- a/curator-examples/pom.xml
+++ b/curator-examples/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>curator-examples</artifactId>
http://git-wip-us.apache.org/repos/asf/curator/blob/0e9c90f6/curator-framework/pom.xml
----------------------------------------------------------------------
diff --git a/curator-framework/pom.xml b/curator-framework/pom.xml
index 9bb3aac..dff0892 100644
--- a/curator-framework/pom.xml
+++ b/curator-framework/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>curator-framework</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Curator Framework</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/0e9c90f6/curator-recipes/pom.xml
----------------------------------------------------------------------
diff --git a/curator-recipes/pom.xml b/curator-recipes/pom.xml
index f73d4ad..50a32bf 100644
--- a/curator-recipes/pom.xml
+++ b/curator-recipes/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>curator-recipes</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Curator Recipes</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/0e9c90f6/curator-test/pom.xml
----------------------------------------------------------------------
diff --git a/curator-test/pom.xml b/curator-test/pom.xml
index be2ce41..8fcffda 100644
--- a/curator-test/pom.xml
+++ b/curator-test/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>curator-test</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<name>Curator Testing</name>
<description>Unit testing utilities.</description>
http://git-wip-us.apache.org/repos/asf/curator/blob/0e9c90f6/curator-x-discovery-server/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-discovery-server/pom.xml b/curator-x-discovery-server/pom.xml
index 0a387e5..5c56b45 100644
--- a/curator-x-discovery-server/pom.xml
+++ b/curator-x-discovery-server/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>curator-x-discovery-server</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Curator Service Discovery Server</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/0e9c90f6/curator-x-discovery/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-discovery/pom.xml b/curator-x-discovery/pom.xml
index 34d554f..82169cb 100644
--- a/curator-x-discovery/pom.xml
+++ b/curator-x-discovery/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>curator-x-discovery</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Curator Service Discovery</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/0e9c90f6/curator-x-rpc/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-rpc/pom.xml b/curator-x-rpc/pom.xml
index f4d1160..50c5353 100644
--- a/curator-x-rpc/pom.xml
+++ b/curator-x-rpc/pom.xml
@@ -22,12 +22,12 @@
<parent>
<artifactId>apache-curator</artifactId>
<groupId>org.apache.curator</groupId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>curator-x-rpc</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<name>Curator RPC Proxy</name>
<description>A proxy that bridges non-java environments with the Curator framework and recipes</description>
http://git-wip-us.apache.org/repos/asf/curator/blob/0e9c90f6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7315440..d899fd5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Apache Curator</name>
@@ -95,7 +95,7 @@
<connection>scm:git:https://git-wip-us.apache.org/repos/asf/curator.git</connection>
<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/curator.git
</developerConnection>
- <tag>apache-curator-3.0.0-SNAPSHOT</tag>
+ <tag>HEAD</tag>
</scm>
<issueManagement>
[6/8] curator git commit: Merge branch 'master' into CURATOR-267
Posted by ra...@apache.org.
Merge branch 'master' into CURATOR-267
Conflicts:
curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/722d0cee
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/722d0cee
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/722d0cee
Branch: refs/heads/CURATOR-3.0
Commit: 722d0cee3c0ad1ef65f25a80f5363bfcfd9e3792
Parents: 275b1d5 a14b277
Author: randgalt <ra...@apache.org>
Authored: Fri Oct 16 13:39:51 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Fri Oct 16 13:39:51 2015 -0500
----------------------------------------------------------------------
.../curator/framework/imps/NamespaceFacade.java | 6 --
.../curator/framework/imps/SyncBuilderImpl.java | 2 +-
.../curator/framework/imps/TestFramework.java | 42 ++++++++
.../recipes/nodes/PersistentEphemeralNode.java | 101 +++++++++----------
.../nodes/TestPersistentEphemeralNode.java | 82 +++++++++++++++
5 files changed, 172 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/722d0cee/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
----------------------------------------------------------------------
diff --cc curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
index ff9cb12,a3298ab..684e0d9
--- 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
@@@ -352,12 -355,8 +355,13 @@@ public class PersistentEphemeralNode im
}
}
- private byte[] getData()
+ /**
+ * Return the current value of our data
+ *
+ * @return our data
+ */
- public byte[] getData() {
++ public byte[] getData()
+ {
return this.data.get();
}
[7/8] curator git commit: Merge branch 'CURATOR-3.0' of
https://git-wip-us.apache.org/repos/asf/curator into CURATOR-3.0
Posted by ra...@apache.org.
Merge branch 'CURATOR-3.0' of https://git-wip-us.apache.org/repos/asf/curator 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/8ff8ab88
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8ff8ab88
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8ff8ab88
Branch: refs/heads/CURATOR-3.0
Commit: 8ff8ab885a6e94fb9f72c1d00b776343e023a7d1
Parents: 0e9c90f 1a24052
Author: randgalt <ra...@apache.org>
Authored: Fri Oct 16 13:45:36 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Fri Oct 16 13:45:36 2015 -0500
----------------------------------------------------------------------
.../java/org/apache/curator/framework/imps/SyncBuilderImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
[3/8] curator git commit: updated doc
Posted by ra...@apache.org.
updated doc
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/275b1d5e
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/275b1d5e
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/275b1d5e
Branch: refs/heads/CURATOR-3.0
Commit: 275b1d5e9f13c8d4dd76961a2fc6f2c86536cf9b
Parents: a49d2bb
Author: randgalt <ra...@apache.org>
Authored: Sun Sep 27 17:22:15 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Sep 27 17:22:15 2015 -0500
----------------------------------------------------------------------
curator-recipes/src/site/confluence/group-member.confluence | 2 ++
curator-recipes/src/site/confluence/index.confluence | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/275b1d5e/curator-recipes/src/site/confluence/group-member.confluence
----------------------------------------------------------------------
diff --git a/curator-recipes/src/site/confluence/group-member.confluence b/curator-recipes/src/site/confluence/group-member.confluence
index dcb27b3..a370675 100644
--- a/curator-recipes/src/site/confluence/group-member.confluence
+++ b/curator-recipes/src/site/confluence/group-member.confluence
@@ -5,6 +5,8 @@ Group membership management. Adds this instance into a group and keeps a cache o
h2. Participating Classes
* GroupMember
+* PersistentEphemeralNode
+* PathChildrenCache
h2. Usage
h3. Creating a GroupMember
http://git-wip-us.apache.org/repos/asf/curator/blob/275b1d5e/curator-recipes/src/site/confluence/index.confluence
----------------------------------------------------------------------
diff --git a/curator-recipes/src/site/confluence/index.confluence b/curator-recipes/src/site/confluence/index.confluence
index 71de8df..01dfc7e 100644
--- a/curator-recipes/src/site/confluence/index.confluence
+++ b/curator-recipes/src/site/confluence/index.confluence
@@ -30,7 +30,7 @@ regarding "Curator Recipes Own Their ZNode/Paths".
||Nodes||
|[[Persistent Ephemeral Node|persistent-ephemeral-node.html]] \- An ephemeral node that attempts to stay present in ZooKeeper, even through connection and session interruptions.|
-|[Group Member|group-member-node.html]] \- Group membership management. Adds this instance into a group and keeps a cache of members in the group.|
+|[Group Member|group-member.html]] \- Group membership management. Adds this instance into a group and keeps a cache of members in the group.|
||Queues||
|[[Distributed Queue|distributed-queue.html]] \- An implementation of the Distributed Queue ZK recipe. Items put into the queue are guaranteed to be ordered (by means of ZK's PERSISTENT_SEQUENTIAL node). If a single consumer takes items out of the queue, they will be ordered FIFO. If ordering is important, use a LeaderSelector to nominate a single consumer.|
[2/8] curator git commit: api for setting data
Posted by ra...@apache.org.
api for setting data
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/a49d2bb4
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/a49d2bb4
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/a49d2bb4
Branch: refs/heads/CURATOR-3.0
Commit: a49d2bb4f83a9627ad546a149a8f77831d174ef1
Parents: 3029856
Author: randgalt <ra...@apache.org>
Authored: Sun Sep 27 17:06:46 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Sep 27 17:06:46 2015 -0500
----------------------------------------------------------------------
.../framework/recipes/nodes/GroupMember.java | 22 ++++++++++++++++----
.../recipes/nodes/PersistentEphemeralNode.java | 7 ++++++-
.../recipes/nodes/TestGroupMember.java | 7 +++++++
3 files changed, 31 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/a49d2bb4/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
index 5aa8ca2..b914ba4 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/GroupMember.java
@@ -28,7 +28,6 @@ import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.curator.utils.CloseableUtils;
import org.apache.curator.utils.ZKPaths;
import java.io.Closeable;
-import java.util.Arrays;
import java.util.Map;
/**
@@ -40,7 +39,6 @@ public class GroupMember implements Closeable
private final PersistentEphemeralNode pen;
private final PathChildrenCache cache;
private final String thisId;
- private final byte[] payload;
/**
* @param client client
@@ -61,7 +59,6 @@ public class GroupMember implements Closeable
public GroupMember(CuratorFramework client, String membershipPath, String thisId, byte[] payload)
{
this.thisId = Preconditions.checkNotNull(thisId, "thisId cannot be null");
- this.payload = Arrays.copyOf(payload, payload.length);
cache = newPathChildrenCache(client, membershipPath);
pen = newPersistentEphemeralNode(client, membershipPath, thisId, payload);
@@ -85,6 +82,23 @@ public class GroupMember implements Closeable
}
/**
+ * Change the data stored in this instance's node
+ *
+ * @param data new data (cannot be null)
+ */
+ public void setThisData(byte[] data)
+ {
+ try
+ {
+ pen.setData(data);
+ }
+ catch ( Exception e )
+ {
+ Throwables.propagate(e);
+ }
+ }
+
+ /**
* Have thisId leave the group and stop caching membership
*/
@Override
@@ -112,7 +126,7 @@ public class GroupMember implements Closeable
}
if ( !thisIdAdded )
{
- builder.put(thisId, payload); // this instance is always a member
+ builder.put(thisId, pen.getData()); // this instance is always a member
}
return builder.build();
}
http://git-wip-us.apache.org/repos/asf/curator/blob/a49d2bb4/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 7e00e10..ff9cb12 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
@@ -352,7 +352,12 @@ public class PersistentEphemeralNode implements Closeable
}
}
- private byte[] getData() {
+ /**
+ * Return the current value of our data
+ *
+ * @return our data
+ */
+ public byte[] getData() {
return this.data.get();
}
http://git-wip-us.apache.org/repos/asf/curator/blob/a49d2bb4/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
index 3d4b951..b67831d 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestGroupMember.java
@@ -68,6 +68,13 @@ public class TestGroupMember extends BaseClassForTests
Assert.assertEquals(currentMembers1.size(), 1);
Assert.assertTrue(currentMembers1.containsKey("1"));
Assert.assertFalse(currentMembers1.containsKey("2"));
+
+ groupMember1.setThisData("something".getBytes());
+
+ timing.sleepABit();
+ currentMembers1 = groupMember1.getCurrentMembers();
+ Assert.assertTrue(currentMembers1.containsKey("1"));
+ Assert.assertEquals(currentMembers1.get("1"), "something".getBytes());
}
finally
{
[8/8] curator git commit: Merge branch 'master' into CURATOR-3.0
Posted by ra...@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/ac5c1326
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ac5c1326
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ac5c1326
Branch: refs/heads/CURATOR-3.0
Commit: ac5c132684e8cf8f07741f12fefff39803925f99
Parents: 8ff8ab8 722d0ce
Author: randgalt <ra...@apache.org>
Authored: Fri Oct 16 13:45:40 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Fri Oct 16 13:45:40 2015 -0500
----------------------------------------------------------------------
.../framework/CuratorFrameworkFactory.java | 31 ++--
.../framework/recipes/nodes/GroupMember.java | 154 +++++++++++++++++++
.../recipes/nodes/PersistentEphemeralNode.java | 7 +-
.../src/site/confluence/group-member.confluence | 44 ++++++
.../src/site/confluence/index.confluence | 3 +-
.../recipes/nodes/TestGroupMember.java | 86 +++++++++++
6 files changed, 310 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/ac5c1326/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/ac5c1326/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentEphemeralNode.java
----------------------------------------------------------------------
[4/8] curator git commit: [maven-release-plugin] prepare release
apache-curator-3.0.0-SNAPSHOT
Posted by ra...@apache.org.
[maven-release-plugin] prepare release apache-curator-3.0.0-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b58b5c23
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b58b5c23
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b58b5c23
Branch: refs/heads/CURATOR-3.0
Commit: b58b5c236a663402fd401143d72e666aa853e7ed
Parents: c111118
Author: randgalt <ra...@apache.org>
Authored: Mon Oct 12 00:28:31 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Oct 12 00:28:31 2015 -0500
----------------------------------------------------------------------
curator-client/pom.xml | 4 ++--
curator-examples/pom.xml | 2 +-
curator-framework/pom.xml | 4 ++--
curator-recipes/pom.xml | 4 ++--
curator-test/pom.xml | 4 ++--
curator-x-discovery-server/pom.xml | 4 ++--
curator-x-discovery/pom.xml | 4 ++--
curator-x-rpc/pom.xml | 4 ++--
pom.xml | 4 ++--
9 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/b58b5c23/curator-client/pom.xml
----------------------------------------------------------------------
diff --git a/curator-client/pom.xml b/curator-client/pom.xml
index 7bb437c..226ad4a 100644
--- a/curator-client/pom.xml
+++ b/curator-client/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
</parent>
<artifactId>curator-client</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
<packaging>bundle</packaging>
<name>Curator Client</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/b58b5c23/curator-examples/pom.xml
----------------------------------------------------------------------
diff --git a/curator-examples/pom.xml b/curator-examples/pom.xml
index 536f727..f99b171 100644
--- a/curator-examples/pom.xml
+++ b/curator-examples/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
</parent>
<artifactId>curator-examples</artifactId>
http://git-wip-us.apache.org/repos/asf/curator/blob/b58b5c23/curator-framework/pom.xml
----------------------------------------------------------------------
diff --git a/curator-framework/pom.xml b/curator-framework/pom.xml
index a7df78c..9bb3aac 100644
--- a/curator-framework/pom.xml
+++ b/curator-framework/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
</parent>
<artifactId>curator-framework</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
<packaging>bundle</packaging>
<name>Curator Framework</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/b58b5c23/curator-recipes/pom.xml
----------------------------------------------------------------------
diff --git a/curator-recipes/pom.xml b/curator-recipes/pom.xml
index 3394361..f73d4ad 100644
--- a/curator-recipes/pom.xml
+++ b/curator-recipes/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
</parent>
<artifactId>curator-recipes</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
<packaging>bundle</packaging>
<name>Curator Recipes</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/b58b5c23/curator-test/pom.xml
----------------------------------------------------------------------
diff --git a/curator-test/pom.xml b/curator-test/pom.xml
index d401da5..be2ce41 100644
--- a/curator-test/pom.xml
+++ b/curator-test/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
</parent>
<artifactId>curator-test</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
<name>Curator Testing</name>
<description>Unit testing utilities.</description>
http://git-wip-us.apache.org/repos/asf/curator/blob/b58b5c23/curator-x-discovery-server/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-discovery-server/pom.xml b/curator-x-discovery-server/pom.xml
index 3c0aa0f..0a387e5 100644
--- a/curator-x-discovery-server/pom.xml
+++ b/curator-x-discovery-server/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
</parent>
<artifactId>curator-x-discovery-server</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
<packaging>bundle</packaging>
<name>Curator Service Discovery Server</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/b58b5c23/curator-x-discovery/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-discovery/pom.xml b/curator-x-discovery/pom.xml
index 8367d9a..34d554f 100644
--- a/curator-x-discovery/pom.xml
+++ b/curator-x-discovery/pom.xml
@@ -24,11 +24,11 @@
<parent>
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
</parent>
<artifactId>curator-x-discovery</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
<packaging>bundle</packaging>
<name>Curator Service Discovery</name>
http://git-wip-us.apache.org/repos/asf/curator/blob/b58b5c23/curator-x-rpc/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-rpc/pom.xml b/curator-x-rpc/pom.xml
index d9d0519..f4d1160 100644
--- a/curator-x-rpc/pom.xml
+++ b/curator-x-rpc/pom.xml
@@ -22,12 +22,12 @@
<parent>
<artifactId>apache-curator</artifactId>
<groupId>org.apache.curator</groupId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>curator-x-rpc</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
<name>Curator RPC Proxy</name>
<description>A proxy that bridges non-java environments with the Curator framework and recipes</description>
http://git-wip-us.apache.org/repos/asf/curator/blob/b58b5c23/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7e8728a..7315440 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
<groupId>org.apache.curator</groupId>
<artifactId>apache-curator</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
<packaging>pom</packaging>
<name>Apache Curator</name>
@@ -95,7 +95,7 @@
<connection>scm:git:https://git-wip-us.apache.org/repos/asf/curator.git</connection>
<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/curator.git
</developerConnection>
- <tag>HEAD</tag>
+ <tag>apache-curator-3.0.0-SNAPSHOT</tag>
</scm>
<issueManagement>