kaisun2000 commented on a change in pull request #1035:
URL: https://github.com/apache/helix/pull/1035#discussion_r434994595
##########
File path:
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java
##########
@@ -1865,17 +1934,24 @@ public Object call() throws Exception {
* exist.
*/
public List<String> watchForChilds(final String path) {
+ return watchForChilds(path, false);
+ }
+
+ private List<String> watchForChilds(final String path, boolean
skipWatchingNodeNotExist) {
if (_zookeeperEventThread != null && Thread.currentThread() ==
_zookeeperEventThread) {
throw new IllegalArgumentException("Must not be done in the zookeeper
event thread.");
}
return retryUntilConnected(new Callable<List<String>>() {
@Override
public List<String> call() throws Exception {
- exists(path, true);
+ if (!skipWatchingNodeNotExist) {
Review comment:
This is intentional.
if skipWatchingNodeNoExist is true, we skip install **"data"** watch using
exists(). Thus, if the directory (parent path) is not created, it won't leak a
"data" watch in server.
Note, the getChildren() also installs **"child"** watch if the parent path
exists(). Otherwise, it would return null.
Note **child** watch and **data** watch are two different watch from ZK
server perspective, stored in different data structure. **Data** watch can be
installed to path not exist yet, **child** watch can't.
If the parent path exists, we only need child watch to function correctly.
skipWatchingNodeNotExist is true in this case. This is also the case when
CallbackHandler has CALLBACK notification.
If we want to wait till paren path to be created, we set
skipWatchingNodeNotExist to be false. This is the case when CallbackHandler has
INIT notification.
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]