ddanielr commented on code in PR #5143:
URL: https://github.com/apache/accumulo/pull/5143#discussion_r1875901166
##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java:
##########
@@ -316,43 +277,46 @@ public List<String> getChildren(final String zPath) {
public List<String> run() throws KeeperException, InterruptedException {
var zcNode = nodeCache.get(zPath);
- if (zcNode != null && zcNode.childrenSet) {
+ if (zcNode != null && zcNode.cachedChildren()) {
return zcNode.getChildren();
}
log.trace("{} {} was not in children cache, looking up in zookeeper",
cacheId, zPath);
- try {
- zcNode = nodeCache.compute(zPath, (zp, zcn) -> {
- // recheck the children now that lock is held on key
- if (zcn != null && zcn.childrenSet) {
- return zcn;
- }
+ zcNode = nodeCache.compute(zPath, (zp, zcn) -> {
+ // recheck the children now that lock is held on key
+ if (zcn != null && zcn.cachedChildren()) {
+ return zcn;
+ }
- try {
- final ZooKeeper zooKeeper = getZooKeeper();
- List<String> children;
- children = zooKeeper.getChildren(zPath, watcher);
- if (children != null) {
- children = List.copyOf(children);
- }
- return new ZcNode(zcn, children);
- } catch (KeeperException e) {
- throw new ZcException(e);
- } catch (InterruptedException e) {
- throw new ZcInterruptedException(e);
+ try {
+ final ZooKeeper zooKeeper = getZooKeeper();
+ // Register a watcher on the node to monitor creation/deletion
events for the node. It
+ // is possible that an event from this watch could trigger prior
to calling getChildren.
+ // That is ok because the compute() call on the map has a lock and
processing the event
+ // will block until compute() returns. After compute() returns the
event processing
+ // would clear the map entry.
+ Stat stat = zooKeeper.exists(zPath, watcher);
Review Comment:
I was able to build this branch using zookeeper 3.7.1 and
`Zookeeper.removeWatches` was present.
The [release notes for
2.1.0](https://accumulo.apache.org/release/accumulo-2.1.0/) mention 3.8.0 so
this change should be fine.
> During much of this release’s development, ZooKeeper 3.5 was used as a
minimum. However, that version reach its end-of-life during development, and we
do not recommend using end-of-life versions of ZooKeeper. The latest bugfix
version of 3.6, 3.7, or 3.8 should also work fine. By default, our POM depends
on 3.8.0.
--
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]