dao-jun commented on code in PR #21816:
URL: https://github.com/apache/pulsar/pull/21816#discussion_r1438003739


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainer.java:
##########
@@ -204,6 +281,24 @@ public ManagedCursor getSlowestReader() {
         }
     }
 
+    /**
+     * @return Returns the CursorInfo for the cursor with the oldest position,
+     *         or null if there aren't any tracked cursors
+     */
+    public CursorInfo getCursorWithOldestPosition() {
+        long stamp = rwLock.readLock();
+        try {
+            if (heap.isEmpty()) {
+                return null;
+            } else {
+                Item item = heap.get(0);

Review Comment:
   @dragosvictor Actually, we can use `PriorityQueue#remove(Object o)` or 
`PriorityQueue#removeIf(Predicate<Object> filter)` to remove elements randomly. 
But it doesn't matter, the current implementation also works fine. 



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