public class Task extends Object implements Runnable
The Flink operators (implemented as subclasses of
AbstractInvokable
have only data
readers, -writers, and certain event callbacks. The task connects those to the
network stack and actor messages, and tracks the state of the execution and
handles exceptions.
Tasks have no knowledge about how they relate to other tasks, or whether they are the first attempt to execute the task, or a repeated attempt. All of that is only known to the JobManager. All the task knows are its own runnable code, the task's configuration, and the IDs of the intermediate results to consume and produce (if any).
Each Task is run by one dedicated thread.
Constructor and Description |
---|
Task(TaskDeploymentDescriptor tdd,
MemoryManager memManager,
IOManager ioManager,
NetworkEnvironment networkEnvironment,
BroadcastVariableManager bcVarManager,
ActorGateway taskManagerActor,
ActorGateway jobManagerActor,
scala.concurrent.duration.FiniteDuration actorAskTimeout,
LibraryCacheManager libraryCache,
FileCache fileCache,
TaskManagerRuntimeInfo taskManagerConfig)
IMPORTANT: This constructor may not start any work that would need to
be undone in the case of a failing task deployment.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelExecution()
Cancels the task execution.
|
void |
failExternally(Throwable cause)
Marks task execution failed for an external reason (a reason other than the task code itself
throwing an exception).
|
AccumulatorRegistry |
getAccumulatorRegistry() |
SingleInputGate[] |
getAllInputGates() |
ResultPartitionWriter[] |
getAllWriters() |
Thread |
getExecutingThread() |
ExecutionAttemptID |
getExecutionId() |
ExecutionState |
getExecutionState()
Returns the current execution state of the task.
|
Throwable |
getFailureCause()
If the task has failed, this method gets the exception that caused this task to fail.
|
SingleInputGate |
getInputGateById(IntermediateDataSetID id) |
Configuration |
getJobConfiguration() |
JobID |
getJobID() |
JobVertexID |
getJobVertexId() |
ResultPartition[] |
getProducedPartitions() |
Configuration |
getTaskConfiguration() |
TaskInfo |
getTaskInfo() |
boolean |
isCanceledOrFailed()
Checks whether the task has failed, is canceled, or is being canceled at the moment.
|
void |
notifyCheckpointComplete(long checkpointID) |
void |
onPartitionStateUpdate(IntermediateDataSetID resultId,
IntermediateResultPartitionID partitionId,
ExecutionState partitionState)
Answer to a partition state check issued after a failed partition request.
|
void |
registerExecutionListener(ActorGateway listener) |
void |
run()
The core work method that bootstraps the task and executes it code
|
void |
startTaskThread()
Starts the task's thread.
|
void |
stopExecution()
Stops the executing task by calling
StoppableTask.stop() . |
String |
toString() |
void |
triggerCheckpointBarrier(long checkpointID,
long checkpointTimestamp)
Calls the invokable to trigger a checkpoint, if the invokable implements the interface
StatefulTask . |
public Task(TaskDeploymentDescriptor tdd, MemoryManager memManager, IOManager ioManager, NetworkEnvironment networkEnvironment, BroadcastVariableManager bcVarManager, ActorGateway taskManagerActor, ActorGateway jobManagerActor, scala.concurrent.duration.FiniteDuration actorAskTimeout, LibraryCacheManager libraryCache, FileCache fileCache, TaskManagerRuntimeInfo taskManagerConfig)
IMPORTANT: This constructor may not start any work that would need to be undone in the case of a failing task deployment.
public JobID getJobID()
public JobVertexID getJobVertexId()
public ExecutionAttemptID getExecutionId()
public TaskInfo getTaskInfo()
public Configuration getJobConfiguration()
public Configuration getTaskConfiguration()
public ResultPartitionWriter[] getAllWriters()
public SingleInputGate[] getAllInputGates()
public ResultPartition[] getProducedPartitions()
public SingleInputGate getInputGateById(IntermediateDataSetID id)
public AccumulatorRegistry getAccumulatorRegistry()
public Thread getExecutingThread()
public ExecutionState getExecutionState()
public boolean isCanceledOrFailed()
public Throwable getFailureCause()
public void startTaskThread()
public void run()
public void stopExecution() throws UnsupportedOperationException
StoppableTask.stop()
.
This method never blocks.
UnsupportedOperationException
- if the AbstractInvokable
does not implement StoppableTask
public void cancelExecution()
This method never blocks.
public void failExternally(Throwable cause)
This method never blocks.
public void registerExecutionListener(ActorGateway listener)
public void triggerCheckpointBarrier(long checkpointID, long checkpointTimestamp)
StatefulTask
.checkpointID
- The ID identifying the checkpoint.checkpointTimestamp
- The timestamp associated with the checkpoint.public void notifyCheckpointComplete(long checkpointID)
public void onPartitionStateUpdate(IntermediateDataSetID resultId, IntermediateResultPartitionID partitionId, ExecutionState partitionState) throws IOException, InterruptedException
IOException
InterruptedException
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.