anvinjain commented on a change in pull request #11135:
URL: https://github.com/apache/pulsar/pull/11135#discussion_r661153891



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
##########
@@ -310,13 +311,15 @@ protected int calculateNumOfMessageToRead(int 
currentTotalAvailablePermits) {
                     }
                     topic.getBrokerService().executor().schedule(() -> 
readMoreEntries(), MESSAGE_RATE_BACKOFF_MS,
                             TimeUnit.MILLISECONDS);
-                    return -1;
+                    return Pair.of(-1, -1L);
                 } else {
-                    // if dispatch-rate is in msg then read only msg according 
to available permit
-                    long availablePermitsOnMsg = 
topicRateLimiter.getAvailableDispatchRateLimitOnMsg();
-                    if (availablePermitsOnMsg > 0) {
-                        messagesToRead = Math.min(messagesToRead, (int) 
availablePermitsOnMsg);
-                    }
+                    Pair<Integer, Long> calculateResult = 
computeReadLimits(messagesToRead,
+                            (int) 
topicRateLimiter.getAvailableDispatchRateLimitOnMsg(),
+                            
topicRateLimiter.getAvailableDispatchRateLimitOnByte(), bytesToRead);

Review comment:
       You have not changed the order of arguments here (after changing the 
order in the function definition). It should be
   
   ```java
    computeReadLimits(
       messagesToRead,
       (int) topicRateLimiter.getAvailableDispatchRateLimitOnMsg(),
       bytesToRead,
       topicRateLimiter.getAvailableDispatchRateLimitOnByte());
   ```
   
   Please fix at other places too where this function is called.
   
   




-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to