Interface ReadOnlyCursor

All Known Implementing Classes:
ReadOnlyCursorImpl

@LimitedPrivate @Stable public interface ReadOnlyCursor
  • Method Details

    • readEntries

      List<Entry> readEntries(int numberOfEntriesToRead) throws 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
      InterruptedException
    • asyncReadEntries

      void asyncReadEntries(int numberOfEntriesToRead, AsyncCallbacks.ReadEntriesCallback callback, 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:
    • asyncReadEntries

      void asyncReadEntries(int numberOfEntriesToRead, long maxSizeBytes, AsyncCallbacks.ReadEntriesCallback callback, 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

      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:
      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
    • close

      Close the cursor and releases the associated resources.
      Throws:
      InterruptedException
      ManagedLedgerException
    • asyncClose

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