-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Issue 7759] Support set Max Consumer on topic level. #7968
Conversation
/pulsarbot run-failure-checks |
@codelipenghui @jianyun8023 @jiazhai PTAL. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
protected void internalGetMaxConsumers(AsyncResponse asyncResponse) { | ||
validateAdminAccessForTenant(namespaceName.getTenant()); | ||
validatePoliciesReadOnlyAccess(); | ||
if (topicName.isGlobal()) { | ||
validateGlobalNamespaceOwnership(namespaceName); | ||
} | ||
checkTopicLevelPolicyEnable(); | ||
Optional<Integer> maxConsumers = getTopicPolicies(topicName) | ||
.map(TopicPolicies::getMaxConsumerPerTopic); | ||
if (!maxConsumers.isPresent()) { | ||
asyncResponse.resume(Response.noContent().build()); | ||
} else { | ||
asyncResponse.resume(maxConsumers.get()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not recommended to use AsyncResponse
, just return the value directly.
more info to see #7884
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about making a new PR to resolve them all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the new code can comply with this rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Assert.assertEquals(getMaxConsumers, maxConsumers); | ||
|
||
admin.topics().deletePartitionedTopic(persistenceTopic, true); | ||
admin.topics().deletePartitionedTopic(testTopic, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove admin.topics().deletePartitionedTopic(testTopic, true);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'testTopic' was created in BeforeMethod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
# Conflicts: # pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
/pulsarbot run-failure-checks |
jcommander.addCommand("get-maxConsumers", new GetMaxConsumers()); | ||
jcommander.addCommand("set-maxConsumers", new SetMaxConsumers()); | ||
jcommander.addCommand("remove-maxConsumers", new RemoveMaxConsumers()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jcommander.addCommand("get-maxConsumers", new GetMaxConsumers()); | |
jcommander.addCommand("set-maxConsumers", new SetMaxConsumers()); | |
jcommander.addCommand("remove-maxConsumers", new RemoveMaxConsumers()); | |
jcommander.addCommand("get-max-consumers", new GetMaxConsumers()); | |
jcommander.addCommand("set-max-consumers", new SetMaxConsumers()); | |
jcommander.addCommand("remove-max-consumers", new RemoveMaxConsumers()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And please also update the max producers as the above pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/pulsarbot run-failure-checks |
Fix [https://github.com/apache/pulsar/issues/7759](https://github.com/apache/pulsar/issues/7759), and master issue [https://github.com/apache/pulsar/issues/2688](https://github.com/apache/pulsar/issues/2688) ### Motivation Support set/get/remove maxConsumers on a topic level.
Fix #7759, and master issue #2688
Motivation
Support set/get/remove maxConsumers on a topic level.
Verifying this change
new unit test added.