public class GapAwareTrackingToken extends Object implements TrackingToken, Serializable
TrackingToken
that uses the global insertion sequence number of the event to determine
tracking order and additionally stores a set of possible gaps that have been detected while tracking the event
store.
By storing the sequence numbers of gaps, i.e. sequence numbers of events that may have been inserted but have not been committed to the store, consumers are able to track the event store uninterruptedly even when there are gaps in the sequence numbers of events. If a gap is detected the event store can check if meanwhile this gap has been filled each time a new batch of events is fetched.
Modifier and Type | Method and Description |
---|---|
GapAwareTrackingToken |
advanceTo(long index,
int maxGapOffset)
Deprecated.
Use
advanceTo(long, int, boolean) instead |
GapAwareTrackingToken |
advanceTo(long index,
int maxGapOffset,
boolean allowGaps)
Returns a new
GapAwareTrackingToken instance based on this token but which has advanced to given index . |
boolean |
equals(Object o) |
SortedSet<Long> |
getGaps()
Get a
SortedSet of this token's gaps. |
long |
getIndex()
Get the highest global sequence of events seen up until the point of this tracking token.
|
boolean |
hasGaps()
Check if this token contains one ore more gaps.
|
int |
hashCode() |
static GapAwareTrackingToken |
newInstance(long index,
Collection<Long> gaps)
|
String |
toString() |
public static GapAwareTrackingToken newInstance(long index, Collection<Long> gaps)
index
- the highest global sequence number of events up until (and including) this tracking tokengaps
- global sequence numbers of events that have not been seen yet even though these sequence numbers are
smaller than the current index. These missing sequence numbers may be filled in later when those
events get committed to the store or may never be filled in if those events never get committed.@Deprecated public GapAwareTrackingToken advanceTo(long index, int maxGapOffset)
advanceTo(long, int, boolean)
insteadGapAwareTrackingToken
instance based on this token but which has advanced to given index
. Gaps that have fallen behind the index by more than the maxGapOffset
will not be included in the
new token.
Note that the given index
should be one of the current token's gaps or be higher than the current token's
index.
index
- the global sequence number of the next eventmaxGapOffset
- the maximum distance between a gap and the token's indexpublic GapAwareTrackingToken advanceTo(long index, int maxGapOffset, boolean allowGaps)
GapAwareTrackingToken
instance based on this token but which has advanced to given index
. Gaps that have fallen behind the index by more than the maxGapOffset
will not be included in the
new token.
Note that the given index
should be one of the current token's gaps or be higher than the current token's
index.
If allowGaps
is set to false
, any gaps that occur before the given index
are removed
from the returned token.
index
- the global sequence number of the next eventmaxGapOffset
- the maximum distance between a gap and the token's indexallowGaps
- whether advancing to the given index should take into account that gaps may have appearedpublic long getIndex()
public SortedSet<Long> getGaps()
SortedSet
of this token's gaps.public boolean hasGaps()
true
if this token contains gaps, false
otherwiseCopyright © 2010–2017. All rights reserved.