Package org.apache.bookkeeper.mledger
Interface ReadOnlyCursor
-
- All Known Implementing Classes:
ReadOnlyCursorImpl
@LimitedPrivate @Stable public interface ReadOnlyCursor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidasyncClose(AsyncCallbacks.CloseCallback callback, java.lang.Object ctx)Close the cursor asynchronously and release the associated resources.voidasyncReadEntries(int numberOfEntriesToRead, long maxSizeBytes, AsyncCallbacks.ReadEntriesCallback callback, java.lang.Object ctx, PositionImpl maxPosition)Asynchronously read entries from the ManagedLedger.voidasyncReadEntries(int numberOfEntriesToRead, AsyncCallbacks.ReadEntriesCallback callback, java.lang.Object ctx, PositionImpl maxPosition)Asynchronously read entries from the ManagedLedger.voidclose()Close the cursor and releases the associated resources.PositionfindNewestMatching(ManagedCursor.FindPositionConstraint constraint, com.google.common.base.Predicate<Entry> condition)Find the newest entry that matches the given predicate.longgetNumberOfEntries()Return the number of messages that this cursor still has to read.longgetNumberOfEntries(com.google.common.collect.Range<PositionImpl> range)Return the number of messages that this cursor still has to read.PositiongetReadPosition()Get the read position.booleanhasMoreEntries()Tells whether this cursor has already consumed all the available entries.java.util.List<Entry>readEntries(int numberOfEntriesToRead)Read entries from the ManagedLedger, up to the specified number.voidskipEntries(int numEntriesToSkip)Skip n entries from the read position of this cursor.
-
-
-
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:
ManagedLedgerExceptionjava.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 returncallback- callback objectctx- opaque contextmaxPosition- 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 returnmaxSizeBytes- max size in bytes of the entries to returncallback- callback objectctx- opaque contextmaxPosition- 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 entriescondition- predicate that reads an entry an applies a condition- Returns:
- Position of the newest entry that matches the given predicate
- Throws:
java.lang.InterruptedExceptionManagedLedgerException
-
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
void close() throws java.lang.InterruptedException, ManagedLedgerExceptionClose the cursor and releases the associated resources.- Throws:
java.lang.InterruptedExceptionManagedLedgerException
-
asyncClose
void asyncClose(AsyncCallbacks.CloseCallback callback, java.lang.Object ctx)
Close the cursor asynchronously and release the associated resources.- Parameters:
callback- callback objectctx- opaque context
-
-