public class StateCleaningCountTrigger extends Trigger<Object,GlobalWindow>
Trigger
that fires once the count of elements in a pane reaches the given count
or the cleanup timer is triggered.Modifier and Type | Class and Description |
---|---|
static class |
StateCleaningCountTrigger.Sum |
Trigger.OnMergeContext, Trigger.TriggerContext
Constructor and Description |
---|
StateCleaningCountTrigger(StreamQueryConfig queryConfig,
long maxCount) |
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(GlobalWindow window,
Trigger.TriggerContext ctx)
Clears any state that the trigger might still hold for the given window.
|
protected long |
maxRetentionTime() |
protected long |
minRetentionTime() |
static StateCleaningCountTrigger |
of(StreamQueryConfig queryConfig,
long maxCount)
Create a
StateCleaningCountTrigger instance. |
TriggerResult |
onElement(Object element,
long timestamp,
GlobalWindow window,
Trigger.TriggerContext ctx)
Called for every element that gets added to a pane.
|
TriggerResult |
onEventTime(long time,
GlobalWindow window,
Trigger.TriggerContext ctx)
Called when an event-time timer that was set using the trigger context fires.
|
static void |
onMerge(W x$1,
Trigger.OnMergeContext x$2) |
TriggerResult |
onProcessingTime(long time,
GlobalWindow window,
Trigger.TriggerContext ctx)
Called when a processing-time timer that was set using the trigger context fires.
|
protected boolean |
stateCleaningEnabled() |
String |
toString() |
public StateCleaningCountTrigger(StreamQueryConfig queryConfig, long maxCount)
public static StateCleaningCountTrigger of(StreamQueryConfig queryConfig, long maxCount)
StateCleaningCountTrigger
instance.
queryConfig
- query configuration.maxCount
- The count of elements at which to fire.public static void onMerge(W x$1, Trigger.OnMergeContext x$2) throws Exception
Exception
protected long minRetentionTime()
protected long maxRetentionTime()
protected boolean stateCleaningEnabled()
public boolean canMerge()
Trigger
MergingWindowAssigner
.
If this returns true
you must properly implement
Trigger.onMerge(Window, OnMergeContext)
canMerge
in class Trigger<Object,GlobalWindow>
public TriggerResult onElement(Object element, long timestamp, GlobalWindow window, Trigger.TriggerContext ctx)
Trigger
onElement
in class Trigger<Object,GlobalWindow>
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 onProcessingTime(long time, GlobalWindow window, Trigger.TriggerContext ctx)
Trigger
onProcessingTime
in class Trigger<Object,GlobalWindow>
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 onEventTime(long time, GlobalWindow window, Trigger.TriggerContext ctx)
Trigger
onEventTime
in class Trigger<Object,GlobalWindow>
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(GlobalWindow window, Trigger.TriggerContext ctx)
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,GlobalWindow>
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.