iosdev747 commented on code in PR #23094:
URL: https://github.com/apache/pulsar/pull/23094#discussion_r1695702384


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java:
##########
@@ -771,8 +782,13 @@ private CompletableFuture<Void> 
filterAndUnloadMatchedNamespaceAsync(NamespaceIs
                             .map(tenant -> 
adminClient.namespaces().getNamespacesAsync(tenant));
                     return FutureUtil.waitForAll(completableFutureStream)
                             .thenApply(namespaces -> {
-                                // if namespace match any policy regex, add it 
to ns list to be unload.
+                                // Filter namespaces that have current cluster 
in their replication_clusters
+                                // if namespace match any policy regex, add it 
to ns list to be unloaded.
                                 return namespaces.stream()
+                                        .filter(namespaceName -> 
adminClient.namespaces()
+                                                
.getPoliciesAsync(namespaceName)
+                                                .thenApply(policies -> 
policies.replication_clusters.contains(cluster))
+                                                .join())

Review Comment:
   For the filter to work, I need to call join to wait for the future 
completion. The reason for doing it this way is that policy is required to 
decide whether to remove the namespace or not. Can you suggest how I can make 
it async? Nothing better comes to my mind that doesn't need too much code 
refactoring...



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to