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



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
##########
@@ -263,8 +264,7 @@ public synchronized void readMoreEntries() {
                             consumerList.size());
                 }
                 havePendingRead = true;
-                cursor.asyncReadEntriesOrWait(messagesToRead, 
serviceConfig.getDispatcherMaxReadSizeBytes(),
-                        this,
+                cursor.asyncReadEntriesOrWait(messagesToRead, bytesToRead, 
this,

Review comment:
       in line 230, when bytesToRead or messageToRead is -1, it will not 
process read operation.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
##########
@@ -234,6 +238,19 @@ public void resetCloseFuture() {
         // noop
     }
 
+    protected static Pair<Integer, Integer> calculateToRead(int 
messagesToRead, int availablePermitsOnMsg,
+                                                     int 
availablePermitsOnByte, int bytesToRead) {
+        if (availablePermitsOnMsg > 0) {
+            messagesToRead = Math.min(messagesToRead, availablePermitsOnMsg);
+        }
+
+        if (availablePermitsOnByte > 0) {
+            bytesToRead = availablePermitsOnByte;

Review comment:
       good catch!

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
##########
@@ -234,6 +238,19 @@ public void resetCloseFuture() {
         // noop
     }
 
+    protected static Pair<Integer, Integer> calculateToRead(int 
messagesToRead, int availablePermitsOnMsg,

Review comment:
       good suggestion.




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