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

 ##########
 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:
   yes
   You already did a great work and the client with your changes is  still 
compatibile at 100% with 3.5 servers in case of not using persistent watches.
   If we change the protocol regarding watches (adding some watchtype to the 
wireprotocol) you will really need a "compatibility flag" on the client 
configuration or some more complicated handshake with version/feature discovery.
   

----------------------------------------------------------------
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