mattisonchao commented on a change in pull request #13887:
URL: https://github.com/apache/pulsar/pull/13887#discussion_r789627545



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -4577,12 +4575,10 @@ protected void 
internalSetReplicatedSubscriptionStatus(AsyncResponse asyncRespon
         }
     }
 
-    private void 
internalSetReplicatedSubscriptionStatusForNonPartitionedTopic(AsyncResponse 
asyncResponse,
-            String subName, boolean authoritative, boolean enabled) {
-        try {
-            // Redirect the request to the appropriate broker if this broker 
is not the owner of the topic
-            validateTopicOwnership(topicName, authoritative);
-
+    private CompletableFuture<Void> 
internalSetReplicatedSubscriptionStatusForNonPartitionedTopicAsync(AsyncResponse
 asyncResponse,
+        String subName,boolean authoritative,boolean enabled) {
+        // Redirect the request to the appropriate broker if this broker is 
not the owner of the topic
+        return validateTopicOwnershipAsync(topicName, 
authoritative).thenRun(() -> {
             Topic topic = getTopicReference(topicName);

Review comment:
       This method can be async.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -4504,26 +4504,24 @@ protected void 
internalSetReplicatedSubscriptionStatus(AsyncResponse asyncRespon
             return;
         }
 
-        // Permission to consume this topic is required
-        try {
-            validateTopicOperation(topicName, 
TopicOperation.SET_REPLICATED_SUBSCRIPTION_STATUS, subName);
-        } catch (Exception e) {
-            resumeAsyncResponseExceptionally(asyncResponse, e);
-            return;
-        }
+        // 1.Permission to consume this topic is required
+        // 2.Redirect the request to the peer-cluster if the local cluster is 
not included in the replication clusters
+        CompletableFuture<Void> future =
+                validateTopicOperationAsync(topicName, 
TopicOperation.SET_REPLICATED_SUBSCRIPTION_STATUS, subName)
+                        .thenCompose(__-> 
validateGlobalNamespaceOwnershipAsync(namespaceName));

Review comment:
       ```suggestion
                           .thenCompose(__ -> 
validateGlobalNamespaceOwnershipAsync(namespaceName));
   ```

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -4577,12 +4575,10 @@ protected void 
internalSetReplicatedSubscriptionStatus(AsyncResponse asyncRespon
         }
     }
 
-    private void 
internalSetReplicatedSubscriptionStatusForNonPartitionedTopic(AsyncResponse 
asyncResponse,
-            String subName, boolean authoritative, boolean enabled) {
-        try {
-            // Redirect the request to the appropriate broker if this broker 
is not the owner of the topic
-            validateTopicOwnership(topicName, authoritative);
-
+    private CompletableFuture<Void> 
internalSetReplicatedSubscriptionStatusForNonPartitionedTopicAsync(AsyncResponse
 asyncResponse,
+        String subName,boolean authoritative,boolean enabled) {

Review comment:
       ```suggestion
           String subName, boolean authoritative, boolean enabled) {
   ```




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


Reply via email to