Class AsyncProcessingTimeoutTrigger<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

    @Experimental
    public class AsyncProcessingTimeoutTrigger<T,​W extends org.apache.flink.streaming.api.windowing.windows.Window>
    extends org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W>
    A AsyncTrigger that can turn any AsyncTrigger into a timeout AsyncTrigger.

    On the first arriving element a configurable processing-time timeout will be set. Using of(AsyncTrigger, Duration, boolean, boolean), you can also re-new the timer for each arriving element by specifying resetTimerOnNewRecord and you can specify whether AsyncTrigger.clear(Window, AsyncTrigger.TriggerContext) should be called on timout via shouldClearOnTimeout.

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger

        org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.OnMergeContext, org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.TriggerContext
    • Constructor Summary

      Constructors 
      Constructor Description
      AsyncProcessingTimeoutTrigger​(org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W> nestedTrigger, long interval, boolean resetTimerOnNewRecord, boolean shouldClearOnTimeout)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.flink.api.common.state.v2.StateFuture<Void> clear​(W window, org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.TriggerContext ctx)  
      long getInterval()  
      org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W> getNestedTrigger()  
      org.apache.flink.api.common.state.v2.ValueStateDescriptor<Long> getTimeoutStateDesc()  
      boolean isResetTimerOnNewRecord()  
      boolean isShouldClearOnTimeout()  
      static <T,​W extends org.apache.flink.streaming.api.windowing.windows.Window>
      AsyncProcessingTimeoutTrigger<T,​W>
      of​(org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W> nestedTrigger, Duration timeout)
      Creates a new AsyncProcessingTimeoutTrigger 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>
      AsyncProcessingTimeoutTrigger<T,​W>
      of​(org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W> nestedTrigger, Duration timeout, boolean resetTimerOnNewRecord, boolean shouldClearOnTimeout)
      Creates a new AsyncProcessingTimeoutTrigger that fires when the inner trigger is fired or when the timeout timer fires.
      org.apache.flink.api.common.state.v2.StateFuture<org.apache.flink.streaming.api.windowing.triggers.TriggerResult> onElement​(T element, long timestamp, W window, org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.TriggerContext ctx)  
      org.apache.flink.api.common.state.v2.StateFuture<org.apache.flink.streaming.api.windowing.triggers.TriggerResult> onEventTime​(long time, W window, org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.TriggerContext ctx)  
      org.apache.flink.api.common.state.v2.StateFuture<org.apache.flink.streaming.api.windowing.triggers.TriggerResult> onProcessingTime​(long time, W window, org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.TriggerContext ctx)  
      String toString()  
      • Methods inherited from class org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger

        canMerge, isEndOfStreamTrigger, onMerge
    • Constructor Detail

      • AsyncProcessingTimeoutTrigger

        public AsyncProcessingTimeoutTrigger​(org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W> nestedTrigger,
                                             long interval,
                                             boolean resetTimerOnNewRecord,
                                             boolean shouldClearOnTimeout)
    • Method Detail

      • onElement

        public org.apache.flink.api.common.state.v2.StateFuture<org.apache.flink.streaming.api.windowing.triggers.TriggerResult> onElement​(T element,
                                                                                                                                           long timestamp,
                                                                                                                                           W window,
                                                                                                                                           org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.TriggerContext ctx)
                                                                                                                                    throws Exception
        Specified by:
        onElement in class org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W extends org.apache.flink.streaming.api.windowing.windows.Window>
        Throws:
        Exception
      • onProcessingTime

        public org.apache.flink.api.common.state.v2.StateFuture<org.apache.flink.streaming.api.windowing.triggers.TriggerResult> onProcessingTime​(long time,
                                                                                                                                                  W window,
                                                                                                                                                  org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.TriggerContext ctx)
                                                                                                                                           throws Exception
        Specified by:
        onProcessingTime in class org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W extends org.apache.flink.streaming.api.windowing.windows.Window>
        Throws:
        Exception
      • onEventTime

        public org.apache.flink.api.common.state.v2.StateFuture<org.apache.flink.streaming.api.windowing.triggers.TriggerResult> onEventTime​(long time,
                                                                                                                                             W window,
                                                                                                                                             org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.TriggerContext ctx)
                                                                                                                                      throws Exception
        Specified by:
        onEventTime in class org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W extends org.apache.flink.streaming.api.windowing.windows.Window>
        Throws:
        Exception
      • clear

        public org.apache.flink.api.common.state.v2.StateFuture<Void> clear​(W window,
                                                                            org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger.TriggerContext ctx)
                                                                     throws Exception
        Specified by:
        clear in class org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<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> AsyncProcessingTimeoutTrigger<T,​W> of​(org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W> nestedTrigger,
                                                                                                                                              Duration timeout)
        Creates a new AsyncProcessingTimeoutTrigger that fires when the inner trigger is fired or when the timeout timer fires.

        For example: AsyncProcessingTimeoutTrigger.of(AsyncCountTrigger.of(3), 100), will create a AsyncCountTrigger 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 AsyncTrigger
        timeout - the timeout interval
        Returns:
        AsyncProcessingTimeoutTrigger with the above configuration.
      • of

        public static <T,​W extends org.apache.flink.streaming.api.windowing.windows.Window> AsyncProcessingTimeoutTrigger<T,​W> of​(org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W> nestedTrigger,
                                                                                                                                              Duration timeout,
                                                                                                                                              boolean resetTimerOnNewRecord,
                                                                                                                                              boolean shouldClearOnTimeout)
        Creates a new AsyncProcessingTimeoutTrigger that fires when the inner trigger is fired or when the timeout timer fires.

        For example: AsyncProcessingTimeoutTrigger.of(CountTrigger.of(3), 100, false, true), will create a AsyncCountTrigger 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 AsyncTrigger
        timeout - the timeout interval
        resetTimerOnNewRecord - each time a new element arrives, reset the timer and start a new one
        shouldClearOnTimeout - whether to call AsyncTrigger.clear(Window, AsyncTrigger.TriggerContext) when the processing-time timer fires
        Returns:
        AsyncProcessingTimeoutTrigger with the above configuration.
      • getNestedTrigger

        @VisibleForTesting
        public org.apache.flink.runtime.asyncprocessing.operators.windowing.triggers.AsyncTrigger<T,​W> getNestedTrigger()
      • getInterval

        @VisibleForTesting
        public long getInterval()
      • isResetTimerOnNewRecord

        @VisibleForTesting
        public boolean isResetTimerOnNewRecord()
      • isShouldClearOnTimeout

        @VisibleForTesting
        public boolean isShouldClearOnTimeout()
      • getTimeoutStateDesc

        @VisibleForTesting
        public org.apache.flink.api.common.state.v2.ValueStateDescriptor<Long> getTimeoutStateDesc()