[1/8] curator git commit: added support for zkwatches

2018-12-09 Thread cammckenzie
Repository: curator
Updated Branches:
  refs/heads/CURATOR-477 [created] 2d4aa5778


added support for zkwatches


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/d4a0d954
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/d4a0d954
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/d4a0d954

Branch: refs/heads/CURATOR-477
Commit: d4a0d95488345bfb0983553bfbfbc40643ac031b
Parents: 8950151
Author: Rama 
Authored: Mon Aug 20 12:16:12 2018 +0530
Committer: Rama 
Committed: Mon Aug 20 12:16:12 2018 +0530

--
 .../framework/recipes/cache/TreeCache.java  | 41 +---
 .../framework/recipes/cache/TestTreeCache.java  | 25 
 2 files changed, 60 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/d4a0d954/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 7f8aad7..7bcc8d1 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
@@ -73,6 +73,7 @@ public class TreeCache implements Closeable
 {
 private static final Logger LOG = LoggerFactory.getLogger(TreeCache.class);
 private final boolean createParentNodes;
+private final boolean createZkWatches;
 private final TreeCacheSelector selector;
 
 public static final class Builder
@@ -84,6 +85,7 @@ public class TreeCache implements Closeable
 private ExecutorService executorService = null;
 private int maxDepth = Integer.MAX_VALUE;
 private boolean createParentNodes = false;
+private boolean createZkWatches = true;
 private TreeCacheSelector selector = new DefaultTreeCacheSelector();
 
 private Builder(CuratorFramework client, String path)
@@ -102,7 +104,7 @@ public class TreeCache implements Closeable
 {
 executor = 
Executors.newSingleThreadExecutor(defaultThreadFactory);
 }
-return new TreeCache(client, path, cacheData, dataIsCompressed, 
maxDepth, executor, createParentNodes, selector);
+return new TreeCache(client, path, cacheData, dataIsCompressed, 
maxDepth, executor, createParentNodes, createZkWatches, selector);
 }
 
 /**
@@ -166,6 +168,18 @@ public class TreeCache implements Closeable
 }
 
 /**
+ * By default, TreeCache creates {@link 
org.apache.zookeeper.ZooKeeper} watches for every created path.
+ * Change this behavior with this method.
+ * @param createZkWatches true to create watches
+ * @return this for chaining
+ */
+public Builder setCreateZkWatches(boolean createZkWatches)
+{
+this.createZkWatches = createZkWatches;
+return this;
+}
+
+/**
  * By default, {@link DefaultTreeCacheSelector} is used. Change the 
selector here.
  *
  * @param selector new selector
@@ -253,7 +267,11 @@ public class TreeCache implements Closeable
 {
 if ( treeState.get() == TreeState.STARTED )
 {
-
client.getChildren().usingWatcher(this).inBackground(this).forPath(path);
+if (createZkWatches) {
+
client.getChildren().usingWatcher(this).inBackground(this).forPath(path);
+} else {
+client.getChildren().inBackground(this).forPath(path);
+}
 }
 }
 
@@ -263,11 +281,20 @@ public class TreeCache implements Closeable
 {
 if ( dataIsCompressed )
 {
-
client.getData().decompressed().usingWatcher(this).inBackground(this).forPath(path);
+if (createZkWatches) {
+
client.getData().decompressed().usingWatcher(this).inBackground(this).forPath(path);
+} else {
+
client.getData().decompressed().inBackground(this).forPath(path);
+}
 }
 else
 {
-
client.getData().usingWatcher(this).inBackground(this).forPath(path);
+   if (createZkWatches) {
+   
client.getData().usingWatcher(this).inBackground(this).forPath(path);
+   } else {
+   client.getData().inBackground(this).forPath(path);
+
+   }
 }

[1/8] curator git commit: added support for zkwatches

2018-12-09 Thread cammckenzie
Repository: curator
Updated Branches:
  refs/heads/master 5b15f5fab -> 2d4aa5778


added support for zkwatches


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/d4a0d954
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/d4a0d954
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/d4a0d954

Branch: refs/heads/master
Commit: d4a0d95488345bfb0983553bfbfbc40643ac031b
Parents: 8950151
Author: Rama 
Authored: Mon Aug 20 12:16:12 2018 +0530
Committer: Rama 
Committed: Mon Aug 20 12:16:12 2018 +0530

--
 .../framework/recipes/cache/TreeCache.java  | 41 +---
 .../framework/recipes/cache/TestTreeCache.java  | 25 
 2 files changed, 60 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/curator/blob/d4a0d954/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 7f8aad7..7bcc8d1 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
@@ -73,6 +73,7 @@ public class TreeCache implements Closeable
 {
 private static final Logger LOG = LoggerFactory.getLogger(TreeCache.class);
 private final boolean createParentNodes;
+private final boolean createZkWatches;
 private final TreeCacheSelector selector;
 
 public static final class Builder
@@ -84,6 +85,7 @@ public class TreeCache implements Closeable
 private ExecutorService executorService = null;
 private int maxDepth = Integer.MAX_VALUE;
 private boolean createParentNodes = false;
+private boolean createZkWatches = true;
 private TreeCacheSelector selector = new DefaultTreeCacheSelector();
 
 private Builder(CuratorFramework client, String path)
@@ -102,7 +104,7 @@ public class TreeCache implements Closeable
 {
 executor = 
Executors.newSingleThreadExecutor(defaultThreadFactory);
 }
-return new TreeCache(client, path, cacheData, dataIsCompressed, 
maxDepth, executor, createParentNodes, selector);
+return new TreeCache(client, path, cacheData, dataIsCompressed, 
maxDepth, executor, createParentNodes, createZkWatches, selector);
 }
 
 /**
@@ -166,6 +168,18 @@ public class TreeCache implements Closeable
 }
 
 /**
+ * By default, TreeCache creates {@link 
org.apache.zookeeper.ZooKeeper} watches for every created path.
+ * Change this behavior with this method.
+ * @param createZkWatches true to create watches
+ * @return this for chaining
+ */
+public Builder setCreateZkWatches(boolean createZkWatches)
+{
+this.createZkWatches = createZkWatches;
+return this;
+}
+
+/**
  * By default, {@link DefaultTreeCacheSelector} is used. Change the 
selector here.
  *
  * @param selector new selector
@@ -253,7 +267,11 @@ public class TreeCache implements Closeable
 {
 if ( treeState.get() == TreeState.STARTED )
 {
-
client.getChildren().usingWatcher(this).inBackground(this).forPath(path);
+if (createZkWatches) {
+
client.getChildren().usingWatcher(this).inBackground(this).forPath(path);
+} else {
+client.getChildren().inBackground(this).forPath(path);
+}
 }
 }
 
@@ -263,11 +281,20 @@ public class TreeCache implements Closeable
 {
 if ( dataIsCompressed )
 {
-
client.getData().decompressed().usingWatcher(this).inBackground(this).forPath(path);
+if (createZkWatches) {
+
client.getData().decompressed().usingWatcher(this).inBackground(this).forPath(path);
+} else {
+
client.getData().decompressed().inBackground(this).forPath(path);
+}
 }
 else
 {
-
client.getData().usingWatcher(this).inBackground(this).forPath(path);
+   if (createZkWatches) {
+   
client.getData().usingWatcher(this).inBackground(this).forPath(path);
+   } else {
+   client.getData().inBackground(this).forPath(path);
+
+   }
 }
 }