Skip to content

Commit

Permalink
Remove unneeded ZK operations for setting watches (#12866)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored Nov 19, 2021
1 parent bd4753d commit 0977044
Showing 1 changed file with 2 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,6 @@ public CompletableFuture<Optional<GetResult>> get(String path) {
if (code == Code.OK) {
future.complete(Optional.of(new GetResult(data, getStat(path1, stat))));
} else if (code == Code.NONODE) {
// Place a watch on the non-existing node, so we'll get notified
// when it gets created and we can invalidate the negative cache.
existsFromStore(path).thenAccept(exists -> {
if (exists) {
get(path).thenAccept(c -> future.complete(c))
.exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
} else {
// Z-node does not exist
future.complete(Optional.empty());
}
}).exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
future.complete(Optional.empty());
} else {
future.completeExceptionally(getException(code, path));
Expand All @@ -180,25 +163,8 @@ public CompletableFuture<List<String>> getChildrenFromStore(String path) {
Collections.sort(children);
future.complete(children);
} else if (code == Code.NONODE) {
// The node we want may not exist yet, so put a watcher on its existence
// before throwing up the exception. Its possible that the node could have
// been created after the call to getChildren, but before the call to exists().
// If this is the case, exists will return true, and we just call getChildren
// again.
existsFromStore(path).thenAccept(exists -> {
if (exists) {
getChildrenFromStore(path).thenAccept(c -> future.complete(c)).exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
} else {
// Z-node does not exist
future.complete(Collections.emptyList());
}
}).exceptionally(ex -> {
future.completeExceptionally(ex);
return null;
});
// Z-node does not exist
future.complete(Collections.emptyList());
} else {
future.completeExceptionally(getException(code, path));
}
Expand Down

0 comments on commit 0977044

Please sign in to comment.