zookeeper-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] eolivelli commented on a change in pull request #1106: ZOOKEEPER-1416 - Persistent, recursive watchers
Date Thu, 03 Oct 2019 14:34:39 GMT
eolivelli commented on a change in pull request #1106: ZOOKEEPER-1416 - Persistent, recursive
watchers
URL: https://github.com/apache/zookeeper/pull/1106#discussion_r331074728
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
 ##########
 @@ -3028,6 +3147,104 @@ public void removeAllWatches(String path, WatcherType watcherType,
boolean local
         removeWatches(ZooDefs.OpCode.removeWatches, path, null, watcherType, local, cb, ctx);
     }
 
+    /**
+     * Modes available to {@link ZooKeeper#addWatch(String, Watcher, AddWatchMode)}
+     */
+    public enum AddWatchMode {
+        /**
+         * <p>
+         * Set a watcher on the given path that does not get removed when triggered (i.e.
it stays active
+         * until it is removed). This watcher
+         * is triggered for both data and child events. To remove the watcher, use
+         * <tt>removeWatches()</tt> with <tt>WatcherType.Any</tt>.
The watcher behaves as if you placed an exists() watch and
+         * a getData() watch on the ZNode at the given path.
+         * </p>
+         */
+        PERSISTENT(ZooDefs.AddWatchModes.persistent),
+
+        /**
+         * <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) 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>
+         * 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>
+         */
+        PERSISTENT_RECURSIVE(ZooDefs.AddWatchModes.persistentRecursive)
+        ;
+
+        public int getMode() {
+            return mode;
+        }
+
+        private final int mode;
+
+        AddWatchMode(int mode) {
+            this.mode = mode;
+        }
+    }
+
+    /**
+     * Add a watch to the given znode using the given mode. Note: not all
+     * watch types can be set with this method. Only the modes available
+     * in {@link AddWatchMode} can be set with this method.
+     *
+     * @param basePath the path that the watcher applies to
+     * @param watcher the watcher
+     * @param mode type of watcher to add
+     * @throws InterruptedException If the server transaction is interrupted.
+     * @throws KeeperException If the server signals an error with a non-zero
+     *  error code.
+     */
+    public void addWatch(String basePath, Watcher watcher, AddWatchMode mode)
 
 Review comment:
   @Randgalt  this is perfect to me !

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message