Class ProcessingTimeoutTrigger<T,​W extends Window>

  • Type Parameters:
    T - The type of elements on which this trigger can operate.
    W - The type of Window on which this trigger can operate.
    All Implemented Interfaces:
    Serializable

    @PublicEvolving
    public class ProcessingTimeoutTrigger<T,​W extends Window>
    extends Trigger<T,​W>
    A 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.

    See Also:
    Serialized Form
    • Method Detail

      • onElement

        public TriggerResult onElement​(T element,
                                       long timestamp,
                                       W window,
                                       Trigger.TriggerContext ctx)
                                throws Exception
        Description copied from class: Trigger
        Called 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:
        onElement in class Trigger<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: Trigger
        Called when a processing-time timer that was set using the trigger context fires.
        Specified by:
        onProcessingTime in class Trigger<T,​W extends Window>
        Parameters:
        timestamp - The timestamp at which the timer fired.
        window - The window for which the timer fired.
        ctx - A context object that can be used to register timer callbacks.
        Throws:
        Exception
      • onEventTime

        public TriggerResult onEventTime​(long timestamp,
                                         W window,
                                         Trigger.TriggerContext ctx)
                                  throws Exception
        Description copied from class: Trigger
        Called when an event-time timer that was set using the trigger context fires.
        Specified by:
        onEventTime in class Trigger<T,​W extends Window>
        Parameters:
        timestamp - The timestamp at which the timer fired.
        window - The window for which the timer fired.
        ctx - A context object that can be used to register timer callbacks.
        Throws:
        Exception
      • of

        public static <T,​W extends WindowProcessingTimeoutTrigger<T,​W> 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.

        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).

        Parameters:
        nestedTrigger - the nested Trigger
        timeout - the timeout interval
        Returns:
        ProcessingTimeoutTrigger with the above configuration.
      • of

        public static <T,​W extends WindowProcessingTimeoutTrigger<T,​W> 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.

        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).

        Type Parameters:
        T - The type of the element.
        W - The type of Windows on which this trigger can operate.
        Parameters:
        nestedTrigger - the nested Trigger
        timeout - the timeout interval
        resetTimerOnNewRecord - each time a new element arrives, reset the timer and start a new one
        shouldClearOnTimeout - whether to call Trigger.clear(Window, TriggerContext) when the processing-time timer fires
        Returns:
        ProcessingTimeoutTrigger with the above configuration.