public final class TrackerStatus extends Object implements EventTrackerStatus
EventTrackerStatus
, providing simply modification methods to switch from one EventTrackerStatus
value object to another.Constructor and Description |
---|
TrackerStatus(Segment segment,
boolean caughtUp,
TrackingToken trackingToken,
Throwable errorState)
|
TrackerStatus(Segment segment,
TrackingToken trackingToken)
|
Modifier and Type | Method and Description |
---|---|
TrackerStatus |
advancedTo(TrackingToken trackingToken)
|
TrackerStatus |
caughtUp()
Returns this
TrackerStatus if it is caught up, otherwise return a new instance with the caught up flag
set to true. |
boolean |
equals(Object o) |
OptionalLong |
getCurrentPosition()
Return the estimated relative current token position this Segment represents.
|
Throwable |
getError()
Returns the exception that caused processing to fail, if present.
|
TrackingToken |
getInternalTrackingToken()
Return the
TrackingToken this EventTrackerStatus portrays the status of. |
OptionalLong |
getResetPosition()
Return the relative position at which a reset was triggered for this Segment.
|
Segment |
getSegment()
The segment for which this status is valid.
|
TrackingToken |
getTrackingToken()
The tracking token of the last event that has been seen by this Segment.
|
int |
hashCode() |
boolean |
isCaughtUp()
Whether the Segment of this status has caught up with the head of the event stream.
|
boolean |
isErrorState()
Indicates whether this status represents an error.
|
boolean |
isMerging()
Indicates whether this Segment is still merging two (or more) Segments.
|
boolean |
isReplaying()
Indicates whether this Segment is still replaying previously processed Events.
|
TrackerStatus |
markError(Throwable error)
|
OptionalLong |
mergeCompletedPosition()
Return the estimated relative token position this Segment will have after a merge operation is complete.
|
TrackerStatus[] |
split()
Splits the current status object to reflect the status of their underlying segments being split.
|
static TrackerStatus[] |
split(Segment segment,
TrackingToken trackingToken)
Split the given
segment and trackingToken in two. |
String |
toString() |
TrackerStatus |
unmarkError()
Return a new
TrackerStatus based on this status, removing the errorState . |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isDifferent, isDifferent, matchPositions, matchStates, trackerAdded, trackerRemoved
public TrackerStatus(Segment segment, TrackingToken trackingToken)
segment
- the Segment
this EventTrackerStatus
shares the status oftrackingToken
- the TrackingToken
this EventTrackerStatus
shares the status ofpublic TrackerStatus(Segment segment, boolean caughtUp, TrackingToken trackingToken, Throwable errorState)
EventTrackerStatus
to portray the status of the given segment
and trackingToken
. The caughtUp boolean
specifies whether the trackingToken
reached the head of the
stream at least once. A Throwable
can be provided to signal this EventTrackerStatus
is in an
error statesegment
- the Segment
this EventTrackerStatus
shares the status ofcaughtUp
- a boolean
specifying whether this EventTrackerStatus
reached the head of the
stream at least once.trackingToken
- the TrackingToken
this EventTrackerStatus
shares the status oferrorState
- a Throwable
defining the error status of this EventTrackerStatus
. If null
, the status is not in an error statepublic TrackerStatus caughtUp()
TrackerStatus
if it is caught up, otherwise return a new instance with the caught up flag
set to true.TrackerStatus
if it is caught up, otherwise return a new instance with the caught up flag
set to truepublic TrackerStatus advancedTo(TrackingToken trackingToken)
TrackerStatus
' TrackingToken
towards the given trackingToken
. If this
status' token is identical to the given token, return this
. Otherwise create a new TrackerStatus
instance using the given trackingToken
.trackingToken
- the TrackingToken
to advance this TrackerStatus
' token towards, if they are
not the sameTrackerStatus
if the given trackingToken
is identical to the current one, otherwise
a new TrackerStatus
instance with the given trackingToken
public TrackerStatus markError(Throwable error)
error
- the Throwable
used to define the errorState
TrackerStatus
based on this status, setting the given error
as the errorState
public TrackerStatus unmarkError()
TrackerStatus
based on this status, removing the errorState
.TrackerStatus
based on this status, removing the errorState
public TrackingToken getInternalTrackingToken()
TrackingToken
this EventTrackerStatus
portrays the status of.TrackingToken
this EventTrackerStatus
portrays the status ofpublic TrackerStatus[] split()
public static TrackerStatus[] split(Segment segment, TrackingToken trackingToken)
segment
and trackingToken
in two. Constructs an array containing two TrackerStatus
s objects based on the split.segment
- the Segment
to split in twotrackingToken
- the TrackingToken
to split in twoTrackerStatus
s objects based on the split of the given segment
and trackingToken
public Segment getSegment()
EventTrackerStatus
getSegment
in interface EventTrackerStatus
public boolean isCaughtUp()
EventTrackerStatus
isCaughtUp
in interface EventTrackerStatus
public boolean isReplaying()
EventTrackerStatus
Note that this method will only recognize a replay if the tokens have been reset using TrackingEventProcessor.resetTokens()
. Removing tokens directly from the underlying TokenStore
will not
be recognized as a replay.
isReplaying
in interface EventTrackerStatus
true
if this segment is replaying historic events after a reset
, otherwise false
public boolean isMerging()
EventTrackerStatus
isMerging
in interface EventTrackerStatus
true
if this segment is merging Segments, otherwise false
public OptionalLong mergeCompletedPosition()
EventTrackerStatus
EventTrackerStatus.isMerging()
} returns true. In case no estimation
can be given or no merge in progress, an OptionalLong.empty()
will be returned.mergeCompletedPosition
in interface EventTrackerStatus
public TrackingToken getTrackingToken()
EventTrackerStatus
The returned tracking token represents the position of this segment in the event stream. In case of a recent merge of segments, the token represents the lowest position of the two merged segments.
getTrackingToken
in interface EventTrackerStatus
public boolean isErrorState()
EventTrackerStatus
true
, the EventTrackerStatus.getError()
will return the exception that caused the failure.isErrorState
in interface EventTrackerStatus
true
if an error was reported, otherwise false
public Throwable getError()
EventTrackerStatus
null
.getError
in interface EventTrackerStatus
null
when processing normallypublic OptionalLong getCurrentPosition()
EventTrackerStatus
OptionalLong.empty()
will be returned.getCurrentPosition
in interface EventTrackerStatus
public OptionalLong getResetPosition()
EventTrackerStatus
OptionalLong.empty()
will be returned.getResetPosition
in interface EventTrackerStatus
Copyright © 2010–2024. All rights reserved.