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

[GitHub] [pulsar] mattisonchao commented on a change in pull request #14141: [Broker] Make PersistentTopicsBase#internalUpdatePartitionedTopic async

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



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/PersistentTopics.java
##########
@@ -228,15 +228,27 @@ public void createNonPartitionedTopic(
             @ApiResponse(code = 406, message = "The number of partitions should be more than 0"
                     + " and less than or equal to maxNumPartitionsPerPartitionedTopic"),
             @ApiResponse(code = 409, message = "Partitioned topic does not exist")})
-    public void updatePartitionedTopic(@PathParam("property") String property, @PathParam("cluster") String cluster,
+    public void updatePartitionedTopic(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("property") String property, @PathParam("cluster") String cluster,
             @PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
             @QueryParam("updateLocalTopicOnly") @DefaultValue("false") boolean updateLocalTopicOnly,
             @ApiParam(value = "Is authentication required to perform this operation")
             @QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
             @QueryParam("force") @DefaultValue("false") boolean force,
             int numPartitions) {
-        validateTopicName(property, cluster, namespace, encodedTopic);
-        internalUpdatePartitionedTopic(numPartitions, updateLocalTopicOnly, authoritative, force);
+        try {
+            validateTopicName(property, cluster, namespace, encodedTopic);
+            internalUpdatePartitionedTopicAsync(numPartitions, updateLocalTopicOnly, authoritative, force)
+                    .thenAccept(__ -> asyncResponse.resume(Response.noContent().build()))
+                    .exceptionally(ex -> {
+                        resumeAsyncResponseExceptionally(asyncResponse, ex);
+                        return null;
+                    });
+        } catch (Exception e) {

Review comment:
       Looks we just need to catch  ``validateTopicName(property, cluster, namespace, encodedTopic);`` right?




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