M - the type of input MessageEnvelopes in the MessageStream@InterfaceStability.Unstable public final class Triggers<M extends MessageEnvelope> 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))))))
.accumulateFiredPanes());
| Modifier and Type | Method and Description |
|---|---|
static <M extends MessageEnvelope> |
any(Trigger<M>... triggers)
Creates a trigger that fires when any of the provided triggers fire.
|
static Trigger |
count(long count)
Creates a
Trigger that fires when the number of MessageEnvelopes in the pane
reaches the specified count. |
static <M extends MessageEnvelope> |
repeat(Trigger<M> trigger)
Repeats the provided trigger forever.
|
static Trigger |
timeSinceFirstMessage(java.time.Duration duration)
Creates a trigger that fires after the specified duration has passed since the first
MessageEnvelope in
the pane. |
static Trigger |
timeSinceLastMessage(java.time.Duration duration)
Creates a trigger that fires when there is no new
MessageEnvelope for the specified duration in the pane. |
public static Trigger count(long count)
Trigger that fires when the number of MessageEnvelopes in the pane
reaches the specified count.count - the number of MessageEnvelopes to fire the trigger afterpublic static Trigger timeSinceFirstMessage(java.time.Duration duration)
MessageEnvelope in
the pane.duration - the duration since the first elementpublic static Trigger timeSinceLastMessage(java.time.Duration duration)
MessageEnvelope for the specified duration in the pane.duration - the duration since the last elementpublic static <M extends MessageEnvelope> Trigger any(Trigger<M>... triggers)
M - the type of input MessageEnvelope in the windowtriggers - the individual triggerspublic static <M extends MessageEnvelope> Trigger repeat(Trigger<M> trigger)
Creating a RepeatingTrigger from an AnyTrigger is equivalent to creating an AnyTrigger from
its individual RepeatingTriggers.
M - the type of input MessageEnvelope in the windowtrigger - the individual trigger to repeat