Class ProcessingTimeoutTrigger<T,W extends org.apache.flink.streaming.api.windowing.windows.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,org.apache.flink.streaming.runtime.operators.windowing.AsyncTriggerConverter
@PublicEvolving public class ProcessingTimeoutTrigger<T,W extends org.apache.flink.streaming.api.windowing.windows.Window> extends org.apache.flink.streaming.api.windowing.triggers.Trigger<T,W> implements org.apache.flink.streaming.runtime.operators.windowing.AsyncTriggerConverterATriggerthat 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
org.apache.flink.streaming.api.windowing.triggers.Trigger.OnMergeContext, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext
-
Nested classes/interfaces inherited from interface org.apache.flink.streaming.runtime.operators.windowing.AsyncTriggerConverter
org.apache.flink.streaming.runtime.operators.windowing.AsyncTriggerConverter.UserDefinedAsyncTrigger<T extends Object,W extends org.apache.flink.streaming.api.windowing.windows.Window>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear(W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx)ObjectconvertToAsync()static <T,W extends org.apache.flink.streaming.api.windowing.windows.Window>
ProcessingTimeoutTrigger<T,W>of(org.apache.flink.streaming.api.windowing.triggers.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 org.apache.flink.streaming.api.windowing.windows.Window>
ProcessingTimeoutTrigger<T,W>of(org.apache.flink.streaming.api.windowing.triggers.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.org.apache.flink.streaming.api.windowing.triggers.TriggerResultonElement(T element, long timestamp, W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx)org.apache.flink.streaming.api.windowing.triggers.TriggerResultonEventTime(long timestamp, W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx)org.apache.flink.streaming.api.windowing.triggers.TriggerResultonProcessingTime(long timestamp, W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx)StringtoString()
-
-
-
Method Detail
-
onElement
public org.apache.flink.streaming.api.windowing.triggers.TriggerResult onElement(T element, long timestamp, W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx) throws Exception
-
onProcessingTime
public org.apache.flink.streaming.api.windowing.triggers.TriggerResult onProcessingTime(long timestamp, W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx) throws Exception
-
onEventTime
public org.apache.flink.streaming.api.windowing.triggers.TriggerResult onEventTime(long timestamp, W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx) throws Exception
-
clear
public void clear(W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx) throws Exception
-
of
public static <T,W extends org.apache.flink.streaming.api.windowing.windows.Window> ProcessingTimeoutTrigger<T,W> of(org.apache.flink.streaming.api.windowing.triggers.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 org.apache.flink.streaming.api.windowing.windows.Window> ProcessingTimeoutTrigger<T,W> of(org.apache.flink.streaming.api.windowing.triggers.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.
-
convertToAsync
@Nonnull public Object convertToAsync()
- Specified by:
convertToAsyncin interfaceorg.apache.flink.streaming.runtime.operators.windowing.AsyncTriggerConverter
-
-