public class MergedTrackingToken extends Object implements TrackingToken, Serializable, WrappedToken
Modifier | Constructor and Description |
---|---|
|
MergedTrackingToken(TrackingToken lowerSegmentToken,
TrackingToken upperSegmentToken)
Initialize a Merged Token, with the
lowerSegmentToken representing the progress of the segment with the
lower segmentId, and upperSegmentToken representing the progress of the segment with the higher
segmentId. |
protected |
MergedTrackingToken(TrackingToken lowerSegmentToken,
TrackingToken upperSegmentToken,
boolean lowerSegmentAdvanced,
boolean upperSegmentAdvanced)
Initialize a Merged Token, with the
lowerSegmentToken representing the progress of the segment with the
lower segmentId, and upperSegmentToken representing the progress of the segment with the higher
segmentId, additionally indicating if either of these segments were advanced by the latest call to advancedTo(TrackingToken) |
Modifier and Type | Method and Description |
---|---|
TrackingToken |
advancedTo(TrackingToken newToken)
Advance this token to the given
newToken . |
boolean |
covers(TrackingToken other)
Indicates whether this token covers the
other token completely. |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isLowerSegmentAdvanced()
Indicates whether the last call to
advancedTo(TrackingToken) caused the lower segment to advance |
static boolean |
isMergeInProgress(TrackingToken trackingToken)
Indicates whether the given
trackingToken represents a token that is part of a merge. |
boolean |
isUpperSegmentAdvanced()
Indicates whether the last call to
advancedTo(TrackingToken) caused the upper segment to advance |
TrackingToken |
lowerBound()
Returns the token representing the current position in the stream.
|
TrackingToken |
lowerBound(TrackingToken other)
Returns a token that represents the lower bound between this and the
other token. |
TrackingToken |
lowerSegmentToken()
Returns the token indicating the progress of the lower half (the half with the lower segmentId) of the merged
segment represented by this token
|
static TrackingToken |
merged(TrackingToken lowerSegmentToken,
TrackingToken upperSegmentToken)
Create a merged token using the given
lowerSegmentToken and upperSegmentToken . |
static OptionalLong |
mergePosition(TrackingToken trackingToken)
Return the estimated relative token position this Segment will have after a merge operation is complete.
|
OptionalLong |
position()
Return the estimated relative position this token represents.
|
String |
toString() |
<R extends TrackingToken> |
unwrap(Class<R> tokenType)
Retrieve a token of given
tokenType if it is wrapped by this token. |
TrackingToken |
upperBound()
Returns the token representing the furthest position in the stream described by this token.
|
TrackingToken |
upperBound(TrackingToken other)
Returns the token that represents the furthest possible position in a stream that either this token or the given
other represents. |
TrackingToken |
upperSegmentToken()
Returns the token indicating the progress of the upper half (the half with the higher segmentId) of the merged
segment represented by this token
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
advance, unwrap, unwrapLowerBound, unwrapUpperBound
@ConstructorProperties(value={"lowerSegmentToken","upperSegmentToken"}) public MergedTrackingToken(TrackingToken lowerSegmentToken, TrackingToken upperSegmentToken)
lowerSegmentToken
representing the progress of the segment with the
lower segmentId, and upperSegmentToken
representing the progress of the segment with the higher
segmentId.lowerSegmentToken
- the token of the half with the lower segment IDupperSegmentToken
- the token of the half with the higher segment IDprotected MergedTrackingToken(TrackingToken lowerSegmentToken, TrackingToken upperSegmentToken, boolean lowerSegmentAdvanced, boolean upperSegmentAdvanced)
lowerSegmentToken
representing the progress of the segment with the
lower segmentId, and upperSegmentToken
representing the progress of the segment with the higher
segmentId, additionally indicating if either of these segments were advanced by the latest call to advancedTo(TrackingToken)
lowerSegmentToken
- the token of the half with the lower segment IDupperSegmentToken
- the token of the half with the higher segment IDlowerSegmentAdvanced
- whether the lower segment advanced in the last callupperSegmentAdvanced
- whether the upper segment advanced in the last callpublic static TrackingToken merged(TrackingToken lowerSegmentToken, TrackingToken upperSegmentToken)
lowerSegmentToken
and upperSegmentToken
.lowerSegmentToken
- the token of the half with the lower segment IDupperSegmentToken
- the token of the half with the higher segment IDpublic static boolean isMergeInProgress(TrackingToken trackingToken)
trackingToken
represents a token that is part of a merge.trackingToken
- the token to verifytrue
if the token indicates a mergepublic static OptionalLong mergePosition(TrackingToken trackingToken)
OptionalLong.empty()
will be returned.public TrackingToken lowerBound(TrackingToken other)
TrackingToken
other
token. Effectively, the
returned token will cause messages not received by both this and the other
token to be redelivered.lowerBound
in interface TrackingToken
other
- The token to compare to this onepublic OptionalLong position()
TrackingToken
OptionalLong.empty()
will be returned.position
in interface TrackingToken
public TrackingToken upperBound(TrackingToken other)
TrackingToken
other
represents. Effectively, this means this token will only deliver messages that neither this, nor
the other have been received.upperBound
in interface TrackingToken
other
- The token to compare this token topublic boolean covers(TrackingToken other)
TrackingToken
other
token completely. That means that this token represents a
position in a stream that has received all of the messages that a stream represented by the other
token
has received.
Note that this operation is only safe when comparing tokens obtained from messages from the same
StreamableMessageSource
.
covers
in interface TrackingToken
other
- The token to compare to this onetrue
if this token covers the other, otherwise false
public TrackingToken advancedTo(TrackingToken newToken)
WrappedToken
newToken
.advancedTo
in interface WrappedToken
newToken
- The token representing the position to advance topublic <R extends TrackingToken> Optional<R> unwrap(Class<R> tokenType)
WrappedToken
tokenType
if it is wrapped by this token.unwrap
in interface WrappedToken
R
- The generic type of the token to unwrap totokenType
- The type of token to unwrap topublic TrackingToken lowerBound()
WrappedToken
lowerBound
in interface WrappedToken
public TrackingToken upperBound()
WrappedToken
upperBound
in interface WrappedToken
public TrackingToken lowerSegmentToken()
public TrackingToken upperSegmentToken()
public boolean isLowerSegmentAdvanced()
advancedTo(TrackingToken)
caused the lower segment to advancepublic boolean isUpperSegmentAdvanced()
advancedTo(TrackingToken)
caused the upper segment to advanceCopyright © 2010–2022. All rights reserved.