@InterfaceStability.Unstable public final class Triggers extends java.lang.Object
Trigger
instances to be used with a Window
.
The below example groups an input into tumbling windows of 10s and emits early results periodically every 4s in processing time, or for every 50 messages. It also specifies that window results are accumulating.
MessageStream<> windowedStream = stream.window(Windows.tumblingWindow(Duration.of(10, TimeUnit.SECONDS))
.setEarlyTrigger(Triggers.repeat(Triggers.any(Triggers.count(50), Triggers.timeSinceFirstMessage(Duration.of(4, TimeUnit.SECONDS))))))
.setAccumulationMode(AccumulationMode.ACCUMULATING));
Modifier and Type | Method and Description |
---|---|
static <M> Trigger<M> |
any(Trigger<M>... triggers)
Creates a trigger that fires when any of the provided triggers fire.
|
static <M> Trigger<M> |
count(long count)
Creates a
Trigger that fires when the number of messages in the pane
reaches the specified count. |
static <M> Trigger<M> |
repeat(Trigger<M> trigger)
Repeats the provided trigger forever.
|
static <M> Trigger<M> |
timeSinceFirstMessage(java.time.Duration duration)
Creates a trigger that fires after the specified duration has passed since the first message in
the pane.
|
static <M> Trigger<M> |
timeSinceLastMessage(java.time.Duration duration)
Creates a trigger that fires when there is no new message for the specified duration in the pane.
|
public static <M> Trigger<M> count(long count)
Trigger
that fires when the number of messages in the pane
reaches the specified count.M
- the type of input message in the windowcount
- the number of messages to fire the trigger afterpublic static <M> Trigger<M> timeSinceFirstMessage(java.time.Duration duration)
M
- the type of input message in the windowduration
- the duration since the first elementpublic static <M> Trigger<M> timeSinceLastMessage(java.time.Duration duration)
M
- the type of input message in the windowduration
- the duration since the last elementpublic static <M> Trigger<M> any(Trigger<M>... triggers)
M
- the type of input message in the windowtriggers
- the individual triggerspublic static <M> Trigger<M> repeat(Trigger<M> trigger)
Creating a RepeatingTrigger
from an AnyTrigger
is equivalent to creating an AnyTrigger
from
its individual RepeatingTrigger
s.
M
- the type of input message in the windowtrigger
- the individual trigger to repeat