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/08 13:20:04 UTC

[GitHub] [pulsar] codelipenghui commented on a diff in pull request #16946: [Improve][Broker]Reduce GetReplicatedSubscriptionStatus local REST call

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -5250,42 +5258,42 @@ protected void internalGetReplicatedSubscriptionStatus(AsyncResponse asyncRespon
         });
     }
 
+    private CompletableFuture<Map<String, Boolean>> getReplicatedSubscriptionStatusFromLocalBroker(
+            TopicName localTopicName,
+            String subName) {
+        return getTopicReferenceAsync(localTopicName).thenCompose(topic -> {
+            Subscription sub = topic.getSubscription(subName);
+            if (sub == null) {
+                return FutureUtil.failedFuture(new RestException(Status.NOT_FOUND,
+                    getSubNotFoundErrorMessage(localTopicName.toString(), subName)));
+            }
+            if (topic instanceof PersistentTopic && sub instanceof PersistentSubscription) {
+                Map<String, Boolean> res = Maps.newHashMap();
+                res.put(localTopicName.toString(), sub.isReplicated());
+                return CompletableFuture.completedFuture(res);

Review Comment:
   ```suggestion
                  return CompletableFuture.completedFuture(Collections.singletonMap(localTopicName.toString(), 
                           sub.isReplicated()));
   ```



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