类 ManagedCursorContainer
java.lang.Object
org.apache.bookkeeper.mledger.impl.ManagedCursorContainer
- 所有已实现的接口:
Iterable<ManagedCursor>
Contains 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 heap and a map of cursors. The map is used to relate a cursor name with
an entry index in the heap. The heap data structure sorts cursors in a binary tree which is represented
in a single array. More details about heap implementations:
https://en.wikipedia.org/wiki/Heap_(data_structure)#Implementation
The heap is updated and kept sorted when a cursor is updated.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidadd(ManagedCursor cursor, Position position) Add a cursor to the container.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 heap tracking the slowest reader.Get the slowest reader position for the cursors that are ordered.booleanCheck whether that are any durable cursors.booleanisEmpty()Check whether there are any cursors.iterator()booleanremoveCursor(String name) toString()从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 java.lang.Iterable
forEach, spliterator
-
构造器详细资料
-
ManagedCursorContainer
public ManagedCursorContainer()
-
-
方法详细资料
-
add
Add a cursor to the container. The cursor will be optionally tracked for the slowest reader when a position is passed as the second argument. It is expected that the position is updated withcursorUpdated(ManagedCursor, Position)method when the position changes.- 参数:
cursor- cursor to addposition- position of the cursor to use for ordering, pass null if the cursor's position shouldn't be tracked for the slowest reader.
-
get
-
removeCursor
-
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 heap tracking the slowest reader. Only those cursors are tracked and can be updated which were added to the container with theadd(ManagedCursor, Position)method that specified the initial position in the position parameter.- 参数:
cursor- the cursor to update the position fornewPosition- the updated position for the cursor- 返回:
- a pair of positions, representing the previous slowest reader and the new slowest reader (after the update).
-
getSlowestReaderPosition
Get the slowest reader position for the cursors that are ordered.- 返回:
- the slowest reader position
-
getSlowestReader
-
isEmpty
public boolean isEmpty()Check whether there are any cursors.- 返回:
- true is there are no cursors and false if there are
-
hasDurableCursors
public boolean hasDurableCursors()Check whether that are any durable cursors.- 返回:
- true if there are durable cursors and false if there are not
-
toString
-
iterator
- 指定者:
iterator在接口中Iterable<ManagedCursor>
-