@PublicEvolving public class EventTimeTrigger extends Trigger<Object,TimeWindow>
Trigger
that fires once the watermark passes the end of the window to which a pane
belongs.Watermark
,
Serialized FormTrigger.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 EventTimeTrigger |
create()
Creates an event-time trigger that fires once the watermark 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) throws Exception
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.Exception
public TriggerResult onEventTime(long time, TimeWindow window, Trigger.TriggerContext ctx)
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.public TriggerResult onProcessingTime(long time, TimeWindow window, Trigger.TriggerContext ctx) throws Exception
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.Exception
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 EventTimeTrigger create()
Once the trigger fires all elements are discarded. Elements that arrive late immediately trigger window evaluation with just this one element.
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.