You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2018/12/10 17:28:07 UTC
[1/5] curator git commit: fixed CachedModeledFrameworkImpl children
queries, https://issues.apache.org/jira/browse/CURATOR-479
Repository: curator
Updated Branches:
refs/heads/master 2d4aa5778 -> 2a9f04aa3
fixed CachedModeledFrameworkImpl children queries, https://issues.apache.org/jira/browse/CURATOR-479
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/1429676e
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/1429676e
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/1429676e
Branch: refs/heads/master
Commit: 1429676ea43ecfbfe3dd7f28f222d58105e41d3f
Parents: d13a12f
Author: Hendrik Haddorp <he...@gmx.net>
Authored: Sat Dec 8 21:42:11 2018 +0100
Committer: Hendrik Haddorp <he...@gmx.net>
Committed: Sat Dec 8 21:42:11 2018 +0100
----------------------------------------------------------------------
.../details/CachedModeledFrameworkImpl.java | 4 +-
.../modeled/TestCachedModeledFramework.java | 48 +++++++++++++++++++-
2 files changed, 49 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/1429676e/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java
index f701ab3..10d7379 100644
--- a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java
+++ b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java
@@ -248,7 +248,7 @@ class CachedModeledFrameworkImpl<T> implements CachedModeledFramework<T>
List<ZPath> paths = cache.currentChildren(client.modelSpec().path())
.keySet()
.stream()
- .filter(path -> path.equals(cache.basePath()))
+ .filter(path -> path.startsWith(client.modelSpec().path()) && !path.equals(client.modelSpec().path()))
.collect(Collectors.toList());
return completed(paths);
}
@@ -259,7 +259,7 @@ class CachedModeledFrameworkImpl<T> implements CachedModeledFramework<T>
List<ZNode<T>> nodes = cache.currentChildren(client.modelSpec().path())
.entrySet()
.stream()
- .filter(e -> e.getKey().equals(cache.basePath()))
+ .filter(e -> e.getKey().startsWith(client.modelSpec().path()) && !e.getKey().equals(client.modelSpec().path()))
.map(Map.Entry::getValue)
.collect(Collectors.toList());
return completed(nodes);
http://git-wip-us.apache.org/repos/asf/curator/blob/1429676e/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java
index 80c1f8b..73dc017 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestCachedModeledFramework.java
@@ -27,6 +27,8 @@ import org.testng.Assert;
import org.testng.annotations.Test;
import java.io.IOException;
import java.math.BigInteger;
+import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
@@ -73,7 +75,7 @@ public class TestCachedModeledFramework extends TestModeledFrameworkBase
public void testPostInitializedFilter()
{
TestModel model1 = new TestModel("a", "b", "c", 1, BigInteger.ONE);
- TestModel model2 = new TestModel("d", "e", "e", 1, BigInteger.ONE);
+ TestModel model2 = new TestModel("d", "e", "f", 1, BigInteger.ONE);
CachedModeledFramework<TestModel> client = ModeledFramework.wrap(async, modelSpec).cached();
Semaphore semaphore = new Semaphore(0);
ModeledCacheListener<TestModel> listener = (t, p, s, m) -> semaphore.release();
@@ -93,4 +95,48 @@ public class TestCachedModeledFramework extends TestModeledFrameworkBase
client.close();
}
}
+
+ @Test
+ public void testChildren() throws Exception
+ {
+ TestModel parent = new TestModel("a", "b", "c", 20, BigInteger.ONE);
+ TestModel child1 = new TestModel("d", "e", "f", 1, BigInteger.ONE);
+ TestModel child2 = new TestModel("g", "h", "i", 1, BigInteger.ONE);
+ try (CachedModeledFramework<TestModel> client = ModeledFramework.wrap(async, modelSpec).cached())
+ {
+ Semaphore semaphore = new Semaphore(0);
+ client.listenable().addListener((t, p, s, m) ->
+ {
+ if (m.equals(child2))
+ {
+ semaphore.release();
+ }
+ });
+
+ client.start();
+ complete(client.child("p").set(parent));
+ complete(client.child("p").child("c1").set(child1));
+ complete(client.child("p").child("c2").set(child2));
+ Assert.assertTrue(timing.forWaiting().acquireSemaphore(semaphore));
+
+ complete(client.child("p").children(), (v, e) ->
+ {
+ Assert.assertEquals(v.size(), 2);
+ Assert.assertTrue(v.contains(client.child("p").child("c1").modelSpec().path()));
+ Assert.assertTrue(v.contains(client.child("p").child("c2").modelSpec().path()));
+ });
+
+ complete(client.child("p").childrenAsZNodes(), (v, e) ->
+ {
+ Assert.assertEquals(v.size(), 2);
+ Set<TestModel> children = new HashSet<>();
+ children.add(child1);
+ children.add(child2);
+ for (ZNode<TestModel> node: v)
+ {
+ Assert.assertTrue(children.contains(node.model()));
+ }
+ });
+ }
+ }
}
[2/5] curator git commit: Merge branch 'CURATOR-479' of
github.com:Hendrik-H/curator into CURATOR-479
Posted by ra...@apache.org.
Merge branch 'CURATOR-479' of github.com:Hendrik-H/curator into CURATOR-479
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/a0f5f6ec
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/a0f5f6ec
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/a0f5f6ec
Branch: refs/heads/master
Commit: a0f5f6eccbbc7483bf4a9b9165e0ea8d64c3999b
Parents: 771e9a4 1429676
Author: randgalt <ra...@apache.org>
Authored: Sun Dec 9 17:07:54 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Dec 9 17:07:54 2018 -0500
----------------------------------------------------------------------
.../details/CachedModeledFrameworkImpl.java | 4 +-
.../modeled/TestCachedModeledFramework.java | 48 +++++++++++++++++++-
2 files changed, 49 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
[4/5] curator git commit: Merge branch 'CURATOR-479'
Posted by ra...@apache.org.
Merge branch 'CURATOR-479'
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/b6cabde8
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/b6cabde8
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/b6cabde8
Branch: refs/heads/master
Commit: b6cabde8e987fae8033bbed0e6cc76507ae4173f
Parents: b1e69a6 8187833
Author: randgalt <ra...@apache.org>
Authored: Mon Dec 10 12:27:20 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Dec 10 12:27:20 2018 -0500
----------------------------------------------------------------------
.../apache/curator/x/async/modeled/ZPath.java | 16 ++++++-
.../details/CachedModeledFrameworkImpl.java | 4 +-
.../x/async/modeled/details/ZPathImpl.java | 22 +++++++++
.../modeled/TestCachedModeledFramework.java | 48 +++++++++++++++++++-
.../curator/x/async/modeled/TestZPath.java | 10 ++++
5 files changed, 96 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
[3/5] curator git commit: CURATOR-479
Posted by ra...@apache.org.
CURATOR-479
Added new method to ZPath, isParentOf(). The, use it in CachedModeledFrameworkImpl.children() and CachedModeledFrameworkImpl.childrenAsZNodes() which were not implemented correctly.
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/81878339
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/81878339
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/81878339
Branch: refs/heads/master
Commit: 81878339179595c304d7efce4450807b218839be
Parents: a0f5f6e
Author: randgalt <ra...@apache.org>
Authored: Sun Dec 9 17:46:12 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun Dec 9 17:46:12 2018 -0500
----------------------------------------------------------------------
.../apache/curator/x/async/modeled/ZPath.java | 16 +++++++++++++-
.../details/CachedModeledFrameworkImpl.java | 4 ++--
.../x/async/modeled/details/ZPathImpl.java | 22 ++++++++++++++++++++
.../curator/x/async/modeled/TestZPath.java | 10 +++++++++
4 files changed, 49 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/81878339/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ZPath.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ZPath.java b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ZPath.java
index 70ac536..3b0e47c 100644
--- a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ZPath.java
+++ b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/ZPath.java
@@ -249,7 +249,7 @@ public interface ZPath extends Resolvable
/**
* Return true if this path starts with the given path. i.e.
- * <code>ZPath.from("/one/two/three").startsWith(ZPath.from("/one/two"))</code> returns true
+ * <code>ZPath.parse("/one/two/three").startsWith(ZPath.parse("/one/two"))</code> returns true
*
* @param path base path
* @return true/false
@@ -257,6 +257,20 @@ public interface ZPath extends Resolvable
boolean startsWith(ZPath path);
/**
+ * Return true if this path is a parent, grandparent, etc. of the given path i.e.
+ * <code>ZPath.parse("/one").isParentOf(ZPath.parse("/one/two/three"))</code> returns true.
+ * However, <code>ZPath.from("/one/two/three").isParentOf(ZPath.from("/one/two/three"))</code>
+ * returns false.
+ *
+ * @param path base path
+ * @return true/false
+ */
+ default boolean isParentOf(ZPath path)
+ {
+ return path.startsWith(this) && !path.fullPath().equals(fullPath());
+ }
+
+ /**
* The string full path that this ZPath represents
*
* @return full path
http://git-wip-us.apache.org/repos/asf/curator/blob/81878339/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java
index 10d7379..726b476 100644
--- a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java
+++ b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/CachedModeledFrameworkImpl.java
@@ -248,7 +248,7 @@ class CachedModeledFrameworkImpl<T> implements CachedModeledFramework<T>
List<ZPath> paths = cache.currentChildren(client.modelSpec().path())
.keySet()
.stream()
- .filter(path -> path.startsWith(client.modelSpec().path()) && !path.equals(client.modelSpec().path()))
+ .filter(path -> client.modelSpec().path().isParentOf(path))
.collect(Collectors.toList());
return completed(paths);
}
@@ -259,7 +259,7 @@ class CachedModeledFrameworkImpl<T> implements CachedModeledFramework<T>
List<ZNode<T>> nodes = cache.currentChildren(client.modelSpec().path())
.entrySet()
.stream()
- .filter(e -> e.getKey().startsWith(client.modelSpec().path()) && !e.getKey().equals(client.modelSpec().path()))
+ .filter(e -> client.modelSpec().path().isParentOf(e.getKey()))
.map(Map.Entry::getValue)
.collect(Collectors.toList());
return completed(nodes);
http://git-wip-us.apache.org/repos/asf/curator/blob/81878339/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java
index fff742e..65b25d5 100644
--- a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java
+++ b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java
@@ -18,6 +18,7 @@
*/
package org.apache.curator.x.async.modeled.details;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import org.apache.curator.x.async.modeled.NodeName;
@@ -144,6 +145,27 @@ public class ZPathImpl implements ZPath
return (nodes.size() >= rhs.nodes.size()) && nodes.subList(0, rhs.nodes.size()).equals(rhs.nodes);
}
+ @VisibleForTesting
+ public boolean defaultIsParentOf(ZPath path)
+ {
+ return ZPath.super.isParentOf(path);
+ }
+
+ @Override
+ public boolean isParentOf(ZPath path)
+ {
+ ZPathImpl rhs;
+ if ( path instanceof ZPathImpl )
+ {
+ rhs = (ZPathImpl)path;
+ }
+ else
+ {
+ rhs = parseInternal(path.fullPath(), s -> s);
+ }
+ return (rhs.nodes.size() > nodes.size()) && rhs.nodes.subList(0, nodes.size()).equals(nodes);
+ }
+
@Override
public Pattern toSchemaPathPattern()
{
http://git-wip-us.apache.org/repos/asf/curator/blob/81878339/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
index d2c24da..894d0cd 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
@@ -59,6 +59,16 @@ public class TestZPath
Assert.assertTrue(checkIdLike.isResolved());
checkIdLike = ZPath.parse("/one/" + ZPath.parameter("others") + "/three");
Assert.assertTrue(checkIdLike.isResolved());
+
+ Assert.assertTrue(ZPath.parse("/one").isParentOf(ZPath.parse("/one/two/three")));
+ Assert.assertTrue(path.isParentOf(path.child("one")));
+ Assert.assertFalse(path.isParentOf(path));
+ Assert.assertFalse(path.isParentOf(path.parent()));
+
+ // check default implementation
+ Assert.assertTrue(((ZPathImpl)path).defaultIsParentOf(path.child("one")));
+ Assert.assertFalse(((ZPathImpl)path).defaultIsParentOf(path));
+ Assert.assertFalse(((ZPathImpl)path).defaultIsParentOf(path.parent()));
}
@Test
[5/5] curator git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/curator
Posted by ra...@apache.org.
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/2a9f04aa
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/2a9f04aa
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/2a9f04aa
Branch: refs/heads/master
Commit: 2a9f04aa3eb0f7d0a97e5810afa22feb58a84f06
Parents: b6cabde 2d4aa57
Author: randgalt <ra...@apache.org>
Authored: Mon Dec 10 12:28:01 2018 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Dec 10 12:28:01 2018 -0500
----------------------------------------------------------------------
.../framework/imps/GzipCompressionProvider.java | 311 +++++++++++++++++--
.../imps/TestGzipCompressionProvider.java | 125 ++++++++
.../framework/recipes/cache/TreeCache.java | 42 ++-
.../framework/recipes/cache/TestTreeCache.java | 25 ++
4 files changed, 474 insertions(+), 29 deletions(-)
----------------------------------------------------------------------