Class ManagedCursorContainer

  • All Implemented Interfaces:
    java.lang.Iterable<ManagedCursor>

    public class ManagedCursorContainer
    extends java.lang.Object
    implements java.lang.Iterable<ManagedCursor>
    Contains all the cursors for a ManagedLedger.

    The goal is to always know the slowest consumer and hence decide which is the oldest ledger we need to keep.

    This data structure maintains a list and a map of cursors. The map is used to relate a cursor name with an entry in the linked-list. The list is a sorted double linked-list of cursors.

    When a cursor is markDeleted, this list is updated and the cursor is moved in its new position.

    To minimize the moving around, the order is maintained using the ledgerId, but not the entryId, since we only care about ledgers to be deleted.

    • Constructor Detail

      • ManagedCursorContainer

        public ManagedCursorContainer()
    • Method Detail

      • removeCursor

        public void removeCursor​(java.lang.String name)
      • cursorUpdated

        public org.apache.commons.lang3.tuple.Pair<PositionImpl,​PositionImpl> cursorUpdated​(ManagedCursor cursor,
                                                                                                  Position newPosition)
        Signal that a cursor position has been updated and that the container must re-order the cursor list.
        Parameters:
        cursor -
        Returns:
        a pair of positions, representing the previous slowest consumer and the new slowest consumer (after the update).
      • getSlowestReaderPosition

        public PositionImpl getSlowestReaderPosition()
        Get the slowest reader position, meaning older acknowledged position between all the cursors.
        Returns:
        the slowest reader position
      • isEmpty

        public boolean isEmpty()
        Check whether there are any cursors
        Returns:
        true is there are no cursors and false if there are
      • hasDurableCursors

        public boolean hasDurableCursors()
        Check whether that are any durable cursors
        Returns:
        true if there are durable cursors and false if there are not
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • iterator

        public java.util.Iterator<ManagedCursor> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<ManagedCursor>