From notifications-return-2110-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Thu Oct 3 14:28:13 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id E197D18065B for ; Thu, 3 Oct 2019 16:28:12 +0200 (CEST) Received: (qmail 99845 invoked by uid 500); 3 Oct 2019 14:28:12 -0000 Mailing-List: contact notifications-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list notifications@zookeeper.apache.org Received: (qmail 99836 invoked by uid 99); 3 Oct 2019 14:28:12 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Oct 2019 14:28:12 +0000 From: GitBox To: notifications@zookeeper.apache.org Subject: [GitHub] [zookeeper] Randgalt commented on a change in pull request #1106: ZOOKEEPER-1416 - Persistent, recursive watchers Message-ID: <157011289212.611.5513800666347359143.gitbox@gitbox.apache.org> Date: Thu, 03 Oct 2019 14:28:12 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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); } + /** + *

+ * 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 + * removeWatches() with WatcherType.Any + *

+ * + *

+ * If recursive is false, the watcher behaves as if you placed an exists() watch and + * a getData() watch on the ZNode at the given path. + *

+ * + *

+ * If recursive is true, the watcher behaves as if you placed an exists() watch and + * a getData() watch on the ZNode at the given path and any ZNodes that are children + * of the given path including children added later. + *

+ * + *

+ * 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. + *

+ * + * @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: users@infra.apache.org With regards, Apache Git Services