Class ProcessingTimeoutTrigger<T,​W extends org.apache.flink.streaming.api.windowing.windows.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 org.apache.flink.streaming.api.windowing.windows.Window>
    extends org.apache.flink.streaming.api.windowing.triggers.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
    • 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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear​(W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx)  
      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 new ProcessingTimeoutTrigger that 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 new ProcessingTimeoutTrigger that fires when the inner trigger is fired or when the timeout timer fires.
      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)  
      org.apache.flink.streaming.api.windowing.triggers.TriggerResult onEventTime​(long timestamp, W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx)  
      org.apache.flink.streaming.api.windowing.triggers.TriggerResult onProcessingTime​(long timestamp, W window, org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx)  
      String toString()  
      • Methods inherited from class org.apache.flink.streaming.api.windowing.triggers.Trigger

        canMerge, onMerge
    • 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
        Specified by:
        onElement in class org.apache.flink.streaming.api.windowing.triggers.Trigger<T,​W extends org.apache.flink.streaming.api.windowing.windows.Window>
        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
        Specified by:
        onProcessingTime in class org.apache.flink.streaming.api.windowing.triggers.Trigger<T,​W extends org.apache.flink.streaming.api.windowing.windows.Window>
        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
        Specified by:
        onEventTime in class org.apache.flink.streaming.api.windowing.triggers.Trigger<T,​W extends org.apache.flink.streaming.api.windowing.windows.Window>
        Throws:
        Exception
      • clear

        public void clear​(W window,
                          org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext ctx)
                   throws Exception
        Specified by:
        clear in class org.apache.flink.streaming.api.windowing.triggers.Trigger<T,​W extends org.apache.flink.streaming.api.windowing.windows.Window>
        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 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 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 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.