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/25 11:04:33 UTC

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

Technoboy- commented on code in PR #15280:
URL: https://github.com/apache/pulsar/pull/15280#discussion_r857508630


##########
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:
   You create new list -> `new ArrayList<>`, so no need to use `unmodifiableList`



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