IN
- Type of the input elementsKEY
- Type of the key on which the input stream is keyedOUT
- Type of the output elementspublic abstract class AbstractKeyedCEPPatternOperator<IN,KEY,OUT> extends AbstractStreamOperator<OUT> implements OneInputStreamOperator<IN,OUT>, Triggerable<KEY,VoidNamespace>, CheckpointedRestoringOperator
NFA
and a priority queue to buffer out of order elements. Both data structures are
stored using the managed keyed state. Additionally, the set of all seen keys is kept as part of the
operator state. This is necessary to trigger the execution for all keys upon receiving a new
watermark.AbstractStreamOperator.CountingOutput, AbstractStreamOperator.LatencyGauge
chainingStrategy, config, latencyGauge, LOG, metrics, output
Constructor and Description |
---|
AbstractKeyedCEPPatternOperator(TypeSerializer<IN> inputSerializer,
boolean isProcessingTime,
TypeSerializer<KEY> keySerializer,
NFACompiler.NFAFactory<IN> nfaFactory,
boolean migratingFromOldKeyedOperator) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
advanceTime(NFA<IN> nfa,
long timestamp)
Advances the time for the given NFA to the given timestamp.
|
int |
getPQSize(KEY key) |
boolean |
hasNonEmptyNFA(KEY key) |
boolean |
hasNonEmptyPQ(KEY key) |
void |
initializeState(StateInitializationContext context)
Stream operators with state which can be restored need to override this hook method.
|
void |
onEventTime(InternalTimer<KEY,VoidNamespace> timer)
Invoked when an event-time timer fires.
|
void |
onProcessingTime(InternalTimer<KEY,VoidNamespace> timer)
Invoked when a processing-time timer fires.
|
void |
open()
This method is called immediately before any elements are processed, it should contain the
operator's initialization logic, e.g.
|
void |
processElement(StreamRecord<IN> element)
Processes one element that arrived at this operator.
|
protected abstract void |
processEvent(NFA<IN> nfa,
IN event,
long timestamp)
Process the given event by giving it to the NFA and outputting the produced set of matched
event sequences.
|
void |
restoreState(FSDataInputStream in)
Restores the operator state, if this operator's execution is recovering from a checkpoint.
|
close, dispose, getChainingStrategy, getContainingTask, getCurrentKey, getExecutionConfig, getInternalTimerService, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getUserCodeClassloader, initializeState, notifyOfCompletedCheckpoint, numEventTimeTimers, numProcessingTimeTimers, processLatencyMarker, processLatencyMarker1, processLatencyMarker2, processWatermark, processWatermark1, processWatermark2, reportOrForwardLatencyMarker, setChainingStrategy, setCurrentKey, setKeyContextElement1, setKeyContextElement2, setup, snapshotLegacyOperatorState, snapshotState, snapshotState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
processLatencyMarker, processWatermark
close, dispose, getChainingStrategy, getMetricGroup, initializeState, notifyOfCompletedCheckpoint, setChainingStrategy, setKeyContextElement1, setKeyContextElement2, setup, snapshotLegacyOperatorState, snapshotState
public AbstractKeyedCEPPatternOperator(TypeSerializer<IN> inputSerializer, boolean isProcessingTime, TypeSerializer<KEY> keySerializer, NFACompiler.NFAFactory<IN> nfaFactory, boolean migratingFromOldKeyedOperator)
public void initializeState(StateInitializationContext context) throws Exception
AbstractStreamOperator
initializeState
in class AbstractStreamOperator<OUT>
context
- context that allows to register different states.Exception
public void open() throws Exception
AbstractStreamOperator
The default implementation does nothing.
open
in interface StreamOperator<OUT>
open
in class AbstractStreamOperator<OUT>
Exception
- An exception in this method causes the operator to fail.public void processElement(StreamRecord<IN> element) throws Exception
OneInputStreamOperator
processElement
in interface OneInputStreamOperator<IN,OUT>
Exception
public void onEventTime(InternalTimer<KEY,VoidNamespace> timer) throws Exception
Triggerable
onEventTime
in interface Triggerable<KEY,VoidNamespace>
Exception
public void onProcessingTime(InternalTimer<KEY,VoidNamespace> timer) throws Exception
Triggerable
onProcessingTime
in interface Triggerable<KEY,VoidNamespace>
Exception
protected abstract void processEvent(NFA<IN> nfa, IN event, long timestamp)
nfa
- NFA to be used for the event detectionevent
- The current event to be processedtimestamp
- The timestamp of the eventprotected abstract void advanceTime(NFA<IN> nfa, long timestamp)
nfa
- to advance the time fortimestamp
- to advance the time topublic void restoreState(FSDataInputStream in) throws Exception
CheckpointedRestoringOperator
This method is called after StreamOperator.setup(StreamTask, StreamConfig, Output)
and before StreamOperator.open()
.
restoreState
in interface CheckpointedRestoringOperator
in
- The stream from which we have to restore our state.Exception
- Exceptions during state restore should be forwarded, so that the system can
properly react to failed state restore and fail the execution attempt.@VisibleForTesting public boolean hasNonEmptyNFA(KEY key) throws IOException
IOException
@VisibleForTesting public boolean hasNonEmptyPQ(KEY key) throws Exception
Exception
@VisibleForTesting public int getPQSize(KEY key) throws Exception
Exception
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.