From 1ff90c510a5777e6559e62a905fcc97fbad0ed6d Mon Sep 17 00:00:00 2001 From: Matteo Merli Date: Fri, 19 Nov 2021 06:53:39 -0800 Subject: [PATCH] Remove unneeded ZK operations for setting watches (#12866) --- .../pulsar/metadata/impl/ZKMetadataStore.java | 38 +------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java b/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java index 2cee1c7a627f62..03ac79fc6c9f3f 100644 --- a/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java +++ b/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java @@ -138,23 +138,6 @@ public CompletableFuture> 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)); @@ -180,25 +163,8 @@ public CompletableFuture> 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)); }