Jason918 commented on code in PR #16946:
URL: https://github.com/apache/pulsar/pull/16946#discussion_r958088114
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -5233,42 +5241,41 @@ protected void
internalGetReplicatedSubscriptionStatus(AsyncResponse asyncRespon
});
}
+ private CompletableFuture<Map<String, Boolean>>
getReplicatedSubscriptionStatusFromBroker(TopicName partitionName,
+
String subName) {
+ return getTopicReferenceAsync(partitionName).thenCompose(topic -> {
+ Subscription sub = topic.getSubscription(subName);
+ if (sub == null) {
+ return FutureUtil.failedFuture(new
RestException(Status.NOT_FOUND,
+ getSubNotFoundErrorMessage(partitionName.toString(),
subName)));
+ }
+ if (topic instanceof PersistentTopic && sub instanceof
PersistentSubscription) {
+ Map<String, Boolean> res = Maps.newHashMap();
+ res.put(partitionName.toString(), sub.isReplicated());
+ return CompletableFuture.completedFuture(res);
+ } else {
+ return FutureUtil.failedFuture(new
RestException(Status.METHOD_NOT_ALLOWED,
+ "Cannot get replicated subscriptions on non-persistent
topics"));
+ }
+ });
+ }
+
private void internalGetReplicatedSubscriptionStatusForNonPartitionedTopic(
AsyncResponse asyncResponse,
String subName,
boolean authoritative) {
// Redirect the request to the appropriate broker if this broker is
not the owner of the topic
validateTopicOwnershipAsync(topicName, authoritative)
- .thenCompose(__ -> getTopicReferenceAsync(topicName))
- .thenAccept(topic -> {
- if (topic == null) {
Review Comment:
Better not remove this check?
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -5233,42 +5241,41 @@ protected void
internalGetReplicatedSubscriptionStatus(AsyncResponse asyncRespon
});
}
+ private CompletableFuture<Map<String, Boolean>>
getReplicatedSubscriptionStatusFromBroker(TopicName partitionName,
Review Comment:
`getReplicatedSubscriptionStatusFromBroker` -->
`getReplicatedSubscriptionStatusFromLocalBroker` or
`getLocalReplicatedSubscriptionStatus` ?
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -5233,42 +5241,41 @@ protected void
internalGetReplicatedSubscriptionStatus(AsyncResponse asyncRespon
});
}
+ private CompletableFuture<Map<String, Boolean>>
getReplicatedSubscriptionStatusFromBroker(TopicName partitionName,
Review Comment:
`partitionName` here is confusing. It also applies to non-partitioned topic.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]