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/09/02 13:44:41 UTC

[GitHub] [pulsar] codelipenghui commented on a diff in pull request #17402: [improve][admin] Make `getBundleRange` async

codelipenghui commented on code in PR #17402:
URL: https://github.com/apache/pulsar/pull/17402#discussion_r961695428


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -1219,27 +1219,31 @@ protected CompletableFuture<TopicHashPositions> internalGetTopicHashPositionsAsy
                 });
     }
 
-    private String getBundleRange(String bundleName) {
-        NamespaceBundle nsBundle;
+    private CompletableFuture<String> getBundleRangeAsync(String bundleName) {
+        CompletableFuture<NamespaceBundle> future;
         if (BundleType.LARGEST.toString().equals(bundleName)) {
-            nsBundle = findLargestBundleWithTopics(namespaceName);
+            future = findLargestBundleWithTopicsAsync(namespaceName);
         } else if (BundleType.HOT.toString().equals(bundleName)) {
-            nsBundle = findHotBundle(namespaceName);
+            future = findHotBundleAsync(namespaceName);
         } else {
-            return bundleName;
-        }
-        if (nsBundle == null) {
-            return null;
+            return CompletableFuture.completedFuture(bundleName);
         }
-        return nsBundle.getBundleRange();
+        return future.thenApply(nsBundle -> {
+            if (nsBundle == null) {
+                return null;
+            }

Review Comment:
   Can we just throw `RestException` here so that you don't need to check in https://github.com/apache/pulsar/pull/17402/files#diff-8696b1e2ba4ee355256e31b33ccc4f1cab77f1c6c79f7b4ab508b73d43d8ad55R1160-R1163
   
   



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