Randgalt commented on a change in pull request #1106: ZOOKEEPER-1416 - 
Persistent, recursive watchers
URL: https://github.com/apache/zookeeper/pull/1106#discussion_r331070858
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
 ##########
 @@ -3028,6 +3112,77 @@ public void removeAllWatches(String path, WatcherType 
watcherType, boolean local
         removeWatches(ZooDefs.OpCode.removeWatches, path, null, watcherType, 
local, cb, ctx);
     }
 
+    /**
+     * <p>
+     * Set a watcher on the given path that: a) does not get removed when 
triggered (i.e. it stays active
+     * until it is removed); b) optionally applies not only to the registered 
path but all child paths recursively. This watcher
+     * is triggered for both data and child events. To remove the watcher, use
+     * <tt>removeWatches()</tt> with <tt>WatcherType.Any</tt>
+     * </p>
+     *
+     * <p>
+     * If <tt>recursive</tt> is <tt>false</tt>, the watcher behaves as if you 
placed an exists() watch and
+     * a getData() watch on the ZNode at the given path.
+     * </p>
+     *
+     * <p>
+     * If <tt>recursive</tt> is <tt>true</tt>, the watcher behaves as if you 
placed an exists() watch and
+     * a getData() watch on the ZNode at the given path <strong>and</strong> 
any ZNodes that are children
+     * of the given path including children added later.
+     * </p>
+     *
+     * <p>
+     * NOTE: when there are active recursive watches there is a small 
performance decrease as all segments
+     * of ZNode paths must be checked for watch triggering.
+     * </p>
+     *
+     * @param basePath the top path that the watcher applies to
+     * @param watcher the watcher
+     * @param recursive if true applies not only to the registered path but 
all child paths recursively including
+     *                  any child nodes added in the future
+     * @throws InterruptedException If the server transaction is interrupted.
+     * @throws KeeperException If the server signals an error with a non-zero
+     *  error code.
+     */
+    public void addPersistentWatch(String basePath, Watcher watcher, boolean 
recursive)
 
 Review comment:
   Look at the commit I just pushed. This is merely a refinement. I think this 
is much better actually and we'll thank ourselves in the future. Now, things 
are more generic "add watch with a mode". The mode is currently only persistent 
or recursive but we now have room to change in the future. The number/scope of 
the change is exactly the same as before.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to