public class ReplayToken extends Object implements TrackingToken, WrappedToken, Serializable
Constructor and Description |
---|
ReplayToken(TrackingToken tokenAtReset)
Initialize a ReplayToken, using the given
tokenAtReset to represent the position at which a reset was
triggered. |
ReplayToken(TrackingToken tokenAtReset,
TrackingToken newRedeliveryToken)
Initializes a ReplayToken with
tokenAtReset which represents the position at which a reset was triggered
and the newRedeliveryToken which represents current token. |
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. |
static TrackingToken |
createReplayToken(TrackingToken tokenAtReset)
Creates a new TrackingToken that represents the tail position of a stream, in reset state, when appropriate.
|
static TrackingToken |
createReplayToken(TrackingToken tokenAtReset,
TrackingToken startPosition)
Creates a new TrackingToken that represents the given
startPosition of a stream, in reset state,
when appropriate. |
boolean |
equals(Object o) |
TrackingToken |
getCurrentToken()
Gets the current token.
|
TrackingToken |
getTokenAtReset()
Gets the token representing the position at which the reset was triggered.
|
static OptionalLong |
getTokenAtReset(TrackingToken trackingToken)
Return the relative position at which a reset was triggered for this Segment.
|
int |
hashCode() |
static boolean |
isReplay(Message<?> message)
Indicates whether the given message is "redelivered", as a result of a previous reset.
|
static boolean |
isReplay(TrackingToken trackingToken)
Indicates whether the given
trackingToken represents a position that is part of a replay. |
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. |
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. |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
advance, unwrap, unwrapLowerBound, unwrapUpperBound
public ReplayToken(TrackingToken tokenAtReset)
tokenAtReset
to represent the position at which a reset was
triggered. The current token is reset to the initial position.
Using the createReplayToken(TrackingToken)
is preferred, as it covers cases where a replay is started
tokenAtReset
- The token representing the position at which the reset was triggered.@ConstructorProperties(value={"tokenAtReset","currentToken"}) public ReplayToken(TrackingToken tokenAtReset, TrackingToken newRedeliveryToken)
tokenAtReset
which represents the position at which a reset was triggered
and the newRedeliveryToken
which represents current token.tokenAtReset
- The token representing the position at which the reset was triggerednewRedeliveryToken
- The current tokenpublic static TrackingToken createReplayToken(TrackingToken tokenAtReset, TrackingToken startPosition)
startPosition
of a stream, in reset state,
when appropriate.tokenAtReset
- The token present when the reset was triggeredstartPosition
- The position where the token should be reset topublic static TrackingToken createReplayToken(TrackingToken tokenAtReset)
tokenAtReset
- The token present when the reset was triggeredpublic static boolean isReplay(Message<?> message)
true
, this
means this message has been delivered to this processor before its token was reset.message
- The message to inspecttrue
if the message is a replaypublic static boolean isReplay(TrackingToken trackingToken)
trackingToken
represents a position that is part of a replay.trackingToken
- The token to verifytrue
if the token indicates a replaypublic static OptionalLong getTokenAtReset(TrackingToken trackingToken)
OptionalLong.empty()
will be returned.public TrackingToken getTokenAtReset()
public TrackingToken getCurrentToken()
public TrackingToken advancedTo(TrackingToken newToken)
WrappedToken
newToken
.advancedTo
in interface WrappedToken
newToken
- The token representing the position to advance topublic 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 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 lowerBound()
WrappedToken
lowerBound
in interface WrappedToken
public TrackingToken upperBound()
WrappedToken
upperBound
in interface WrappedToken
public <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 OptionalLong position()
TrackingToken
OptionalLong.empty()
will be returned.position
in interface TrackingToken
Copyright © 2010–2022. All rights reserved.