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 TypeMethodDescriptionboolean
canStopPolling
(Instant now, StateT state) Called by theWatch
transform to determine whether the given termination state signals thatWatch
should stop callingWatch.Growth.PollFn
for the current input, regardless of whether the lastWatch.Growth.PollResult
was complete or incomplete.forNewInput
(Instant now, @Nullable InputT input) Called by theWatch
transform to create a new independent termination state for a newly arrivedInputT
.Used to encode the state of thisWatch.Growth.TerminationCondition
.default StateT
onPollComplete
(StateT state) Called by theWatch
transform to compute a new termination state after every poll completion.default StateT
onSeenNewOutput
(Instant now, StateT state) Called by theWatch
transform to compute a new termination state, in case after calling theWatch.Growth.PollFn
for the current input, theWatch.Growth.PollResult
included 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 theWatch
transform to create a new independent termination state for a newly arrivedInputT
. -
onSeenNewOutput
Called by theWatch
transform to compute a new termination state, in case after calling theWatch.Growth.PollFn
for the current input, theWatch.Growth.PollResult
included a previously unseenOutputT
. -
onPollComplete
Called by theWatch
transform to compute a new termination state after every poll completion. -
canStopPolling
Called by theWatch
transform to determine whether the given termination state signals thatWatch
should stop callingWatch.Growth.PollFn
for the current input, regardless of whether the lastWatch.Growth.PollResult
was complete or incomplete. -
toString
Creates a human-readable representation of the given state of this condition.
-