wangjialing218 commented on a change in pull request #13204:
URL: https://github.com/apache/pulsar/pull/13204#discussion_r769350330
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -2274,6 +2289,21 @@ private void updateManagedLedgerConfig() {
configRegisteredListeners.put(configKey, listener);
}
+ public <T> void
registerPublishBufferLimitListener(Consumer<PublishBufferEvent> listener) {
+ publishBufferLimitListeners.add(listener);
+ }
+
+ private void checkPulishBufferLimit() {
+ publishBufferLimitListeners.forEach(listener -> {
+ if (maxPendingBytes > 0 && totalPendingBytes.sum() >
maxPendingBytes) {
Review comment:
We do not need to call sum() for each listener in this method. We could
use follow flow:
Step1: check if maxPendingBytes > 0
Step2: do sum() and compare with threshold
Step3: inform each listener if necessary
--
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]