You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/04/26 13:23:30 UTC

[GitHub] [pulsar] mattisonchao commented on a diff in pull request #15280: [improve][broker][DONT'MERGE] Make some methods of `BrokersBase` pure async.

mattisonchao commented on code in PR #15280:
URL: https://github.com/apache/pulsar/pull/15280#discussion_r858708645


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java:
##########
@@ -731,16 +731,21 @@ public CompletableFuture<Boolean> isNamespaceBundleOwned(NamespaceBundle bundle)
         return pulsar.getLocalMetadataStore().exists(ServiceUnitUtils.path(bundle));
     }
 
-    public Map<String, NamespaceOwnershipStatus> getOwnedNameSpacesStatus() throws Exception {
-        NamespaceIsolationPolicies nsIsolationPolicies = this.getLocalNamespaceIsolationPolicies();
-        Map<String, NamespaceOwnershipStatus> ownedNsStatus = new HashMap<String, NamespaceOwnershipStatus>();
-        for (OwnedBundle nsObj : this.ownershipCache.getOwnedBundles().values()) {
-            NamespaceOwnershipStatus nsStatus = this.getNamespaceOwnershipStatus(nsObj,
-                    nsIsolationPolicies.getPolicyByNamespace(nsObj.getNamespaceBundle().getNamespaceObject()));
-            ownedNsStatus.put(nsObj.getNamespaceBundle().toString(), nsStatus);
-        }
-
-        return ownedNsStatus;
+    public CompletableFuture<Map<String, NamespaceOwnershipStatus>> getOwnedNameSpacesStatusAsync() {
+       return getLocalNamespaceIsolationPoliciesAsync()
+                .thenCompose(namespaceIsolationPolicies -> {
+                    List<CompletableFuture<OwnedBundle>> ownedBundleFutures = Collections.unmodifiableList(
+                            new ArrayList<>(ownershipCache.getOwnedBundlesAsync().values()));
+                    return FutureUtil.waitForAll(ownedBundleFutures)

Review Comment:
   fixed



-- 
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-unsubscribe@pulsar.apache.org

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