Class ProcessingTimeoutTrigger<T,W extends Window>
- java.lang.Object
-
- org.apache.flink.streaming.api.windowing.triggers.Trigger<T,W>
-
- org.apache.flink.streaming.api.windowing.triggers.ProcessingTimeoutTrigger<T,W>
-
- Type Parameters:
T- The type of elements on which this trigger can operate.W- The type ofWindowon which this trigger can operate.
- All Implemented Interfaces:
Serializable
@PublicEvolving public class ProcessingTimeoutTrigger<T,W extends Window> extends Trigger<T,W>
ATriggerthat can turn anyTriggerinto a timeoutTrigger.On the first arriving element a configurable processing-time timeout will be set. Using
of(Trigger, Duration, boolean, boolean), you can also re-new the timer for each arriving element by specifyingresetTimerOnNewRecordand you can specify whetherTrigger.clear(Window, TriggerContext)should be called on timout viashouldClearOnTimeout.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.flink.streaming.api.windowing.triggers.Trigger
Trigger.OnMergeContext, Trigger.TriggerContext
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear(W window, Trigger.TriggerContext ctx)Clears any state that the trigger might still hold for the given window.static <T,W extends Window>
ProcessingTimeoutTrigger<T,W>of(Trigger<T,W> nestedTrigger, Duration timeout)Creates a newProcessingTimeoutTriggerthat fires when the inner trigger is fired or when the timeout timer fires.static <T,W extends Window>
ProcessingTimeoutTrigger<T,W>of(Trigger<T,W> nestedTrigger, Duration timeout, boolean resetTimerOnNewRecord, boolean shouldClearOnTimeout)Creates a newProcessingTimeoutTriggerthat fires when the inner trigger is fired or when the timeout timer fires.TriggerResultonElement(T element, long timestamp, W window, Trigger.TriggerContext ctx)Called for every element that gets added to a pane.TriggerResultonEventTime(long timestamp, W window, Trigger.TriggerContext ctx)Called when an event-time timer that was set using the trigger context fires.TriggerResultonProcessingTime(long timestamp, W window, Trigger.TriggerContext ctx)Called when a processing-time timer that was set using the trigger context fires.StringtoString()
-
-
-
Method Detail
-
onElement
public TriggerResult onElement(T element, long timestamp, W window, Trigger.TriggerContext ctx) throws Exception
Description copied from class:TriggerCalled for every element that gets added to a pane. The result of this will determine whether the pane is evaluated to emit results.- Specified by:
onElementin classTrigger<T,W extends Window>- Parameters:
element- The element that arrived.timestamp- The timestamp of the element that arrived.window- The window to which the element is being added.ctx- A context object that can be used to register timer callbacks.- Throws:
Exception
-
onProcessingTime
public TriggerResult onProcessingTime(long timestamp, W window, Trigger.TriggerContext ctx) throws Exception
Description copied from class:TriggerCalled when a processing-time timer that was set using the trigger context fires.
-
onEventTime
public TriggerResult onEventTime(long timestamp, W window, Trigger.TriggerContext ctx) throws Exception
Description copied from class:TriggerCalled when an event-time timer that was set using the trigger context fires.
-
clear
public void clear(W window, Trigger.TriggerContext ctx) throws Exception
Description copied from class:TriggerClears any state that the trigger might still hold for the given window. This is called when a window is purged. Timers set usingTrigger.TriggerContext.registerEventTimeTimer(long)andTrigger.TriggerContext.registerProcessingTimeTimer(long)should be deleted here as well as state acquired usingTrigger.TriggerContext.getPartitionedState(StateDescriptor).
-
of
public static <T,W extends Window> ProcessingTimeoutTrigger<T,W> of(Trigger<T,W> nestedTrigger, Duration timeout)
Creates a newProcessingTimeoutTriggerthat fires when the inner trigger is fired or when the timeout timer fires.For example:
ProcessingTimeoutTrigger.of(CountTrigger.of(3), 100), will create a CountTrigger with timeout of 100 millis. So, if the first record arrives at timet, and the second record arrives at timet+50, the trigger will fire when the third record arrives or when the time is {code t+100} (timeout).- Parameters:
nestedTrigger- the nestedTriggertimeout- the timeout interval- Returns:
ProcessingTimeoutTriggerwith the above configuration.
-
of
public static <T,W extends Window> ProcessingTimeoutTrigger<T,W> of(Trigger<T,W> nestedTrigger, Duration timeout, boolean resetTimerOnNewRecord, boolean shouldClearOnTimeout)
Creates a newProcessingTimeoutTriggerthat fires when the inner trigger is fired or when the timeout timer fires.For example:
ProcessingTimeoutTrigger.of(CountTrigger.of(3), 100, false, true), will create a CountTrigger with timeout of 100 millis. So, if the first record arrives at timet, and the second record arrives at timet+50, the trigger will fire when the third record arrives or when the time is {code t+100} (timeout).- Type Parameters:
T- The type of the element.W- The type ofWindowson which this trigger can operate.- Parameters:
nestedTrigger- the nestedTriggertimeout- the timeout intervalresetTimerOnNewRecord- each time a new element arrives, reset the timer and start a new oneshouldClearOnTimeout- whether to callTrigger.clear(Window, TriggerContext)when the processing-time timer fires- Returns:
ProcessingTimeoutTriggerwith the above configuration.
-
-