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/07/10 05:39:33 UTC

[GitHub] [pulsar] HQebupt opened a new pull request, #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

HQebupt opened a new pull request, #16504:
URL: https://github.com/apache/pulsar/pull/16504

   ### Motivation
   
   See #14365 
   
   ### Verifying this change
   
   Make sure that the change passes the CI checks.
   
   ### Does this pull request potentially affect one of the following parts:
   
   If `yes` was chosen, please highlight the changes
   
   - Dependencies (does it add or upgrade a dependency): (no)
   - The public API: (no)
   - The schema: (no)
   - The default values of configurations: (no)
   - The wire protocol: (no)
   - The rest endpoints: (no)
   - The admin cli options: (no)
   - Anything that affects deployment: (no)
   
   ### Documentation
   Check the box below and label this PR (if you have committer privilege).
   
   Need to update docs? 
   - [x] `doc-not-needed` 
   


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


[GitHub] [pulsar] gaoran10 commented on a diff in pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
gaoran10 commented on code in PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#discussion_r918672831


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java:
##########
@@ -988,14 +988,21 @@ public DispatchRate getReplicatorDispatchRate(@PathParam("tenant") String tenant
     @ApiOperation(hidden = true, value = "Get backlog quota map on a namespace.")
     @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
             @ApiResponse(code = 404, message = "Namespace does not exist") })
