wangjialing218 commented on a change in pull request #11325:
URL: https://github.com/apache/pulsar/pull/11325#discussion_r725828201



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/DispatchRateLimiter.java
##########
@@ -173,12 +188,20 @@ public void updateDispatchRate() {
         }
 
         updateDispatchRate(dispatchRate.get());
-        log.info("[{}] configured {} message-dispatch rate at broker {}", 
this.topicName, type, dispatchRate.get());
-    }
+        if (type == Type.BROKER) {
+            log.info("configured broker message-dispatch rate {}", 
dispatchRate.get());
+        } else {
+            log.info("[{}] configured {} message-dispatch rate at broker {}", 
this.topicName, type, dispatchRate.get());
+        }
+}
 
     public static boolean isDispatchRateNeeded(BrokerService brokerService, 
Optional<Policies> policies,
             String topicName, Type type) {
         final ServiceConfiguration serviceConfig = 
brokerService.pulsar().getConfiguration();
+        if (type == Type.BROKER) {

Review comment:
       Broker level and topic level rate dispath limiter have same priority, as 
long as subscription level rate limiter. Because the enforcement is done at 
different level.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
##########
@@ -238,6 +240,27 @@ public void resetCloseFuture() {
         // noop
     }
 
+    protected abstract void reScheduleRead();
+
+    protected boolean reachDispatchRateLimit(DispatchRateLimiter 
dispatchRateLimiter,
+                                             MutablePair<Integer, Long> 
calculateToRead) {
+        if (dispatchRateLimiter.isDispatchRateLimitingEnabled()) {
+            if (!dispatchRateLimiter.hasMessageDispatchPermit()) {
+                reScheduleRead();
+                return true;
+            } else {
+                // update messagesToRead according to available dispatch rate 
limit.
+                Pair<Integer, Long> calculateResult = 
computeReadLimits(calculateToRead.getLeft(),
+                        (int) 
dispatchRateLimiter.getAvailableDispatchRateLimitOnMsg(),
+                        calculateToRead.getRight(),
+                        
dispatchRateLimiter.getAvailableDispatchRateLimitOnByte());
+                calculateToRead.setLeft(calculateResult.getLeft());
+                calculateToRead.setRight(calculateResult.getRight());

Review comment:
       Done




-- 
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]


Reply via email to