wolfstudy commented on a change in pull request #13164:
URL: https://github.com/apache/pulsar/pull/13164#discussion_r763877092



##########
File path: 
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
##########
@@ -296,4 +297,39 @@ public boolean partitionedTopicExists(TopicName tn) throws 
MetadataStoreExceptio
             return future;
         }
     }
+
+    // clear resource of `/loadbalance/bundle-data/{tenant}/{namespace}/` for 
zk-node
+    public CompletableFuture<Void> deleteBundleDataAsync(NamespaceName ns) {
+        final String namespaceBundlePath = joinPath(BUNDLE_DATA_BASE_PATH, 
ns.toString());
+        CompletableFuture<Void> future = new CompletableFuture<Void>();
+        deleteRecursiveAsync(this, namespaceBundlePath).whenComplete((ignore, 
ex) -> {
+            if (ex != null && ex.getCause() instanceof 
KeeperException.NoNodeException) {
+                future.complete(null);
+            } else if (ex != null) {
+                future.completeExceptionally(ex);
+            } else {
+                future.complete(null);
+            }
+        });
+
+        return future;
+    }
+
+    // clear resource of `/loadbalance/bundle-data/{tenant}/` for zk-node
+    public CompletableFuture<Void> deleteBundleDataTenantAsync(String tenant) {
+        final String namespaceBundlePath = joinPath(BUNDLE_DATA_BASE_PATH, 
tenant);
+        CompletableFuture<Void> future = new CompletableFuture<Void>();
+        deleteRecursiveAsync(this, namespaceBundlePath).whenComplete((ignore, 
ex) -> {
+            if (ex != null && ex.getCause() instanceof 
KeeperException.NoNodeException) {

Review comment:
       If you use `ex.getCause()`, you get should not be a KeeperException, but 
an exception of the megastore that encapsulates the zk client. So here should 
use `ex.getCause().getCause()`?

##########
File path: 
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
##########
@@ -296,4 +297,39 @@ public boolean partitionedTopicExists(TopicName tn) throws 
MetadataStoreExceptio
             return future;
         }
     }
+
+    // clear resource of `/loadbalance/bundle-data/{tenant}/{namespace}/` for 
zk-node
+    public CompletableFuture<Void> deleteBundleDataAsync(NamespaceName ns) {
+        final String namespaceBundlePath = joinPath(BUNDLE_DATA_BASE_PATH, 
ns.toString());
+        CompletableFuture<Void> future = new CompletableFuture<Void>();
+        deleteRecursiveAsync(this, namespaceBundlePath).whenComplete((ignore, 
ex) -> {
+            if (ex != null && ex.getCause() instanceof 
KeeperException.NoNodeException) {
+                future.complete(null);
+            } else if (ex != null) {
+                future.completeExceptionally(ex);
+            } else {
+                future.complete(null);
+            }
+        });
+
+        return future;
+    }
+
+    // clear resource of `/loadbalance/bundle-data/{tenant}/` for zk-node
+    public CompletableFuture<Void> deleteBundleDataTenantAsync(String tenant) {
+        final String namespaceBundlePath = joinPath(BUNDLE_DATA_BASE_PATH, 
tenant);

Review comment:
       Maybe `tenantBundlePath` is good name then `namespaceBundlePath`

##########
File path: 
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
##########
@@ -296,4 +297,39 @@ public boolean partitionedTopicExists(TopicName tn) throws 
MetadataStoreExceptio
             return future;
         }
     }
+
+    // clear resource of `/loadbalance/bundle-data/{tenant}/{namespace}/` for 
zk-node
+    public CompletableFuture<Void> deleteBundleDataAsync(NamespaceName ns) {
+        final String namespaceBundlePath = joinPath(BUNDLE_DATA_BASE_PATH, 
ns.toString());
+        CompletableFuture<Void> future = new CompletableFuture<Void>();
+        deleteRecursiveAsync(this, namespaceBundlePath).whenComplete((ignore, 
ex) -> {
+            if (ex != null && ex.getCause() instanceof 
KeeperException.NoNodeException) {

Review comment:
       Please use `ex.getCause().getCause()`




-- 
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]


Reply via email to