java.lang.Object
org.axonframework.messaging.eventhandling.processing.streaming.segmenting.TrackerStatus
All Implemented Interfaces:
EventTrackerStatus

public final class TrackerStatus extends Object implements EventTrackerStatus
Implementation of the EventTrackerStatus, providing simply modification methods to switch from one EventTrackerStatus value object to another.
Since:
3.0
Author:
Allard Buijze
  • Constructor Details

  • Method Details

    • caughtUp

      public TrackerStatus caughtUp()
      Returns this TrackerStatus if it is caught up, otherwise return a new instance with the caught up flag set to true.
      Returns:
      this TrackerStatus if it is caught up, otherwise return a new instance with the caught up flag set to true
    • advancedTo

      public TrackerStatus advancedTo(TrackingToken trackingToken)
      Advance this 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.
      Parameters:
      trackingToken - the TrackingToken to advance this TrackerStatus' token towards, if they are not the same
      Returns:
      this TrackerStatus if the given trackingToken is identical to the current one, otherwise a new TrackerStatus instance with the given trackingToken
    • markError

      public TrackerStatus markError(Throwable error)
      Return a new TrackerStatus based on this status, setting the given error as the errorState.
      Parameters:
      error - the Throwable used to define the errorState
      Returns:
      a new TrackerStatus based on this status, setting the given error as the errorState
    • unmarkError

      public TrackerStatus unmarkError()
      Return a new TrackerStatus based on this status, removing the errorState.
      Returns:
      a new TrackerStatus based on this status, removing the errorState
    • getInternalTrackingToken

      public TrackingToken getInternalTrackingToken()
      Return the TrackingToken this EventTrackerStatus portrays the status of.
      Returns:
      the TrackingToken this EventTrackerStatus portrays the status of
    • split

      public TrackerStatus[] split()
      Splits the current status object to reflect the status of their underlying segments being split.
      Returns:
      an array with two status objects, representing the status of the split segments
    • split

      public static TrackerStatus[] split(Segment segment, TrackingToken trackingToken)
      Split the given segment and trackingToken in two. Constructs an array containing two TrackerStatuss objects based on the split.
      Parameters:
      segment - the Segment to split in two
      trackingToken - the TrackingToken to split in two
      Returns:
      an array of two TrackerStatuss objects based on the split of the given segment and trackingToken
    • getSegment

      public Segment getSegment()
      Description copied from interface: EventTrackerStatus
      The segment for which this status is valid.
      Specified by:
      getSegment in interface EventTrackerStatus
      Returns:
      segment for which this status is valid
    • isCaughtUp

      public boolean isCaughtUp()
      Description copied from interface: EventTrackerStatus
      Whether the Segment of this status has caught up with the head of the event stream. Note that this is no guarantee that this segment is still processing at (or near) real-time events. It merely indicates that this segment has been at the head of the stream since it started processing. It may have fallen back since then.
      Specified by:
      isCaughtUp in interface EventTrackerStatus
      Returns:
      whether the Segment of this status has caught up with the head of the event stream
    • isReplaying

      public boolean isReplaying()
      Description copied from interface: EventTrackerStatus
      Indicates whether this Segment is still replaying previously processed Events.

      Note that this method will only recognize a replay if the tokens have been reset using StreamingEventProcessor.resetTokens(). Removing tokens directly from the underlying TokenStore will not be recognized as a replay.

      Specified by:
      isReplaying in interface EventTrackerStatus
      Returns:
      true if this segment is replaying historic events after a reset, otherwise false
    • isMerging

      public boolean isMerging()
      Description copied from interface: EventTrackerStatus
      Indicates whether this Segment is still merging two (or more) Segments. The merging process will be done once all Segments have reached the same position.
      Specified by:
      isMerging in interface EventTrackerStatus
      Returns:
      true if this segment is merging Segments, otherwise false
    • mergeCompletedPosition

      public OptionalLong mergeCompletedPosition()
      Description copied from interface: EventTrackerStatus
      Return the estimated relative token position this Segment will have after a merge operation is complete. Will return a non-empty result as long as EventTrackerStatus.isMerging() } returns true. In case no estimation can be given or no merge in progress, an OptionalLong.empty() will be returned.
      Specified by:
      mergeCompletedPosition in interface EventTrackerStatus
      Returns:
      return the estimated relative position this Segment will reach after a merge operation is complete.
    • getTrackingToken

      public TrackingToken getTrackingToken()
      Description copied from interface: EventTrackerStatus
      The tracking token of the last event that has been seen by this Segment.

      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.

      Specified by:
      getTrackingToken in interface EventTrackerStatus
      Returns:
      tracking token of the last event that has been seen by this Segment
    • isErrorState

      public boolean isErrorState()
      Description copied from interface: EventTrackerStatus
      Indicates whether this status represents an error. When this method return true, the EventTrackerStatus.getError() will return the exception that caused the failure.
      Specified by:
      isErrorState in interface EventTrackerStatus
      Returns:
      true if an error was reported, otherwise false
    • getError

      public Throwable getError()
      Description copied from interface: EventTrackerStatus
      Returns the exception that caused processing to fail, if present. If the segment is being processed normally, this method returns null.
      Specified by:
      getError in interface EventTrackerStatus
      Returns:
      the exception that caused processing to fail, or null when processing normally
    • getCurrentPosition

      public OptionalLong getCurrentPosition()
      Description copied from interface: EventTrackerStatus
      Return the estimated relative current token position this Segment represents. In case of replay is active, return the estimated relative position reached by merge operation. In case of merge is active, return the estimated relative position reached by merge operation. In case no estimation can be given, or no replay or merge in progress, an OptionalLong.empty() will be returned.
      Specified by:
      getCurrentPosition in interface EventTrackerStatus
      Returns:
      return the estimated relative current token position this Segment represents
    • getResetPosition

      public OptionalLong getResetPosition()
      Description copied from interface: EventTrackerStatus
      Return the relative position at which a reset was triggered for this Segment. In case a replay finished or no replay is active, an OptionalLong.empty() will be returned.
      Specified by:
      getResetPosition in interface EventTrackerStatus
      Returns:
      the relative position at which a reset was triggered for this Segment
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object