jianyun8023 commented on a change in pull request #7914:
URL: https://github.com/apache/pulsar/pull/7914#discussion_r479863900
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -2368,6 +2371,53 @@ protected void internalGetPersistence(AsyncResponse
asyncResponse){
return
pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName,
topicPolicies.get());
}
+ protected void internalGetMaxProducers(AsyncResponse asyncResponse) {
+ validateAdminAccessForTenant(namespaceName.getTenant());
+ validatePoliciesReadOnlyAccess();
+ if (topicName.isGlobal()) {
+ validateGlobalNamespaceOwnership(namespaceName);
+ }
+ checkTopicLevelPolicyEnable();
+ Optional<Integer> maxProducers = getTopicPolicies(topicName)
+ .map(TopicPolicies::getMaxProducerPerTopic);
+ if (!maxProducers.isPresent()) {
+ asyncResponse.resume(Response.noContent().build());
+ } else {
+ asyncResponse.resume(maxProducers.get());
+ }
+ }
Review comment:
Please return `CompletableFuture< Integer >` instead of passing in
`AsyncResponse`.
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -2368,6 +2371,53 @@ protected void internalGetPersistence(AsyncResponse
asyncResponse){
return
pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName,
topicPolicies.get());
}
+ protected void internalGetMaxProducers(AsyncResponse asyncResponse) {
+ validateAdminAccessForTenant(namespaceName.getTenant());
+ validatePoliciesReadOnlyAccess();
+ if (topicName.isGlobal()) {
+ validateGlobalNamespaceOwnership(namespaceName);
+ }
+ checkTopicLevelPolicyEnable();
+ Optional<Integer> maxProducers = getTopicPolicies(topicName)
+ .map(TopicPolicies::getMaxProducerPerTopic);
+ if (!maxProducers.isPresent()) {
+ asyncResponse.resume(Response.noContent().build());
+ } else {
+ asyncResponse.resume(maxProducers.get());
+ }
+ }
Review comment:
Or directly return `Integer`.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]