Interface SegmentProgressContext
SegmentProgressStrategy uses to observe and persist the progress of the single Segment it
is bound to, provided to the strategy on
creation.
The context owns token persistence: a strategy decides which TrackingToken is safe and calls
persistProgress(TrackingToken, ProcessingContext), which performs the monotonic store and resets the
claim-extension deadline. The strategy never touches the
TokenStore directly. This keeps the
store decision (and the claim-extension timing coupled to it) behind the context, so a strategy carries only the
decision logic.
Internal API. This interface is marked Internal: it is the contract between a streaming processor and a
progress strategy, consumed by advanced (and out-of-module) strategies rather than by end users, and its shape may
change in a minor or patch release.
- Since:
- 5.3.0
- Author:
- Allard Buijze
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@Nullable TrackingTokenReturns the highestTrackingTokenhanded to the handler so far for this segment, ornullif nothing has been consumed yet.persistProgress(@Nullable TrackingToken candidate, ProcessingContext context) Persistscandidateas this segment's progress within the givencontext, keeping the storedTrackingTokenmonotonic.voidWakes the segment's worker so a commit cycle runs.segment()Returns theSegmentthis strategy is responsible for.
-
Method Details
-
segment
Segment segment()Returns theSegmentthis strategy is responsible for.- Returns:
- the segment this strategy is bound to
-
lastConsumedToken
@Nullable TrackingToken lastConsumedToken()Returns the highestTrackingTokenhanded to the handler so far for this segment, ornullif nothing has been consumed yet.This is the position a strategy treats as "safe up to here" when deciding what to persist.
- Returns:
- the last consumed token, or
nullif nothing has been consumed yet
-
scheduleWorker
void scheduleWorker()Wakes the segment's worker so a commit cycle runs. The lever a strategy uses to act on out-of-band work (such as an asynchronous checkpoint request) recorded between worker cycles; safe to call from any thread. -
persistProgress
CompletableFuture<Void> persistProgress(@Nullable TrackingToken candidate, ProcessingContext context) Persistscandidateas this segment's progress within the givencontext, keeping the storedTrackingTokenmonotonic. Anull, already-stored, or non-advancing token is ignored; a successful store also resets the claim-extension deadline. The store runs as part ofcontextso it commits atomically with the surrounding batch (or release) transaction.- Parameters:
candidate- the token the strategy decided is safe, ornullfor nothing to persistcontext- the processing context whose transaction the store participates in- Returns:
- a
CompletableFuturecompleting when the store (if any) has been applied
-