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/09/01 05:09:57 UTC

[GitHub] [pulsar] nodece commented on a diff in pull request #17383: [improve][broker] Improve `backlogQuota` endpoint to pure async.

nodece commented on code in PR #17383:
URL: https://github.com/apache/pulsar/pull/17383#discussion_r960223523


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java:
##########
@@ -1161,12 +1168,31 @@ public void getBacklogQuotaMap(
             @ApiResponse(code = 412, message = "Specified backlog quota exceeds retention quota."
                     + " Increase retention quota and retry request")})
     public void setBacklogQuota(
+            @Suspended final AsyncResponse asyncResponse,
             @PathParam("property") String property, @PathParam("cluster") String cluster,
             @PathParam("namespace") String namespace,
             @QueryParam("backlogQuotaType") BacklogQuotaType backlogQuotaType,
             BacklogQuota backlogQuota) {
         validateNamespaceName(property, cluster, namespace);
-        internalSetBacklogQuota(backlogQuotaType, backlogQuota);
+        validateNamespacePolicyOperationAsync(namespaceName, PolicyName.BACKLOG, PolicyOperation.WRITE)
+                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
+                .thenCompose(__ -> internalSetBacklogQuotaAsync(backlogQuotaType, backlogQuota))
+                .thenAccept(__ -> {
+                    asyncResponse.resume(Response.noContent().build());
+                    String jsonQuota;
+                    try {
+                        jsonQuota = ObjectMapperFactory.getThreadLocal().writeValueAsString(backlogQuota);
+                    } catch (JsonProcessingException e) {
+                        jsonQuota = e.getMessage();
+                    }
+                    log.info("[{}] Successfully updated backlog quota map: namespace={}, map={}", clientAppId(),

Review Comment:
   Using `backlogQuotaType` should be working fine here.



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