T - The type of elements on which this trigger can operate.W - The type of Window on which this trigger can operate.@PublicEvolving public class ProcessingTimeoutTrigger<T,W extends Window> extends Trigger<T,W>
Trigger that can turn any Trigger into a timeout Trigger.
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 specifying resetTimerOnNewRecord and you can specify whether Trigger.clear(Window, TriggerContext) should be called on timout via shouldClearOnTimeout.
Trigger.OnMergeContext, Trigger.TriggerContext| Modifier and Type | Method and Description |
|---|---|
void |
clear(W window,
Trigger.TriggerContext ctx)
Clears any state that the trigger might still hold for the given window.
|
static <T,W extends Window> |
of(Trigger<T,W> nestedTrigger,
java.time.Duration timeout)
Creates a new
ProcessingTimeoutTrigger that fires when the inner trigger is fired or
when the timeout timer fires. |
static <T,W extends Window> |
of(Trigger<T,W> nestedTrigger,
java.time.Duration timeout,
boolean resetTimerOnNewRecord,
boolean shouldClearOnTimeout)
Creates a new
ProcessingTimeoutTrigger that fires when the inner trigger is fired or
when the timeout timer fires. |
TriggerResult |
onElement(T element,
long timestamp,
W window,
Trigger.TriggerContext ctx)
Called for every element that gets added to a pane.
|
TriggerResult |
onEventTime(long timestamp,
W window,
Trigger.TriggerContext ctx)
Called when an event-time timer that was set using the trigger context fires.
|
TriggerResult |
onProcessingTime(long timestamp,
W window,
Trigger.TriggerContext ctx)
Called when a processing-time timer that was set using the trigger context fires.
|
String |
toString() |
public TriggerResult onElement(T element, long timestamp, W window, Trigger.TriggerContext ctx) throws Exception
TriggeronElement in class Trigger<T,W extends Window>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.Exceptionpublic TriggerResult onProcessingTime(long timestamp, W window, Trigger.TriggerContext ctx) throws Exception
Triggerpublic TriggerResult onEventTime(long timestamp, W window, Trigger.TriggerContext ctx) throws Exception
Triggerpublic void clear(W window, Trigger.TriggerContext ctx) throws Exception
TriggerTrigger.TriggerContext.registerEventTimeTimer(long) and
Trigger.TriggerContext.registerProcessingTimeTimer(long) should be deleted here as well as
state acquired using Trigger.TriggerContext.getPartitionedState(StateDescriptor).public static <T,W extends Window> ProcessingTimeoutTrigger<T,W> of(Trigger<T,W> nestedTrigger, java.time.Duration timeout)
ProcessingTimeoutTrigger that 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 time t,
and the second record arrives at time t+50 , the trigger will fire when the third
record arrives or when the time is {code t+100} (timeout).
nestedTrigger - the nested Triggertimeout - the timeout intervalProcessingTimeoutTrigger with the above configuration.public static <T,W extends Window> ProcessingTimeoutTrigger<T,W> of(Trigger<T,W> nestedTrigger, java.time.Duration timeout, boolean resetTimerOnNewRecord, boolean shouldClearOnTimeout)
ProcessingTimeoutTrigger that 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
time t, and the second record arrives at time t+50 , the trigger will fire
when the third record arrives or when the time is {code t+100} (timeout).
T - The type of the element.W - The type of Windows on which this trigger can operate.nestedTrigger - the nested Triggertimeout - the timeout intervalresetTimerOnNewRecord - each time a new element arrives, reset the timer and start a new
oneshouldClearOnTimeout - whether to call Trigger.clear(Window, TriggerContext)
when the processing-time timer firesProcessingTimeoutTrigger with the above configuration.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.