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 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:
  • 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

    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)
     
     

    Methods inherited from class org.apache.flink.streaming.api.windowing.triggers.Trigger

    canMerge, onMerge

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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.