@PublicEvolving public class ProcessingTimeTrigger extends Trigger<Object,TimeWindow>
Trigger
that fires once the current system time passes the end of the window
to which a pane belongs.Trigger.OnMergeContext, Trigger.TriggerContext
Modifier and Type | Method and Description |
---|---|
boolean |
canMerge()
Returns true if this trigger supports merging of trigger state and can therefore
be used with a
MergingWindowAssigner . |
void |
clear(TimeWindow window,
Trigger.TriggerContext ctx)
Clears any state that the trigger might still hold for the given window.
|
static ProcessingTimeTrigger |
create()
Creates a new trigger that fires once system time passes the end of the window.
|
TriggerResult |
onElement(Object element,
long timestamp,
TimeWindow window,
Trigger.TriggerContext ctx)
Called for every element that gets added to a pane.
|
TriggerResult |
onEventTime(long time,
TimeWindow window,
Trigger.TriggerContext ctx)
Called when an event-time timer that was set using the trigger context fires.
|
void |
onMerge(TimeWindow window,
Trigger.OnMergeContext ctx)
Called when several windows have been merged into one window by the
WindowAssigner . |
TriggerResult |
onProcessingTime(long time,
TimeWindow window,
Trigger.TriggerContext ctx)
Called when a processing-time timer that was set using the trigger context fires.
|
String |
toString() |
public TriggerResult onElement(Object element, long timestamp, TimeWindow window, Trigger.TriggerContext ctx)
Trigger
onElement
in class Trigger<Object,TimeWindow>
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.public TriggerResult onEventTime(long time, TimeWindow window, Trigger.TriggerContext ctx) throws Exception
Trigger
onEventTime
in class Trigger<Object,TimeWindow>
time
- 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.Exception
public TriggerResult onProcessingTime(long time, TimeWindow window, Trigger.TriggerContext ctx)
Trigger
onProcessingTime
in class Trigger<Object,TimeWindow>
time
- 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.public void clear(TimeWindow window, Trigger.TriggerContext ctx) throws Exception
Trigger
Trigger.TriggerContext.registerEventTimeTimer(long)
and Trigger.TriggerContext.registerProcessingTimeTimer(long)
should be deleted here as
well as state acquired using Trigger.TriggerContext.getPartitionedState(StateDescriptor)
.clear
in class Trigger<Object,TimeWindow>
Exception
public boolean canMerge()
Trigger
MergingWindowAssigner
.
If this returns true
you must properly implement
Trigger.onMerge(Window, OnMergeContext)
canMerge
in class Trigger<Object,TimeWindow>
public void onMerge(TimeWindow window, Trigger.OnMergeContext ctx)
Trigger
WindowAssigner
.onMerge
in class Trigger<Object,TimeWindow>
window
- The new window that results from the merge.ctx
- A context object that can be used to register timer callbacks and access state.public static ProcessingTimeTrigger create()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.