dlmarion commented on code in PR #5256:
URL: https://github.com/apache/accumulo/pull/5256#discussion_r1917176726
##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java:
##########
@@ -152,53 +189,53 @@ public void process(WatchedEvent event) {
break;
}
- externalWatcher.ifPresent(w -> w.accept(event));
+ externalWatchers.forEach(ew -> ew.accept(event));
}
}
- /**
- * Creates a new cache without an external watcher.
- *
- * @param zk the ZooKeeper instance
- * @throws NullPointerException if zk is {@code null}
- */
- public ZooCache(ZooSession zk) {
- this(zk, Optional.empty(), Duration.ofMinutes(3));
+ public ZooCache(ZooSession zk, String root, ZooCacheWatcher... watchers) {
+ this.zk = requireNonNull(zk);
+ for (ZooCacheWatcher zcw : watchers) {
+ externalWatchers.add(zcw);
+ }
+ setupWatchers(requireNonNull(root));
+ log.trace("{} created new cache", cacheId, new Exception());
}
- /**
- * Creates a new cache. The given watcher is called whenever a watched node
changes.
- *
- * @param zk the ZooKeeper instance
- * @param watcher watcher object
- * @throws NullPointerException if zk or watcher is {@code null}
- */
- public ZooCache(ZooSession zk, ZooCacheWatcher watcher) {
- this(zk, Optional.of(watcher), Duration.ofMinutes(3));
+ public void addZooCacheWatcher(ZooCacheWatcher watcher) {
+ externalWatchers.add(requireNonNull(watcher));
Review Comment:
TableManager gets the shared ZooCache from ServerContext, then adds its own
watcher.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]