michaeljmarshall commented on code in PR #17273:
URL: https://github.com/apache/pulsar/pull/17273#discussion_r956465408


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainer.java:
##########
@@ -45,33 +45,48 @@
  */
 public class ManagedCursorContainer implements Iterable<ManagedCursor> {
 
+    private final OrderingType orderingType;
+    private final OrderingFilter orderingFilter;
+
     private static class Item {
         final ManagedCursor cursor;
         PositionImpl position;
         int idx;
 
-        Item(ManagedCursor cursor, int idx) {
+        Item(ManagedCursor cursor, PositionImpl position, int idx) {
             this.cursor = cursor;
-            this.position = (PositionImpl) cursor.getMarkDeletedPosition();
+            this.position = position;
             this.idx = idx;
         }
     }
 
-    public enum CursorType {
-        DurableCursor,
-        NonDurableCursor,
-        ALL
+    private enum OrderingType {
+        MARKDELETED_POSITION,
+        READ_POSITION
+    }

Review Comment:
   As part of this change, I think we'll need to update the Javadoc for this 
class since we're making the ordering configurable.



##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -3513,31 +3495,22 @@ public void activateCursor(ManagedCursor cursor) {
         if (activeCursors.get(cursor.getName()) == null) {
             activeCursors.add(cursor);
         }
-        if (!cursor.isDurable() && 
nonDurableActiveCursors.get(cursor.getName()) == null) {
-            nonDurableActiveCursors.add(cursor);
-        }
     }
 
     public void deactivateCursor(ManagedCursor cursor) {
+        deactivateCursorByName(cursor.getName());
+    }
+
+    private void deactivateCursorByName(String cursorName) {
         synchronized (activeCursors) {
-            if (activeCursors.get(cursor.getName()) != null) {
-                activeCursors.removeCursor(cursor.getName());
-                if (!activeCursors.hasDurableCursors()) {
-                    // cleanup cache if there is no active subscription
-                    entryCache.clear();
-                } else {
-                    // if removed subscription was the slowest subscription : 
update cursor and let it clear cache:
-                    // till new slowest-cursor's read-position
-                    discardEntriesFromCache((ManagedCursorImpl) 
activeCursors.getSlowestReader(),
-                            getPreviousPosition((PositionImpl) 
activeCursors.getSlowestReader().getReadPosition()));
-                }
-            }
-            if (!cursor.isDurable()) {
-                nonDurableActiveCursors.removeCursor(cursor.getName());
+            if (activeCursors.get(cursorName) != null) {
+                activeCursors.removeCursor(cursorName);

Review Comment:
   Nit: could we update the `removeCursor` to could return a `boolean` based on 
whether the cursor was removed? Then we'd save the `get` call on 3507 which 
internally requires us to acquire the `rwLock`.



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