public static interface Watch.Growth.TerminationCondition<InputT,StateT>
extends java.io.Serializable
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.
Modifier and Type | Method and Description |
---|---|
boolean |
canStopPolling(Instant now,
StateT state)
Called by the
Watch transform to determine whether the given termination state
signals that Watch should stop calling Watch.Growth.PollFn for the current input,
regardless of whether the last Watch.Growth.PollResult was complete or incomplete. |
StateT |
forNewInput(Instant now,
InputT input)
Called by the
Watch transform to create a new independent termination state for a
newly arrived InputT . |
Coder<StateT> |
getStateCoder()
Used to encode the state of this
Watch.Growth.TerminationCondition . |
StateT |
onSeenNewOutput(Instant now,
StateT state)
Called by the
Watch transform to compute a new termination state, in case after
calling the Watch.Growth.PollFn for the current input, the Watch.Growth.PollResult included a
previously unseen OutputT . |
java.lang.String |
toString(StateT state)
Creates a human-readable representation of the given state of this condition.
|
Coder<StateT> getStateCoder()
Watch.Growth.TerminationCondition
.StateT forNewInput(Instant now, InputT input)
Watch
transform to create a new independent termination state for a
newly arrived InputT
.StateT onSeenNewOutput(Instant now, StateT state)
Watch
transform to compute a new termination state, in case after
calling the Watch.Growth.PollFn
for the current input, the Watch.Growth.PollResult
included a
previously unseen OutputT
.boolean canStopPolling(Instant now, StateT state)
Watch
transform to determine whether the given termination state
signals that Watch
should stop calling Watch.Growth.PollFn
for the current input,
regardless of whether the last Watch.Growth.PollResult
was complete or incomplete.java.lang.String toString(StateT state)