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/06/21 09:51:01 UTC

[GitHub] [pulsar] AnonHxy commented on a diff in pull request #16141: [improve][broker][PIP-149]make getInternalStats method async

AnonHxy commented on code in PR #16141:
URL: https://github.com/apache/pulsar/pull/16141#discussion_r902408489


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/NonPersistentTopics.java:
##########
@@ -93,25 +92,32 @@ public void getPartitionedMetadata(
             @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
             @ApiResponse(code = 403, message = "Don't have admin permission"),
             @ApiResponse(code = 404, message = "Topic does not exist")})
-    public PersistentTopicInternalStats getInternalStats(@PathParam("property") String property,
-                                                         @PathParam("cluster") String cluster, @PathParam("namespace")
-                                                                     String namespace,
-                                                         @PathParam("topic") @Encoded String encodedTopic,
-                                                         @QueryParam("authoritative") @DefaultValue("false")
-                                                                     boolean authoritative,
-                                                         @QueryParam("metadata") @DefaultValue("false")
-                                                                     boolean metadata) {
+    public void getInternalStats(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("property") String property,
+            @PathParam("cluster") String cluster, @PathParam("namespace")
+                    String namespace,
+            @PathParam("topic") @Encoded String encodedTopic,
+            @QueryParam("authoritative") @DefaultValue("false")
+                    boolean authoritative,
+            @QueryParam("metadata") @DefaultValue("false")
+                    boolean metadata) {
         validateTopicName(property, cluster, namespace, encodedTopic);

Review Comment:
   Better to invoke `validateTopicName` like this. Otherwise if validate topic name failure, `resumeAsyncResponseExceptionally` will not be invoked.
   ```
    CompletableFuture.completedFuture(null)
               .thenRun(() -> validateTopicName(tenant, namespace, encodedTopic))
               .thenCompose(() -> validateTopicOwnershipAsync(topicName, authoritative))
               ....
   ```



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/NonPersistentTopics.java:
##########
@@ -93,25 +93,32 @@ public void getPartitionedMetadata(
             @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
             @ApiResponse(code = 403, message = "Don't have admin permission"),
             @ApiResponse(code = 404, message = "Topic does not exist")})
-    public PersistentTopicInternalStats getInternalStats(@PathParam("property") String property,
-                                                         @PathParam("cluster") String cluster, @PathParam("namespace")
-                                                                     String namespace,
-                                                         @PathParam("topic") @Encoded String encodedTopic,
-                                                         @QueryParam("authoritative") @DefaultValue("false")
-                                                                     boolean authoritative,
-                                                         @QueryParam("metadata") @DefaultValue("false")
-                                                                     boolean metadata) {
+    public void getInternalStats(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("property") String property,
+            @PathParam("cluster") String cluster, @PathParam("namespace")
+                    String namespace,
+            @PathParam("topic") @Encoded String encodedTopic,
+            @QueryParam("authoritative") @DefaultValue("false")
+                    boolean authoritative,
+            @QueryParam("metadata") @DefaultValue("false")

Review Comment:
   I think it'better to remain line98-104  unchanged.



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