Skip to content
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

Merged
merged 9 commits into from
Sep 8, 2020
Merged

[Issue 7759] Support set Max Consumer on topic level. #7968

merged 9 commits into from
Sep 8, 2020

Conversation

zhanghaou
Copy link
Contributor

Fix #7759, and master issue #2688

Motivation

Support set/get/remove maxConsumers on a topic level.

Verifying this change

new unit test added.

@zhanghaou
Copy link
Contributor Author

/pulsarbot run-failure-checks

@zhanghaou
Copy link
Contributor Author

@codelipenghui @jianyun8023 @jiazhai PTAL. Thanks.

Copy link
Contributor

@jianyun8023 jianyun8023 left a 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.

Comment on lines 2420 to 2434
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());
}
}
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

zhanghaou and others added 3 commits September 7, 2020 15:11
# Conflicts:
#	pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
@zhanghaou
Copy link
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui codelipenghui added this to the 2.7.0 milestone Sep 7, 2020
@codelipenghui codelipenghui added component/topic-policy doc-required Your PR changes impact docs and you will update later. labels Sep 7, 2020
Comment on lines 156 to 158
jcommander.addCommand("get-maxConsumers", new GetMaxConsumers());
jcommander.addCommand("set-maxConsumers", new SetMaxConsumers());
jcommander.addCommand("remove-maxConsumers", new RemoveMaxConsumers());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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());

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@zhanghaou
Copy link
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui codelipenghui merged commit 6eefee7 into apache:master Sep 8, 2020
@codelipenghui codelipenghui mentioned this pull request Sep 9, 2020
14 tasks
@zhanghaou zhanghaou deleted the set-max-consumer branch September 10, 2020 06:55
@Anonymitaet Anonymitaet added doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. and removed doc-required Your PR changes impact docs and you will update later. labels Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Your PR contains doc changes, no matter whether the changes are in markdown or code files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support set Max Consumer on topic level.
4 participants