Interface ReadOnlyCursor

  • All Known Implementing Classes:
    ReadOnlyCursorImpl

    @LimitedPrivate
    @Stable
    public interface ReadOnlyCursor
    • Method Detail

      • readEntries

        java.util.List<Entry> readEntries​(int numberOfEntriesToRead)
                                   throws java.lang.InterruptedException,
                                          ManagedLedgerException
        Read entries from the ManagedLedger, up to the specified number. The returned list can be smaller.
        Parameters:
        numberOfEntriesToRead - maximum number of entries to return
        Returns:
        the list of entries
        Throws:
        ManagedLedgerException
        java.lang.InterruptedException
      • asyncReadEntries

        void asyncReadEntries​(int numberOfEntriesToRead,
                              AsyncCallbacks.ReadEntriesCallback callback,
                              java.lang.Object ctx,
                              PositionImpl maxPosition)
        Asynchronously read entries from the ManagedLedger.
        Parameters:
        numberOfEntriesToRead - maximum number of entries to return
        callback - callback object
        ctx - opaque context
        maxPosition - max position can read
        See Also:
        readEntries(int)
      • asyncReadEntries

        void asyncReadEntries​(int numberOfEntriesToRead,
                              long maxSizeBytes,
                              AsyncCallbacks.ReadEntriesCallback callback,
                              java.lang.Object ctx,
                              PositionImpl maxPosition)
        Asynchronously read entries from the ManagedLedger.
        Parameters:
        numberOfEntriesToRead - maximum number of entries to return
        maxSizeBytes - max size in bytes of the entries to return
        callback - callback object
        ctx - opaque context
        maxPosition - max position can read
      • getReadPosition

        Position getReadPosition()
        Get the read position. This points to the next message to be read from the cursor.
        Returns:
        the read position
      • hasMoreEntries

        boolean hasMoreEntries()
        Tells whether this cursor has already consumed all the available entries.

        This method is not blocking.

        Returns:
        true if there are pending entries to read, false otherwise
      • getNumberOfEntries

        long getNumberOfEntries()
        Return the number of messages that this cursor still has to read.

        This method has linear time complexity on the number of ledgers included in the managed ledger.

        Returns:
        the number of entries
      • skipEntries

        void skipEntries​(int numEntriesToSkip)
        Skip n entries from the read position of this cursor.
        Parameters:
        numEntriesToSkip - number of entries to skip
      • findNewestMatching

        Position findNewestMatching​(ManagedCursor.FindPositionConstraint constraint,
                                    com.google.common.base.Predicate<Entry> condition)
                             throws java.lang.InterruptedException,
                                    ManagedLedgerException
        Find the newest entry that matches the given predicate.
        Parameters:
        constraint - search only active entries or all entries
        condition - predicate that reads an entry an applies a condition
        Returns:
        Position of the newest entry that matches the given predicate
        Throws:
        java.lang.InterruptedException
        ManagedLedgerException
      • getNumberOfEntries

        long getNumberOfEntries​(com.google.common.collect.Range<PositionImpl> range)
        Return the number of messages that this cursor still has to read.

        This method has linear time complexity on the number of ledgers included in the managed ledger.

        Parameters:
        range - the range between two positions
        Returns:
        the number of entries in range
      • asyncClose

        void asyncClose​(AsyncCallbacks.CloseCallback callback,
                        java.lang.Object ctx)
        Close the cursor asynchronously and release the associated resources.
        Parameters:
        callback - callback object
        ctx - opaque context