[4/4] git commit: Merge branch 'CURATOR-93' of github.com:cammckenzie/curator into CURATOR-93
Merge branch 'CURATOR-93' of github.com:cammckenzie/curator into CURATOR-93 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/2f751df4 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/2f751df4 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/2f751df4 Branch: refs/heads/master Commit: 2f751df40a79e67c2d42fe44e02a67f1fba0b184 Parents: 7d19242 2df9b97 Author: randgalt Authored: Wed Jun 18 21:44:59 2014 -0500 Committer: randgalt Committed: Wed Jun 18 21:44:59 2014 -0500 -- .../transaction/TransactionCreateBuilder.java | 1 - .../transaction/TransactionSetDataBuilder.java | 4 +- .../framework/imps/CreateBuilderImpl.java | 2 +- .../framework/imps/SetDataBuilderImpl.java | 14 +++ .../imps/TestCompressionInTransaction.java | 100 ++- 5 files changed, 116 insertions(+), 5 deletions(-) --
[1/2] git commit: fixed typo
Repository: curator Updated Branches: refs/heads/master 879170804 -> 2c0c52322 fixed typo Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/9ecf1f15 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/9ecf1f15 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/9ecf1f15 Branch: refs/heads/master Commit: 9ecf1f154f52b50b4013c0e7faf6b0b505df9ef6 Parents: 2f751df Author: randgalt Authored: Mon Jul 7 13:12:49 2014 -0500 Committer: randgalt Committed: Mon Jul 7 13:12:49 2014 -0500 -- curator-x-rpc/src/site/confluence/events.confluence | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/9ecf1f15/curator-x-rpc/src/site/confluence/events.confluence -- diff --git a/curator-x-rpc/src/site/confluence/events.confluence b/curator-x-rpc/src/site/confluence/events.confluence index 8b3f711..6a3e29b 100644 --- a/curator-x-rpc/src/site/confluence/events.confluence +++ b/curator-x-rpc/src/site/confluence/events.confluence @@ -33,7 +33,7 @@ h3. CuratorEvent |children|list of string|list of node names if the event type has it| |aclList|list of Acl|list of ACL data if the event type has it| |watchedEvent|WatchedEvent|if the event type is WATCHED| -|leaderEvent|LeaderEvent|if the event type is WATCHED| +|leaderEvent|LeaderEvent|if the event type is LEADER| |childrenCacheEvent|PathChildrenCacheEvent|if the event type is PATH\_CHILDREN\_CACHE| h3. CuratorEventType
[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/curator
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/curator Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/2c0c5232 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/2c0c5232 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/2c0c5232 Branch: refs/heads/master Commit: 2c0c523223e562b7c31485cabfc3f327793ebdd4 Parents: 9ecf1f1 8791708 Author: randgalt Authored: Mon Jul 7 13:12:54 2014 -0500 Committer: randgalt Committed: Mon Jul 7 13:12:54 2014 -0500 -- pom.xml | 12 1 file changed, 12 insertions(+) --
git commit: Added Curator RPC to list of modules
Repository: curator Updated Branches: refs/heads/master dfc1c03df -> a74916fb2 Added Curator RPC to list of modules Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/a74916fb Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/a74916fb Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/a74916fb Branch: refs/heads/master Commit: a74916fb228f6b05e22f2a06e7654cebdf305077 Parents: dfc1c03 Author: randgalt Authored: Tue Jul 8 08:08:39 2014 -0500 Committer: randgalt Committed: Tue Jul 8 08:08:39 2014 -0500 -- src/site/confluence/index.confluence | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/curator/blob/a74916fb/src/site/confluence/index.confluence -- diff --git a/src/site/confluence/index.confluence b/src/site/confluence/index.confluence index 724097c..cd533cf 100644 --- a/src/site/confluence/index.confluence +++ b/src/site/confluence/index.confluence @@ -32,3 +32,4 @@ most users, the only artifact you need is curator\-recipes. |org.apache.curator|curator\-examples|Example usages of various Curator features.| |org.apache.curator|curator\-x\-discovery|A Service Discovery implementation built on the Curator Framework.| |org.apache.curator|curator\-x\-discovery-server|A RESTful server that can be used with Curator Discovery.| +|org.apache.curator|curator\-x\-rpc|A proxy that bridges non\-java environments with the Curator framework and recipes.|
git commit: in testSorting(), if the queue put is slow, the consumer would get ahead breaking the test. Instead, wait to consume items until they've all been added
Repository: curator Updated Branches: refs/heads/master a74916fb2 -> 599cb9ffb in testSorting(), if the queue put is slow, the consumer would get ahead breaking the test. Instead, wait to consume items until they've all been added Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/599cb9ff Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/599cb9ff Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/599cb9ff Branch: refs/heads/master Commit: 599cb9ffba81dbd8da0c6d0cfcf0597ab544bf4e Parents: a74916f Author: randgalt Authored: Tue Jul 8 12:29:31 2014 -0500 Committer: randgalt Committed: Tue Jul 8 12:29:31 2014 -0500 -- .../recipes/queue/TestDistributedDelayQueue.java | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/599cb9ff/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedDelayQueue.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedDelayQueue.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedDelayQueue.java index 3759c34..74cd2ee 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedDelayQueue.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedDelayQueue.java @@ -142,14 +142,14 @@ public class TestDistributedDelayQueue extends BaseClassForTests final int QTY = 1000; Timing timing = new Timing(); -DistributedDelayQueue queue = null; +DistributedDelayQueue putQueue = null; +DistributedDelayQueue getQueue = null; CuratorFrameworkclient = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); client.start(); try { -BlockingQueueConsumer consumer = new BlockingQueueConsumer(Mockito.mock(ConnectionStateListener.class)); -queue = QueueBuilder.builder(client, consumer, new LongSerializer(), "/test2").putInBackground(false).buildDelayQueue(); -queue.start(); +putQueue = QueueBuilder.builder(client, null, new LongSerializer(), "/test2").putInBackground(false).buildDelayQueue(); +putQueue.start(); Map data = new HashMap(); @@ -174,8 +174,12 @@ public class TestDistributedDelayQueue extends BaseClassForTests //delay and value for ( Long key : keys ) { -queue.put(data.get(key), key); -} +putQueue.put(data.get(key), key); +} + +BlockingQueueConsumer consumer = new BlockingQueueConsumer(Mockito.mock(ConnectionStateListener.class)); +getQueue = QueueBuilder.builder(client, consumer, new LongSerializer(), "/test2").putInBackground(false).buildDelayQueue(); +getQueue.start(); long lastValue = -1; for ( int i = 0; i < QTY; ++i ) @@ -188,7 +192,8 @@ public class TestDistributedDelayQueue extends BaseClassForTests } finally { -CloseableUtils.closeQuietly(queue); +CloseableUtils.closeQuietly(putQueue); +CloseableUtils.closeQuietly(getQueue); CloseableUtils.closeQuietly(client); } }
git commit: don't produce dependency reduced pom
Repository: curator Updated Branches: refs/heads/master 599cb9ffb -> 52236f169 don't produce dependency reduced pom Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/52236f16 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/52236f16 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/52236f16 Branch: refs/heads/master Commit: 52236f16981adf8918236280d5d011f4891580a8 Parents: 599cb9f Author: randgalt Authored: Wed Jul 9 10:20:50 2014 -0500 Committer: randgalt Committed: Wed Jul 9 10:20:50 2014 -0500 -- curator-x-rpc/dependency-reduced-pom.xml | 108 -- curator-x-rpc/pom.xml| 2 +- 2 files changed, 1 insertion(+), 109 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/52236f16/curator-x-rpc/dependency-reduced-pom.xml -- diff --git a/curator-x-rpc/dependency-reduced-pom.xml b/curator-x-rpc/dependency-reduced-pom.xml deleted file mode 100644 index 25e5f68..000 --- a/curator-x-rpc/dependency-reduced-pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - -http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";> - -apache-curator -org.apache.curator -2.5.1-SNAPSHOT - - 4.0.0 - curator-x-rpc - 2.5.1-SNAPSHOT - - - -${project.basedir}/src/main/resources - - curator/help.txt - - - -${project.basedir}/src/main/thrift - - curator.thrift - - - - - -maven-shade-plugin - - -package - - shade - - - - - - org.apache.curator.x.rpc.CuratorProjectionServer - - - - - - - true - - - *:* - -META-INF/*.SF -META-INF/*.DSA -META-INF/*.RSA - - - - - - - - - - org.apache.curator - curator-test - 2.5.1-SNAPSHOT - test - - - log4j-over-slf4j - org.slf4j - - - slf4j-log4j12 - org.slf4j - - - log4j - log4j - - - javassist - org.javassist - - - commons-math - org.apache.commons - - - - - org.testng - testng - 6.8.8 - test - - - bsh - org.beanshell - - - jcommander - com.beust - - - - - - http://git-wip-us.apache.org/repos/asf/curator/blob/52236f16/curator-x-rpc/pom.xml -- diff --git a/curator-x-rpc/pom.xml b/curator-x-rpc/pom.xml index d166d91..1b7fa40 100644 --- a/curator-x-rpc/pom.xml +++ b/curator-x-rpc/pom.xml @@ -116,7 +116,7 @@ org.apache.maven.plugins maven-shade-plugin - true + false *:*
git commit: ignore thrift and json files
Repository: curator Updated Branches: refs/heads/master 52236f169 -> 4cbb25527 ignore thrift and json files Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/4cbb2552 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/4cbb2552 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/4cbb2552 Branch: refs/heads/master Commit: 4cbb2552783da17f667ba7cf242219ea2f423772 Parents: 52236f1 Author: randgalt Authored: Wed Jul 9 10:22:54 2014 -0500 Committer: randgalt Committed: Wed Jul 9 10:22:54 2014 -0500 -- pom.xml | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/4cbb2552/pom.xml -- diff --git a/pom.xml b/pom.xml index 9efb4b5..a18204c 100644 --- a/pom.xml +++ b/pom.xml @@ -720,7 +720,8 @@ **/help.txt **/*.rdf **/.gitignore -**/.thrift +**/*.thrift +**/*.json **/.idea/** **/DISCLAIMER **/DEPENDENCIES @@ -764,7 +765,8 @@ **/*.rdf **/help.txt **/.gitignore -**/.thrift +**/*.thrift +**/*.json **/.idea/** **/DISCLAIMER **/DEPENDENCIES
git commit: Correct license header
Repository: curator Updated Branches: refs/heads/master 4cbb25527 -> c358bbce9 Correct license header Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/c358bbce Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/c358bbce Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/c358bbce Branch: refs/heads/master Commit: c358bbce9a728bc9b5372ac67b78b11e03895c11 Parents: 4cbb255 Author: randgalt Authored: Wed Jul 9 10:36:30 2014 -0500 Committer: randgalt Committed: Wed Jul 9 10:36:30 2014 -0500 -- doap.rdf | 16 1 file changed, 12 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/c358bbce/doap.rdf -- diff --git a/doap.rdf b/doap.rdf index 55efacc..294499e 100644 --- a/doap.rdf +++ b/doap.rdf @@ -6,12 +6,20 @@ xmlns:asfext="http://projects.apache.org/ns/asfext#"; xmlns:foaf="http://xmlns.com/foaf/0.1/";> http://curator.apache.org/";> 2011-02-06
[1/4] git commit: CURATOR-118 Add config to release plugin
Repository: curator Updated Branches: refs/heads/CURATOR-118 [created] 5df92bf88 CURATOR-118 Add config to release plugin Auto-version submodules because they should all be the same version. Add tag template to match the existing precedent. Don't push tag until it's been voted on. Use local checkout to save on bandwidth. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6e184ca0 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6e184ca0 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6e184ca0 Branch: refs/heads/CURATOR-118 Commit: 6e184ca00c3f5600b7130a2a9b47834e4025ef3f Parents: c358bbc Author: Mike Drob Authored: Wed Jul 9 10:52:41 2014 -0500 Committer: Mike Drob Committed: Wed Jul 9 10:52:41 2014 -0500 -- pom.xml | 6 ++ 1 file changed, 6 insertions(+) -- http://git-wip-us.apache.org/repos/asf/curator/blob/6e184ca0/pom.xml -- diff --git a/pom.xml b/pom.xml index a18204c..d0cd6c4 100644 --- a/pom.xml +++ b/pom.xml @@ -559,6 +559,12 @@ org.apache.maven.plugins maven-release-plugin ${maven-release-plugin-version} + +true + ${artifactID}-@{project.version} +false +true +
[3/4] git commit: fixed typo
fixed typo Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6a7704d9 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6a7704d9 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6a7704d9 Branch: refs/heads/CURATOR-118 Commit: 6a7704d98633f228fb6334df879adac0bf18f761 Parents: 8a43132 Author: randgalt Authored: Sun Jul 20 20:42:57 2014 -0500 Committer: randgalt Committed: Sun Jul 20 20:42:57 2014 -0500 -- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/6a7704d9/pom.xml -- diff --git a/pom.xml b/pom.xml index d0cd6c4..a37307c 100644 --- a/pom.xml +++ b/pom.xml @@ -561,7 +561,7 @@ ${maven-release-plugin-version} true - ${artifactID}-@{project.version} + ${artifactID}-${project.version} false true
[1/4] git commit: CURATOR-118 Add config to release plugin
Repository: curator Updated Branches: refs/heads/master 67399386f -> 5df92bf88 CURATOR-118 Add config to release plugin Auto-version submodules because they should all be the same version. Add tag template to match the existing precedent. Don't push tag until it's been voted on. Use local checkout to save on bandwidth. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6e184ca0 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6e184ca0 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6e184ca0 Branch: refs/heads/master Commit: 6e184ca00c3f5600b7130a2a9b47834e4025ef3f Parents: c358bbc Author: Mike Drob Authored: Wed Jul 9 10:52:41 2014 -0500 Committer: Mike Drob Committed: Wed Jul 9 10:52:41 2014 -0500 -- pom.xml | 6 ++ 1 file changed, 6 insertions(+) -- http://git-wip-us.apache.org/repos/asf/curator/blob/6e184ca0/pom.xml -- diff --git a/pom.xml b/pom.xml index a18204c..d0cd6c4 100644 --- a/pom.xml +++ b/pom.xml @@ -559,6 +559,12 @@ org.apache.maven.plugins maven-release-plugin ${maven-release-plugin-version} + +true + ${artifactID}-@{project.version} +false +true +
[2/4] git commit: Merge remote-tracking branch 'temp/CURATOR-118' into CURATOR-118
Merge remote-tracking branch 'temp/CURATOR-118' into CURATOR-118 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/8a431329 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8a431329 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8a431329 Branch: refs/heads/master Commit: 8a431329189608217d0246aefc09c0e0b7060f15 Parents: 6739938 6e184ca Author: randgalt Authored: Sun Jul 20 20:40:54 2014 -0500 Committer: randgalt Committed: Sun Jul 20 20:40:54 2014 -0500 -- pom.xml | 6 ++ 1 file changed, 6 insertions(+) --
[2/4] git commit: Merge remote-tracking branch 'temp/CURATOR-118' into CURATOR-118
Merge remote-tracking branch 'temp/CURATOR-118' into CURATOR-118 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/8a431329 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8a431329 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8a431329 Branch: refs/heads/CURATOR-118 Commit: 8a431329189608217d0246aefc09c0e0b7060f15 Parents: 6739938 6e184ca Author: randgalt Authored: Sun Jul 20 20:40:54 2014 -0500 Committer: randgalt Committed: Sun Jul 20 20:40:54 2014 -0500 -- pom.xml | 6 ++ 1 file changed, 6 insertions(+) --
[3/4] git commit: fixed typo
fixed typo Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6a7704d9 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6a7704d9 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6a7704d9 Branch: refs/heads/master Commit: 6a7704d98633f228fb6334df879adac0bf18f761 Parents: 8a43132 Author: randgalt Authored: Sun Jul 20 20:42:57 2014 -0500 Committer: randgalt Committed: Sun Jul 20 20:42:57 2014 -0500 -- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/6a7704d9/pom.xml -- diff --git a/pom.xml b/pom.xml index d0cd6c4..a37307c 100644 --- a/pom.xml +++ b/pom.xml @@ -561,7 +561,7 @@ ${maven-release-plugin-version} true - ${artifactID}-@{project.version} + ${artifactID}-${project.version} false true
[4/4] git commit: fixed another typo
fixed another typo Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5df92bf8 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5df92bf8 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5df92bf8 Branch: refs/heads/CURATOR-118 Commit: 5df92bf8861184d25b3e367f6fa5fc595fe8b6e0 Parents: 6a7704d Author: randgalt Authored: Sun Jul 20 20:46:04 2014 -0500 Committer: randgalt Committed: Sun Jul 20 20:46:04 2014 -0500 -- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/5df92bf8/pom.xml -- diff --git a/pom.xml b/pom.xml index a37307c..2129e56 100644 --- a/pom.xml +++ b/pom.xml @@ -561,7 +561,7 @@ ${maven-release-plugin-version} true - ${artifactID}-${project.version} + ${project.artifactId}-${project.version} false true
[4/4] git commit: fixed another typo
fixed another typo Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5df92bf8 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5df92bf8 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5df92bf8 Branch: refs/heads/master Commit: 5df92bf8861184d25b3e367f6fa5fc595fe8b6e0 Parents: 6a7704d Author: randgalt Authored: Sun Jul 20 20:46:04 2014 -0500 Committer: randgalt Committed: Sun Jul 20 20:46:04 2014 -0500 -- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/5df92bf8/pom.xml -- diff --git a/pom.xml b/pom.xml index a37307c..2129e56 100644 --- a/pom.xml +++ b/pom.xml @@ -561,7 +561,7 @@ ${maven-release-plugin-version} true - ${artifactID}-${project.version} + ${project.artifactId}-${project.version} false true
git commit: Test case that shows the problem
Repository: curator Updated Branches: refs/heads/CURATOR-123 [created] feb13e1c1 Test case that shows the problem Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/feb13e1c Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/feb13e1c Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/feb13e1c Branch: refs/heads/CURATOR-123 Commit: feb13e1c16de7078dfc1310d9403441d1b2dae9e Parents: 5df92bf Author: randgalt Authored: Tue Jul 22 16:05:19 2014 -0500 Committer: randgalt Committed: Tue Jul 22 16:05:19 2014 -0500 -- .../curator/framework/imps/TestReadOnly.java| 165 +-- 1 file changed, 115 insertions(+), 50 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/feb13e1c/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java -- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java index 537617c..d6d63f8 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java @@ -16,93 +16,158 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.framework.imps; -import org.apache.curator.utils.CloseableUtils; +import com.google.common.collect.Queues; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.curator.retry.RetryNTimes; +import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.InstanceSpec; import org.apache.curator.test.TestingCluster; import org.apache.curator.test.Timing; +import org.apache.curator.utils.CloseableUtils; import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.Iterator; +import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class TestReadOnly { -@Test -public void testReadOnly() throws Exception +@BeforeMethod +public void setup() { System.setProperty("readonlymode.enabled", "true"); +} + +@AfterMethod +public void tearDown() +{ +System.setProperty("readonlymode.enabled", "false"); +} + +@Test +public void testConnectionStateNewClient() throws Exception +{ +Timing timing = new Timing(); +TestingCluster cluster = new TestingCluster(3); +CuratorFramework client = null; try { -Timing timing = new Timing(); +cluster.start(); + +client = CuratorFrameworkFactory.newClient(cluster.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(100)); +client.start(); +client.checkExists().forPath("/"); +client.close(); +client = null; -CuratorFrameworkclient = null; -TestingCluster cluster = new TestingCluster(2); -try +System.out.println("killing 2 instances"); +Iterator iterator = cluster.getInstances().iterator(); +for ( int i = 0; i < 2; ++i ) { -cluster.start(); - -client = CuratorFrameworkFactory.builder() -.connectString(cluster.getConnectString()) -.canBeReadOnly(true) -.connectionTimeoutMs(timing.connection()) -.sessionTimeoutMs(timing.session()) -.retryPolicy(new ExponentialBackoffRetry(100, 3)) -.build(); -client.start(); - -client.create().forPath("/test"); - -final CountDownLatchreadOnlyLatch = new CountDownLatch(1); -final CountDownLatchreconnectedLatch = new CountDownLatch(1); -ConnectionStateListener listener = new ConnectionStateListener() +cluster.killServer(iterator.next()); +} + +System.out.println("reconnecting client"); +client = CuratorFrameworkFactory.builder() +.connectS
git commit: Fix that causes CONNECT to be sent when the read/write connection is established. It can be argued that CONNECT should never be sent though. Discussing...
Repository: curator Updated Branches: refs/heads/CURATOR-123 feb13e1c1 -> a86a667bb Fix that causes CONNECT to be sent when the read/write connection is established. It can be argued that CONNECT should never be sent though. Discussing... Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/a86a667b Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/a86a667b Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/a86a667b Branch: refs/heads/CURATOR-123 Commit: a86a667bb1213fec26fbdb8354bdc01b9fe70396 Parents: feb13e1 Author: randgalt Authored: Tue Jul 22 16:07:13 2014 -0500 Committer: randgalt Committed: Tue Jul 22 16:07:13 2014 -0500 -- .../org/apache/curator/framework/state/ConnectionStateManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/a86a667b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java index 2a0cdd1..67ff13d 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java @@ -180,7 +180,7 @@ public class ConnectionStateManager implements Closeable currentConnectionState = newConnectionState; ConnectionState localState = newConnectionState; -boolean isNegativeMessage = ((newConnectionState == ConnectionState.LOST) || (newConnectionState == ConnectionState.SUSPENDED)); +boolean isNegativeMessage = ((newConnectionState == ConnectionState.LOST) || (newConnectionState == ConnectionState.SUSPENDED) || (newConnectionState == ConnectionState.READ_ONLY)); if ( !isNegativeMessage && initialConnectMessageSent.compareAndSet(false, true) ) { localState = ConnectionState.CONNECTED;
[1/3] git commit: Test case that shows the problem
Repository: curator Updated Branches: refs/heads/master 5df92bf88 -> 5f5ee9665 Test case that shows the problem Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/feb13e1c Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/feb13e1c Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/feb13e1c Branch: refs/heads/master Commit: feb13e1c16de7078dfc1310d9403441d1b2dae9e Parents: 5df92bf Author: randgalt Authored: Tue Jul 22 16:05:19 2014 -0500 Committer: randgalt Committed: Tue Jul 22 16:05:19 2014 -0500 -- .../curator/framework/imps/TestReadOnly.java| 165 +-- 1 file changed, 115 insertions(+), 50 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/feb13e1c/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java -- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java index 537617c..d6d63f8 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java @@ -16,93 +16,158 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.framework.imps; -import org.apache.curator.utils.CloseableUtils; +import com.google.common.collect.Queues; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.curator.retry.RetryNTimes; +import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.InstanceSpec; import org.apache.curator.test.TestingCluster; import org.apache.curator.test.Timing; +import org.apache.curator.utils.CloseableUtils; import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.Iterator; +import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class TestReadOnly { -@Test -public void testReadOnly() throws Exception +@BeforeMethod +public void setup() { System.setProperty("readonlymode.enabled", "true"); +} + +@AfterMethod +public void tearDown() +{ +System.setProperty("readonlymode.enabled", "false"); +} + +@Test +public void testConnectionStateNewClient() throws Exception +{ +Timing timing = new Timing(); +TestingCluster cluster = new TestingCluster(3); +CuratorFramework client = null; try { -Timing timing = new Timing(); +cluster.start(); + +client = CuratorFrameworkFactory.newClient(cluster.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(100)); +client.start(); +client.checkExists().forPath("/"); +client.close(); +client = null; -CuratorFrameworkclient = null; -TestingCluster cluster = new TestingCluster(2); -try +System.out.println("killing 2 instances"); +Iterator iterator = cluster.getInstances().iterator(); +for ( int i = 0; i < 2; ++i ) { -cluster.start(); - -client = CuratorFrameworkFactory.builder() -.connectString(cluster.getConnectString()) -.canBeReadOnly(true) -.connectionTimeoutMs(timing.connection()) -.sessionTimeoutMs(timing.session()) -.retryPolicy(new ExponentialBackoffRetry(100, 3)) -.build(); -client.start(); - -client.create().forPath("/test"); - -final CountDownLatchreadOnlyLatch = new CountDownLatch(1); -final CountDownLatchreconnectedLatch = new CountDownLatch(1); -ConnectionStateListener listener = new ConnectionStateListener() +cluster.killServer(iterator.next()); +} + +System.out.println("reconnecting client"); +client = CuratorFrameworkFactory.builder() +.connectString(cluster.getConnectString()) +
[3/3] git commit: removed printlns
removed printlns Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5f5ee966 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5f5ee966 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5f5ee966 Branch: refs/heads/master Commit: 5f5ee966569064a8d75fd19f32cb7e7a2bd7b0e1 Parents: a86a667 Author: randgalt Authored: Tue Jul 22 17:46:19 2014 -0500 Committer: randgalt Committed: Tue Jul 22 17:46:19 2014 -0500 -- .../test/java/org/apache/curator/framework/imps/TestReadOnly.java | 3 --- 1 file changed, 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/5f5ee966/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java -- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java index d6d63f8..13ceec6 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java @@ -70,14 +70,12 @@ public class TestReadOnly client.close(); client = null; -System.out.println("killing 2 instances"); Iterator iterator = cluster.getInstances().iterator(); for ( int i = 0; i < 2; ++i ) { cluster.killServer(iterator.next()); } -System.out.println("reconnecting client"); client = CuratorFrameworkFactory.builder() .connectString(cluster.getConnectString()) .sessionTimeoutMs(timing.session()) @@ -100,7 +98,6 @@ public class TestReadOnly ); client.start(); -System.out.println("making api call"); client.checkExists().forPath("/"); ConnectionState state = states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
[2/3] git commit: Fix that causes CONNECT to be sent when the read/write connection is established. It can be argued that CONNECT should never be sent though. Discussing...
Fix that causes CONNECT to be sent when the read/write connection is established. It can be argued that CONNECT should never be sent though. Discussing... Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/a86a667b Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/a86a667b Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/a86a667b Branch: refs/heads/master Commit: a86a667bb1213fec26fbdb8354bdc01b9fe70396 Parents: feb13e1 Author: randgalt Authored: Tue Jul 22 16:07:13 2014 -0500 Committer: randgalt Committed: Tue Jul 22 16:07:13 2014 -0500 -- .../org/apache/curator/framework/state/ConnectionStateManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/a86a667b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java index 2a0cdd1..67ff13d 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionStateManager.java @@ -180,7 +180,7 @@ public class ConnectionStateManager implements Closeable currentConnectionState = newConnectionState; ConnectionState localState = newConnectionState; -boolean isNegativeMessage = ((newConnectionState == ConnectionState.LOST) || (newConnectionState == ConnectionState.SUSPENDED)); +boolean isNegativeMessage = ((newConnectionState == ConnectionState.LOST) || (newConnectionState == ConnectionState.SUSPENDED) || (newConnectionState == ConnectionState.READ_ONLY)); if ( !isNegativeMessage && initialConnectMessageSent.compareAndSet(false, true) ) { localState = ConnectionState.CONNECTED;
git commit: removed printlns
Repository: curator Updated Branches: refs/heads/CURATOR-123 a86a667bb -> 5f5ee9665 removed printlns Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5f5ee966 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5f5ee966 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5f5ee966 Branch: refs/heads/CURATOR-123 Commit: 5f5ee966569064a8d75fd19f32cb7e7a2bd7b0e1 Parents: a86a667 Author: randgalt Authored: Tue Jul 22 17:46:19 2014 -0500 Committer: randgalt Committed: Tue Jul 22 17:46:19 2014 -0500 -- .../test/java/org/apache/curator/framework/imps/TestReadOnly.java | 3 --- 1 file changed, 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/5f5ee966/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java -- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java index d6d63f8..13ceec6 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReadOnly.java @@ -70,14 +70,12 @@ public class TestReadOnly client.close(); client = null; -System.out.println("killing 2 instances"); Iterator iterator = cluster.getInstances().iterator(); for ( int i = 0; i < 2; ++i ) { cluster.killServer(iterator.next()); } -System.out.println("reconnecting client"); client = CuratorFrameworkFactory.builder() .connectString(cluster.getConnectString()) .sessionTimeoutMs(timing.session()) @@ -100,7 +98,6 @@ public class TestReadOnly ); client.start(); -System.out.println("making api call"); client.checkExists().forPath("/"); ConnectionState state = states.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS);
[3/3] git commit: Merge remote-tracking branch 'temp/CURATOR-124' into CURATOR-124
Merge remote-tracking branch 'temp/CURATOR-124' into CURATOR-124 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/27a0dc86 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/27a0dc86 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/27a0dc86 Branch: refs/heads/master Commit: 27a0dc86a8f12f68af68dec4286b5e3738b12d69 Parents: 5f5ee96 c71a5a7 Author: randgalt Authored: Wed Jul 23 17:31:49 2014 -0500 Committer: randgalt Committed: Wed Jul 23 17:31:49 2014 -0500 -- .../recipes/cache/PathChildrenCache.java| 15 ++--- .../recipes/cache/TestPathChildrenCache.java| 59 ++-- 2 files changed, 62 insertions(+), 12 deletions(-) --
[1/3] git commit: CURATOR-124 - PathChildrenCache StartMode doc
Repository: curator Updated Branches: refs/heads/master 5f5ee9665 -> 27a0dc86a CURATOR-124 - PathChildrenCache StartMode doc Updated PathChildrenCache.StartMode.NORMAL JavaDoc to accurately depict the cache startup behavior. Added test testChildrenInitializedNormal to assert the startup behavior indicated in the JavaDoc. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/e2eed559 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/e2eed559 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/e2eed559 Branch: refs/heads/master Commit: e2eed55985b1d5efbc74ca04afcdac28c8400fe6 Parents: 5df92bf Author: Patrick Peralta Authored: Tue Jul 22 13:23:43 2014 -0400 Committer: Patrick Peralta Committed: Tue Jul 22 13:23:43 2014 -0400 -- .../recipes/cache/PathChildrenCache.java| 15 ++--- .../recipes/cache/TestPathChildrenCache.java| 59 ++-- 2 files changed, 62 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/e2eed559/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java index ad433d8..18e008b 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java @@ -253,20 +253,21 @@ public class PathChildrenCache implements Closeable public enum StartMode { /** - * cache will _not_ be primed. i.e. it will start empty and you will receive - * events for all nodes added, etc. + * The cache will be primed (in the background) with initial values. + * Events for existing and new nodes will be posted. */ NORMAL, /** - * {@link PathChildrenCache#rebuild()} will be called before this method returns in - * order to get an initial view of the node. + * The cache will be primed (in the foreground) with initial values. + * {@link PathChildrenCache#rebuild()} will be called before this + * method returns in order to get an initial view of the node. */ BUILD_INITIAL_CACHE, /** * After cache is primed with initial values (in the background) a - * {@link PathChildrenCacheEvent.Type#INITIALIZED} will be posted + * {@link PathChildrenCacheEvent.Type#INITIALIZED} will be posted. */ POST_INITIALIZED_EVENT } @@ -767,9 +768,9 @@ public class PathChildrenCache implements Closeable //so just ignore these events if ( state.get() != State.CLOSED ) { -handleException(e); +handleException(e); } - + Thread.currentThread().interrupt(); } catch ( Exception e ) http://git-wip-us.apache.org/repos/asf/curator/blob/e2eed559/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java index 653a8b1..60f2e88 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java @@ -172,6 +172,55 @@ public class TestPathChildrenCache extends BaseClassForTests } @Test +public void testChildrenInitializedNormal() throws Exception +{ +Timing timing = new Timing(); +PathChildrenCache cache = null; +CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); +try +{ +client.start(); +client.create().forPath("/test"); + +cache = new PathChildrenCache(client, "/test", true); + +final CountDownLatch addedLatch = new CountDownLatch(3); +cache.getListenable().addListener +( +new PathChildrenCacheListener()
[2/3] git commit: Updated per review comments
Updated per review comments Updated BUILD_INITIAL_CACHE doc to indicate that the start() method with this mode will cause a synchronous rebuilding of the cache. Removed extra line. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/c71a5a7a Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/c71a5a7a Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/c71a5a7a Branch: refs/heads/master Commit: c71a5a7aacf64b2a639d7cbdef462dd2c4d50de9 Parents: e2eed55 Author: Patrick Peralta Authored: Wed Jul 23 15:06:49 2014 -0400 Committer: Patrick Peralta Committed: Wed Jul 23 15:06:49 2014 -0400 -- .../curator/framework/recipes/cache/PathChildrenCache.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/c71a5a7a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java index 18e008b..d08 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java @@ -260,8 +260,9 @@ public class PathChildrenCache implements Closeable /** * The cache will be primed (in the foreground) with initial values. - * {@link PathChildrenCache#rebuild()} will be called before this - * method returns in order to get an initial view of the node. + * {@link PathChildrenCache#rebuild()} will be called before + * the {@link PathChildrenCache#start(StartMode)} method returns + * in order to get an initial view of the node. */ BUILD_INITIAL_CACHE, @@ -770,7 +771,6 @@ public class PathChildrenCache implements Closeable { handleException(e); } - Thread.currentThread().interrupt(); } catch ( Exception e )
git commit: CURATOR-126: Fix race condition in CuratorFrameworkImpl.close()
Repository: curator Updated Branches: refs/heads/CURATOR-126 [created] 785e9f6c8 CURATOR-126: Fix race condition in CuratorFrameworkImpl.close() Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/785e9f6c Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/785e9f6c Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/785e9f6c Branch: refs/heads/CURATOR-126 Commit: 785e9f6c8a528d0c07652450471dcb71a5717776 Parents: 15a0aac Author: Scott Blum Authored: Mon Jul 28 14:10:37 2014 -0400 Committer: Scott Blum Committed: Mon Jul 28 17:13:17 2014 -0400 -- .../framework/CuratorFrameworkFactory.java | 17 +++ .../framework/imps/CuratorFrameworkImpl.java| 22 +++- 2 files changed, 34 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/785e9f6c/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 2d21fb7..8ef2580 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 @@ -52,6 +52,7 @@ public class CuratorFrameworkFactory private static final DefaultZookeeperFactoryDEFAULT_ZOOKEEPER_FACTORY = new DefaultZookeeperFactory(); private static final DefaultACLProvider DEFAULT_ACL_PROVIDER = new DefaultACLProvider(); private static final long DEFAULT_INACTIVE_THRESHOLD_MS = (int)TimeUnit.MINUTES.toMillis(3); +private static final intDEFAULT_CLOSE_WAIT_MS = (int)TimeUnit.SECONDS.toMillis(1); /** * Return a new builder that builds a CuratorFramework @@ -101,6 +102,7 @@ public class CuratorFrameworkFactory private EnsembleProviderensembleProvider; private int sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT_MS; private int connectionTimeoutMs = DEFAULT_CONNECTION_TIMEOUT_MS; +private int maxCloseWaitMs = DEFAULT_CLOSE_WAIT_MS; private RetryPolicy retryPolicy; private ThreadFactory threadFactory = null; private String namespace; @@ -239,6 +241,16 @@ public class CuratorFrameworkFactory } /** + * @param maxCloseWaitMs time to wait during close to join background threads + * @return this + */ +public Builder maxCloseWaitMs(int maxCloseWaitMs) +{ +this.maxCloseWaitMs = maxCloseWaitMs; +return this; +} + +/** * @param retryPolicy retry policy to use * @return this */ @@ -336,6 +348,11 @@ public class CuratorFrameworkFactory return connectionTimeoutMs; } +public int getMaxCloseWaitMs() +{ +return maxCloseWaitMs; +} + public RetryPolicy getRetryPolicy() { return retryPolicy; http://git-wip-us.apache.org/repos/asf/curator/blob/785e9f6c/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 23a3248..7f7cc98 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -63,6 +63,7 @@ public class CuratorFrameworkImpl implements CuratorFramework private final ListenerContainer listeners; private final ListenerContainer unhandledErrorListeners; private final ThreadFactory threadFactory; +private final int maxCloseWaitMs; private final BlockingQueue> backgroundOperations; private final NamespaceImpl namespace; private final ConnectionStateManager connectionStateManager; @@ -127,6 +128,7 @@ public class CuratorFrameworkImpl implements CuratorFramework backgroundOperations = new DelayQueue>(); namespace = new NamespaceImpl(this, builder.getNamespace()); threadFactory = getThreadFactory(builder); +maxCloseWaitMs = builder.getMaxCloseWaitMs(); connectionStateManager = new ConnectionStateManager(this, builder.getThreadFactory
git commit: Altered test to make it expose problem. Needed to add debugUnhandledErrorListener for this
Repository: curator Updated Branches: refs/heads/CURATOR-126 a8a3e1475 -> ccac7baac Altered test to make it expose problem. Needed to add debugUnhandledErrorListener for this Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/ccac7baa Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ccac7baa Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ccac7baa Branch: refs/heads/CURATOR-126 Commit: ccac7baac38b9fe3dc5b322639ea409f7fa0f2b6 Parents: a8a3e14 Author: randgalt Authored: Mon Jul 28 19:00:12 2014 -0500 Committer: randgalt Committed: Mon Jul 28 19:00:12 2014 -0500 -- .../framework/imps/CuratorFrameworkImpl.java| 8 +- .../framework/imps/TestFrameworkBackground.java | 111 --- 2 files changed, 53 insertions(+), 66 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/ccac7baa/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 7f7cc98..01cacee 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -57,7 +57,6 @@ import java.util.concurrent.atomic.AtomicReference; public class CuratorFrameworkImpl implements CuratorFramework { - private final Logger log = LoggerFactory.getLogger(getClass()); private final CuratorZookeeperClient client; private final ListenerContainer listeners; @@ -86,6 +85,7 @@ public class CuratorFrameworkImpl implements CuratorFramework } volatile DebugBackgroundListener debugListener = null; +volatile UnhandledErrorListener debugUnhandledErrorListener = null; private final AtomicReference state; @@ -313,6 +313,7 @@ public class CuratorFrameworkImpl implements CuratorFramework Thread.currentThread().interrupt(); } } + listeners.clear(); unhandledErrorListeners.clear(); connectionStateManager.close(); @@ -566,6 +567,11 @@ public class CuratorFrameworkImpl implements CuratorFramework return null; } }); + +if ( debugUnhandledErrorListener != null ) +{ +debugUnhandledErrorListener.unhandledError(reason, e); +} } String unfixForNamespace(String path) http://git-wip-us.apache.org/repos/asf/curator/blob/ccac7baa/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java -- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java index f9fea4f..3f1c41f 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java @@ -20,30 +20,26 @@ package org.apache.curator.framework.imps; import com.google.common.collect.Lists; - -import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.utils.CloseableUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.api.BackgroundCallback; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.framework.api.UnhandledErrorListener; -import org.apache.curator.framework.imps.OperationAndData.ErrorCallback; import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.RetryNTimes; import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.BaseClassForTests; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; +import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.KeeperException.Code; import org.testng.Assert; import org.testng.annotations.Test; - import java.util.Arrays; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -68,7 +64,8 @@ public cl
[1/3] git commit: CURATOR-126: Fix race condition in CuratorFrameworkImpl.close()
Repository: curator Updated Branches: refs/heads/master 15a0aacec -> ccac7baac CURATOR-126: Fix race condition in CuratorFrameworkImpl.close() Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/785e9f6c Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/785e9f6c Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/785e9f6c Branch: refs/heads/master Commit: 785e9f6c8a528d0c07652450471dcb71a5717776 Parents: 15a0aac Author: Scott Blum Authored: Mon Jul 28 14:10:37 2014 -0400 Committer: Scott Blum Committed: Mon Jul 28 17:13:17 2014 -0400 -- .../framework/CuratorFrameworkFactory.java | 17 +++ .../framework/imps/CuratorFrameworkImpl.java| 22 +++- 2 files changed, 34 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/785e9f6c/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 2d21fb7..8ef2580 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 @@ -52,6 +52,7 @@ public class CuratorFrameworkFactory private static final DefaultZookeeperFactoryDEFAULT_ZOOKEEPER_FACTORY = new DefaultZookeeperFactory(); private static final DefaultACLProvider DEFAULT_ACL_PROVIDER = new DefaultACLProvider(); private static final long DEFAULT_INACTIVE_THRESHOLD_MS = (int)TimeUnit.MINUTES.toMillis(3); +private static final intDEFAULT_CLOSE_WAIT_MS = (int)TimeUnit.SECONDS.toMillis(1); /** * Return a new builder that builds a CuratorFramework @@ -101,6 +102,7 @@ public class CuratorFrameworkFactory private EnsembleProviderensembleProvider; private int sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT_MS; private int connectionTimeoutMs = DEFAULT_CONNECTION_TIMEOUT_MS; +private int maxCloseWaitMs = DEFAULT_CLOSE_WAIT_MS; private RetryPolicy retryPolicy; private ThreadFactory threadFactory = null; private String namespace; @@ -239,6 +241,16 @@ public class CuratorFrameworkFactory } /** + * @param maxCloseWaitMs time to wait during close to join background threads + * @return this + */ +public Builder maxCloseWaitMs(int maxCloseWaitMs) +{ +this.maxCloseWaitMs = maxCloseWaitMs; +return this; +} + +/** * @param retryPolicy retry policy to use * @return this */ @@ -336,6 +348,11 @@ public class CuratorFrameworkFactory return connectionTimeoutMs; } +public int getMaxCloseWaitMs() +{ +return maxCloseWaitMs; +} + public RetryPolicy getRetryPolicy() { return retryPolicy; http://git-wip-us.apache.org/repos/asf/curator/blob/785e9f6c/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 23a3248..7f7cc98 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -63,6 +63,7 @@ public class CuratorFrameworkImpl implements CuratorFramework private final ListenerContainer listeners; private final ListenerContainer unhandledErrorListeners; private final ThreadFactory threadFactory; +private final int maxCloseWaitMs; private final BlockingQueue> backgroundOperations; private final NamespaceImpl namespace; private final ConnectionStateManager connectionStateManager; @@ -127,6 +128,7 @@ public class CuratorFrameworkImpl implements CuratorFramework backgroundOperations = new DelayQueue>(); namespace = new NamespaceImpl(this, builder.getNamespace()); threadFactory = getThreadFactory(builder); +maxCloseWaitMs = builder.getMaxCloseWaitMs(); connectionStateManager = new ConnectionStateManager(this, builder.getThreadFactory());
[3/3] git commit: Altered test to make it expose problem. Needed to add debugUnhandledErrorListener for this
Altered test to make it expose problem. Needed to add debugUnhandledErrorListener for this Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/ccac7baa Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ccac7baa Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ccac7baa Branch: refs/heads/master Commit: ccac7baac38b9fe3dc5b322639ea409f7fa0f2b6 Parents: a8a3e14 Author: randgalt Authored: Mon Jul 28 19:00:12 2014 -0500 Committer: randgalt Committed: Mon Jul 28 19:00:12 2014 -0500 -- .../framework/imps/CuratorFrameworkImpl.java| 8 +- .../framework/imps/TestFrameworkBackground.java | 111 --- 2 files changed, 53 insertions(+), 66 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/ccac7baa/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 7f7cc98..01cacee 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -57,7 +57,6 @@ import java.util.concurrent.atomic.AtomicReference; public class CuratorFrameworkImpl implements CuratorFramework { - private final Logger log = LoggerFactory.getLogger(getClass()); private final CuratorZookeeperClient client; private final ListenerContainer listeners; @@ -86,6 +85,7 @@ public class CuratorFrameworkImpl implements CuratorFramework } volatile DebugBackgroundListener debugListener = null; +volatile UnhandledErrorListener debugUnhandledErrorListener = null; private final AtomicReference state; @@ -313,6 +313,7 @@ public class CuratorFrameworkImpl implements CuratorFramework Thread.currentThread().interrupt(); } } + listeners.clear(); unhandledErrorListeners.clear(); connectionStateManager.close(); @@ -566,6 +567,11 @@ public class CuratorFrameworkImpl implements CuratorFramework return null; } }); + +if ( debugUnhandledErrorListener != null ) +{ +debugUnhandledErrorListener.unhandledError(reason, e); +} } String unfixForNamespace(String path) http://git-wip-us.apache.org/repos/asf/curator/blob/ccac7baa/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java -- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java index f9fea4f..3f1c41f 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java @@ -20,30 +20,26 @@ package org.apache.curator.framework.imps; import com.google.common.collect.Lists; - -import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.utils.CloseableUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.api.BackgroundCallback; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.framework.api.UnhandledErrorListener; -import org.apache.curator.framework.imps.OperationAndData.ErrorCallback; import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.RetryNTimes; import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.BaseClassForTests; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; +import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.KeeperException.Code; import org.testng.Assert; import org.testng.annotations.Test; - import java.util.Arrays; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -68,7 +64,8 @@ public class TestFrameworkBackground extends BaseClassForTests @Override public void
[2/3] git commit: CURATOR-126 - Added a unit test to reproduce this case.
CURATOR-126 - Added a unit test to reproduce this case. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/a8a3e147 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/a8a3e147 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/a8a3e147 Branch: refs/heads/master Commit: a8a3e14755ea69aaa186a40e67173ad7b686d9e3 Parents: 785e9f6 Author: Cameron McKenzie Authored: Tue Jul 29 09:28:14 2014 +1000 Committer: Cameron McKenzie Committed: Tue Jul 29 09:28:14 2014 +1000 -- .../framework/imps/TestFrameworkBackground.java | 86 1 file changed, 86 insertions(+) -- http://git-wip-us.apache.org/repos/asf/curator/blob/a8a3e147/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java -- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java index 44792d9..f9fea4f 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java @@ -20,12 +20,15 @@ package org.apache.curator.framework.imps; import com.google.common.collect.Lists; + import org.apache.curator.test.BaseClassForTests; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.api.BackgroundCallback; import org.apache.curator.framework.api.CuratorEvent; +import org.apache.curator.framework.api.UnhandledErrorListener; +import org.apache.curator.framework.imps.OperationAndData.ErrorCallback; import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.RetryNTimes; @@ -35,10 +38,12 @@ import org.apache.curator.test.Timing; import org.apache.zookeeper.KeeperException.Code; import org.testng.Assert; import org.testng.annotations.Test; + import java.util.Arrays; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -215,4 +220,85 @@ public class TestFrameworkBackground extends BaseClassForTests } } + +/** + * CURATOR-126 + * Shutdown the Curator client while there are still background operations running. + */ +@Test +public void testShutdown() throws Exception +{ +final int MAX_CLOSE_WAIT_MS = 5000; +Timing timing = new Timing(); +CuratorFramework client = CuratorFrameworkFactory.builder().connectString(server.getConnectString()).sessionTimeoutMs(timing.session()). +connectionTimeoutMs(timing.connection()).retryPolicy(new RetryOneTime(1)).maxCloseWaitMs(MAX_CLOSE_WAIT_MS).build(); +try +{ +client.start(); + +BackgroundCallback callback = new BackgroundCallback() +{ +@Override +public void processResult(CuratorFramework client, CuratorEvent event) throws Exception +{ +} +}; + +final CountDownLatch operationReadyLatch = new CountDownLatch(1); + +//This gets called just before the operation is run. +((CuratorFrameworkImpl)client).debugListener = new CuratorFrameworkImpl.DebugBackgroundListener() +{ +@Override +public void listen(OperationAndData data) +{ +operationReadyLatch.countDown(); + +try { +Thread.sleep(MAX_CLOSE_WAIT_MS / 2); +} catch(InterruptedException e) { +} +} +}; + + Assert.assertTrue(client.getZookeeperClient().blockUntilConnectedOrTimedOut(), "Failed to connect"); + +server.stop(); + +BackgroundOperation background = new BackgroundOperation() +{ + +@Override +public void performBackgroundOperation(OperationAndData data) +throws Exception +{ +} +}; + +ErrorCallback errorCallback = new ErrorCallback() +{ + +@Override
[1/2] git commit: Closes #23
Repository: curator Updated Branches: refs/heads/master ccac7baac -> 9c0a61700 Closes #23 Altered test to make it expose problem. Needed to add debugUnhandledErrorListener for this Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/537801c2 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/537801c2 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/537801c2 Branch: refs/heads/master Commit: 537801c2f8a03fd7a4ad07e3a11994c7f669d2d7 Parents: a8a3e14 Author: randgalt Authored: Mon Jul 28 19:00:12 2014 -0500 Committer: randgalt Committed: Mon Jul 28 19:56:22 2014 -0500 -- .../framework/imps/CuratorFrameworkImpl.java| 8 +- .../framework/imps/TestFrameworkBackground.java | 111 --- 2 files changed, 53 insertions(+), 66 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/537801c2/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index 7f7cc98..01cacee 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -57,7 +57,6 @@ import java.util.concurrent.atomic.AtomicReference; public class CuratorFrameworkImpl implements CuratorFramework { - private final Logger log = LoggerFactory.getLogger(getClass()); private final CuratorZookeeperClient client; private final ListenerContainer listeners; @@ -86,6 +85,7 @@ public class CuratorFrameworkImpl implements CuratorFramework } volatile DebugBackgroundListener debugListener = null; +volatile UnhandledErrorListener debugUnhandledErrorListener = null; private final AtomicReference state; @@ -313,6 +313,7 @@ public class CuratorFrameworkImpl implements CuratorFramework Thread.currentThread().interrupt(); } } + listeners.clear(); unhandledErrorListeners.clear(); connectionStateManager.close(); @@ -566,6 +567,11 @@ public class CuratorFrameworkImpl implements CuratorFramework return null; } }); + +if ( debugUnhandledErrorListener != null ) +{ +debugUnhandledErrorListener.unhandledError(reason, e); +} } String unfixForNamespace(String path) http://git-wip-us.apache.org/repos/asf/curator/blob/537801c2/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java -- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java index f9fea4f..3f1c41f 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkBackground.java @@ -20,30 +20,26 @@ package org.apache.curator.framework.imps; import com.google.common.collect.Lists; - -import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.utils.CloseableUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.api.BackgroundCallback; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.framework.api.UnhandledErrorListener; -import org.apache.curator.framework.imps.OperationAndData.ErrorCallback; import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.RetryNTimes; import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.BaseClassForTests; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; +import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.KeeperException.Code; import org.testng.Assert; import org.testng.annotations.Test; - import java.util.Arrays; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -68,7 +64,8 @@ public cl
[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/curator
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/curator Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/9c0a6170 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/9c0a6170 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/9c0a6170 Branch: refs/heads/master Commit: 9c0a61700768439f4c622442c1bb6f7aab20f7f8 Parents: 537801c ccac7ba Author: randgalt Authored: Mon Jul 28 19:56:52 2014 -0500 Committer: randgalt Committed: Mon Jul 28 19:56:52 2014 -0500 -- --
[2/3] git commit: Merge remote-tracking branch 'temp/CURATOR-128' into CURATOR-128
Merge remote-tracking branch 'temp/CURATOR-128' into CURATOR-128 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/8699efc3 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8699efc3 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8699efc3 Branch: refs/heads/CURATOR-128 Commit: 8699efc39e7d3b7d0081eeb485e8f731e43d40b7 Parents: 3a563ac 96d2a55 Author: randgalt Authored: Wed Jul 30 11:42:23 2014 -0500 Committer: randgalt Committed: Wed Jul 30 11:42:23 2014 -0500 -- .../java/org/apache/curator/utils/ZKPaths.java | 35 ++ .../org/apache/curator/utils/TestZKPaths.java | 50 .../framework/imps/TestNamespaceFacade.java | 44 - 3 files changed, 120 insertions(+), 9 deletions(-) --
[1/3] git commit: CURATOR-128: access root in a namespace; ZKPaths.makePath lenient.
Repository: curator Updated Branches: refs/heads/CURATOR-128 [created] bd319a92c CURATOR-128: access root in a namespace; ZKPaths.makePath lenient. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/96d2a55a Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/96d2a55a Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/96d2a55a Branch: refs/heads/CURATOR-128 Commit: 96d2a55a03f8d0357f8f8cfa80a39a095d70667c Parents: b174dfb Author: Scott Blum Authored: Tue Jul 29 20:17:11 2014 -0400 Committer: Scott Blum Committed: Tue Jul 29 21:08:02 2014 -0400 -- .../java/org/apache/curator/utils/ZKPaths.java | 35 ++ .../org/apache/curator/utils/TestZKPaths.java | 50 .../framework/imps/TestNamespaceFacade.java | 44 - 3 files changed, 120 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/96d2a55a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index 04b2141..dfc69a7 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -38,6 +38,9 @@ public class ZKPaths */ public static StringfixForNamespace(String namespace, String path) { +// Child path must be valid in and of itself. +PathUtils.validatePath(path); + if ( namespace != null ) { return makePath(namespace, path); @@ -268,21 +271,37 @@ public class ZKPaths { StringBuilder path = new StringBuilder(); -if ( !parent.startsWith("/") ) +// Add parent piece, with no trailing slash. +if ( parent != null && parent.length() > 0) { -path.append("/"); +if ( !parent.startsWith("/") ) +{ +path.append('/'); +} +if ( parent.endsWith("/") ) +{ +path.append(parent.substring(0, parent.length() - 1)); +} +else +{ +path.append(parent); +} } -path.append(parent); -if ( (child == null) || (child.length() == 0) ) + +if ( (child == null) || (child.length() == 0) || (child.equals("/")) ) { +// Special case, empty parent and child +if ( path.length() == 0 ) +{ +return "/"; +} return path.toString(); } -if ( !parent.endsWith("/") ) -{ -path.append("/"); -} +// Now add the separator between parent and child. +path.append('/'); +// Finally, add the child. if ( child.startsWith("/") ) { path.append(child.substring(1)); http://git-wip-us.apache.org/repos/asf/curator/blob/96d2a55a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java -- diff --git a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java new file mode 100644 index 000..f757984 --- /dev/null +++ b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java @@ -0,0 +1,50 @@ +/** + * 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.utils; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class TestZKPaths +{ +@Test +public void testMakePath() +{ +Assert.assertEquals(ZKPaths.makePath("/", "/"), "/"); +Assert.assertEquals(ZKPaths.makePath("", "/"), "/"); +Assert.assertEquals(ZKPaths.makePath("/", ""), "/"); +Assert.assertEquals(ZKPaths.makePath("", ""
[3/3] git commit: some reformatting and added tests with nulls
some reformatting and added tests with nulls Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/bd319a92 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/bd319a92 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/bd319a92 Branch: refs/heads/CURATOR-128 Commit: bd319a92cfc4c714f5dd48730f0fdf685e03445e Parents: 8699efc Author: randgalt Authored: Wed Jul 30 11:49:42 2014 -0500 Committer: randgalt Committed: Wed Jul 30 11:49:42 2014 -0500 -- .../java/org/apache/curator/utils/ZKPaths.java | 87 ++-- .../org/apache/curator/utils/TestZKPaths.java | 15 2 files changed, 59 insertions(+), 43 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/bd319a92/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index dfc69a7..820f45f 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.utils; import com.google.common.collect.Lists; @@ -33,10 +34,10 @@ public class ZKPaths * Apply the namespace to the given path * * @param namespace namespace (can be null) - * @param path path + * @param path path * @return adjusted path */ -public static StringfixForNamespace(String namespace, String path) +public static String fixForNamespace(String namespace, String path) { // Child path must be valid in and of itself. PathUtils.validatePath(path); @@ -50,7 +51,7 @@ public class ZKPaths /** * Given a full path, return the node name. i.e. "/one/two/three" will return "three" - * + * * @param path the path * @return the node */ @@ -62,7 +63,7 @@ public class ZKPaths { return path; } -if ( (i + 1) >= path.length() ) +if ( (i + 1) >= path.length() ) { return ""; } @@ -71,8 +72,8 @@ public class ZKPaths public static class PathAndNode { -private final Stringpath; -private final Stringnode; +private final String path; +private final String node; public PathAndNode(String path, String node) { @@ -105,7 +106,7 @@ public class ZKPaths { return new PathAndNode(path, ""); } -if ( (i + 1) >= path.length() ) +if ( (i + 1) >= path.length() ) { return new PathAndNode("/", ""); } @@ -120,12 +121,10 @@ public class ZKPaths * * @param zookeeper the client * @param path path to ensure - * @throws InterruptedException thread interruption - * @throws org.apache.zookeeper.KeeperException - * Zookeeper errors + * @throws InterruptedException thread interruption + * @throws org.apache.zookeeper.KeeperException Zookeeper errors */ -public static void mkdirs(ZooKeeper zookeeper, String path) -throws InterruptedException, KeeperException +public static void mkdirs(ZooKeeper zookeeper, String path) throws InterruptedException, KeeperException { mkdirs(zookeeper, path, true, null); } @@ -134,15 +133,13 @@ public class ZKPaths * Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish * between directories and files. So, every node in the path is created. The data for each node is an empty blob * - * @param zookeeper the client - * @param path path to ensure + * @param zookeeperthe client + * @param path path to ensure * @param makeLastNode if true, all nodes are created. If false, only the parent nodes are created - * @throws InterruptedException thread interruption - * @throws org.apache.zookeeper.KeeperException - * Zookeeper errors + * @throws InterruptedException thread interruption + * @throws org.apache.zookeeper.KeeperException Zookeeper errors */ -public static void mkdirs(ZooKeeper zookeeper, String path, boolean makeLastNode) -throws InterruptedException, KeeperException +public static void mkdirs(ZooKeeper zookeeper, String path, boolean makeLastNode) throws InterruptedEx
[3/3] git commit: some reformatting and added tests with nulls
some reformatting and added tests with nulls Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/bd319a92 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/bd319a92 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/bd319a92 Branch: refs/heads/master Commit: bd319a92cfc4c714f5dd48730f0fdf685e03445e Parents: 8699efc Author: randgalt Authored: Wed Jul 30 11:49:42 2014 -0500 Committer: randgalt Committed: Wed Jul 30 11:49:42 2014 -0500 -- .../java/org/apache/curator/utils/ZKPaths.java | 87 ++-- .../org/apache/curator/utils/TestZKPaths.java | 15 2 files changed, 59 insertions(+), 43 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/bd319a92/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index dfc69a7..820f45f 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.utils; import com.google.common.collect.Lists; @@ -33,10 +34,10 @@ public class ZKPaths * Apply the namespace to the given path * * @param namespace namespace (can be null) - * @param path path + * @param path path * @return adjusted path */ -public static StringfixForNamespace(String namespace, String path) +public static String fixForNamespace(String namespace, String path) { // Child path must be valid in and of itself. PathUtils.validatePath(path); @@ -50,7 +51,7 @@ public class ZKPaths /** * Given a full path, return the node name. i.e. "/one/two/three" will return "three" - * + * * @param path the path * @return the node */ @@ -62,7 +63,7 @@ public class ZKPaths { return path; } -if ( (i + 1) >= path.length() ) +if ( (i + 1) >= path.length() ) { return ""; } @@ -71,8 +72,8 @@ public class ZKPaths public static class PathAndNode { -private final Stringpath; -private final Stringnode; +private final String path; +private final String node; public PathAndNode(String path, String node) { @@ -105,7 +106,7 @@ public class ZKPaths { return new PathAndNode(path, ""); } -if ( (i + 1) >= path.length() ) +if ( (i + 1) >= path.length() ) { return new PathAndNode("/", ""); } @@ -120,12 +121,10 @@ public class ZKPaths * * @param zookeeper the client * @param path path to ensure - * @throws InterruptedException thread interruption - * @throws org.apache.zookeeper.KeeperException - * Zookeeper errors + * @throws InterruptedException thread interruption + * @throws org.apache.zookeeper.KeeperException Zookeeper errors */ -public static void mkdirs(ZooKeeper zookeeper, String path) -throws InterruptedException, KeeperException +public static void mkdirs(ZooKeeper zookeeper, String path) throws InterruptedException, KeeperException { mkdirs(zookeeper, path, true, null); } @@ -134,15 +133,13 @@ public class ZKPaths * Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish * between directories and files. So, every node in the path is created. The data for each node is an empty blob * - * @param zookeeper the client - * @param path path to ensure + * @param zookeeperthe client + * @param path path to ensure * @param makeLastNode if true, all nodes are created. If false, only the parent nodes are created - * @throws InterruptedException thread interruption - * @throws org.apache.zookeeper.KeeperException - * Zookeeper errors + * @throws InterruptedException thread interruption + * @throws org.apache.zookeeper.KeeperException Zookeeper errors */ -public static void mkdirs(ZooKeeper zookeeper, String path, boolean makeLastNode) -throws InterruptedException, KeeperException +public static void mkdirs(ZooKeeper zookeeper, String path, boolean makeLastNode) throws InterruptedExceptio
[1/3] git commit: CURATOR-128: access root in a namespace; ZKPaths.makePath lenient.
Repository: curator Updated Branches: refs/heads/master 3a563acd2 -> bd319a92c CURATOR-128: access root in a namespace; ZKPaths.makePath lenient. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/96d2a55a Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/96d2a55a Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/96d2a55a Branch: refs/heads/master Commit: 96d2a55a03f8d0357f8f8cfa80a39a095d70667c Parents: b174dfb Author: Scott Blum Authored: Tue Jul 29 20:17:11 2014 -0400 Committer: Scott Blum Committed: Tue Jul 29 21:08:02 2014 -0400 -- .../java/org/apache/curator/utils/ZKPaths.java | 35 ++ .../org/apache/curator/utils/TestZKPaths.java | 50 .../framework/imps/TestNamespaceFacade.java | 44 - 3 files changed, 120 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/96d2a55a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index 04b2141..dfc69a7 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -38,6 +38,9 @@ public class ZKPaths */ public static StringfixForNamespace(String namespace, String path) { +// Child path must be valid in and of itself. +PathUtils.validatePath(path); + if ( namespace != null ) { return makePath(namespace, path); @@ -268,21 +271,37 @@ public class ZKPaths { StringBuilder path = new StringBuilder(); -if ( !parent.startsWith("/") ) +// Add parent piece, with no trailing slash. +if ( parent != null && parent.length() > 0) { -path.append("/"); +if ( !parent.startsWith("/") ) +{ +path.append('/'); +} +if ( parent.endsWith("/") ) +{ +path.append(parent.substring(0, parent.length() - 1)); +} +else +{ +path.append(parent); +} } -path.append(parent); -if ( (child == null) || (child.length() == 0) ) + +if ( (child == null) || (child.length() == 0) || (child.equals("/")) ) { +// Special case, empty parent and child +if ( path.length() == 0 ) +{ +return "/"; +} return path.toString(); } -if ( !parent.endsWith("/") ) -{ -path.append("/"); -} +// Now add the separator between parent and child. +path.append('/'); +// Finally, add the child. if ( child.startsWith("/") ) { path.append(child.substring(1)); http://git-wip-us.apache.org/repos/asf/curator/blob/96d2a55a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java -- diff --git a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java new file mode 100644 index 000..f757984 --- /dev/null +++ b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java @@ -0,0 +1,50 @@ +/** + * 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.utils; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class TestZKPaths +{ +@Test +public void testMakePath() +{ +Assert.assertEquals(ZKPaths.makePath("/", "/"), "/"); +Assert.assertEquals(ZKPaths.makePath("", "/"), "/"); +Assert.assertEquals(ZKPaths.makePath("/", ""), "/"); +Assert.assertEquals(ZKPaths.makePath("", ""), "/")
[1/2] git commit: Closes #25
Repository: curator Updated Branches: refs/heads/master bd319a92c -> 10bd72c51 Closes #25 some reformatting and added tests with nulls Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/49c20982 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/49c20982 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/49c20982 Branch: refs/heads/master Commit: 49c20982a32399d55b8ff29f5ef6e6f5fd5995f5 Parents: 8699efc Author: randgalt Authored: Wed Jul 30 11:49:42 2014 -0500 Committer: randgalt Committed: Wed Jul 30 12:28:48 2014 -0500 -- .../java/org/apache/curator/utils/ZKPaths.java | 87 ++-- .../org/apache/curator/utils/TestZKPaths.java | 15 2 files changed, 59 insertions(+), 43 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/49c20982/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index dfc69a7..820f45f 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.utils; import com.google.common.collect.Lists; @@ -33,10 +34,10 @@ public class ZKPaths * Apply the namespace to the given path * * @param namespace namespace (can be null) - * @param path path + * @param path path * @return adjusted path */ -public static StringfixForNamespace(String namespace, String path) +public static String fixForNamespace(String namespace, String path) { // Child path must be valid in and of itself. PathUtils.validatePath(path); @@ -50,7 +51,7 @@ public class ZKPaths /** * Given a full path, return the node name. i.e. "/one/two/three" will return "three" - * + * * @param path the path * @return the node */ @@ -62,7 +63,7 @@ public class ZKPaths { return path; } -if ( (i + 1) >= path.length() ) +if ( (i + 1) >= path.length() ) { return ""; } @@ -71,8 +72,8 @@ public class ZKPaths public static class PathAndNode { -private final Stringpath; -private final Stringnode; +private final String path; +private final String node; public PathAndNode(String path, String node) { @@ -105,7 +106,7 @@ public class ZKPaths { return new PathAndNode(path, ""); } -if ( (i + 1) >= path.length() ) +if ( (i + 1) >= path.length() ) { return new PathAndNode("/", ""); } @@ -120,12 +121,10 @@ public class ZKPaths * * @param zookeeper the client * @param path path to ensure - * @throws InterruptedException thread interruption - * @throws org.apache.zookeeper.KeeperException - * Zookeeper errors + * @throws InterruptedException thread interruption + * @throws org.apache.zookeeper.KeeperException Zookeeper errors */ -public static void mkdirs(ZooKeeper zookeeper, String path) -throws InterruptedException, KeeperException +public static void mkdirs(ZooKeeper zookeeper, String path) throws InterruptedException, KeeperException { mkdirs(zookeeper, path, true, null); } @@ -134,15 +133,13 @@ public class ZKPaths * Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish * between directories and files. So, every node in the path is created. The data for each node is an empty blob * - * @param zookeeper the client - * @param path path to ensure + * @param zookeeperthe client + * @param path path to ensure * @param makeLastNode if true, all nodes are created. If false, only the parent nodes are created - * @throws InterruptedException thread interruption - * @throws org.apache.zookeeper.KeeperException - * Zookeeper errors + * @throws InterruptedException thread interruption + * @throws org.apache.zookeeper.KeeperException Zookeeper errors */ -public static void mkdirs(ZooKeeper zookeeper, String path, boolean makeLastNode) -throws InterruptedException, KeeperException +public st
[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/curator
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/curator Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/10bd72c5 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/10bd72c5 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/10bd72c5 Branch: refs/heads/master Commit: 10bd72c510edff5f065bab6cd969ef0e6132ac85 Parents: 49c2098 bd319a9 Author: randgalt Authored: Wed Jul 30 12:29:07 2014 -0500 Committer: randgalt Committed: Wed Jul 30 12:29:07 2014 -0500 -- --
[2/3] git commit: Merge remote-tracking branch 'temp/CURATOR-128' into CURATOR-128
Merge remote-tracking branch 'temp/CURATOR-128' into CURATOR-128 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/8699efc3 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8699efc3 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8699efc3 Branch: refs/heads/master Commit: 8699efc39e7d3b7d0081eeb485e8f731e43d40b7 Parents: 3a563ac 96d2a55 Author: randgalt Authored: Wed Jul 30 11:42:23 2014 -0500 Committer: randgalt Committed: Wed Jul 30 11:42:23 2014 -0500 -- .../java/org/apache/curator/utils/ZKPaths.java | 35 ++ .../org/apache/curator/utils/TestZKPaths.java | 50 .../framework/imps/TestNamespaceFacade.java | 44 - 3 files changed, 120 insertions(+), 9 deletions(-) --
[2/2] git commit: Merge remote-tracking branch 'temp/CURATOR-6' into CURATOR-6
Merge remote-tracking branch 'temp/CURATOR-6' into CURATOR-6 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b3100765 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b3100765 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b3100765 Branch: refs/heads/CURATOR-6 Commit: b310076585f268693af485bc1a9d3a7d08719951 Parents: 10bd72c aacdda3 Author: randgalt Authored: Wed Jul 30 15:03:06 2014 -0500 Committer: randgalt Committed: Wed Jul 30 15:03:06 2014 -0500 -- .../java/org/apache/curator/framework/state/ConnectionState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --
[2/2] git commit: Merge remote-tracking branch 'temp/CURATOR-6' into CURATOR-6
Merge remote-tracking branch 'temp/CURATOR-6' into CURATOR-6 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b3100765 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b3100765 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b3100765 Branch: refs/heads/master Commit: b310076585f268693af485bc1a9d3a7d08719951 Parents: 10bd72c aacdda3 Author: randgalt Authored: Wed Jul 30 15:03:06 2014 -0500 Committer: randgalt Committed: Wed Jul 30 15:03:06 2014 -0500 -- .../java/org/apache/curator/framework/state/ConnectionState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --
[1/2] git commit: CURATOR-6 Add javadoc for ConenctionState
Repository: curator Updated Branches: refs/heads/CURATOR-6 [created] b31007658 CURATOR-6 Add javadoc for ConenctionState Add possibility to go LOST -> RECONNECTED to ConnectionState JavaDoc Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/aacdda3e Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/aacdda3e Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/aacdda3e Branch: refs/heads/CURATOR-6 Commit: aacdda3e155b70016f26c14bff01bfb329b14b2b Parents: 3a563ac Author: Mike Drob Authored: Wed Jul 30 11:55:12 2014 -0500 Committer: Mike Drob Committed: Wed Jul 30 11:55:12 2014 -0500 -- .../java/org/apache/curator/framework/state/ConnectionState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/aacdda3e/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java index 2e08b34..3ca1d66 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java @@ -51,7 +51,7 @@ public enum ConnectionState }, /** - * A suspended or read-only connection has been re-established + * A suspended, lost, or read-only connection has been re-established */ RECONNECTED {
[1/2] git commit: CURATOR-6 Add javadoc for ConenctionState
Repository: curator Updated Branches: refs/heads/master 10bd72c51 -> b31007658 CURATOR-6 Add javadoc for ConenctionState Add possibility to go LOST -> RECONNECTED to ConnectionState JavaDoc Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/aacdda3e Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/aacdda3e Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/aacdda3e Branch: refs/heads/master Commit: aacdda3e155b70016f26c14bff01bfb329b14b2b Parents: 3a563ac Author: Mike Drob Authored: Wed Jul 30 11:55:12 2014 -0500 Committer: Mike Drob Committed: Wed Jul 30 11:55:12 2014 -0500 -- .../java/org/apache/curator/framework/state/ConnectionState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/aacdda3e/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java index 2e08b34..3ca1d66 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java @@ -51,7 +51,7 @@ public enum ConnectionState }, /** - * A suspended or read-only connection has been re-established + * A suspended, lost, or read-only connection has been re-established */ RECONNECTED {
[2/2] git commit: removed patch file
removed patch file Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/2aea22a8 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/2aea22a8 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/2aea22a8 Branch: refs/heads/CURATOR-33 Commit: 2aea22a835b6bb2bef129e0669fb77ceef2ffa47 Parents: 03bc3be Author: randgalt Authored: Wed Jul 30 20:27:31 2014 -0500 Committer: randgalt Committed: Wed Jul 30 20:27:31 2014 -0500 -- CURATOR-33.patch | 2664 - 1 file changed, 2664 deletions(-) --
[1/2] removed patch file
Repository: curator Updated Branches: refs/heads/CURATOR-33 03bc3bee0 -> 2aea22a83 http://git-wip-us.apache.org/repos/asf/curator/blob/2aea22a8/CURATOR-33.patch -- diff --git a/CURATOR-33.patch b/CURATOR-33.patch deleted file mode 100644 index dbcb9d4..000 --- a/CURATOR-33.patch +++ /dev/null @@ -1,2664 +0,0 @@ -diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java -index d66f7f3..03b169e 100644 a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java -+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java -@@ -1,32 +1,28 @@ - /** -- * 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. -+ * 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.cache; - --import com.google.common.annotations.VisibleForTesting; --import com.google.common.base.Function; --import com.google.common.base.Preconditions; --import com.google.common.base.Predicate; --import com.google.common.collect.ImmutableList; --import com.google.common.collect.Lists; --import com.google.common.collect.Maps; --import com.google.common.collect.Sets; -+import java.io.Closeable; -+import java.io.IOException; -+import java.util.List; -+import java.util.Map; -+import java.util.Set; -+import java.util.concurrent.ConcurrentMap; -+import java.util.concurrent.Exchanger; -+import java.util.concurrent.ExecutorService; -+import java.util.concurrent.Executors; -+import java.util.concurrent.ThreadFactory; -+import java.util.concurrent.atomic.AtomicReference; -+ - import org.apache.curator.framework.CuratorFramework; - import org.apache.curator.framework.api.BackgroundCallback; - import org.apache.curator.framework.api.CuratorEvent; -@@ -43,79 +39,71 @@ import org.apache.zookeeper.Watcher; - import org.apache.zookeeper.data.Stat; - import org.slf4j.Logger; - import org.slf4j.LoggerFactory; --import java.io.Closeable; --import java.io.IOException; --import java.util.List; --import java.util.Map; --import java.util.Set; --import java.util.concurrent.ConcurrentMap; --import java.util.concurrent.Exchanger; --import java.util.concurrent.ExecutorService; --import java.util.concurrent.Executors; --import java.util.concurrent.ThreadFactory; --import java.util.concurrent.atomic.AtomicReference; -+ -+import com.google.common.annotations.VisibleForTesting; -+import com.google.common.base.Function; -+import com.google.common.base.Preconditions; -+import com.google.common.base.Predicate; -+import com.google.common.collect.ImmutableList; -+import com.google.common.collect.Lists; -+import com.google.common.collect.Maps; -+import com.google.common.collect.Sets; - - /** -- * 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. -+ * -+ * 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
git commit: closes #27 *Invalid*
Repository: curator Updated Branches: refs/heads/master b31007658 -> dcb44a150 closes #27 *Invalid* Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/dcb44a15 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/dcb44a15 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/dcb44a15 Branch: refs/heads/master Commit: dcb44a1505cb4bd426ad56e6c1587e7c05dd2bc4 Parents: b310076 Author: randgalt Authored: Thu Jul 31 08:13:49 2014 -0500 Committer: randgalt Committed: Thu Jul 31 08:13:49 2014 -0500 -- --
Git Push Summary
Repository: curator Updated Branches: refs/heads/CURATOR-33 [deleted] 2aea22a83
[4/5] git commit: Use Splitter; remove println's.
Use Splitter; remove println's. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/eb1bae5b Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/eb1bae5b Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/eb1bae5b Branch: refs/heads/CURATOR-33 Commit: eb1bae5b3ed189dd38283ccdb2e0df6fd79dd2bd Parents: 678e200 Author: Scott Blum Authored: Mon Jul 28 14:05:51 2014 -0400 Committer: Scott Blum Committed: Mon Jul 28 14:05:51 2014 -0400 -- .../java/org/apache/curator/utils/ZKPaths.java | 21 .../framework/recipes/cache/TreeCache.java | 3 --- 2 files changed, 4 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/eb1bae5b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index 1ffd71b..1e17217 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -18,13 +18,13 @@ */ package org.apache.curator.utils; +import com.google.common.base.Splitter; import com.google.common.collect.Lists; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.ZooDefs; import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.data.ACL; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -112,6 +112,8 @@ public class ZKPaths return new PathAndNode(parentPath, node); } +private static final Splitter PATH_SPLITTER = Splitter.on('/').omitEmptyStrings(); + /** * Given a full path, return the the individual parts, without slashes. * The root path will return an empty list. @@ -122,22 +124,7 @@ public class ZKPaths public static List split(String path) { PathUtils.validatePath(path); -if (path.length() == 1) { -return Collections.emptyList(); -} -int lastPos = 1; -List parts = new ArrayList(); -while (true) -{ -int nextPos = path.indexOf('/', lastPos); -if (nextPos < 0) { -parts.add(path.substring(lastPos)); -break; -} -parts.add(path.substring(lastPos, nextPos)); -lastPos = nextPos + 1; -} -return parts; +return PATH_SPLITTER.splitToList(path); } /** http://git-wip-us.apache.org/repos/asf/curator/blob/eb1bae5b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index f71c21d..4781253 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -167,7 +167,6 @@ public class TreeCache implements Closeable @Override public void process(WatchedEvent event) { -System.out.println(event); try { switch ( event.getType() ) @@ -196,7 +195,6 @@ public class TreeCache implements Closeable @Override public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { -System.out.println(event); switch ( event.getType() ) { case EXISTS: @@ -583,7 +581,6 @@ public class TreeCache implements Closeable private void publishEvent(final TreeCacheEvent event) { -System.out.println(event); if ( treeState.get() != TreeState.CLOSED ) { executorService.submit(new Runnable()
[5/5] git commit: Merge remote-tracking branch 'temp/CURATOR-33' into CURATOR-33
Merge remote-tracking branch 'temp/CURATOR-33' into CURATOR-33 Conflicts: curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/fd5c8aa1 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/fd5c8aa1 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/fd5c8aa1 Branch: refs/heads/CURATOR-33 Commit: fd5c8aa1dcdc60b88f3f229aaba36304a4d90b9a Parents: dcb44a1 eb1bae5 Author: randgalt Authored: Thu Jul 31 10:03:10 2014 -0500 Committer: randgalt Committed: Thu Jul 31 10:03:10 2014 -0500 -- .../java/org/apache/curator/utils/ZKPaths.java | 16 + .../framework/recipes/cache/TreeCache.java | 605 +++ .../framework/recipes/cache/TreeCacheEvent.java | 126 .../recipes/cache/TreeCacheListener.java| 37 ++ .../framework/recipes/cache/TestTreeCache.java | 420 + 5 files changed, 1204 insertions(+) -- http://git-wip-us.apache.org/repos/asf/curator/blob/fd5c8aa1/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --cc curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index 820f45f,1e17217..352bfd6 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@@ -16,9 -16,9 +16,10 @@@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.utils; + import com.google.common.base.Splitter; import com.google.common.collect.Lists; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException;
[3/5] git commit: Fix event ordering on JDK 1.7
Fix event ordering on JDK 1.7 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/678e2002 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/678e2002 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/678e2002 Branch: refs/heads/CURATOR-33 Commit: 678e2002cdc060659e8ccd61f7ac95683781ab04 Parents: f31c1f9 Author: Scott Blum Authored: Thu Jul 24 06:24:37 2014 -0400 Committer: Scott Blum Committed: Thu Jul 24 06:24:37 2014 -0400 -- .../framework/recipes/cache/TreeCache.java | 21 ++-- 1 file changed, 15 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/678e2002/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index 735d5e7..f71c21d 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory; import java.io.Closeable; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.SortedSet; import java.util.concurrent.ConcurrentMap; @@ -230,16 +231,24 @@ public class TreeCache implements Closeable } } +// Present new children in sorted order for test determinism. +List newChildren = new ArrayList(); for ( String child : event.getChildren() ) { -String fullPath = ZKPaths.makePath(path, child); if ( !childMap.containsKey(child) ) { -TreeNode node = new TreeNode(fullPath, this); -if ( childMap.putIfAbsent(child, node) == null ) -{ -node.wasCreated(); -} +newChildren.add(child); +} +} + +Collections.sort(newChildren); +for ( String child : newChildren ) +{ +String fullPath = ZKPaths.makePath(path, child); +TreeNode node = new TreeNode(fullPath, this); +if ( childMap.putIfAbsent(child, node) == null ) +{ +node.wasCreated(); } } }
[2/5] git commit: Remove Java 8 Collections.emptySortedSet().
Remove Java 8 Collections.emptySortedSet(). Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f31c1f9a Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f31c1f9a Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f31c1f9a Branch: refs/heads/CURATOR-33 Commit: f31c1f9a31c0c12ac2886ed1c7edf0dfd4fe0fb0 Parents: 547a7e2 Author: Scott Blum Authored: Wed Jul 23 21:10:35 2014 -0400 Committer: Scott Blum Committed: Wed Jul 23 21:10:35 2014 -0400 -- .../org/apache/curator/framework/recipes/cache/TreeCache.java | 3 +-- .../apache/curator/framework/recipes/cache/TestTreeCache.java | 7 +++ 2 files changed, 4 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/f31c1f9a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index 31bff1e..735d5e7 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -40,7 +40,6 @@ import org.slf4j.LoggerFactory; import java.io.Closeable; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.SortedSet; import java.util.concurrent.ConcurrentMap; @@ -470,7 +469,7 @@ public class TreeCache implements Closeable SortedSet result; if ( map == null ) { -result = Collections.emptySortedSet(); +result = ImmutableSortedSet.of(); } else { http://git-wip-us.apache.org/repos/asf/curator/blob/f31c1f9a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index b8a009b..2922d40 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -34,7 +34,6 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -141,7 +140,7 @@ public class TestTreeCache extends BaseClassForTests assertNoMoreEvents(); Assert.assertEquals(cache.getCurrentChildren("/test"), ImmutableSortedSet.of("1", "2", "3")); -Assert.assertEquals(cache.getCurrentChildren("/test/1"), Collections.emptySet()); +Assert.assertEquals(cache.getCurrentChildren("/test/1"), ImmutableSortedSet.of()); Assert.assertEquals(cache.getCurrentChildren("/test/2"), ImmutableSortedSet.of("sub")); Assert.assertNull(cache.getCurrentChildren("/test/non_exist")); } @@ -292,7 +291,7 @@ public class TestTreeCache extends BaseClassForTests cache.start(); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test"); assertEvent(TreeCacheEvent.Type.INITIALIZED); -Assert.assertEquals(cache.getCurrentChildren("/test"), Collections.emptySortedSet()); +Assert.assertEquals(cache.getCurrentChildren("/test"), ImmutableSortedSet.of()); client.create().forPath("/test/one", "hey there".getBytes()); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one"); @@ -306,7 +305,7 @@ public class TestTreeCache extends BaseClassForTests client.delete().forPath("/test/one"); assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/one"); -Assert.assertEquals(cache.getCurrentChildren("/test"), Collections.emptySortedSet()); +Assert.assertEquals(cache.getCurrentChildren("/test"), ImmutableSortedSet.of()); assertNoMoreEvents(); }
[1/5] git commit: CURATOR-33 recursive TreeCache recipe
Repository: curator Updated Branches: refs/heads/CURATOR-33 [created] fd5c8aa1d CURATOR-33 recursive TreeCache recipe Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/547a7e23 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/547a7e23 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/547a7e23 Branch: refs/heads/CURATOR-33 Commit: 547a7e23eb48fece49420bbcfdc84e763bf74461 Parents: c358bbc Author: Scott Blum Authored: Mon Jul 14 20:38:07 2014 -0400 Committer: Scott Blum Committed: Fri Jul 18 03:01:33 2014 -0400 -- .../java/org/apache/curator/utils/ZKPaths.java | 29 + .../org/apache/curator/utils/TestZKPaths.java | 38 ++ .../framework/recipes/cache/TreeCache.java | 600 +++ .../framework/recipes/cache/TreeCacheEvent.java | 126 .../recipes/cache/TreeCacheListener.java| 37 ++ .../framework/recipes/cache/TestTreeCache.java | 421 + 6 files changed, 1251 insertions(+) -- http://git-wip-us.apache.org/repos/asf/curator/blob/547a7e23/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index 04b2141..1ffd71b 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -24,6 +24,7 @@ import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.ZooDefs; import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.data.ACL; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -112,6 +113,34 @@ public class ZKPaths } /** + * Given a full path, return the the individual parts, without slashes. + * The root path will return an empty list. + * + * @param path the path + * @return an array of parts + */ +public static List split(String path) +{ +PathUtils.validatePath(path); +if (path.length() == 1) { +return Collections.emptyList(); +} +int lastPos = 1; +List parts = new ArrayList(); +while (true) +{ +int nextPos = path.indexOf('/', lastPos); +if (nextPos < 0) { +parts.add(path.substring(lastPos)); +break; +} +parts.add(path.substring(lastPos, nextPos)); +lastPos = nextPos + 1; +} +return parts; +} + +/** * Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish * between directories and files. So, every node in the path is created. The data for each node is an empty blob * http://git-wip-us.apache.org/repos/asf/curator/blob/547a7e23/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java -- diff --git a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java new file mode 100644 index 000..fd03929 --- /dev/null +++ b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java @@ -0,0 +1,38 @@ +/** + * 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.utils; + +import org.testng.Assert; +import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.Arrays; + +public class TestZKPaths +{ + +@Test +public void testSplit() +{ +Assert.assertEquals(ZKPaths.split("/"), new ArrayList()); +Assert.assertEquals(ZKPaths.split("/test"), Arrays.asList("test")); +Assert.assertEquals(ZKPaths.split("/test/one"), Arrays.asList("test", "one")); +Assert.assertEquals(ZKPaths.split("/test/one/two"), Arrays.asList("test", "one", "two")); +} +}
git commit: CURATOR-130 Add null check to input processing.
Repository: curator Updated Branches: refs/heads/CURATOR-130 [created] f5767c890 CURATOR-130 Add null check to input processing. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f5767c89 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f5767c89 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f5767c89 Branch: refs/heads/CURATOR-130 Commit: f5767c8909d25761fcc5ed1a8f462fb8f0533487 Parents: dcb44a1 Author: Mike Drob Authored: Thu Jul 31 15:10:17 2014 -0500 Committer: Mike Drob Committed: Thu Jul 31 15:10:17 2014 -0500 -- curator-examples/src/main/java/cache/PathCacheExample.java | 8 +++- .../src/main/java/discovery/DiscoveryExample.java| 8 +++- 2 files changed, 14 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/f5767c89/curator-examples/src/main/java/cache/PathCacheExample.java -- diff --git a/curator-examples/src/main/java/cache/PathCacheExample.java b/curator-examples/src/main/java/cache/PathCacheExample.java index eec01bc..bec8093 100644 --- a/curator-examples/src/main/java/cache/PathCacheExample.java +++ b/curator-examples/src/main/java/cache/PathCacheExample.java @@ -119,7 +119,13 @@ public class PathCacheExample { System.out.print("> "); -String command = in.readLine().trim(); +String line = in.readLine(); +if ( line == null ) +{ +break; +} + +String command = line.trim(); String[]parts = command.split("\\s"); if ( parts.length == 0 ) { http://git-wip-us.apache.org/repos/asf/curator/blob/f5767c89/curator-examples/src/main/java/discovery/DiscoveryExample.java -- diff --git a/curator-examples/src/main/java/discovery/DiscoveryExample.java b/curator-examples/src/main/java/discovery/DiscoveryExample.java index 6313207..d377e5e 100644 --- a/curator-examples/src/main/java/discovery/DiscoveryExample.java +++ b/curator-examples/src/main/java/discovery/DiscoveryExample.java @@ -91,7 +91,13 @@ public class DiscoveryExample { System.out.print("> "); -String command = in.readLine().trim(); +String line = in.readLine(); +if ( line == null ) +{ +break; +} + +String command = line.trim(); String[]parts = command.split("\\s"); if ( parts.length == 0 ) {
git commit: CURATOR-130 Add null check to input processing.
Repository: curator Updated Branches: refs/heads/master dcb44a150 -> f5767c890 CURATOR-130 Add null check to input processing. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f5767c89 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f5767c89 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f5767c89 Branch: refs/heads/master Commit: f5767c8909d25761fcc5ed1a8f462fb8f0533487 Parents: dcb44a1 Author: Mike Drob Authored: Thu Jul 31 15:10:17 2014 -0500 Committer: Mike Drob Committed: Thu Jul 31 15:10:17 2014 -0500 -- curator-examples/src/main/java/cache/PathCacheExample.java | 8 +++- .../src/main/java/discovery/DiscoveryExample.java| 8 +++- 2 files changed, 14 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/f5767c89/curator-examples/src/main/java/cache/PathCacheExample.java -- diff --git a/curator-examples/src/main/java/cache/PathCacheExample.java b/curator-examples/src/main/java/cache/PathCacheExample.java index eec01bc..bec8093 100644 --- a/curator-examples/src/main/java/cache/PathCacheExample.java +++ b/curator-examples/src/main/java/cache/PathCacheExample.java @@ -119,7 +119,13 @@ public class PathCacheExample { System.out.print("> "); -String command = in.readLine().trim(); +String line = in.readLine(); +if ( line == null ) +{ +break; +} + +String command = line.trim(); String[]parts = command.split("\\s"); if ( parts.length == 0 ) { http://git-wip-us.apache.org/repos/asf/curator/blob/f5767c89/curator-examples/src/main/java/discovery/DiscoveryExample.java -- diff --git a/curator-examples/src/main/java/discovery/DiscoveryExample.java b/curator-examples/src/main/java/discovery/DiscoveryExample.java index 6313207..d377e5e 100644 --- a/curator-examples/src/main/java/discovery/DiscoveryExample.java +++ b/curator-examples/src/main/java/discovery/DiscoveryExample.java @@ -91,7 +91,13 @@ public class DiscoveryExample { System.out.print("> "); -String command = in.readLine().trim(); +String line = in.readLine(); +if ( line == null ) +{ +break; +} + +String command = line.trim(); String[]parts = command.split("\\s"); if ( parts.length == 0 ) {
Git Push Summary
Repository: curator Updated Branches: refs/heads/CURATOR-33 [deleted] fd5c8aa1d
[1/3] git commit: CURATOR-33 recursive TreeCache recipe
Repository: curator Updated Branches: refs/heads/CURATOR-33 [created] f4743336e CURATOR-33 recursive TreeCache recipe Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/470d7e73 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/470d7e73 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/470d7e73 Branch: refs/heads/CURATOR-33 Commit: 470d7e73e1a491f255dd034f6ee9229b78710557 Parents: f5767c8 Author: Scott Blum Authored: Mon Jul 14 20:38:07 2014 -0400 Committer: Scott Blum Committed: Thu Jul 31 18:04:58 2014 -0400 -- .../java/org/apache/curator/utils/ZKPaths.java | 16 + .../org/apache/curator/utils/TestZKPaths.java | 11 + .../framework/recipes/cache/TreeCache.java | 605 +++ .../framework/recipes/cache/TreeCacheEvent.java | 126 .../recipes/cache/TreeCacheListener.java| 37 ++ .../framework/recipes/cache/TestTreeCache.java | 420 + 6 files changed, 1215 insertions(+) -- http://git-wip-us.apache.org/repos/asf/curator/blob/470d7e73/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index 820f45f..352bfd6 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -19,6 +19,7 @@ package org.apache.curator.utils; +import com.google.common.base.Splitter; import com.google.common.collect.Lists; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; @@ -115,6 +116,21 @@ public class ZKPaths return new PathAndNode(parentPath, node); } +private static final Splitter PATH_SPLITTER = Splitter.on('/').omitEmptyStrings(); + +/** + * Given a full path, return the the individual parts, without slashes. + * The root path will return an empty list. + * + * @param path the path + * @return an array of parts + */ +public static List split(String path) +{ +PathUtils.validatePath(path); +return PATH_SPLITTER.splitToList(path); +} + /** * Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish * between directories and files. So, every node in the path is created. The data for each node is an empty blob http://git-wip-us.apache.org/repos/asf/curator/blob/470d7e73/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java -- diff --git a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java index fb49d8b..04d07c5 100644 --- a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java +++ b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java @@ -21,6 +21,8 @@ package org.apache.curator.utils; import org.testng.Assert; import org.testng.annotations.Test; +import java.util.Arrays; +import java.util.Collections; public class TestZKPaths { @@ -62,4 +64,13 @@ public class TestZKPaths Assert.assertEquals(ZKPaths.makePath("foo", "/bar"), "/foo/bar"); Assert.assertEquals(ZKPaths.makePath("/foo", "/bar"), "/foo/bar"); } + +@Test +public void testSplit() +{ +Assert.assertEquals(ZKPaths.split("/"), Collections.emptyList()); +Assert.assertEquals(ZKPaths.split("/test"), Collections.singletonList("test")); +Assert.assertEquals(ZKPaths.split("/test/one"), Arrays.asList("test", "one")); +Assert.assertEquals(ZKPaths.split("/test/one/two"), Arrays.asList("test", "one", "two")); +} } http://git-wip-us.apache.org/repos/asf/curator/blob/470d7e73/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java new file mode 100644 index 000..4781253 --- /dev/null +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -0,0 +1,605 @@ +/** + * 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");
[2/3] git commit: Namespaces working.
Namespaces working. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/cf700d37 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/cf700d37 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/cf700d37 Branch: refs/heads/CURATOR-33 Commit: cf700d37322786a153065169bc921fe41466e793 Parents: 470d7e7 Author: Scott Blum Authored: Tue Jul 29 19:28:23 2014 -0400 Committer: Scott Blum Committed: Thu Jul 31 18:23:49 2014 -0400 -- .../framework/recipes/cache/TestTreeCache.java | 116 ++- 1 file changed, 90 insertions(+), 26 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/cf700d37/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index 2922d40..bc999bf 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -52,16 +52,18 @@ public class TestTreeCache extends BaseClassForTests /** * A TreeCache that records exceptions. */ -private TreeCache newTreeCache(String path, boolean cacheData) -{ -return new TreeCache(client, path, cacheData) +class TreeCache extends org.apache.curator.framework.recipes.cache.TreeCache { + +TreeCache(CuratorFramework client, String path, boolean cacheData) { -@Override -protected void handleException(Throwable e) -{ -exceptions.add(e); -} -}; +super(client, path, cacheData); +} + +@Override +protected void handleException(Throwable e) +{ +exceptions.add(e); +} } @Override @@ -77,6 +79,11 @@ public class TestTreeCache extends BaseClassForTests @Override public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception { +if (event.getData() != null && event.getData().getPath().startsWith("/zookeeper")) +{ +// Suppress any events related to /zookeeper paths +return; +} events.add(event); } }; @@ -84,15 +91,14 @@ public class TestTreeCache extends BaseClassForTests client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); client.start(); client.getUnhandledErrorListenable().addListener(new UnhandledErrorListener() - { - @Override - public void unhandledError(String message, Throwable e) - { - exceptions.add(e); - } - } -); -cache = newTreeCache("/test", true); +{ +@Override +public void unhandledError(String message, Throwable e) +{ +exceptions.add(e); +} +}); +cache = new TreeCache(client, "/test", true); cache.getListenable().addListener(eventListener); } @@ -104,9 +110,18 @@ public class TestTreeCache extends BaseClassForTests { try { -for ( Throwable exception : exceptions ) +if ( exceptions.size() == 1 ) +{ +Assert.fail("Exception was thrown", exceptions.get(0)); +} +else if ( exceptions.size() > 1 ) { -Assert.fail("Exception was thrown", exception); +AssertionError error = new AssertionError("Multiple exceptions were thrown"); +for ( Throwable exception : exceptions ) +{ +error.addSuppressed(exception); +} +throw error; } } finally @@ -169,6 +184,55 @@ public class TestTreeCache extends BaseClassForTests } @Test +public void testFromRoot() throws Exception +{
[3/3] git commit: Added more extensive testing.
Added more extensive testing. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f4743336 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f4743336 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f4743336 Branch: refs/heads/CURATOR-33 Commit: f4743336e09fa4f487b95bf72b2877c789371202 Parents: cf700d3 Author: Scott Blum Authored: Fri Aug 1 02:00:52 2014 -0400 Committer: Scott Blum Committed: Fri Aug 1 02:00:52 2014 -0400 -- .../framework/recipes/cache/TreeCache.java | 113 ++ .../framework/recipes/cache/TreeCacheEvent.java | 10 +- .../recipes/cache/BaseTestTreeCache.java| 173 +++ .../framework/recipes/cache/TestTreeCache.java | 219 +++ .../recipes/cache/TestTreeCacheRandomTree.java | 199 + 5 files changed, 484 insertions(+), 230 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/f4743336/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index 4781253..f73861d 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -20,7 +20,8 @@ package org.apache.curator.framework.recipes.cache; import com.google.common.base.Function; -import com.google.common.collect.ImmutableSortedSet; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.BackgroundCallback; @@ -38,15 +39,15 @@ import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Closeable; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.SortedSet; +import java.util.Map; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -68,7 +69,7 @@ public class TreeCache implements Closeable PENDING, LIVE, DEAD } -final class TreeNode implements Watcher, BackgroundCallback +private final class TreeNode implements Watcher, BackgroundCallback { private final AtomicReference nodeState = new AtomicReference(NodeState.PENDING); private final String path; @@ -77,12 +78,18 @@ public class TreeCache implements Closeable private final AtomicReference data = new AtomicReference(); private final AtomicReference> children = new AtomicReference>(); -TreeNode(String path, TreeNode parent) +private TreeNode(String path, TreeNode parent) { this.path = path; this.parent = parent; } +private void refresh() throws Exception +{ +refreshData(); +refreshChildren(); +} + private void refreshChildren() throws Exception { outstandingOps.incrementAndGet(); @@ -104,8 +111,7 @@ public class TreeCache implements Closeable private void wasReconnected() throws Exception { -refreshData(); -refreshChildren(); +refresh(); ConcurrentMap childMap = children.get(); if ( childMap != null ) { @@ -118,8 +124,7 @@ public class TreeCache implements Closeable private void wasCreated() throws Exception { -refreshData(); -refreshChildren(); +refresh(); } private void wasDeleted() throws Exception @@ -172,7 +177,7 @@ public class TreeCache implements Closeable switch ( event.getType() ) { case NodeCreated: -assert parent == null; +Preconditions.checkState(parent == null, "unexpected NodeCreated on non-root node"); wasCreated(); break; case NodeChildrenChanged: @@ -198,7 +203,7 @@ public class TreeCache implements Closeable switch ( event.getType() ) { case EXISTS: -// TODO: should only happen for root no
git commit: Fix potential race condition.
Repository: curator Updated Branches: refs/heads/CURATOR-33 f4743336e -> 267492779 Fix potential race condition. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/26749277 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/26749277 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/26749277 Branch: refs/heads/CURATOR-33 Commit: 267492779ac127d22c67791c799b73d46dfeac7a Parents: f474333 Author: Scott Blum Authored: Fri Aug 1 15:23:16 2014 -0400 Committer: Scott Blum Committed: Fri Aug 1 15:28:15 2014 -0400 -- .../framework/recipes/cache/TreeCache.java | 58 +--- 1 file changed, 39 insertions(+), 19 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/26749277/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index f73861d..0d5995a 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -71,14 +71,14 @@ public class TreeCache implements Closeable private final class TreeNode implements Watcher, BackgroundCallback { -private final AtomicReference nodeState = new AtomicReference(NodeState.PENDING); -private final String path; -private final TreeNode parent; -private final AtomicReference stat = new AtomicReference(); -private final AtomicReference data = new AtomicReference(); -private final AtomicReference> children = new AtomicReference>(); - -private TreeNode(String path, TreeNode parent) +final AtomicReference nodeState = new AtomicReference(NodeState.PENDING); +final TreeNode parent; +final String path; +final AtomicReference stat = new AtomicReference(); +final AtomicReference data = new AtomicReference(); +final AtomicReference> children = new AtomicReference>(); + +TreeNode(String path, TreeNode parent) { this.path = path; this.parent = parent; @@ -86,19 +86,30 @@ public class TreeCache implements Closeable private void refresh() throws Exception { -refreshData(); -refreshChildren(); +outstandingOps.addAndGet(2); +doRefreshData(); +doRefreshChildren(); } private void refreshChildren() throws Exception { outstandingOps.incrementAndGet(); - client.getChildren().usingWatcher(this).inBackground(this).forPath(path); +doRefreshChildren(); } private void refreshData() throws Exception { outstandingOps.incrementAndGet(); +doRefreshData(); +} + +private void doRefreshChildren() throws Exception +{ + client.getChildren().usingWatcher(this).inBackground(this).forPath(path); +} + +private void doRefreshData() throws Exception +{ if ( dataIsCompressed ) { client.getData().decompressed().usingWatcher(this).inBackground(this).forPath(path); @@ -109,7 +120,7 @@ public class TreeCache implements Closeable } } -private void wasReconnected() throws Exception +void wasReconnected() throws Exception { refresh(); ConcurrentMap childMap = children.get(); @@ -122,12 +133,12 @@ public class TreeCache implements Closeable } } -private void wasCreated() throws Exception +void wasCreated() throws Exception { refresh(); } -private void wasDeleted() throws Exception +void wasDeleted() throws Exception { stat.set(null); data.set(null); @@ -200,6 +211,7 @@ public class TreeCache implements Closeable @Override public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { +Stat newStat = event.getStat(); switch ( event.getType() ) { case EXISTS: @@ -217,7 +229,12 @@ public class TreeCache implements Closeable case CHILDREN: if ( event.getResultCode() == KeeperException.Code.OK.intValue() ) { -stat.set(event.getStat()); +Stat oldStat = stat.get(); +if (oldStat != null
git commit: Style tweaks.
Repository: curator Updated Branches: refs/heads/CURATOR-33 267492779 -> 74497c0d2 Style tweaks. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/74497c0d Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/74497c0d Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/74497c0d Branch: refs/heads/CURATOR-33 Commit: 74497c0d23c0eeeadee47dec6b3da116e05480b6 Parents: 2674927 Author: Scott Blum Authored: Wed Aug 6 22:03:44 2014 -0400 Committer: Scott Blum Committed: Wed Aug 6 22:03:44 2014 -0400 -- .../recipes/cache/BaseTestTreeCache.java| 7 +++ .../framework/recipes/cache/TestTreeCache.java | 20 +++- .../recipes/cache/TestTreeCacheRandomTree.java | 5 ++--- 3 files changed, 20 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/74497c0d/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java index f59af30..5842c21 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java @@ -39,7 +39,7 @@ public class BaseTestTreeCache extends BaseClassForTests { private final Timing timing = new Timing(); CuratorFramework client; -TreeCache cache; +MyTreeCache cache; private List exceptions; private BlockingQueue events; TreeCacheListener eventListener; @@ -47,10 +47,10 @@ public class BaseTestTreeCache extends BaseClassForTests /** * A TreeCache that records exceptions and automatically adds a listener. */ -class TreeCache extends org.apache.curator.framework.recipes.cache.TreeCache +class MyTreeCache extends TreeCache { -TreeCache(CuratorFramework client, String path, boolean cacheData) +MyTreeCache(CuratorFramework client, String path, boolean cacheData) { super(client, path, cacheData); getListenable().addListener(eventListener); @@ -95,7 +95,6 @@ public class BaseTestTreeCache extends BaseClassForTests exceptions.add(e); } }); -cache = new TreeCache(client, "/test", true); } @Override http://git-wip-us.apache.org/repos/asf/curator/blob/74497c0d/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index f35d24d..33d08b0 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -39,6 +39,7 @@ public class TestTreeCache extends BaseTestTreeCache client.create().forPath("/test/3", "three".getBytes()); client.create().forPath("/test/2/sub", "two-sub".getBytes()); +cache = new MyTreeCache(client, "/test", true); cache.start(); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test"); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/1", "one".getBytes()); @@ -57,6 +58,7 @@ public class TestTreeCache extends BaseTestTreeCache @Test public void testStartEmpty() throws Exception { +cache = new MyTreeCache(client, "/test", true); cache.start(); assertEvent(TreeCacheEvent.Type.INITIALIZED); @@ -71,6 +73,7 @@ public class TestTreeCache extends BaseTestTreeCache client.create().forPath("/test"); client.create().forPath("/test/one", "hey there".getBytes()); +cache = new MyTreeCache(client, "/test", true); cache.start(); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test"); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one"); @@ -84,7 +87,7 @@ public class TestTreeCache extends BaseTestTreeCache client.create().forPath("/test"); client.create().forPath("/test/one", "hey there".getBytes()); -cache = new TreeCache(client, "/", true); +cache = new MyTreeCache(client, "/", true); cache.start(); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/"); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test"); @@ -106,7 +109,7 @@ public class TestT
[1/3] git commit: Style tweaks.
Repository: curator Updated Branches: refs/heads/CURATOR-33 74497c0d2 -> 9eafd05f2 Style tweaks. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/be85e96e Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/be85e96e Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/be85e96e Branch: refs/heads/CURATOR-33 Commit: be85e96e007eb4f678997cdad9933e597b62a8a2 Parents: 2674927 Author: Scott Blum Authored: Wed Aug 6 22:03:44 2014 -0400 Committer: Scott Blum Committed: Wed Aug 6 23:57:53 2014 -0400 -- .../framework/recipes/cache/TreeCache.java | 2 ++ .../recipes/cache/BaseTestTreeCache.java| 7 +++ .../framework/recipes/cache/TestTreeCache.java | 20 +++- .../recipes/cache/TestTreeCacheRandomTree.java | 5 ++--- 4 files changed, 22 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/be85e96e/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index 0d5995a..1ec0440 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -305,6 +305,7 @@ public class TreeCache implements Closeable break; default: handleException(new Exception(String.format("Unknown event %s", event))); +break; } if ( outstandingOps.decrementAndGet() == 0 ) @@ -593,6 +594,7 @@ public class TreeCache implements Closeable publishEvent(TreeCacheEvent.Type.CONNECTION_LOST); break; +case CONNECTED: case RECONNECTED: try { http://git-wip-us.apache.org/repos/asf/curator/blob/be85e96e/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java index f59af30..5842c21 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java @@ -39,7 +39,7 @@ public class BaseTestTreeCache extends BaseClassForTests { private final Timing timing = new Timing(); CuratorFramework client; -TreeCache cache; +MyTreeCache cache; private List exceptions; private BlockingQueue events; TreeCacheListener eventListener; @@ -47,10 +47,10 @@ public class BaseTestTreeCache extends BaseClassForTests /** * A TreeCache that records exceptions and automatically adds a listener. */ -class TreeCache extends org.apache.curator.framework.recipes.cache.TreeCache +class MyTreeCache extends TreeCache { -TreeCache(CuratorFramework client, String path, boolean cacheData) +MyTreeCache(CuratorFramework client, String path, boolean cacheData) { super(client, path, cacheData); getListenable().addListener(eventListener); @@ -95,7 +95,6 @@ public class BaseTestTreeCache extends BaseClassForTests exceptions.add(e); } }); -cache = new TreeCache(client, "/test", true); } @Override http://git-wip-us.apache.org/repos/asf/curator/blob/be85e96e/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index f35d24d..33d08b0 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -39,6 +39,7 @@ public class TestTreeCache extends BaseTestTreeCache client.create().forPath("/test/3", "three".getBytes()); client.create().forPath("/test/2/sub", "two-sub".getBytes()); +cache = new MyTreeCache(client, "/test", true); cache.start(); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
[3/3] git commit: Merge branch 'CURATOR-33' of github.com:dragonsinth/curator into CURATOR-33
Merge branch 'CURATOR-33' of github.com:dragonsinth/curator into CURATOR-33 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/9eafd05f Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/9eafd05f Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/9eafd05f Branch: refs/heads/CURATOR-33 Commit: 9eafd05f285bf8cd9d44263f9dd5daea07e69491 Parents: 74497c0 462121f Author: randgalt Authored: Thu Aug 7 20:58:33 2014 -0500 Committer: randgalt Committed: Thu Aug 7 20:58:33 2014 -0500 -- .../framework/recipes/cache/TreeCache.java | 22 +-- .../recipes/cache/BaseTestTreeCache.java| 4 +++ .../framework/recipes/cache/TestTreeCache.java | 28 3 files changed, 52 insertions(+), 2 deletions(-) --
[2/3] git commit: Fix startup connection problem.
Fix startup connection problem. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/462121f9 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/462121f9 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/462121f9 Branch: refs/heads/CURATOR-33 Commit: 462121f98a4129f9b96ff0a5ebeafe4eac224a38 Parents: be85e96 Author: Scott Blum Authored: Thu Aug 7 15:25:21 2014 -0400 Committer: Scott Blum Committed: Thu Aug 7 19:26:51 2014 -0400 -- .../framework/recipes/cache/TreeCache.java | 22 --- .../recipes/cache/BaseTestTreeCache.java| 4 +++ .../framework/recipes/cache/TestTreeCache.java | 28 3 files changed, 51 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/462121f9/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index 1ec0440..617d652 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -304,8 +304,11 @@ public class TreeCache implements Closeable } break; default: -handleException(new Exception(String.format("Unknown event %s", event))); -break; +// An unknown event, probably an error of some sort like connection loss. +LOG.info(String.format("Unknown event %s", event)); +// Don't produce an initialized event on error; reconnect can fix this. +outstandingOps.decrementAndGet(); +return; } if ( outstandingOps.decrementAndGet() == 0 ) @@ -424,7 +427,10 @@ public class TreeCache implements Closeable { Preconditions.checkState(treeState.compareAndSet(TreeState.LATENT, TreeState.STARTED), "already started"); client.getConnectionStateListenable().addListener(connectionStateListener); -root.wasCreated(); +if (client.getZookeeperClient().isConnected()) +{ +root.wasCreated(); +} } /** @@ -595,6 +601,16 @@ public class TreeCache implements Closeable break; case CONNECTED: +try +{ +root.wasCreated(); +} +catch ( Exception e ) +{ +handleException(e); +} +break; + case RECONNECTED: try { http://git-wip-us.apache.org/repos/asf/curator/blob/462121f9/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java index 5842c21..1daf14d 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java @@ -85,6 +85,10 @@ public class BaseTestTreeCache extends BaseClassForTests } }; +initCuratorFramework(); +} + +void initCuratorFramework() { client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); client.start(); client.getUnhandledErrorListenable().addListener(new UnhandledErrorListener() http://git-wip-us.apache.org/repos/asf/curator/blob/462121f9/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index 33d08b0..abdbb8b 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -342,4 +342,32 @@ public class TestTreeCache extends BaseTestTreeCache client.delete().forPath("/test/one"); assertNoMoreEvents(); } + +/** + * Make sure TreeCache gets to a sane state whe
[5/9] git commit: Style tweaks.
Style tweaks. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/74497c0d Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/74497c0d Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/74497c0d Branch: refs/heads/master Commit: 74497c0d23c0eeeadee47dec6b3da116e05480b6 Parents: 2674927 Author: Scott Blum Authored: Wed Aug 6 22:03:44 2014 -0400 Committer: Scott Blum Committed: Wed Aug 6 22:03:44 2014 -0400 -- .../recipes/cache/BaseTestTreeCache.java| 7 +++ .../framework/recipes/cache/TestTreeCache.java | 20 +++- .../recipes/cache/TestTreeCacheRandomTree.java | 5 ++--- 3 files changed, 20 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/74497c0d/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java index f59af30..5842c21 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java @@ -39,7 +39,7 @@ public class BaseTestTreeCache extends BaseClassForTests { private final Timing timing = new Timing(); CuratorFramework client; -TreeCache cache; +MyTreeCache cache; private List exceptions; private BlockingQueue events; TreeCacheListener eventListener; @@ -47,10 +47,10 @@ public class BaseTestTreeCache extends BaseClassForTests /** * A TreeCache that records exceptions and automatically adds a listener. */ -class TreeCache extends org.apache.curator.framework.recipes.cache.TreeCache +class MyTreeCache extends TreeCache { -TreeCache(CuratorFramework client, String path, boolean cacheData) +MyTreeCache(CuratorFramework client, String path, boolean cacheData) { super(client, path, cacheData); getListenable().addListener(eventListener); @@ -95,7 +95,6 @@ public class BaseTestTreeCache extends BaseClassForTests exceptions.add(e); } }); -cache = new TreeCache(client, "/test", true); } @Override http://git-wip-us.apache.org/repos/asf/curator/blob/74497c0d/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index f35d24d..33d08b0 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -39,6 +39,7 @@ public class TestTreeCache extends BaseTestTreeCache client.create().forPath("/test/3", "three".getBytes()); client.create().forPath("/test/2/sub", "two-sub".getBytes()); +cache = new MyTreeCache(client, "/test", true); cache.start(); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test"); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/1", "one".getBytes()); @@ -57,6 +58,7 @@ public class TestTreeCache extends BaseTestTreeCache @Test public void testStartEmpty() throws Exception { +cache = new MyTreeCache(client, "/test", true); cache.start(); assertEvent(TreeCacheEvent.Type.INITIALIZED); @@ -71,6 +73,7 @@ public class TestTreeCache extends BaseTestTreeCache client.create().forPath("/test"); client.create().forPath("/test/one", "hey there".getBytes()); +cache = new MyTreeCache(client, "/test", true); cache.start(); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test"); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one"); @@ -84,7 +87,7 @@ public class TestTreeCache extends BaseTestTreeCache client.create().forPath("/test"); client.create().forPath("/test/one", "hey there".getBytes()); -cache = new TreeCache(client, "/", true); +cache = new MyTreeCache(client, "/", true); cache.start(); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/"); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test"); @@ -106,7 +109,7 @@ public class TestTreeCache extends BaseTestTreeCache client.create().forPath("/outer/test");
[1/9] git commit: CURATOR-33 recursive TreeCache recipe
Repository: curator Updated Branches: refs/heads/master 3c1a4edc2 -> ad6c23adc CURATOR-33 recursive TreeCache recipe Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/470d7e73 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/470d7e73 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/470d7e73 Branch: refs/heads/master Commit: 470d7e73e1a491f255dd034f6ee9229b78710557 Parents: f5767c8 Author: Scott Blum Authored: Mon Jul 14 20:38:07 2014 -0400 Committer: Scott Blum Committed: Thu Jul 31 18:04:58 2014 -0400 -- .../java/org/apache/curator/utils/ZKPaths.java | 16 + .../org/apache/curator/utils/TestZKPaths.java | 11 + .../framework/recipes/cache/TreeCache.java | 605 +++ .../framework/recipes/cache/TreeCacheEvent.java | 126 .../recipes/cache/TreeCacheListener.java| 37 ++ .../framework/recipes/cache/TestTreeCache.java | 420 + 6 files changed, 1215 insertions(+) -- http://git-wip-us.apache.org/repos/asf/curator/blob/470d7e73/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java index 820f45f..352bfd6 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java +++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java @@ -19,6 +19,7 @@ package org.apache.curator.utils; +import com.google.common.base.Splitter; import com.google.common.collect.Lists; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; @@ -115,6 +116,21 @@ public class ZKPaths return new PathAndNode(parentPath, node); } +private static final Splitter PATH_SPLITTER = Splitter.on('/').omitEmptyStrings(); + +/** + * Given a full path, return the the individual parts, without slashes. + * The root path will return an empty list. + * + * @param path the path + * @return an array of parts + */ +public static List split(String path) +{ +PathUtils.validatePath(path); +return PATH_SPLITTER.splitToList(path); +} + /** * Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish * between directories and files. So, every node in the path is created. The data for each node is an empty blob http://git-wip-us.apache.org/repos/asf/curator/blob/470d7e73/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java -- diff --git a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java index fb49d8b..04d07c5 100644 --- a/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java +++ b/curator-client/src/test/java/org/apache/curator/utils/TestZKPaths.java @@ -21,6 +21,8 @@ package org.apache.curator.utils; import org.testng.Assert; import org.testng.annotations.Test; +import java.util.Arrays; +import java.util.Collections; public class TestZKPaths { @@ -62,4 +64,13 @@ public class TestZKPaths Assert.assertEquals(ZKPaths.makePath("foo", "/bar"), "/foo/bar"); Assert.assertEquals(ZKPaths.makePath("/foo", "/bar"), "/foo/bar"); } + +@Test +public void testSplit() +{ +Assert.assertEquals(ZKPaths.split("/"), Collections.emptyList()); +Assert.assertEquals(ZKPaths.split("/test"), Collections.singletonList("test")); +Assert.assertEquals(ZKPaths.split("/test/one"), Arrays.asList("test", "one")); +Assert.assertEquals(ZKPaths.split("/test/one/two"), Arrays.asList("test", "one", "two")); +} } http://git-wip-us.apache.org/repos/asf/curator/blob/470d7e73/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java new file mode 100644 index 000..4781253 --- /dev/null +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -0,0 +1,605 @@ +/** + * 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 m
[3/9] git commit: Added more extensive testing.
Added more extensive testing. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f4743336 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f4743336 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f4743336 Branch: refs/heads/master Commit: f4743336e09fa4f487b95bf72b2877c789371202 Parents: cf700d3 Author: Scott Blum Authored: Fri Aug 1 02:00:52 2014 -0400 Committer: Scott Blum Committed: Fri Aug 1 02:00:52 2014 -0400 -- .../framework/recipes/cache/TreeCache.java | 113 ++ .../framework/recipes/cache/TreeCacheEvent.java | 10 +- .../recipes/cache/BaseTestTreeCache.java| 173 +++ .../framework/recipes/cache/TestTreeCache.java | 219 +++ .../recipes/cache/TestTreeCacheRandomTree.java | 199 + 5 files changed, 484 insertions(+), 230 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/f4743336/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index 4781253..f73861d 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -20,7 +20,8 @@ package org.apache.curator.framework.recipes.cache; import com.google.common.base.Function; -import com.google.common.collect.ImmutableSortedSet; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.BackgroundCallback; @@ -38,15 +39,15 @@ import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Closeable; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.SortedSet; +import java.util.Map; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; @@ -68,7 +69,7 @@ public class TreeCache implements Closeable PENDING, LIVE, DEAD } -final class TreeNode implements Watcher, BackgroundCallback +private final class TreeNode implements Watcher, BackgroundCallback { private final AtomicReference nodeState = new AtomicReference(NodeState.PENDING); private final String path; @@ -77,12 +78,18 @@ public class TreeCache implements Closeable private final AtomicReference data = new AtomicReference(); private final AtomicReference> children = new AtomicReference>(); -TreeNode(String path, TreeNode parent) +private TreeNode(String path, TreeNode parent) { this.path = path; this.parent = parent; } +private void refresh() throws Exception +{ +refreshData(); +refreshChildren(); +} + private void refreshChildren() throws Exception { outstandingOps.incrementAndGet(); @@ -104,8 +111,7 @@ public class TreeCache implements Closeable private void wasReconnected() throws Exception { -refreshData(); -refreshChildren(); +refresh(); ConcurrentMap childMap = children.get(); if ( childMap != null ) { @@ -118,8 +124,7 @@ public class TreeCache implements Closeable private void wasCreated() throws Exception { -refreshData(); -refreshChildren(); +refresh(); } private void wasDeleted() throws Exception @@ -172,7 +177,7 @@ public class TreeCache implements Closeable switch ( event.getType() ) { case NodeCreated: -assert parent == null; +Preconditions.checkState(parent == null, "unexpected NodeCreated on non-root node"); wasCreated(); break; case NodeChildrenChanged: @@ -198,7 +203,7 @@ public class TreeCache implements Closeable switch ( event.getType() ) { case EXISTS: -// TODO: should only happen for root node +
[6/9] git commit: Style tweaks.
Style tweaks. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/be85e96e Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/be85e96e Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/be85e96e Branch: refs/heads/master Commit: be85e96e007eb4f678997cdad9933e597b62a8a2 Parents: 2674927 Author: Scott Blum Authored: Wed Aug 6 22:03:44 2014 -0400 Committer: Scott Blum Committed: Wed Aug 6 23:57:53 2014 -0400 -- .../framework/recipes/cache/TreeCache.java | 2 ++ .../recipes/cache/BaseTestTreeCache.java| 7 +++ .../framework/recipes/cache/TestTreeCache.java | 20 +++- .../recipes/cache/TestTreeCacheRandomTree.java | 5 ++--- 4 files changed, 22 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/be85e96e/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index 0d5995a..1ec0440 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -305,6 +305,7 @@ public class TreeCache implements Closeable break; default: handleException(new Exception(String.format("Unknown event %s", event))); +break; } if ( outstandingOps.decrementAndGet() == 0 ) @@ -593,6 +594,7 @@ public class TreeCache implements Closeable publishEvent(TreeCacheEvent.Type.CONNECTION_LOST); break; +case CONNECTED: case RECONNECTED: try { http://git-wip-us.apache.org/repos/asf/curator/blob/be85e96e/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java index f59af30..5842c21 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java @@ -39,7 +39,7 @@ public class BaseTestTreeCache extends BaseClassForTests { private final Timing timing = new Timing(); CuratorFramework client; -TreeCache cache; +MyTreeCache cache; private List exceptions; private BlockingQueue events; TreeCacheListener eventListener; @@ -47,10 +47,10 @@ public class BaseTestTreeCache extends BaseClassForTests /** * A TreeCache that records exceptions and automatically adds a listener. */ -class TreeCache extends org.apache.curator.framework.recipes.cache.TreeCache +class MyTreeCache extends TreeCache { -TreeCache(CuratorFramework client, String path, boolean cacheData) +MyTreeCache(CuratorFramework client, String path, boolean cacheData) { super(client, path, cacheData); getListenable().addListener(eventListener); @@ -95,7 +95,6 @@ public class BaseTestTreeCache extends BaseClassForTests exceptions.add(e); } }); -cache = new TreeCache(client, "/test", true); } @Override http://git-wip-us.apache.org/repos/asf/curator/blob/be85e96e/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index f35d24d..33d08b0 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -39,6 +39,7 @@ public class TestTreeCache extends BaseTestTreeCache client.create().forPath("/test/3", "three".getBytes()); client.create().forPath("/test/2/sub", "two-sub".getBytes()); +cache = new MyTreeCache(client, "/test", true); cache.start(); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test"); assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/1", "one".getBytes()); @@ -57,6 +58,7
[7/9] git commit: Fix startup connection problem.
Fix startup connection problem. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/462121f9 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/462121f9 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/462121f9 Branch: refs/heads/master Commit: 462121f98a4129f9b96ff0a5ebeafe4eac224a38 Parents: be85e96 Author: Scott Blum Authored: Thu Aug 7 15:25:21 2014 -0400 Committer: Scott Blum Committed: Thu Aug 7 19:26:51 2014 -0400 -- .../framework/recipes/cache/TreeCache.java | 22 --- .../recipes/cache/BaseTestTreeCache.java| 4 +++ .../framework/recipes/cache/TestTreeCache.java | 28 3 files changed, 51 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/462121f9/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index 1ec0440..617d652 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -304,8 +304,11 @@ public class TreeCache implements Closeable } break; default: -handleException(new Exception(String.format("Unknown event %s", event))); -break; +// An unknown event, probably an error of some sort like connection loss. +LOG.info(String.format("Unknown event %s", event)); +// Don't produce an initialized event on error; reconnect can fix this. +outstandingOps.decrementAndGet(); +return; } if ( outstandingOps.decrementAndGet() == 0 ) @@ -424,7 +427,10 @@ public class TreeCache implements Closeable { Preconditions.checkState(treeState.compareAndSet(TreeState.LATENT, TreeState.STARTED), "already started"); client.getConnectionStateListenable().addListener(connectionStateListener); -root.wasCreated(); +if (client.getZookeeperClient().isConnected()) +{ +root.wasCreated(); +} } /** @@ -595,6 +601,16 @@ public class TreeCache implements Closeable break; case CONNECTED: +try +{ +root.wasCreated(); +} +catch ( Exception e ) +{ +handleException(e); +} +break; + case RECONNECTED: try { http://git-wip-us.apache.org/repos/asf/curator/blob/462121f9/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java index 5842c21..1daf14d 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java @@ -85,6 +85,10 @@ public class BaseTestTreeCache extends BaseClassForTests } }; +initCuratorFramework(); +} + +void initCuratorFramework() { client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); client.start(); client.getUnhandledErrorListenable().addListener(new UnhandledErrorListener() http://git-wip-us.apache.org/repos/asf/curator/blob/462121f9/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index 33d08b0..abdbb8b 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -342,4 +342,32 @@ public class TestTreeCache extends BaseTestTreeCache client.delete().forPath("/test/one"); assertNoMoreEvents(); } + +/** + * Make sure TreeCache gets to a sane state when we
[2/9] git commit: Namespaces working.
Namespaces working. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/cf700d37 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/cf700d37 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/cf700d37 Branch: refs/heads/master Commit: cf700d37322786a153065169bc921fe41466e793 Parents: 470d7e7 Author: Scott Blum Authored: Tue Jul 29 19:28:23 2014 -0400 Committer: Scott Blum Committed: Thu Jul 31 18:23:49 2014 -0400 -- .../framework/recipes/cache/TestTreeCache.java | 116 ++- 1 file changed, 90 insertions(+), 26 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/cf700d37/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index 2922d40..bc999bf 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -52,16 +52,18 @@ public class TestTreeCache extends BaseClassForTests /** * A TreeCache that records exceptions. */ -private TreeCache newTreeCache(String path, boolean cacheData) -{ -return new TreeCache(client, path, cacheData) +class TreeCache extends org.apache.curator.framework.recipes.cache.TreeCache { + +TreeCache(CuratorFramework client, String path, boolean cacheData) { -@Override -protected void handleException(Throwable e) -{ -exceptions.add(e); -} -}; +super(client, path, cacheData); +} + +@Override +protected void handleException(Throwable e) +{ +exceptions.add(e); +} } @Override @@ -77,6 +79,11 @@ public class TestTreeCache extends BaseClassForTests @Override public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception { +if (event.getData() != null && event.getData().getPath().startsWith("/zookeeper")) +{ +// Suppress any events related to /zookeeper paths +return; +} events.add(event); } }; @@ -84,15 +91,14 @@ public class TestTreeCache extends BaseClassForTests client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); client.start(); client.getUnhandledErrorListenable().addListener(new UnhandledErrorListener() - { - @Override - public void unhandledError(String message, Throwable e) - { - exceptions.add(e); - } - } -); -cache = newTreeCache("/test", true); +{ +@Override +public void unhandledError(String message, Throwable e) +{ +exceptions.add(e); +} +}); +cache = new TreeCache(client, "/test", true); cache.getListenable().addListener(eventListener); } @@ -104,9 +110,18 @@ public class TestTreeCache extends BaseClassForTests { try { -for ( Throwable exception : exceptions ) +if ( exceptions.size() == 1 ) +{ +Assert.fail("Exception was thrown", exceptions.get(0)); +} +else if ( exceptions.size() > 1 ) { -Assert.fail("Exception was thrown", exception); +AssertionError error = new AssertionError("Multiple exceptions were thrown"); +for ( Throwable exception : exceptions ) +{ +error.addSuppressed(exception); +} +throw error; } } finally @@ -169,6 +184,55 @@ public class TestTreeCache extends BaseClassForTests } @Test +public void testFromRoot() throws Exception +{ +
[4/9] git commit: Fix potential race condition.
Fix potential race condition. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/26749277 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/26749277 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/26749277 Branch: refs/heads/master Commit: 267492779ac127d22c67791c799b73d46dfeac7a Parents: f474333 Author: Scott Blum Authored: Fri Aug 1 15:23:16 2014 -0400 Committer: Scott Blum Committed: Fri Aug 1 15:28:15 2014 -0400 -- .../framework/recipes/cache/TreeCache.java | 58 +--- 1 file changed, 39 insertions(+), 19 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/26749277/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index f73861d..0d5995a 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -71,14 +71,14 @@ public class TreeCache implements Closeable private final class TreeNode implements Watcher, BackgroundCallback { -private final AtomicReference nodeState = new AtomicReference(NodeState.PENDING); -private final String path; -private final TreeNode parent; -private final AtomicReference stat = new AtomicReference(); -private final AtomicReference data = new AtomicReference(); -private final AtomicReference> children = new AtomicReference>(); - -private TreeNode(String path, TreeNode parent) +final AtomicReference nodeState = new AtomicReference(NodeState.PENDING); +final TreeNode parent; +final String path; +final AtomicReference stat = new AtomicReference(); +final AtomicReference data = new AtomicReference(); +final AtomicReference> children = new AtomicReference>(); + +TreeNode(String path, TreeNode parent) { this.path = path; this.parent = parent; @@ -86,19 +86,30 @@ public class TreeCache implements Closeable private void refresh() throws Exception { -refreshData(); -refreshChildren(); +outstandingOps.addAndGet(2); +doRefreshData(); +doRefreshChildren(); } private void refreshChildren() throws Exception { outstandingOps.incrementAndGet(); - client.getChildren().usingWatcher(this).inBackground(this).forPath(path); +doRefreshChildren(); } private void refreshData() throws Exception { outstandingOps.incrementAndGet(); +doRefreshData(); +} + +private void doRefreshChildren() throws Exception +{ + client.getChildren().usingWatcher(this).inBackground(this).forPath(path); +} + +private void doRefreshData() throws Exception +{ if ( dataIsCompressed ) { client.getData().decompressed().usingWatcher(this).inBackground(this).forPath(path); @@ -109,7 +120,7 @@ public class TreeCache implements Closeable } } -private void wasReconnected() throws Exception +void wasReconnected() throws Exception { refresh(); ConcurrentMap childMap = children.get(); @@ -122,12 +133,12 @@ public class TreeCache implements Closeable } } -private void wasCreated() throws Exception +void wasCreated() throws Exception { refresh(); } -private void wasDeleted() throws Exception +void wasDeleted() throws Exception { stat.set(null); data.set(null); @@ -200,6 +211,7 @@ public class TreeCache implements Closeable @Override public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { +Stat newStat = event.getStat(); switch ( event.getType() ) { case EXISTS: @@ -217,7 +229,12 @@ public class TreeCache implements Closeable case CHILDREN: if ( event.getResultCode() == KeeperException.Code.OK.intValue() ) { -stat.set(event.getStat()); +Stat oldStat = stat.get(); +if (oldStat != null && oldStat.getMzxid() == newStat.getMzxid()) { +// Only update st
[9/9] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/curator
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/curator Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/ad6c23ad Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ad6c23ad Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ad6c23ad Branch: refs/heads/master Commit: ad6c23adcd504ca98afe07c3ddaed92ae35a1c0d Parents: 9eafd05 3c1a4ed Author: randgalt Authored: Thu Aug 7 21:09:02 2014 -0500 Committer: randgalt Committed: Thu Aug 7 21:09:02 2014 -0500 -- .../org/apache/curator/ConnectionState.java | 1 - .../apache/curator/CuratorZookeeperClient.java | 5 +- .../framework/imps/CuratorFrameworkImpl.java| 5 +- .../recipes/leader/LeaderSelector.java | 1 - .../locks/StandardLockInternalsDriver.java | 1 - .../recipes/nodes/PersistentEphemeralNode.java | 5 +- .../x/discovery/ServiceDiscoveryBuilder.java| 12 +++- .../details/TestServiceDiscoveryBuilder.java| 67 8 files changed, 81 insertions(+), 16 deletions(-) --
[8/9] git commit: Merge branch 'CURATOR-33' of github.com:dragonsinth/curator into CURATOR-33
Merge branch 'CURATOR-33' of github.com:dragonsinth/curator into CURATOR-33 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/9eafd05f Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/9eafd05f Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/9eafd05f Branch: refs/heads/master Commit: 9eafd05f285bf8cd9d44263f9dd5daea07e69491 Parents: 74497c0 462121f Author: randgalt Authored: Thu Aug 7 20:58:33 2014 -0500 Committer: randgalt Committed: Thu Aug 7 20:58:33 2014 -0500 -- .../framework/recipes/cache/TreeCache.java | 22 +-- .../recipes/cache/BaseTestTreeCache.java| 4 +++ .../framework/recipes/cache/TestTreeCache.java | 28 3 files changed, 52 insertions(+), 2 deletions(-) --
git commit: website doc for new TreeCache
Repository: curator Updated Branches: refs/heads/master ad6c23adc -> b052f00ba website doc for new TreeCache Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b052f00b Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b052f00b Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b052f00b Branch: refs/heads/master Commit: b052f00ba550940eb42336e13ee91e6e0a84e8cb Parents: ad6c23a Author: randgalt Authored: Thu Aug 7 21:21:31 2014 -0500 Committer: randgalt Committed: Thu Aug 7 21:21:31 2014 -0500 -- .../src/site/confluence/Tree-cache.confluence | 39 .../src/site/confluence/index.confluence| 1 + .../src/site/confluence/path-cache.confluence | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/b052f00b/curator-recipes/src/site/confluence/Tree-cache.confluence -- diff --git a/curator-recipes/src/site/confluence/Tree-cache.confluence b/curator-recipes/src/site/confluence/Tree-cache.confluence new file mode 100644 index 000..0d67857 --- /dev/null +++ b/curator-recipes/src/site/confluence/Tree-cache.confluence @@ -0,0 +1,39 @@ +h1. Tree Cache + +h2. Description +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. + +h2. Participating Classes +* TreeCache +* TreeCacheListener +* TreeCacheEvent +* ChildData + +h2. Usage +h3. Creating a TreeCache +{code} +public TreeCache(CuratorFramework client, + String path, + boolean cacheData) +Parameters: +client - the client +path - path to watch +cacheData - if true, node contents are cached in addition to the stat +{code} + +h2. General Usage +The cache must be started by calling {{start()}}. Call {{close()}} when you are through with the cache. + +At any time, call {{getCurrentChildren()}} to get the current state of the cache. Alternatively, call {{getCurrentData()}} to get +the data for a given path that's being monitored. + +You can also register to be notified when a change occurs by calling {{getListenable()}} and then: +{code} +public void addListener(TreeCacheListener listener) + Add a change listener +Parameters: +listener - the listener +{code} + +h2. Error Handling +TreeCache instances internally monitor a {{ConnectionStateListener}}. If the connection state changes, the cache will receive messages detailing the change. http://git-wip-us.apache.org/repos/asf/curator/blob/b052f00b/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 0b00ed2..a43963c 100644 --- a/curator-recipes/src/site/confluence/index.confluence +++ b/curator-recipes/src/site/confluence/index.confluence @@ -24,6 +24,7 @@ Curator implements all of the recipes listed on the ZooKeeper recipes doc (excep ||Caches|| |[[Path Cache|path-cache.html]] \- A Path Cache is used to watch a ZNode. Whenever a child is added, updated or removed, the Path Cache will change its state to contain the current set of children, the children's data and the children's state. Path caches in the Curator Framework are provided by the PathChildrenCache class. Changes to the path are passed to registered PathChildrenCacheListener instances.| |[[Node Cache|node-cache.html]] \- A utility that attempts to keep the data from a node locally cached. This class will watch the node, respond to update/create/delete events, pull down the data, etc. You can register a listener that will get notified when changes occur.| +|[[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..| http://git-wip-us.apache.org/repos/asf/curator/blob/b052f00b/curator-recipes/src/site/confluence/path-cache.confluence -- diff --git a/curator-recipes/src/site/confluence/path-cache.confluence b/curator-recipes/src/site/confluence/path-cache.confluence index a8f2320..1ced99d 10
git commit: CURATOR-137: BaseTestTreeCache compiles for JDK6
Repository: curator Updated Branches: refs/heads/master b052f00ba -> 6bd0cc3e9 CURATOR-137: BaseTestTreeCache compiles for JDK6 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6bd0cc3e Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6bd0cc3e Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6bd0cc3e Branch: refs/heads/master Commit: 6bd0cc3e9fff7a1af186893e051e305f636c0bee Parents: b052f00 Author: Scott Blum Authored: Fri Aug 8 16:21:59 2014 -0400 Committer: Scott Blum Committed: Fri Aug 8 16:21:59 2014 -0400 -- .../recipes/cache/BaseTestTreeCache.java| 68 +--- 1 file changed, 29 insertions(+), 39 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/6bd0cc3e/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java index 1daf14d..eb903b5 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java @@ -29,20 +29,32 @@ import org.apache.curator.utils.CloseableUtils; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; public class BaseTestTreeCache extends BaseClassForTests { -private final Timing timing = new Timing(); CuratorFramework client; MyTreeCache cache; -private List exceptions; -private BlockingQueue events; -TreeCacheListener eventListener; +private final AtomicBoolean hadBackgroundException = new AtomicBoolean(false); +private final BlockingQueue events = new LinkedBlockingQueue(); +private final Timing timing = new Timing(); + +final TreeCacheListener eventListener = new TreeCacheListener() +{ +@Override +public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception +{ +if ( event.getData() != null && event.getData().getPath().startsWith("/zookeeper") ) +{ +// Suppress any events related to /zookeeper paths +return; +} +events.add(event); +} +}; /** * A TreeCache that records exceptions and automatically adds a listener. @@ -59,7 +71,7 @@ public class BaseTestTreeCache extends BaseClassForTests @Override protected void handleException(Throwable e) { -exceptions.add(e); +handleBackgroundException(e); } } @@ -68,27 +80,11 @@ public class BaseTestTreeCache extends BaseClassForTests public void setup() throws Exception { super.setup(); - -exceptions = new ArrayList(); -events = new LinkedBlockingQueue(); -eventListener = new TreeCacheListener() -{ -@Override -public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception -{ -if ( event.getData() != null && event.getData().getPath().startsWith("/zookeeper") ) -{ -// Suppress any events related to /zookeeper paths -return; -} -events.add(event); -} -}; - initCuratorFramework(); } -void initCuratorFramework() { +void initCuratorFramework() +{ client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); client.start(); client.getUnhandledErrorListenable().addListener(new UnhandledErrorListener() @@ -96,11 +92,17 @@ public class BaseTestTreeCache extends BaseClassForTests @Override public void unhandledError(String message, Throwable e) { -exceptions.add(e); +handleBackgroundException(e); } }); } +private void handleBackgroundException(Throwable exception) +{ +hadBackgroundException.set(true); +exception.printStackTrace(System.err); +} + @Override @AfterMethod public void teardown() throws Exception @@ -109,19 +111,7 @@ public class BaseTestTreeCache ext
git commit: closes #16 Given that we will deprecate these classes I don't think this is needed anymore
Repository: curator Updated Branches: refs/heads/master 0d1397af1 -> bc81d75a4 closes #16 Given that we will deprecate these classes I don't think this is needed anymore Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/bc81d75a Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/bc81d75a Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/bc81d75a Branch: refs/heads/master Commit: bc81d75a4ef1e9c961cd206491236593c76c74c7 Parents: 0d1397a Author: randgalt Authored: Wed Aug 20 10:47:54 2014 -0500 Committer: randgalt Committed: Wed Aug 20 10:47:54 2014 -0500 -- --
git commit: closes #34 - no longer needed
Repository: curator Updated Branches: refs/heads/master bc81d75a4 -> e6fc38cf5 closes #34 - no longer needed Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/e6fc38cf Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/e6fc38cf Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/e6fc38cf Branch: refs/heads/master Commit: e6fc38cf58b9cf47d596e2b008c8b7526df6af9b Parents: bc81d75 Author: randgalt Authored: Wed Aug 20 15:38:36 2014 -0500 Committer: randgalt Committed: Wed Aug 20 15:38:36 2014 -0500 -- --
[2/2] git commit: Merge branch 'CURATOR-136' of github.com:madrob/curator into CURATOR-136
Merge branch 'CURATOR-136' of github.com:madrob/curator into CURATOR-136 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/7bec246d Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/7bec246d Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/7bec246d Branch: refs/heads/master Commit: 7bec246de89e06716089c3d36c7b20412eba6985 Parents: e6fc38c 05254af Author: randgalt Authored: Wed Aug 20 16:13:35 2014 -0500 Committer: randgalt Committed: Wed Aug 20 16:13:35 2014 -0500 -- .../src/main/java/org/apache/curator/utils/PathUtils.java| 7 +-- .../framework/recipes/atomic/DistributedAtomicValue.java | 4 +++- .../curator/framework/recipes/atomic/PromotedToLock.java | 3 ++- .../framework/recipes/barriers/DistributedBarrier.java | 3 ++- .../framework/recipes/barriers/DistributedDoubleBarrier.java | 3 ++- .../apache/curator/framework/recipes/cache/ChildData.java| 3 ++- .../curator/framework/recipes/cache/GetDataOperation.java| 4 +++- .../apache/curator/framework/recipes/cache/NodeCache.java| 3 ++- .../curator/framework/recipes/cache/PathChildrenCache.java | 3 ++- .../apache/curator/framework/recipes/cache/TreeCache.java| 3 ++- .../apache/curator/framework/recipes/leader/LeaderLatch.java | 5 +++-- .../curator/framework/recipes/leader/LeaderSelector.java | 3 ++- .../apache/curator/framework/recipes/locks/ChildReaper.java | 3 ++- .../framework/recipes/locks/InterProcessMultiLock.java | 1 + .../curator/framework/recipes/locks/InterProcessMutex.java | 3 ++- .../framework/recipes/locks/InterProcessSemaphore.java | 1 + .../framework/recipes/locks/InterProcessSemaphoreV2.java | 2 ++ .../curator/framework/recipes/locks/LockInternals.java | 3 +-- .../curator/framework/recipes/locks/PredicateResults.java| 4 +++- .../framework/recipes/nodes/PersistentEphemeralNode.java | 3 ++- .../curator/framework/recipes/queue/ChildrenCache.java | 3 ++- .../curator/framework/recipes/queue/DistributedQueue.java| 6 +++--- .../apache/curator/framework/recipes/queue/QueueBuilder.java | 5 +++-- .../apache/curator/framework/recipes/queue/QueueSafety.java | 5 +++-- .../framework/recipes/queue/SimpleDistributedQueue.java | 3 ++- .../apache/curator/framework/recipes/shared/SharedValue.java | 3 ++- .../curator/framework/recipes/leader/TestLeaderLatch.java| 8 27 files changed, 67 insertions(+), 30 deletions(-) --
[1/2] git commit: CURATOR-136 Consistent relpath handling in recipes
Repository: curator Updated Branches: refs/heads/master e6fc38cf5 -> 7bec246de CURATOR-136 Consistent relpath handling in recipes LeaderLatch would previously normalize a relative path in some places but not others, causing inconsistent behavior. Make it check for an absolute path on startup. Additionally, scrub through the rest of the recipes and validate that the path given is also valid before processing so that clients will see failures early. Modify PathUtils.validatePath to return the path given, for fluent- style invocation, modelled on guava's Preconditions. This closes #39 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/05254afe Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/05254afe Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/05254afe Branch: refs/heads/master Commit: 05254afea628a1018e1058d230a568746f98df5a Parents: 0d1397a Author: Mike Drob Authored: Mon Aug 11 15:12:53 2014 -0500 Committer: Mike Drob Committed: Wed Aug 20 16:08:40 2014 -0500 -- .../src/main/java/org/apache/curator/utils/PathUtils.java| 7 +-- .../framework/recipes/atomic/DistributedAtomicValue.java | 4 +++- .../curator/framework/recipes/atomic/PromotedToLock.java | 3 ++- .../framework/recipes/barriers/DistributedBarrier.java | 3 ++- .../framework/recipes/barriers/DistributedDoubleBarrier.java | 3 ++- .../apache/curator/framework/recipes/cache/ChildData.java| 3 ++- .../curator/framework/recipes/cache/GetDataOperation.java| 4 +++- .../apache/curator/framework/recipes/cache/NodeCache.java| 3 ++- .../curator/framework/recipes/cache/PathChildrenCache.java | 3 ++- .../apache/curator/framework/recipes/cache/TreeCache.java| 3 ++- .../apache/curator/framework/recipes/leader/LeaderLatch.java | 5 +++-- .../curator/framework/recipes/leader/LeaderSelector.java | 3 ++- .../apache/curator/framework/recipes/locks/ChildReaper.java | 3 ++- .../framework/recipes/locks/InterProcessMultiLock.java | 1 + .../curator/framework/recipes/locks/InterProcessMutex.java | 3 ++- .../framework/recipes/locks/InterProcessSemaphore.java | 1 + .../framework/recipes/locks/InterProcessSemaphoreV2.java | 2 ++ .../curator/framework/recipes/locks/LockInternals.java | 3 +-- .../curator/framework/recipes/locks/PredicateResults.java| 4 +++- .../framework/recipes/nodes/PersistentEphemeralNode.java | 3 ++- .../curator/framework/recipes/queue/ChildrenCache.java | 3 ++- .../curator/framework/recipes/queue/DistributedQueue.java| 6 +++--- .../apache/curator/framework/recipes/queue/QueueBuilder.java | 5 +++-- .../apache/curator/framework/recipes/queue/QueueSafety.java | 5 +++-- .../framework/recipes/queue/SimpleDistributedQueue.java | 3 ++- .../apache/curator/framework/recipes/shared/SharedValue.java | 3 ++- .../curator/framework/recipes/leader/TestLeaderLatch.java| 8 27 files changed, 67 insertions(+), 30 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/05254afe/curator-client/src/main/java/org/apache/curator/utils/PathUtils.java -- diff --git a/curator-client/src/main/java/org/apache/curator/utils/PathUtils.java b/curator-client/src/main/java/org/apache/curator/utils/PathUtils.java index c491874..4fcf05b 100644 --- a/curator-client/src/main/java/org/apache/curator/utils/PathUtils.java +++ b/curator-client/src/main/java/org/apache/curator/utils/PathUtils.java @@ -40,9 +40,10 @@ public class PathUtils { /** * Validate the provided znode path string * @param path znode path string + * @return The given path if it was valid, for fluent chaining * @throws IllegalArgumentException if the path is invalid */ -public static void validatePath(String path) throws IllegalArgumentException { +public static String validatePath(String path) throws IllegalArgumentException { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } @@ -54,7 +55,7 @@ public class PathUtils { "Path must start with / character"); } if (path.length() == 1) { // done checking - it's the root -return; +return path; } if (path.charAt(path.length() - 1) == '/') { throw new IllegalArgumentException( @@ -101,5 +102,7 @@ public class PathUtils { throw new IllegalArgumentException( "Invalid path string \"" + path + "\" caused by " + reason); } + +return path; } } http://git-wip-us.apache.org/repos/asf/curator/blob/05254afe/curator-recipes/src/main/java/org/apache/curator/framework/recipes/atomic/DistributedAto
[2/2] git commit: Merge branch 'master' into CURATOR-132
Merge branch 'master' into CURATOR-132 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/053feb45 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/053feb45 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/053feb45 Branch: refs/heads/master Commit: 053feb45eb7e3cb774dd1551645ddafa9a83f832 Parents: 9735138 7bec246 Author: randgalt Authored: Wed Aug 20 16:24:11 2014 -0500 Committer: randgalt Committed: Wed Aug 20 16:24:11 2014 -0500 -- .../org/apache/curator/ConnectionState.java | 1 - .../apache/curator/CuratorZookeeperClient.java | 5 +- .../org/apache/curator/utils/PathUtils.java | 7 +- .../java/org/apache/curator/utils/ZKPaths.java | 16 + .../org/apache/curator/utils/TestZKPaths.java | 11 + .../framework/imps/CuratorFrameworkImpl.java| 5 +- .../recipes/atomic/DistributedAtomicValue.java | 4 +- .../recipes/atomic/PromotedToLock.java | 3 +- .../recipes/barriers/DistributedBarrier.java| 3 +- .../barriers/DistributedDoubleBarrier.java | 3 +- .../framework/recipes/cache/ChildData.java | 3 +- .../recipes/cache/GetDataOperation.java | 4 +- .../framework/recipes/cache/NodeCache.java | 3 +- .../recipes/cache/PathChildrenCache.java| 7 +- .../framework/recipes/cache/TreeCache.java | 667 +++ .../framework/recipes/cache/TreeCacheEvent.java | 134 .../recipes/cache/TreeCacheListener.java| 37 + .../framework/recipes/leader/LeaderLatch.java | 5 +- .../recipes/leader/LeaderSelector.java | 4 +- .../framework/recipes/locks/ChildReaper.java| 3 +- .../recipes/locks/InterProcessMultiLock.java| 1 + .../recipes/locks/InterProcessMutex.java| 3 +- .../recipes/locks/InterProcessSemaphore.java| 1 + .../recipes/locks/InterProcessSemaphoreV2.java | 2 + .../framework/recipes/locks/LockInternals.java | 3 +- .../recipes/locks/PredicateResults.java | 4 +- .../locks/StandardLockInternalsDriver.java | 1 - .../recipes/nodes/PersistentEphemeralNode.java | 8 +- .../framework/recipes/queue/ChildrenCache.java | 3 +- .../recipes/queue/DistributedQueue.java | 6 +- .../framework/recipes/queue/QueueBuilder.java | 5 +- .../framework/recipes/queue/QueueSafety.java| 5 +- .../recipes/queue/SimpleDistributedQueue.java | 3 +- .../framework/recipes/shared/SharedValue.java | 3 +- .../src/site/confluence/Tree-cache.confluence | 39 ++ .../src/site/confluence/index.confluence| 1 + .../src/site/confluence/path-cache.confluence | 2 +- .../recipes/cache/BaseTestTreeCache.java| 166 + .../recipes/cache/TestPathChildrenCache.java| 105 ++- .../framework/recipes/cache/TestTreeCache.java | 373 +++ .../recipes/cache/TestTreeCacheRandomTree.java | 198 ++ .../recipes/leader/TestLeaderLatch.java | 8 + .../x/discovery/ServiceDiscoveryBuilder.java| 12 +- .../discovery/details/DownInstanceManager.java | 11 +- .../discovery/details/ServiceDiscoveryImpl.java | 26 +- .../details/TestServiceDiscoveryBuilder.java| 67 ++ pom.xml | 16 +- 47 files changed, 1943 insertions(+), 54 deletions(-) --
[1/2] git commit: CURATOR-132 - Modified the NamespaceFacade so that it does not proxy getACL() and setACL() calls to the underlying client (which is not namespace aware), and instead handles them its
Repository: curator Updated Branches: refs/heads/master 7bec246de -> 053feb45e CURATOR-132 - Modified the NamespaceFacade so that it does not proxy getACL() and setACL() calls to the underlying client (which is not namespace aware), and instead handles them itself. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/97351385 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/97351385 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/97351385 Branch: refs/heads/master Commit: 97351385561f3038b2aba9a25a617a204a14e023 Parents: f5767c8 Author: Cam McKenzie Authored: Mon Aug 4 10:04:22 2014 +1000 Committer: Cam McKenzie Committed: Mon Aug 4 10:04:22 2014 +1000 -- .../curator/framework/imps/NamespaceFacade.java | 12 - .../framework/imps/TestNamespaceFacade.java | 46 2 files changed, 46 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/97351385/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java index 3584ff9..818fe5f 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java @@ -71,18 +71,6 @@ class NamespaceFacade extends CuratorFrameworkImpl } @Override -public GetACLBuilder getACL() -{ -return client.getACL(); -} - -@Override -public SetACLBuilder setACL() -{ -return client.setACL(); -} - -@Override public Listenable getConnectionStateListenable() { return client.getConnectionStateListenable(); http://git-wip-us.apache.org/repos/asf/curator/blob/97351385/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java -- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java index f67c603..475e7e9 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestNamespaceFacade.java @@ -18,11 +18,18 @@ */ package org.apache.curator.framework.imps; +import java.util.Collections; +import java.util.List; + import org.apache.curator.test.BaseClassForTests; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.ExponentialBackoffRetry; import org.apache.curator.retry.RetryOneTime; +import org.apache.zookeeper.ZooDefs; +import org.apache.zookeeper.KeeperException.NoAuthException; +import org.apache.zookeeper.data.ACL; import org.testng.Assert; import org.testng.annotations.Test; @@ -183,4 +190,43 @@ public class TestNamespaceFacade extends BaseClassForTests client.close(); Assert.assertEquals(client.isStarted(), namespaced.isStarted()); } + +/** + * Test that ACLs work on a NamespaceFacade. See CURATOR-132 + * @throws Exception + */ +@Test +public void testACL() throws Exception +{ +CuratorFrameworkclient = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); +client.start(); +client.getZookeeperClient().blockUntilConnectedOrTimedOut(); + +client.create().creatingParentsIfNeeded().forPath("/parent/child", "A string".getBytes()); +CuratorFramework client2 = client.usingNamespace("parent"); + +Assert.assertNotNull(client2.getData().forPath("/child")); +client.setACL().withACL(Collections.singletonList( +new ACL(ZooDefs.Perms.WRITE, ZooDefs.Ids.ANYONE_ID_UNSAFE))). +forPath("/parent/child"); +// This will attempt to setACL on /parent/child, Previously this failed because /child +// isn't present. Using "child" would case a failure because the path didn't start with +// a slash +try +{ +List acls = client2.getACL().forPath("/child"); +Assert.assertNotNull(acls); +Assert.assertEquals(acls.size(), 1); +Assert.assertEquals(acls.get(0).getId(), ZooDefs.Ids.ANYONE_ID_UNSAFE); +Assert.assertEquals(acls.get(0).getPerms(), ZooDefs.Perms.WRITE); +
[1/3] git commit: CURATOR-79 - Modified the 'withProtection' handling, so that any failure that is not a ConnectionLossException or other KeeperException is treated the same as a ConnectionLossExcepti
Repository: curator Updated Branches: refs/heads/master 053feb45e -> f8aabb0bc CURATOR-79 - Modified the 'withProtection' handling, so that any failure that is not a ConnectionLossException or other KeeperException is treated the same as a ConnectionLossException. This means that if the thread gets interrupted, or encounters some sort of other error, during creation of a protected zNode, it will remove the affected zNode prior to rethrowing the exception. Exposed the debug UnhandledExceptionListener on the CuratorFrameworkImpl to reproduce this issue via a unit test. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5398b72f Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5398b72f Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5398b72f Branch: refs/heads/master Commit: 5398b72f00ccc0f2ea995865fcaf92d73c6c5818 Parents: 6bd0cc3 Author: Cam McKenzie Authored: Mon Aug 11 08:13:12 2014 +1000 Committer: Cam McKenzie Committed: Mon Aug 11 08:13:12 2014 +1000 -- .../framework/imps/CreateBuilderImpl.java | 20 ++ .../framework/imps/CuratorFrameworkImpl.java| 6 +- .../recipes/locks/TestInterProcessMutex.java| 72 3 files changed, 97 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/5398b72f/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java index 3cf23b8..3028cd5 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java @@ -469,6 +469,26 @@ class CreateBuilderImpl implements CreateBuilder, BackgroundOperationhttp://git-wip-us.apache.org/repos/asf/curator/blob/5398b72f/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java index e86b1e5..fbe1ec7 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java @@ -19,8 +19,10 @@ package org.apache.curator.framework.imps; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Preconditions; + import org.apache.curator.CuratorConnectionLossException; import org.apache.curator.CuratorZookeeperClient; import org.apache.curator.RetryLoop; @@ -44,6 +46,7 @@ import org.apache.zookeeper.Watcher; import org.apache.zookeeper.ZooKeeper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import java.util.Arrays; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; @@ -85,7 +88,8 @@ public class CuratorFrameworkImpl implements CuratorFramework } volatile DebugBackgroundListener debugListener = null; -volatile UnhandledErrorListener debugUnhandledErrorListener = null; +@VisibleForTesting +public volatile UnhandledErrorListener debugUnhandledErrorListener = null; private final AtomicReference state; http://git-wip-us.apache.org/repos/asf/curator/blob/5398b72f/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java index bbc3466..85e5c39 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java @@ -20,9 +20,14 @@ package org.apache.curator.framework.recipes.locks; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.framework.api.UnhandledErrorListener; +import org.apache.curator.framework.imps.CuratorFrameworkImpl; import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.Timing; +import org.apache.zookeeper.KeeperException.NodeExistsExce
[2/3] git commit: CURATOR-79 - Modified exception handling to occur in a single block. Updated some minor unit test niceties.
CURATOR-79 - Modified exception handling to occur in a single block. Updated some minor unit test niceties. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/c92ffee9 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/c92ffee9 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/c92ffee9 Branch: refs/heads/master Commit: c92ffee9de614aa43bf56a5ef9533b59cb9ded81 Parents: 5398b72 Author: Cam McKenzie Authored: Tue Aug 12 09:27:05 2014 +1000 Committer: Cam McKenzie Committed: Tue Aug 12 09:27:05 2014 +1000 -- .../framework/imps/CreateBuilderImpl.java | 31 +--- .../recipes/locks/TestInterProcessMutex.java| 4 +-- 2 files changed, 9 insertions(+), 26 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/c92ffee9/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java -- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java index 3028cd5..70b92ab 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java @@ -452,43 +452,26 @@ class CreateBuilderImpl implements CreateBuilder, BackgroundOperationhttp://git-wip-us.apache.org/repos/asf/curator/blob/c92ffee9/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java index 85e5c39..83f5473 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java @@ -155,12 +155,12 @@ public class TestInterProcessMutex extends TestInterProcessMutexBase //We need to reinterrupt in the debugUnhandledErrorListener above. Thread.currentThread().interrupt(); lock.acquire(); -Assert.fail(); +Assert.fail("Lock acquisition succeeded when failure was expected"); } catch(InterruptedException e) { //Expected lock to have failed. -Assert.assertTrue(!lock.isOwnedByCurrentThread()); +Assert.assertFalse(lock.isOwnedByCurrentThread()); } try
[3/3] git commit: Merge branch 'master' into CURATOR-79
Merge branch 'master' into CURATOR-79 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f8aabb0b Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f8aabb0b Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f8aabb0b Branch: refs/heads/master Commit: f8aabb0bce50f3f0fa7681e436ff1440237a70b3 Parents: c92ffee 053feb4 Author: randgalt Authored: Wed Aug 20 16:25:43 2014 -0500 Committer: randgalt Committed: Wed Aug 20 16:25:43 2014 -0500 -- .../org/apache/curator/utils/PathUtils.java | 7 +- .../curator/framework/imps/NamespaceFacade.java | 12 --- .../framework/imps/TestNamespaceFacade.java | 46 .../recipes/atomic/DistributedAtomicValue.java | 4 +- .../recipes/atomic/PromotedToLock.java | 3 +- .../recipes/barriers/DistributedBarrier.java| 3 +- .../barriers/DistributedDoubleBarrier.java | 3 +- .../framework/recipes/cache/ChildData.java | 3 +- .../recipes/cache/GetDataOperation.java | 4 +- .../framework/recipes/cache/NodeCache.java | 3 +- .../recipes/cache/PathChildrenCache.java| 7 +- .../framework/recipes/cache/TreeCache.java | 3 +- .../framework/recipes/leader/LeaderLatch.java | 5 +- .../recipes/leader/LeaderSelector.java | 3 +- .../framework/recipes/locks/ChildReaper.java| 3 +- .../recipes/locks/InterProcessMultiLock.java| 1 + .../recipes/locks/InterProcessMutex.java| 3 +- .../recipes/locks/InterProcessSemaphore.java| 1 + .../recipes/locks/InterProcessSemaphoreV2.java | 2 + .../framework/recipes/locks/LockInternals.java | 3 +- .../recipes/locks/PredicateResults.java | 4 +- .../recipes/nodes/PersistentEphemeralNode.java | 3 +- .../framework/recipes/queue/ChildrenCache.java | 3 +- .../recipes/queue/DistributedQueue.java | 6 +- .../framework/recipes/queue/QueueBuilder.java | 5 +- .../framework/recipes/queue/QueueSafety.java| 5 +- .../recipes/queue/SimpleDistributedQueue.java | 3 +- .../framework/recipes/shared/SharedValue.java | 3 +- .../recipes/cache/TestPathChildrenCache.java| 105 ++- .../recipes/leader/TestLeaderLatch.java | 8 ++ .../discovery/details/DownInstanceManager.java | 11 +- .../discovery/details/ServiceDiscoveryImpl.java | 26 - pom.xml | 16 ++- 33 files changed, 267 insertions(+), 50 deletions(-) --
[1/2] git commit: CURATOR-142 Make forkCount configurable
Repository: curator Updated Branches: refs/heads/master f8aabb0bc -> 7d30d3d19 CURATOR-142 Make forkCount configurable Value can be set on the command line by invocing as: mvn test -Dsurefire-forkcount=4 # Or whatever number you like This closes #40 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/72934da9 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/72934da9 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/72934da9 Branch: refs/heads/master Commit: 72934da915db7722af73087b06a16f4c9de2b66a Parents: 0d1397a Author: Mike Drob Authored: Wed Aug 20 13:05:06 2014 -0500 Committer: Mike Drob Committed: Wed Aug 20 13:05:45 2014 -0500 -- pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/72934da9/pom.xml -- diff --git a/pom.xml b/pom.xml index 60e718c..8abdca8 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,8 @@ 1.6 +1 + 2.7 2.9.1 @@ -669,7 +671,7 @@ org.apache.maven.plugins maven-surefire-plugin -1 +${surefire-forkcount} false true
[2/2] git commit: Merge branch 'CURATOR-142' of github.com:madrob/curator into CURATOR-142
Merge branch 'CURATOR-142' of github.com:madrob/curator into CURATOR-142 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/7d30d3d1 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/7d30d3d1 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/7d30d3d1 Branch: refs/heads/master Commit: 7d30d3d199d9ff10eb9062196e377459254ed1bd Parents: f8aabb0 72934da Author: randgalt Authored: Wed Aug 20 16:35:50 2014 -0500 Committer: randgalt Committed: Wed Aug 20 16:35:50 2014 -0500 -- pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --
git commit: minor re-format
Repository: curator Updated Branches: refs/heads/CURATOR-84 d5f55177f -> 942e23d4d minor re-format Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/942e23d4 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/942e23d4 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/942e23d4 Branch: refs/heads/CURATOR-84 Commit: 942e23d4ded3e7d687a1c818aacb69c0e7f8ba3d Parents: d5f5517 Author: randgalt Authored: Tue Aug 26 12:55:31 2014 -0500 Committer: randgalt Committed: Tue Aug 26 12:55:31 2014 -0500 -- .../recipes/locks/InterProcessMutex.java| 57 +--- 1 file changed, 26 insertions(+), 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/942e23d4/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java index 02a3d1f..c8032a8 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.framework.recipes.locks; import com.google.common.collect.Maps; @@ -35,15 +36,15 @@ import java.util.concurrent.atomic.AtomicInteger; */ public class InterProcessMutex implements InterProcessLock, Revocable { -private final LockInternals internals; -private final StringbasePath; +private final LockInternals internals; +private final String basePath; -private final ConcurrentMap threadData = Maps.newConcurrentMap(); +private final ConcurrentMap threadData = Maps.newConcurrentMap(); private static class LockData { -final ThreadowningThread; -final StringlockPath; +final Thread owningThread; +final String lockPath; final AtomicInteger lockCount = new AtomicInteger(1); private LockData(Thread owningThread, String lockPath) @@ -57,7 +58,7 @@ public class InterProcessMutex implements InterProcessLock, Revocable getParticipantNodes() throws Exception +public Collection getParticipantNodes() throws Exception { return LockInternals.getParticipantNodes(internals.getClient(), basePath, internals.getLockName(), internals.getDriver()); } @@ -177,21 +178,14 @@ public class InterProcessMutex implements InterProcessLock, Revocable listener, Executor executor) { -internals.makeRevocable -( -new RevocationSpec -( -executor, -new Runnable() +internals.makeRevocable(new RevocationSpec(executor, new Runnable() +{ +@Override +public void run() { -@Override -public void run() -{ -listener.revocationRequested(InterProcessMutex.this); -} +listener.revocationRequested(InterProcessMutex.this); } -) -); +})); } InterProcessMutex(CuratorFramework client, String path, String lockName, int maxLeases, LockInternalsDriver driver) @@ -200,19 +194,20 @@ public class InterProcessMutex implements InterProcessLock, Revocable 0); } -protected byte[]getLockNodeBytes() +protected byte[] getLockNodeBytes() { return null; } -protected String getLockPath() { -LockDatalockData = threadData.get(Thread.currentThread()); +protected String getLockPath() +{ +LockData lockData = threadData.get(Thread.currentThread()); return lockData != null ? lockData.lockPath : null; } @@ -223,9 +218,9 @@ public class InterProcessMutex implements InterProcessLock, Revocable
[6/7] git commit: minor re-format
minor re-format Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/942e23d4 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/942e23d4 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/942e23d4 Branch: refs/heads/master Commit: 942e23d4ded3e7d687a1c818aacb69c0e7f8ba3d Parents: d5f5517 Author: randgalt Authored: Tue Aug 26 12:55:31 2014 -0500 Committer: randgalt Committed: Tue Aug 26 12:55:31 2014 -0500 -- .../recipes/locks/InterProcessMutex.java| 57 +--- 1 file changed, 26 insertions(+), 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/942e23d4/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java index 02a3d1f..c8032a8 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.framework.recipes.locks; import com.google.common.collect.Maps; @@ -35,15 +36,15 @@ import java.util.concurrent.atomic.AtomicInteger; */ public class InterProcessMutex implements InterProcessLock, Revocable { -private final LockInternals internals; -private final StringbasePath; +private final LockInternals internals; +private final String basePath; -private final ConcurrentMap threadData = Maps.newConcurrentMap(); +private final ConcurrentMap threadData = Maps.newConcurrentMap(); private static class LockData { -final ThreadowningThread; -final StringlockPath; +final Thread owningThread; +final String lockPath; final AtomicInteger lockCount = new AtomicInteger(1); private LockData(Thread owningThread, String lockPath) @@ -57,7 +58,7 @@ public class InterProcessMutex implements InterProcessLock, Revocable getParticipantNodes() throws Exception +public Collection getParticipantNodes() throws Exception { return LockInternals.getParticipantNodes(internals.getClient(), basePath, internals.getLockName(), internals.getDriver()); } @@ -177,21 +178,14 @@ public class InterProcessMutex implements InterProcessLock, Revocable listener, Executor executor) { -internals.makeRevocable -( -new RevocationSpec -( -executor, -new Runnable() +internals.makeRevocable(new RevocationSpec(executor, new Runnable() +{ +@Override +public void run() { -@Override -public void run() -{ -listener.revocationRequested(InterProcessMutex.this); -} +listener.revocationRequested(InterProcessMutex.this); } -) -); +})); } InterProcessMutex(CuratorFramework client, String path, String lockName, int maxLeases, LockInternalsDriver driver) @@ -200,19 +194,20 @@ public class InterProcessMutex implements InterProcessLock, Revocable 0); } -protected byte[]getLockNodeBytes() +protected byte[] getLockNodeBytes() { return null; } -protected String getLockPath() { -LockDatalockData = threadData.get(Thread.currentThread()); +protected String getLockPath() +{ +LockData lockData = threadData.get(Thread.currentThread()); return lockData != null ? lockData.lockPath : null; } @@ -223,9 +218,9 @@ public class InterProcessMutex implements InterProcessLock, Revocable
[2/7] git commit: Merge branch 'CURATOR-84' of https://github.com/karkum/curator into CURATOR-84
Merge branch 'CURATOR-84' of https://github.com/karkum/curator into CURATOR-84 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/475a3b00 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/475a3b00 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/475a3b00 Branch: refs/heads/master Commit: 475a3b00a08dab6b5b6beb192ebe91039277a443 Parents: 0d1397a 882f541 Author: Cam McKenzie Authored: Wed Aug 20 16:49:16 2014 +1000 Committer: Cam McKenzie Committed: Wed Aug 20 16:49:16 2014 +1000 -- .../framework/recipes/locks/InterProcessMutex.java | 17 - .../framework/recipes/locks/LockInternals.java | 9 + .../recipes/locks/LockInternalsDriver.java | 4 +++- .../framework/recipes/locks/PredicateResults.java | 8 .../recipes/locks/StandardLockInternalsDriver.java | 17 + 5 files changed, 41 insertions(+), 14 deletions(-) --
[5/7] git commit: CURATOR-84 - Fixed up formatting
CURATOR-84 - Fixed up formatting Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/d5f55177 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/d5f55177 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/d5f55177 Branch: refs/heads/master Commit: d5f55177f4c7a4bd1e95d1e872d65463909a6d35 Parents: 6b19fe2 Author: Cam McKenzie Authored: Thu Aug 21 07:47:00 2014 +1000 Committer: Cam McKenzie Committed: Thu Aug 21 07:47:00 2014 +1000 -- .../recipes/locks/TestInterProcessMutex.java| 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/d5f55177/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java -- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java index c116a50..453de33 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java @@ -111,14 +111,18 @@ public class TestInterProcessMutex extends TestInterProcessMutexBase } @Test -public void testPersistentLock() throws Exception { +public void testPersistentLock() throws Exception +{ final CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)); client.start(); -try { -final InterProcessMutex lock = new InterProcessMutex(client, LOCK_PATH, new StandardLockInternalsDriver() { +try +{ +final InterProcessMutex lock = new InterProcessMutex(client, LOCK_PATH, new StandardLockInternalsDriver() +{ @Override -public String createsTheLock(CuratorFramework client, String path, byte[] lockNodeBytes) throws Exception { +public String createsTheLock(CuratorFramework client, String path, byte[] lockNodeBytes) throws Exception +{ String ourPath; if ( lockNodeBytes != null ) { @@ -145,9 +149,9 @@ public class TestInterProcessMutex extends TestInterProcessMutexBase lock.release(); Assert.assertNull(client.checkExists().forPath(actualLockPath)); } -finally { +finally +{ client.close(); } - } }
[4/7] git commit: Merge branch 'CURATOR-84' of https://github.com/karkum/curator into CURATOR-84
Merge branch 'CURATOR-84' of https://github.com/karkum/curator into CURATOR-84 Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6b19fe2b Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6b19fe2b Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6b19fe2b Branch: refs/heads/master Commit: 6b19fe2b1906f656712c9f5c1da7083870a3e8ac Parents: 475a3b0 6ecfd79 Author: Cam McKenzie Authored: Thu Aug 21 07:40:57 2014 +1000 Committer: Cam McKenzie Committed: Thu Aug 21 07:40:57 2014 +1000 -- .../recipes/locks/TestInterProcessMutex.java| 43 1 file changed, 43 insertions(+) --
[1/7] git commit: CURATOR-84 More flexibility for InterProcessMutex extensions
Repository: curator Updated Branches: refs/heads/master 7d30d3d19 -> f9c69199b CURATOR-84 More flexibility for InterProcessMutex extensions Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/882f5410 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/882f5410 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/882f5410 Branch: refs/heads/master Commit: 882f5410033e55c41fdc8db95e0fb2a2ecff7026 Parents: d2c37d0 Author: Karthik Kumar Authored: Sat Aug 16 13:11:54 2014 -0400 Committer: Karthik Kumar Committed: Tue Aug 19 09:31:41 2014 -0400 -- .../framework/recipes/locks/InterProcessMutex.java | 17 - .../framework/recipes/locks/LockInternals.java | 9 + .../recipes/locks/LockInternalsDriver.java | 4 +++- .../framework/recipes/locks/PredicateResults.java | 8 .../recipes/locks/StandardLockInternalsDriver.java | 17 + 5 files changed, 41 insertions(+), 14 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/882f5410/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java index ffdeb70..02a3d1f 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java @@ -61,7 +61,17 @@ public class InterProcessMutex implements InterProcessLock, Revocablehttp://git-wip-us.apache.org/repos/asf/curator/blob/882f5410/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java index 706b242..74022e0 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java @@ -214,14 +214,7 @@ public class LockInternals try { -if ( localLockNodeBytes != null ) -{ -ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path, localLockNodeBytes); -} -else -{ -ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path); -} +ourPath = driver.createsTheLock(client, path, localLockNodeBytes); hasTheLock = internalLockLoop(startMillis, millisToWait, ourPath); } catch ( KeeperException.NoNodeException e ) http://git-wip-us.apache.org/repos/asf/curator/blob/882f5410/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java index 1570eed..69e3ce6 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java @@ -21,7 +21,9 @@ package org.apache.curator.framework.recipes.locks; import org.apache.curator.framework.CuratorFramework; import java.util.List; -interface LockInternalsDriver extends LockInternalsSorter +public interface LockInternalsDriver extends LockInternalsSorter { public PredicateResults getsTheLock(CuratorFramework client, List children, String sequenceNodeName, int maxLeases) throws Exception; + +public String createsTheLock(CuratorFramework client, String path, byte[] lockNodeBytes) throws Exception; } http://git-wip-us.apache.org/repos/asf/curator/blob/882f5410/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java b/curator-recipes/src/main/java/org/apache/curator/
[7/7] git commit: Merge branch 'master' into CURATOR-84
Merge branch 'master' into CURATOR-84 Conflicts: curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/f9c69199 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/f9c69199 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/f9c69199 Branch: refs/heads/master Commit: f9c69199bf0ff81c49554e55133f319e1d880287 Parents: 942e23d 7d30d3d Author: randgalt Authored: Tue Aug 26 12:58:26 2014 -0500 Committer: randgalt Committed: Tue Aug 26 12:58:26 2014 -0500 -- .../org/apache/curator/utils/PathUtils.java | 7 ++- .../framework/imps/CreateBuilderImpl.java | 11 +++-- .../framework/imps/CuratorFrameworkImpl.java| 6 ++- .../curator/framework/imps/NamespaceFacade.java | 12 - .../framework/imps/TestNamespaceFacade.java | 46 .../recipes/atomic/DistributedAtomicValue.java | 4 +- .../recipes/atomic/PromotedToLock.java | 3 +- .../recipes/barriers/DistributedBarrier.java| 3 +- .../barriers/DistributedDoubleBarrier.java | 3 +- .../framework/recipes/cache/ChildData.java | 3 +- .../recipes/cache/GetDataOperation.java | 4 +- .../framework/recipes/cache/NodeCache.java | 3 +- .../recipes/cache/PathChildrenCache.java| 3 +- .../framework/recipes/cache/TreeCache.java | 3 +- .../framework/recipes/leader/LeaderLatch.java | 5 ++- .../recipes/leader/LeaderSelector.java | 3 +- .../framework/recipes/locks/ChildReaper.java| 3 +- .../recipes/locks/InterProcessMultiLock.java| 1 + .../recipes/locks/InterProcessMutex.java| 3 +- .../recipes/locks/InterProcessSemaphore.java| 1 + .../recipes/locks/InterProcessSemaphoreV2.java | 2 + .../framework/recipes/locks/LockInternals.java | 3 +- .../recipes/nodes/PersistentEphemeralNode.java | 3 +- .../framework/recipes/queue/ChildrenCache.java | 3 +- .../recipes/queue/DistributedQueue.java | 6 +-- .../framework/recipes/queue/QueueBuilder.java | 5 ++- .../framework/recipes/queue/QueueSafety.java| 5 ++- .../recipes/queue/SimpleDistributedQueue.java | 3 +- .../framework/recipes/shared/SharedValue.java | 3 +- .../recipes/leader/TestLeaderLatch.java | 8 pom.xml | 4 +- 31 files changed, 125 insertions(+), 47 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/f9c69199/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java -- http://git-wip-us.apache.org/repos/asf/curator/blob/f9c69199/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java --
[3/7] git commit: CURATOR-84 More flexibility for InterProcessMutex extensions
CURATOR-84 More flexibility for InterProcessMutex extensions Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6ecfd791 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6ecfd791 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6ecfd791 Branch: refs/heads/master Commit: 6ecfd791b47410b0d6d1ddae92eb0cffe406d85b Parents: d2c37d0 Author: Karthik Kumar Authored: Sat Aug 16 13:11:54 2014 -0400 Committer: Karthik Kumar Committed: Wed Aug 20 09:17:08 2014 -0400 -- .../recipes/locks/InterProcessMutex.java| 17 +++- .../framework/recipes/locks/LockInternals.java | 9 +--- .../recipes/locks/LockInternalsDriver.java | 4 +- .../recipes/locks/PredicateResults.java | 8 ++-- .../locks/StandardLockInternalsDriver.java | 17 .../recipes/locks/TestInterProcessMutex.java| 43 6 files changed, 84 insertions(+), 14 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/6ecfd791/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java index ffdeb70..02a3d1f 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/InterProcessMutex.java @@ -61,7 +61,17 @@ public class InterProcessMutex implements InterProcessLock, Revocablehttp://git-wip-us.apache.org/repos/asf/curator/blob/6ecfd791/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java index 706b242..74022e0 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java @@ -214,14 +214,7 @@ public class LockInternals try { -if ( localLockNodeBytes != null ) -{ -ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path, localLockNodeBytes); -} -else -{ -ourPath = client.create().creatingParentsIfNeeded().withProtection().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(path); -} +ourPath = driver.createsTheLock(client, path, localLockNodeBytes); hasTheLock = internalLockLoop(startMillis, millisToWait, ourPath); } catch ( KeeperException.NoNodeException e ) http://git-wip-us.apache.org/repos/asf/curator/blob/6ecfd791/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java index 1570eed..69e3ce6 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternalsDriver.java @@ -21,7 +21,9 @@ package org.apache.curator.framework.recipes.locks; import org.apache.curator.framework.CuratorFramework; import java.util.List; -interface LockInternalsDriver extends LockInternalsSorter +public interface LockInternalsDriver extends LockInternalsSorter { public PredicateResults getsTheLock(CuratorFramework client, List children, String sequenceNodeName, int maxLeases) throws Exception; + +public String createsTheLock(CuratorFramework client, String path, byte[] lockNodeBytes) throws Exception; } http://git-wip-us.apache.org/repos/asf/curator/blob/6ecfd791/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/PredicateResults.java index
git commit: Added APIs for getting/setting shared values with versions for better utility
Repository: curator Updated Branches: refs/heads/CURATOR-151 [created] 0c2a5a5b4 Added APIs for getting/setting shared values with versions for better utility Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0c2a5a5b Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0c2a5a5b Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0c2a5a5b Branch: refs/heads/CURATOR-151 Commit: 0c2a5a5b4f6cc07b9b1cd9c83ad77c3fa0170779 Parents: b66e9b6 Author: randgalt Authored: Thu Oct 2 13:04:26 2014 -0500 Committer: randgalt Committed: Thu Oct 2 13:04:26 2014 -0500 -- .../framework/recipes/shared/SharedCount.java | 28 ++- .../recipes/shared/SharedCountReader.java | 9 +- .../framework/recipes/shared/SharedValue.java | 138 - .../recipes/shared/SharedValueReader.java | 7 + .../recipes/shared/VersionedValue.java | 32 +++ .../recipes/shared/TestSharedCount.java | 195 +-- 6 files changed, 298 insertions(+), 111 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/0c2a5a5b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java index b2d1218..49b2f2d 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java @@ -18,6 +18,7 @@ */ package org.apache.curator.framework.recipes.shared; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; import com.google.common.util.concurrent.MoreExecutors; import org.apache.curator.framework.CuratorFramework; @@ -54,6 +55,13 @@ public class SharedCount implements Closeable, SharedCountReader, Listenable getVersionedValue() +{ +VersionedValue localValue = sharedValue.getVersionedValue(); +return new VersionedValue(localValue.getVersion(), fromBytes(localValue.getValue())); +} + /** * Change the shared count value irrespective of its previous state * @@ -81,6 +89,23 @@ public class SharedCount implements Closeable, SharedCountReader, Listenable newCount) throws Exception +{ +VersionedValue copy = new VersionedValue(newCount.getVersion(), toBytes(newCount.getValue())); +return sharedValue.trySetValue(copy); +} + @Override public void addListener(SharedCountListener listener) { @@ -131,7 +156,8 @@ public class SharedCount implements Closeable, SharedCountReader, Listenablehttp://git-wip-us.apache.org/repos/asf/curator/blob/0c2a5a5b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java index 3d3d6a4..cae31bb 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java @@ -30,5 +30,12 @@ public interface SharedCountReader extends Listenable * * @return count */ -int getCount(); +public int getCount(); + +/** + * Return the current count and version + * + * @return count and version + */ +public VersionedValue getVersionedValue(); } http://git-wip-us.apache.org/repos/asf/curator/blob/0c2a5a5b/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 5c4b53b..80fa53f 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 @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.framework.recipes.shared; import com.google.common.base.Function; @@ -25,6 +26,7 @@ import org.apache.curator.framework.api.CuratorWatcher; import
git commit: Added APIs for getting/setting shared values with versions for better utility
Repository: curator Updated Branches: refs/heads/master b66e9b6a7 -> 0c2a5a5b4 Added APIs for getting/setting shared values with versions for better utility Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0c2a5a5b Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0c2a5a5b Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0c2a5a5b Branch: refs/heads/master Commit: 0c2a5a5b4f6cc07b9b1cd9c83ad77c3fa0170779 Parents: b66e9b6 Author: randgalt Authored: Thu Oct 2 13:04:26 2014 -0500 Committer: randgalt Committed: Thu Oct 2 13:04:26 2014 -0500 -- .../framework/recipes/shared/SharedCount.java | 28 ++- .../recipes/shared/SharedCountReader.java | 9 +- .../framework/recipes/shared/SharedValue.java | 138 - .../recipes/shared/SharedValueReader.java | 7 + .../recipes/shared/VersionedValue.java | 32 +++ .../recipes/shared/TestSharedCount.java | 195 +-- 6 files changed, 298 insertions(+), 111 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/0c2a5a5b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java index b2d1218..49b2f2d 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java @@ -18,6 +18,7 @@ */ package org.apache.curator.framework.recipes.shared; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; import com.google.common.util.concurrent.MoreExecutors; import org.apache.curator.framework.CuratorFramework; @@ -54,6 +55,13 @@ public class SharedCount implements Closeable, SharedCountReader, Listenable getVersionedValue() +{ +VersionedValue localValue = sharedValue.getVersionedValue(); +return new VersionedValue(localValue.getVersion(), fromBytes(localValue.getValue())); +} + /** * Change the shared count value irrespective of its previous state * @@ -81,6 +89,23 @@ public class SharedCount implements Closeable, SharedCountReader, Listenable newCount) throws Exception +{ +VersionedValue copy = new VersionedValue(newCount.getVersion(), toBytes(newCount.getValue())); +return sharedValue.trySetValue(copy); +} + @Override public void addListener(SharedCountListener listener) { @@ -131,7 +156,8 @@ public class SharedCount implements Closeable, SharedCountReader, Listenablehttp://git-wip-us.apache.org/repos/asf/curator/blob/0c2a5a5b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java -- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java index 3d3d6a4..cae31bb 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCountReader.java @@ -30,5 +30,12 @@ public interface SharedCountReader extends Listenable * * @return count */ -int getCount(); +public int getCount(); + +/** + * Return the current count and version + * + * @return count and version + */ +public VersionedValue getVersionedValue(); } http://git-wip-us.apache.org/repos/asf/curator/blob/0c2a5a5b/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 5c4b53b..80fa53f 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 @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.curator.framework.recipes.shared; import com.google.common.base.Function; @@ -25,6 +26,7 @@ import org.apache.curator.framework.api.CuratorWatcher; imp
git commit: setData() was using the wrong path. It exhibited when SEQUENTIAL mode was used
Repository: curator Updated Branches: refs/heads/CURATOR-155 [created] 1e9b76e12 setData() was using the wrong path. It exhibited when SEQUENTIAL mode was used Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/1e9b76e1 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/1e9b76e1 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/1e9b76e1 Branch: refs/heads/CURATOR-155 Commit: 1e9b76e12589a0705b1328e42b2ddc026358c051 Parents: b9fb9ff Author: randgalt Authored: Fri Oct 24 10:44:36 2014 -0500 Committer: randgalt Committed: Fri Oct 24 10:44:36 2014 -0500 -- .../recipes/nodes/PersistentEphemeralNode.java | 2 +- .../nodes/TestPersistentEphemeralNode.java | 27 +--- 2 files changed, 19 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/1e9b76e1/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 1f8be75..d78573c 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 @@ -302,7 +302,7 @@ public class PersistentEphemeralNode implements Closeable this.data.set(Arrays.copyOf(data, data.length)); if ( isActive() ) { -client.setData().inBackground().forPath(basePath, this.data.get()); +client.setData().inBackground().forPath(getActualPath(), this.data.get()); } } http://git-wip-us.apache.org/repos/asf/curator/blob/1e9b76e1/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 c8a72d4..47ae757 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 @@ -189,19 +189,29 @@ public class TestPersistentEphemeralNode extends BaseClassForTests } @Test +public void testSettingDataSequential() throws Exception +{ +setDataTest(PersistentEphemeralNode.Mode.EPHEMERAL_SEQUENTIAL); +} + +@Test public void testSettingData() throws Exception { +setDataTest(PersistentEphemeralNode.Mode.EPHEMERAL); +} + +protected void setDataTest(PersistentEphemeralNode.Mode mode) throws Exception +{ PersistentEphemeralNode node = null; 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 = new PersistentEphemeralNode(client, mode, PATH, "a".getBytes()); node.start(); Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS)); -Assert.assertEquals(node.getActualPath(), PATH); -Assert.assertEquals(client.getData().forPath(PATH), "a".getBytes()); + Assert.assertEquals(client.getData().forPath(node.getActualPath()), "a".getBytes()); final Semaphore semaphore = new Semaphore(0); Watcher watcher = new Watcher() @@ -212,18 +222,17 @@ public class TestPersistentEphemeralNode extends BaseClassForTests semaphore.release(); } }; -client.checkExists().usingWatcher(watcher).forPath(PATH); + client.checkExists().usingWatcher(watcher).forPath(node.getActualPath()); node.setData("b".getBytes()); Assert.assertTrue(timing.acquireSemaphore(semaphore)); -Assert.assertEquals(node.getActualPath(), PATH); - Assert.assertEquals(client.getData().usingWatcher(watcher).forPath(PATH), "b".getBytes()); +Assert.assertEquals(node.getActualPath(), node.getActualPath()); + Assert
git commit: setData() was using the wrong path. It exhibited when SEQUENTIAL mode was used
Repository: curator Updated Branches: refs/heads/master b9fb9ffd5 -> 1e9b76e12 setData() was using the wrong path. It exhibited when SEQUENTIAL mode was used Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/1e9b76e1 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/1e9b76e1 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/1e9b76e1 Branch: refs/heads/master Commit: 1e9b76e12589a0705b1328e42b2ddc026358c051 Parents: b9fb9ff Author: randgalt Authored: Fri Oct 24 10:44:36 2014 -0500 Committer: randgalt Committed: Fri Oct 24 10:44:36 2014 -0500 -- .../recipes/nodes/PersistentEphemeralNode.java | 2 +- .../nodes/TestPersistentEphemeralNode.java | 27 +--- 2 files changed, 19 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/curator/blob/1e9b76e1/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 1f8be75..d78573c 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 @@ -302,7 +302,7 @@ public class PersistentEphemeralNode implements Closeable this.data.set(Arrays.copyOf(data, data.length)); if ( isActive() ) { -client.setData().inBackground().forPath(basePath, this.data.get()); +client.setData().inBackground().forPath(getActualPath(), this.data.get()); } } http://git-wip-us.apache.org/repos/asf/curator/blob/1e9b76e1/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 c8a72d4..47ae757 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 @@ -189,19 +189,29 @@ public class TestPersistentEphemeralNode extends BaseClassForTests } @Test +public void testSettingDataSequential() throws Exception +{ +setDataTest(PersistentEphemeralNode.Mode.EPHEMERAL_SEQUENTIAL); +} + +@Test public void testSettingData() throws Exception { +setDataTest(PersistentEphemeralNode.Mode.EPHEMERAL); +} + +protected void setDataTest(PersistentEphemeralNode.Mode mode) throws Exception +{ PersistentEphemeralNode node = null; 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 = new PersistentEphemeralNode(client, mode, PATH, "a".getBytes()); node.start(); Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS)); -Assert.assertEquals(node.getActualPath(), PATH); -Assert.assertEquals(client.getData().forPath(PATH), "a".getBytes()); + Assert.assertEquals(client.getData().forPath(node.getActualPath()), "a".getBytes()); final Semaphore semaphore = new Semaphore(0); Watcher watcher = new Watcher() @@ -212,18 +222,17 @@ public class TestPersistentEphemeralNode extends BaseClassForTests semaphore.release(); } }; -client.checkExists().usingWatcher(watcher).forPath(PATH); + client.checkExists().usingWatcher(watcher).forPath(node.getActualPath()); node.setData("b".getBytes()); Assert.assertTrue(timing.acquireSemaphore(semaphore)); -Assert.assertEquals(node.getActualPath(), PATH); - Assert.assertEquals(client.getData().usingWatcher(watcher).forPath(PATH), "b".getBytes()); +Assert.assertEquals(node.getActualPath(), node.getActualPath()); + Assert.assertEquals(cl
git commit: javadoc v 8 introduces a lint tool that is causing doc builds to fail. There's no backward compatible way to turn this off so, for now, set failOnError to false for docs
Repository: curator Updated Branches: refs/heads/master 1e9b76e12 -> 5e9ccdeda javadoc v 8 introduces a lint tool that is causing doc builds to fail. There's no backward compatible way to turn this off so, for now, set failOnError to false for docs Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5e9ccded Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5e9ccded Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5e9ccded Branch: refs/heads/master Commit: 5e9ccdeda0fdc7ca511505c24a3fae1a7134d0b2 Parents: 1e9b76e Author: randgalt Authored: Sun Oct 26 13:23:21 2014 -0500 Committer: randgalt Committed: Sun Oct 26 13:23:21 2014 -0500 -- pom.xml | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/curator/blob/5e9ccded/pom.xml -- diff --git a/pom.xml b/pom.xml index 5f98c6c..25293fa 100644 --- a/pom.xml +++ b/pom.xml @@ -521,6 +521,7 @@ -J-Xmx1g +false @@ -697,6 +698,7 @@ -J-Xmx1g +false
svn commit: r1636479 [3/47] - in /curator/site/trunk: ./ apidocs/ apidocs/cache/ apidocs/cache/class-use/ apidocs/discovery/ apidocs/discovery/class-use/ apidocs/framework/ apidocs/framework/class-use
Modified: curator/site/trunk/apidocs/locking/class-use/LockingExample.html URL: http://svn.apache.org/viewvc/curator/site/trunk/apidocs/locking/class-use/LockingExample.html?rev=1636479&r1=1636478&r2=1636479&view=diff == --- curator/site/trunk/apidocs/locking/class-use/LockingExample.html (original) +++ curator/site/trunk/apidocs/locking/class-use/LockingExample.html Tue Nov 4 00:29:50 2014 @@ -2,10 +2,10 @@ - + -Uses of Class locking.LockingExample (Apache Curator 2.6.1-SNAPSHOT API) - +Uses of Class locking.LockingExample (Apache Curator 2.7.0 API) + @@ -13,7 +13,7 @@ - + -locking (Apache Curator 2.6.1-SNAPSHOT API) - +locking (Apache Curator 2.7.0 API) +