OUT
- Operator
- public abstract class StreamTask<OUT,Operator extends StreamOperator<OUT>> extends org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable implements org.apache.flink.runtime.jobgraph.tasks.StatefulTask<StreamTaskStateList>
StreamOperator
s which form
the Task's operator chain. Operators that are chained together execute synchronously in the
same thread and hence on the same stream partition. A common case for these chaines
are successive map/flatmap/filter tasks.
The task chain contains one "head" operator and multiple chained operators. The StreamTask is specialized for the type of the head operator: one-input and two-input tasks, as well as for sources, iteration heads and iteration tails.
The Task class deals with the setup of the streams read by the head operator, and the streams produced by the operators at the ends of the operator chain. Note that the chain may fork and thus have multiple ends. The life cycle of the task is set up as follows:
-- registerInputOutput()
|
+----> Create basic utils (config, etc) and load the chain of operators
+----> operators.setup()
+----> task specific init()
-- restoreState() -> restores state of all operators in the chain
-- invoke()
|
+----> open-operators()
+----> run()
+----> close-operators()
+----> dispose-operators()
+----> common cleanup
+----> task specific cleanup()
The StreamTask
has a lock object called lock
. All calls to methods on a
StreamOperator
must be synchronized on this lock object to ensure that no methods
are called concurrently.
Modifier and Type | Field and Description |
---|---|
protected Operator |
headOperator
the head operator that consumes the input streams of this task
|
protected static org.slf4j.Logger |
LOG
The logger used by the StreamTask and its subclasses
|
static ThreadGroup |
TRIGGER_THREAD_GROUP
The thread group that holds all trigger timer threads
|
Constructor and Description |
---|
StreamTask() |
Modifier and Type | Method and Description |
---|---|
void |
cancel() |
protected abstract void |
cancelTask() |
void |
checkTimerException() |
protected abstract void |
cleanup() |
protected void |
finalize()
The finalize method shuts down the timer.
|
Map<String,org.apache.flink.api.common.accumulators.Accumulator<?,?>> |
getAccumulatorMap() |
protected org.apache.flink.runtime.util.event.EventListener<org.apache.flink.runtime.io.network.api.CheckpointBarrier> |
getCheckpointBarrierListener() |
Object |
getCheckpointLock()
Gets the lock object on which all operations that involve data and state mutation have to lock.
|
StreamConfig |
getConfiguration() |
Output<StreamRecord<OUT>> |
getHeadOutput() |
String |
getName()
Gets the name of the task, in the form "taskname (2/5)".
|
org.apache.flink.runtime.state.StateBackend<?> |
getStateBackend()
Gets the state backend used by this task.
|
RecordWriterOutput<?>[] |
getStreamOutputs() |
protected abstract void |
init() |
void |
invoke() |
void |
notifyCheckpointComplete(long checkpointId) |
void |
registerInputOutput() |
void |
registerTimer(long timestamp,
Triggerable target)
Registers a timer.
|
void |
restoreStateLazy() |
protected abstract void |
run() |
void |
setInitialState(StreamTaskStateList initialState) |
String |
toString() |
void |
triggerCheckpoint(long checkpointId,
long timestamp) |
public static final ThreadGroup TRIGGER_THREAD_GROUP
protected static final org.slf4j.Logger LOG
protected Operator extends StreamOperator<OUT> headOperator
public final void registerInputOutput() throws Exception
registerInputOutput
in class org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable
Exception
public final void invoke() throws Exception
invoke
in class org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable
Exception
public final void cancel() throws Exception
cancel
in class org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable
Exception
protected void finalize() throws Throwable
This should not be relied upon! It will cause shutdown to happen much later than if manual shutdown is attempted, and cause threads to linger for longer than needed.
public String getName()
public Object getCheckpointLock()
public StreamConfig getConfiguration()
public Map<String,org.apache.flink.api.common.accumulators.Accumulator<?,?>> getAccumulatorMap()
public Output<StreamRecord<OUT>> getHeadOutput()
public RecordWriterOutput<?>[] getStreamOutputs()
public void setInitialState(StreamTaskStateList initialState)
setInitialState
in interface org.apache.flink.runtime.jobgraph.tasks.StatefulTask<StreamTaskStateList>
public void triggerCheckpoint(long checkpointId, long timestamp) throws Exception
triggerCheckpoint
in interface org.apache.flink.runtime.jobgraph.tasks.StatefulTask<StreamTaskStateList>
Exception
public void notifyCheckpointComplete(long checkpointId) throws Exception
notifyCheckpointComplete
in interface org.apache.flink.runtime.jobgraph.tasks.StatefulTask<StreamTaskStateList>
Exception
public org.apache.flink.runtime.state.StateBackend<?> getStateBackend()
public void registerTimer(long timestamp, Triggerable target)
public void checkTimerException() throws TimerException
TimerException
protected final org.apache.flink.runtime.util.event.EventListener<org.apache.flink.runtime.io.network.api.CheckpointBarrier> getCheckpointBarrierListener()
Copyright © 2014–2015 The Apache Software Foundation. All rights reserved.