Class Position
java.lang.Object
io.fluxzero.common.api.tracking.Position
Represents the tracking state of a consumer, i.e. the last known indexes of consumed messages per segment.
Fluxzero segments the message log to support parallel consumption. A Position stores
the most recent message index processed for each segment. This allows precise resumption of message
consumption on restarts or rebalances.
A Position is an immutable structure and may be merged or queried to support multi-segment tracking.
-
Constructor Summary
ConstructorsConstructorDescriptionPosition(int[] segment, long lastIndex) Creates a position for a single segment range.Position(long index) Creates a position that applies the same index to all segments.Position(SegmentRange segmentRange) Creates a position for a single segment range.Position(List<SegmentRange> segmentRanges) Creates a position from a list of segment ranges. -
Method Summary
Modifier and TypeMethodDescriptiongetIndex(int segment) Returns the last known index for a specific segment.booleanisNew(int[] segment) Indicates whether no index has been tracked yet for any segment in the given range.booleanisNewIndex(int segment, Long messageIndex) Indicates whether the provided message index is newer than what is currently tracked for a segment.booleanisNewMessage(SerializedMessage message) Indicates whether the message index is newer than what is currently tracked for its segment.lowestIndexForSegment(int[] segment) Returns the lowest tracked index within the given segment range.Merges twoPositionobjects by taking the highest known index per segment.static PositionCreates an empty position.
-
Constructor Details
-
Position
Creates a position from a list of segment ranges.- Parameters:
segmentRanges- a list of segment ranges, this list is expected to be sorted by segment start, segments are expected to not overlap.
-
Position
public Position(long index) Creates a position that applies the same index to all segments. -
Position
public Position(int[] segment, long lastIndex) Creates a position for a single segment range. -
Position
Creates a position for a single segment range.
-
-
Method Details
-
newPosition
Creates an empty position. -
getIndex
-
isNew
public boolean isNew(int[] segment) Indicates whether no index has been tracked yet for any segment in the given range. -
lowestIndexForSegment
-
isNewMessage
Indicates whether the message index is newer than what is currently tracked for its segment. -
isNewIndex
Indicates whether the provided message index is newer than what is currently tracked for a segment. -
merge
-