Technoboy- commented on code in PR #18369:
URL: https://github.com/apache/pulsar/pull/18369#discussion_r1028715168
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java:
##########
@@ -438,14 +438,21 @@ private PublishRate
publishRateInBroker(ServiceConfiguration config) {
return new PublishRate(config.getMaxPublishRatePerTopicInMessages(),
config.getMaxPublishRatePerTopicInBytes());
}
- protected boolean isProducersExceeded() {
+ protected boolean isProducersExceeded(Producer producer) {
+ if (isSystemTopic() || producer.isRemote()) {
+ return false;
+ }
Integer maxProducers = topicPolicies.getMaxProducersPerTopic().get();
- if (maxProducers > 0 && maxProducers <= producers.size()) {
+ if (maxProducers != null && maxProducers > 0 && maxProducers <=
getUserCreatedProducerSize()) {
return true;
}
return false;
}
+ private long getUserCreatedProducerSize() {
+ return producers.values().stream().filter(p -> !(p.isRemote() ||
p.getTopic().isSystemTopic())).count();
+ }
Review Comment:
All the producers (including user-created producers and replicator
producers) stored in `producers `. So when checking the user-created producer
size, we should filter replicator producers.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]