You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "Technoboy- (via GitHub)" <gi...@apache.org> on 2023/06/27 01:31:38 UTC

[GitHub] [pulsar] Technoboy- commented on a diff in pull request #20652: [improve][broker] Make get list from bundle Admin API async

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/NonPersistentTopics.java:
##########
@@ -449,35 +448,39 @@ public void getListFromBundle(
                         bundleRange);
                 asyncResponse.resume(Response.noContent().build());
             } else {
-                NamespaceBundle nsBundle;
-                try {
-                    nsBundle = validateNamespaceBundleOwnership(namespaceName, policies.bundles,
-                        bundleRange, true, true);
-                } catch (WebApplicationException wae) {
-                    asyncResponse.resume(wae);
-                    return;
-                }
-                try {
-                    ConcurrentOpenHashMap<String, ConcurrentOpenHashMap<String, Topic>> bundleTopics =
-                            pulsar().getBrokerService().getMultiLayerTopicsMap().get(namespaceName.toString());
-                    if (bundleTopics == null || bundleTopics.isEmpty()) {
-                        asyncResponse.resume(Collections.emptyList());
-                        return;
-                    }
-                    final List<String> topicList = new ArrayList<>();
-                    String bundleKey = namespaceName.toString() + "/" + nsBundle.getBundleRange();
-                    ConcurrentOpenHashMap<String, Topic> topicMap = bundleTopics.get(bundleKey);
-                    if (topicMap != null) {
-                        topicList.addAll(topicMap.keys().stream()
-                                .filter(name -> !TopicName.get(name).isPersistent())
-                                .collect(Collectors.toList()));
-                    }
-                    asyncResponse.resume(topicList);
-                } catch (Exception e) {
-                    log.error("[{}] Failed to list topics on namespace bundle {}/{}", clientAppId(),
-                            namespaceName, bundleRange, e);
-                    asyncResponse.resume(new RestException(e));
-                }
+                validateNamespaceBundleOwnershipAsync(namespaceName, policies.bundles, bundleRange, true, true)
+                        .thenAccept(nsBundle -> {
+                            try {
+                                ConcurrentOpenHashMap<String, ConcurrentOpenHashMap<String, Topic>> bundleTopics =
+                                        pulsar().getBrokerService()
+                                                .getMultiLayerTopicsMap().get(namespaceName.toString());
+                                if (bundleTopics == null || bundleTopics.isEmpty()) {
+                                    asyncResponse.resume(Collections.emptyList());
+                                    return;
+                                }
+                                final List<String> topicList = new ArrayList<>();
+                                String bundleKey = namespaceName.toString() + "/" + nsBundle.getBundleRange();
+                                ConcurrentOpenHashMap<String, Topic> topicMap = bundleTopics.get(bundleKey);
+                                if (topicMap != null) {
+                                    topicList.addAll(topicMap.keys().stream()
+                                            .filter(name -> !TopicName.get(name).isPersistent())
+                                            .collect(Collectors.toList()));
+                                }
+                                asyncResponse.resume(topicList);
+                            } catch (Exception e) {
+                                log.error("[{}] Failed to list topics on namespace bundle {}/{}", clientAppId(),

Review Comment:
   We can remove `try/catch` block



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