public class GlobalSequenceTrackingToken extends Object implements TrackingToken, Comparable<GlobalSequenceTrackingToken>, Serializable
Constructor and Description |
---|
GlobalSequenceTrackingToken(long globalIndex)
Initializes a
GlobalSequenceTrackingToken from the given globalIndex of the event. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(GlobalSequenceTrackingToken o) |
boolean |
covers(TrackingToken other)
Indicates whether this token covers the
other token completely. |
boolean |
equals(Object o) |
long |
getGlobalIndex()
Get the global sequence number of the event
|
int |
hashCode() |
TrackingToken |
lowerBound(TrackingToken other)
Returns a token that represents the lower bound between this and the
other token. |
GlobalSequenceTrackingToken |
next()
Returns a new
GlobalSequenceTrackingToken instance with sequence number incremented by 1. |
GlobalSequenceTrackingToken |
offsetBy(int offset)
Returns a new
GlobalSequenceTrackingToken instance that is the sum of this token's sequence number and
the given offset . |
OptionalLong |
position()
Return the estimated relative position this token represents.
|
String |
toString() |
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. |
@ConstructorProperties(value="globalIndex") public GlobalSequenceTrackingToken(long globalIndex)
GlobalSequenceTrackingToken
from the given globalIndex
of the event.globalIndex
- the global sequence number of the eventpublic long getGlobalIndex()
public GlobalSequenceTrackingToken offsetBy(int offset)
GlobalSequenceTrackingToken
instance that is the sum of this token's sequence number and
the given offset
.offset
- the offset between this token's sequence number of that of the returned instancepublic GlobalSequenceTrackingToken next()
GlobalSequenceTrackingToken
instance with sequence number incremented by 1.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 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 int compareTo(GlobalSequenceTrackingToken o)
compareTo
in interface Comparable<GlobalSequenceTrackingToken>
public OptionalLong position()
TrackingToken
OptionalLong.empty()
will be returned.position
in interface TrackingToken
Copyright © 2010–2023. All rights reserved.