jiajunwang commented on a change in pull request #1295:
URL: https://github.com/apache/helix/pull/1295#discussion_r490635112
##########
File path:
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java
##########
@@ -2152,6 +2150,19 @@ public void connect(final long
maxMsToWaitUntilConnected, Watcher watcher)
IZkConnection zkConnection = getConnection();
_eventThread = new ZkEventThread(zkConnection.getServers());
+
+ if (_monitor != null) {
+ _monitor.setAndInitZkEventThreadMonitor(_eventThread);
+ }
+
+ try {
Review comment:
I debugged with your code, so the ZkClientPathMonitor objects are
currently only created in the register() method. So that's the reason we lose
the count if register later.
There is a simple fix, we can instantiate all the ZkClientPathMonitors in
the ZkClientMonitor constructor. Like this,
for (ZkClientPathMonitor.PredefinedPath path :
```
ZkClientPathMonitor.PredefinedPath.values()) {
// If monitor root path only, check if the current path is Root.
// Otherwise, add monitors for every path.
if (!_monitorRootOnly ||
path.equals(ZkClientPathMonitor.PredefinedPath.Root)) {
_zkClientPathMonitorMap.put(path,
new ZkClientPathMonitor(path, _monitorType, _monitorKey,
_monitorInstanceName));
}
}
```
Then in the register(), just register all the ZkClientPathMonitor objects
that are in the _zkClientPathMonitorMap.
The good thing is that it seems to be the right thing to do.
----------------------------------------------------------------
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]