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



##########
File path: 
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java
##########
@@ -181,19 +182,46 @@ protected static String joinPath(String... parts) {
         return sb.toString();
     }
 
-
-
     protected static void deleteRecursive(BaseResources resources, final 
String pathRoot) throws MetadataStoreException {
         PathUtils.validatePath(pathRoot);
         List<String> tree = listSubTreeBFS(resources, pathRoot);
         log.debug("Deleting {} with size {}", tree, tree.size());
-        log.debug("Deleting " + tree.size() + " subnodes ");
         for (int i = tree.size() - 1; i >= 0; --i) {
             // Delete the leaves first and eventually get rid of the root
             resources.delete(tree.get(i));
         }
     }
 
+    protected static CompletableFuture<Void> 
deleteRecursiveAsync(BaseResources resources, final String pathRoot) {
+        PathUtils.validatePath(pathRoot);
+        List<String> tree = null;
+        try {
+            tree = listSubTreeBFS(resources, pathRoot);
+        } catch (MetadataStoreException e) {
+            // no-op
+        }
+
+        if (tree != null) {
+            log.debug("Deleting {} with size {}", tree, tree.size());
+
+            final List<CompletableFuture<Void>> futures = new ArrayList<>();
+            for (int i = tree.size() - 1; i >= 0; --i) {
+                // Delete the leaves first and eventually get rid of the root
+                futures.add(resources.deleteAsync(tree.get(i)));
+            }
+
+            FutureUtil.waitForAll(futures).handle((result, exception) -> {
+                if (exception != null) {
+                    log.error("Failed to remove partitioned topics", 
exception);
+                    return null;
+                }
+                return null;
+            });
+        }
+
+        return null;

Review comment:
       Ok, will fix this




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