-    public Map<BacklogQuotaType, BacklogQuota> getBacklogQuotaMap(@PathParam("property") String property,
+    public void getBacklogQuotaMap(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("property") String property,
             @PathParam("cluster") String cluster, @PathParam("namespace") String namespace) {
         validateNamespaceName(property, cluster, namespace);
-        validateNamespacePolicyOperation(NamespaceName.get(property, namespace),
-                PolicyName.BACKLOG, PolicyOperation.READ);
-
-        Policies policies = getNamespacePolicies(namespaceName);
-        return policies.backlog_quota_map;
+        validateNamespacePolicyOperationAsync(NamespaceName.get(property, namespace), PolicyName.BACKLOG,

Review Comment:
   Could we use the param `namespaceName` instead of `NamespaceName.get(property, namespace)`?



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java:
##########
@@ -1037,13 +1037,21 @@ public DispatchRate getReplicatorDispatchRate(@PathParam("tenant") String tenant
     @ApiOperation(value = "Get backlog quota map on a namespace.")
     @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
             @ApiResponse(code = 404, message = "Namespace does not exist") })
-    public Map<BacklogQuotaType, BacklogQuota> getBacklogQuotaMap(@PathParam("tenant") String tenant,
+    public void getBacklogQuotaMap(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("tenant") String tenant,
             @PathParam("namespace") String namespace) {
         validateNamespaceName(tenant, namespace);
-        validateNamespacePolicyOperation(
-                NamespaceName.get(tenant, namespace), PolicyName.BACKLOG, PolicyOperation.READ);
-        Policies policies = getNamespacePolicies(namespaceName);
-        return policies.backlog_quota_map;
+        validateNamespacePolicyOperationAsync(NamespaceName.get(tenant, namespace), PolicyName.BACKLOG,

Review Comment:
   Could we use the param `namespaceName` instead of `NamespaceName.get(tenant, namespace)`?



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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1180074119

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1180345159

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1179672254

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1179695054

   /pulsarbot run-failure-checks
   


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


[GitHub] [pulsar] HQebupt commented on a diff in pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on code in PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#discussion_r919561580


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java:
##########
@@ -988,14 +988,21 @@ public DispatchRate getReplicatorDispatchRate(@PathParam("tenant") String tenant
     @ApiOperation(hidden = true, value = "Get backlog quota map on a namespace.")
     @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
             @ApiResponse(code = 404, message = "Namespace does not exist") })
-    public Map<BacklogQuotaType, BacklogQuota> getBacklogQuotaMap(@PathParam("property") String property,
+    public void getBacklogQuotaMap(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("property") String property,
             @PathParam("cluster") String cluster, @PathParam("namespace") String namespace) {
         validateNamespaceName(property, cluster, namespace);
-        validateNamespacePolicyOperation(NamespaceName.get(property, namespace),
-                PolicyName.BACKLOG, PolicyOperation.READ);
-
-        Policies policies = getNamespacePolicies(namespaceName);
-        return policies.backlog_quota_map;
+        validateNamespacePolicyOperationAsync(namespaceName, PolicyName.BACKLOG,
+                PolicyOperation.READ)
+                .thenCompose(__ -> getNamespacePoliciesAsync(namespaceName))
+                .thenAccept(policies -> asyncResponse.resume(policies.backlog_quota_map))
+                .exceptionally(ex -> {
+                    log.error("[{}] Failed to get backlog quota map on namespace {}:{}", clientAppId(), namespaceName,
+                            ex.getCause().getMessage(), ex);

Review Comment:
   No, it does not. I remove it.



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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1180564871

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] mattisonchao commented on a diff in pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on code in PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#discussion_r919553550


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java:
##########
@@ -988,14 +988,21 @@ public DispatchRate getReplicatorDispatchRate(@PathParam("tenant") String tenant
     @ApiOperation(hidden = true, value = "Get backlog quota map on a namespace.")
     @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
             @ApiResponse(code = 404, message = "Namespace does not exist") })
-    public Map<BacklogQuotaType, BacklogQuota> getBacklogQuotaMap(@PathParam("property") String property,
+    public void getBacklogQuotaMap(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("property") String property,
             @PathParam("cluster") String cluster, @PathParam("namespace") String namespace) {
         validateNamespaceName(property, cluster, namespace);
-        validateNamespacePolicyOperation(NamespaceName.get(property, namespace),
-                PolicyName.BACKLOG, PolicyOperation.READ);
-
-        Policies policies = getNamespacePolicies(namespaceName);
-        return policies.backlog_quota_map;
+        validateNamespacePolicyOperationAsync(namespaceName, PolicyName.BACKLOG,
+                PolicyOperation.READ)
+                .thenCompose(__ -> getNamespacePoliciesAsync(namespaceName))
+                .thenAccept(policies -> asyncResponse.resume(policies.backlog_quota_map))
+                .exceptionally(ex -> {
+                    log.error("[{}] Failed to get backlog quota map on namespace {}:{}", clientAppId(), namespaceName,
+                            ex.getCause().getMessage(), ex);

Review Comment:
   Why do we print exception messages and stack trace both? Do stack traces exclude the exception messages? 



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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1182655980

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1179891173

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] gaoran10 commented on a diff in pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
gaoran10 commented on code in PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#discussion_r918671930


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java:
##########
@@ -1037,13 +1037,21 @@ public DispatchRate getReplicatorDispatchRate(@PathParam("tenant") String tenant
     @ApiOperation(value = "Get backlog quota map on a namespace.")
     @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
             @ApiResponse(code = 404, message = "Namespace does not exist") })
-    public Map<BacklogQuotaType, BacklogQuota> getBacklogQuotaMap(@PathParam("tenant") String tenant,
+    public void getBacklogQuotaMap(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("tenant") String tenant,
             @PathParam("namespace") String namespace) {
         validateNamespaceName(tenant, namespace);
-        validateNamespacePolicyOperation(
-                NamespaceName.get(tenant, namespace), PolicyName.BACKLOG, PolicyOperation.READ);
-        Policies policies = getNamespacePolicies(namespaceName);
-        return policies.backlog_quota_map;
+        validateNamespacePolicyOperationAsync(NamespaceName.get(tenant, namespace), PolicyName.BACKLOG,

Review Comment:
   Could we use the param `namespaceName` to  instead of 



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java:
##########
@@ -1037,13 +1037,21 @@ public DispatchRate getReplicatorDispatchRate(@PathParam("tenant") String tenant
     @ApiOperation(value = "Get backlog quota map on a namespace.")
     @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
             @ApiResponse(code = 404, message = "Namespace does not exist") })
-    public Map<BacklogQuotaType, BacklogQuota> getBacklogQuotaMap(@PathParam("tenant") String tenant,
+    public void getBacklogQuotaMap(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("tenant") String tenant,
             @PathParam("namespace") String namespace) {
         validateNamespaceName(tenant, namespace);
-        validateNamespacePolicyOperation(
-                NamespaceName.get(tenant, namespace), PolicyName.BACKLOG, PolicyOperation.READ);
-        Policies policies = getNamespacePolicies(namespaceName);
-        return policies.backlog_quota_map;
+        validateNamespacePolicyOperationAsync(NamespaceName.get(tenant, namespace), PolicyName.BACKLOG,

Review Comment:
   Could we use the param `namespaceName` to  instead of `NamespaceName.get(tenant, namespace)`?



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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1183087498

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1180017106

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1181214818

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1179743555

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1181371216

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1182850769

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] Technoboy- merged pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
Technoboy- merged PR #16504:
URL: https://github.com/apache/pulsar/pull/16504


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1182887914

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#issuecomment-1179972838

   /pulsarbot run-failure-checks


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


[GitHub] [pulsar] HQebupt commented on a diff in pull request #16504: [improve][broker][PIP-149]make getBacklogQuotaMap method async in Namespaces

Posted by GitBox <gi...@apache.org>.
HQebupt commented on code in PR #16504:
URL: https://github.com/apache/pulsar/pull/16504#discussion_r918773095


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java:
##########
@@ -988,14 +988,21 @@ public DispatchRate getReplicatorDispatchRate(@PathParam("tenant") String tenant
     @ApiOperation(hidden = true, value = "Get backlog quota map on a namespace.")
     @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
             @ApiResponse(code = 404, message = "Namespace does not exist") })
-    public Map<BacklogQuotaType, BacklogQuota> getBacklogQuotaMap(@PathParam("property") String property,
+    public void getBacklogQuotaMap(
+            @Suspended final AsyncResponse asyncResponse,
+            @PathParam("property") String property,
             @PathParam("cluster") String cluster, @PathParam("namespace") String namespace) {
         validateNamespaceName(property, cluster, namespace);
-        validateNamespacePolicyOperation(NamespaceName.get(property, namespace),
-                PolicyName.BACKLOG, PolicyOperation.READ);
-
-        Policies policies = getNamespacePolicies(namespaceName);
-        return policies.backlog_quota_map;
+        validateNamespacePolicyOperationAsync(NamespaceName.get(property, namespace), PolicyName.BACKLOG,

Review Comment:
   Good!



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