Interface Watch.Growth.TerminationCondition<InputT,StateT>
- All Superinterfaces:
Serializable
- Enclosing class:
Watch.Growth<InputT,OutputT, KeyT>
Some built-in termination conditions are Watch.Growth.never(), Watch.Growth.afterTotalOf(org.joda.time.ReadableDuration) and Watch.Growth.afterTimeSinceNewOutput(org.joda.time.ReadableDuration). Conditions can be combined using Watch.Growth.eitherOf(org.apache.beam.sdk.transforms.Watch.Growth.TerminationCondition<InputT, FirstStateT>, org.apache.beam.sdk.transforms.Watch.Growth.TerminationCondition<InputT, SecondStateT>) and Watch.Growth.allOf(org.apache.beam.sdk.transforms.Watch.Growth.TerminationCondition<InputT, FirstStateT>, org.apache.beam.sdk.transforms.Watch.Growth.TerminationCondition<InputT, SecondStateT>). Users can also develop custom termination conditions, for example, one might imagine
a condition that terminates after a given time after the first output appears for the input
(unlike Watch.Growth.afterTotalOf(org.joda.time.ReadableDuration) which operates relative to when the input itself arrives).
A Watch.Growth.TerminationCondition is provided to Watch.Growth.withTerminationPerInput(TerminationCondition) and is used to maintain an independent
state of the termination condition for every input, represented as StateT which must
be immutable, non-null, and encodable via getStateCoder().
All functions take the wall-clock timestamp as Instant for convenience of
unit-testing custom termination conditions.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanStopPolling(Instant now, StateT state) Called by theWatchtransform to determine whether the given termination state signals thatWatchshould stop callingWatch.Growth.PollFnfor the current input, regardless of whether the lastWatch.Growth.PollResultwas complete or incomplete.forNewInput(Instant now, @Nullable InputT input) Called by theWatchtransform to create a new independent termination state for a newly arrivedInputT.Used to encode the state of thisWatch.Growth.TerminationCondition.default StateTonPollComplete(StateT state) Called by theWatchtransform to compute a new termination state after every poll completion.default StateTonSeenNewOutput(Instant now, StateT state) Called by theWatchtransform to compute a new termination state, in case after calling theWatch.Growth.PollFnfor the current input, theWatch.Growth.PollResultincluded a previously unseenOutputT.Creates a human-readable representation of the given state of this condition.
-
Method Details
-
getStateCoder
Used to encode the state of thisWatch.Growth.TerminationCondition. -
forNewInput
Called by theWatchtransform to create a new independent termination state for a newly arrivedInputT. -
onSeenNewOutput
Called by theWatchtransform to compute a new termination state, in case after calling theWatch.Growth.PollFnfor the current input, theWatch.Growth.PollResultincluded a previously unseenOutputT. -
onPollComplete
Called by theWatchtransform to compute a new termination state after every poll completion. -
canStopPolling
Called by theWatchtransform to determine whether the given termination state signals thatWatchshould stop callingWatch.Growth.PollFnfor the current input, regardless of whether the lastWatch.Growth.PollResultwas complete or incomplete. -
toString
Creates a human-readable representation of the given state of this condition.
-