codelipenghui commented on a change in pull request #12045:
URL: https://github.com/apache/pulsar/pull/12045#discussion_r711521606



##########
File path: 
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainerTest.java
##########
@@ -386,6 +389,31 @@ public boolean checkAndUpdateReadPositionChanged() {
         }
     }
 
+    @Test
+    public void testSlowestReadPositionForActiveCursors() throws Exception {

Review comment:
       Better to test the cursor's read position move forward case?

##########
File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainer.java
##########
@@ -319,6 +322,34 @@ private void swap(Item item1, Item item2) {
         item2.idx = idx1;
     }
 
+    private void updateSlowestReadPositionForActiveCursors(ManagedCursor 
managedCursor) {
+        if (managedCursor == null) {
+            PositionImpl slowest = null;
+            for (ManagedCursor cursor : this) {
+                PositionImpl p = (PositionImpl) cursor.getReadPosition();
+                if (slowest == null) {
+                    slowest = p;
+                } else if (p.compareTo(slowest) < 0) {
+                    slowest = p;
+                }
+            }
+            slowestReadPositionForActiveCursors = slowest;
+            return;
+        }
+        PositionImpl position = (PositionImpl) managedCursor.getReadPosition();
+        if (slowestReadPositionForActiveCursors == null) {
+            slowestReadPositionForActiveCursors = position;
+            return;
+        }
+        if (slowestReadPositionForActiveCursors.compareTo(position) > 0) {
+            slowestReadPositionForActiveCursors = position;
+        }

Review comment:
       If the read position of cursors moves forward, the 
`slowestReadPositionForActiveCursors` will not change?




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