public abstract class AbstractInvokable extends Object implements TaskInvokable, CheckpointableTask, CoordinatedTask
TaskInvokable, CheckpointableTask, and CoordinatedTask with most methods throwing UnsupportedOperationException or doing
nothing.
Any subclass that supports recoverable state and participates in checkpointing needs to
override the methods of CheckpointableTask, such as triggerCheckpointAsync(CheckpointMetaData, CheckpointOptions), triggerCheckpointOnBarrier(CheckpointMetaData, CheckpointOptions, CheckpointMetricsBuilder),
abortCheckpointOnBarrier(long, CheckpointException) and notifyCheckpointCompleteAsync(long).
| 构造器和说明 |
|---|
AbstractInvokable(Environment environment)
Create an Invokable task and set its environment.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
abortCheckpointOnBarrier(long checkpointId,
CheckpointException cause)
Aborts a checkpoint as the result of receiving possibly some checkpoint barriers, but at
least one
CancelCheckpointMarker. |
Future<Void> |
cancel()
This method is called when a task is canceled either as a result of a user abort or an
execution failure.
|
void |
cleanUp(Throwable throwable)
Cleanup any resources used in
TaskInvokable.invoke() OR TaskInvokable.restore(). |
void |
dispatchOperatorEvent(OperatorID operator,
org.apache.flink.util.SerializedValue<OperatorEvent> event) |
int |
getCurrentNumberOfSubtasks()
Returns the current number of subtasks the respective task is split into.
|
Environment |
getEnvironment()
Returns the environment of this task.
|
org.apache.flink.api.common.ExecutionConfig |
getExecutionConfig()
Returns the global ExecutionConfig.
|
int |
getIndexInSubtaskGroup()
Returns the index of this subtask in the subtask group.
|
org.apache.flink.configuration.Configuration |
getJobConfiguration()
Returns the job configuration object which was attached to the original
JobGraph. |
org.apache.flink.configuration.Configuration |
getTaskConfiguration()
Returns the task configuration object which was attached to the original
JobVertex. |
ClassLoader |
getUserCodeClassLoader()
Returns the user code class loader of this invokable.
|
abstract void |
invoke()
Starts the execution.
|
boolean |
isUsingNonBlockingInput() |
void |
maybeInterruptOnCancel(Thread toInterrupt,
String taskName,
Long timeout)
Checks whether the task should be interrupted during cancellation and if so, execute the
specified
Runnable interruptAction. |
Future<Void> |
notifyCheckpointAbortAsync(long checkpointId,
long latestCompletedCheckpointId)
Invoked when a checkpoint has been aborted, i.e., when the checkpoint coordinator has
received a decline message from one task and try to abort the targeted checkpoint by
notification.
|
Future<Void> |
notifyCheckpointCompleteAsync(long checkpointId)
Invoked when a checkpoint has been completed, i.e., when the checkpoint coordinator has
received the notification from all participating tasks.
|
void |
restore()
This method can be called before
TaskInvokable.invoke() to restore an invokable object for the
last valid state, if it has it. |
CompletableFuture<Boolean> |
triggerCheckpointAsync(CheckpointMetaData checkpointMetaData,
CheckpointOptions checkpointOptions)
This method is called to trigger a checkpoint, asynchronously by the checkpoint coordinator.
|
void |
triggerCheckpointOnBarrier(CheckpointMetaData checkpointMetaData,
CheckpointOptions checkpointOptions,
CheckpointMetricsBuilder checkpointMetrics)
This method is called when a checkpoint is triggered as a result of receiving checkpoint
barriers on all input streams.
|
public AbstractInvokable(Environment environment)
environment - The environment assigned to this invokable.public abstract void invoke()
throws Exception
TaskInvokableThis method is called by the task manager when the actual execution of the task starts.
All resources should be cleaned up by calling TaskInvokable.cleanUp(Throwable) ()} after the
method returns.
invoke 在接口中 TaskInvokableExceptionpublic Future<Void> cancel() throws Exception
TaskInvokablecancel 在接口中 TaskInvokableAbstractInvokable is fully terminated.
Note that it may never complete if the invokable is stuck.Exceptionpublic void cleanUp(@Nullable Throwable throwable) throws Exception
TaskInvokableTaskInvokable.invoke() OR TaskInvokable.restore(). This method must be
called regardless whether the aforementioned calls succeeded or failed.cleanUp 在接口中 TaskInvokablethrowable - iff failure happened during the execution of TaskInvokable.restore() or TaskInvokable.invoke(), null otherwise.
ATTENTION: CancelTaskException should not be treated as a failure.
Exceptionpublic void maybeInterruptOnCancel(Thread toInterrupt, @Nullable String taskName, @Nullable Long timeout)
TaskInvokableRunnable interruptAction.maybeInterruptOnCancel 在接口中 TaskInvokabletaskName - optional taskName to log stack tracetimeout - optional timeout to log stack tracepublic final Environment getEnvironment()
public final ClassLoader getUserCodeClassLoader()
public int getCurrentNumberOfSubtasks()
public int getIndexInSubtaskGroup()
public final org.apache.flink.configuration.Configuration getTaskConfiguration()
JobVertex.JobVertexpublic org.apache.flink.configuration.Configuration getJobConfiguration()
JobGraph.JobGraphpublic org.apache.flink.api.common.ExecutionConfig getExecutionConfig()
public CompletableFuture<Boolean> triggerCheckpointAsync(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions)
CheckpointableTaskThis method is called for tasks that start the checkpoints by injecting the initial
barriers, i.e., the source tasks. In contrast, checkpoints on downstream operators, which are
the result of receiving checkpoint barriers, invoke the CheckpointableTask.triggerCheckpointOnBarrier(CheckpointMetaData, CheckpointOptions, CheckpointMetricsBuilder)
method.
triggerCheckpointAsync 在接口中 CheckpointableTaskcheckpointMetaData - Meta data for about this checkpointcheckpointOptions - Options for performing this checkpointfalse if the checkpoint was not carried out, true otherwisepublic void triggerCheckpointOnBarrier(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions, CheckpointMetricsBuilder checkpointMetrics) throws IOException
CheckpointableTasktriggerCheckpointOnBarrier 在接口中 CheckpointableTaskcheckpointMetaData - Meta data for about this checkpointcheckpointOptions - Options for performing this checkpointcheckpointMetrics - Metrics about this checkpointIOException - Exceptions thrown as the result of triggering a checkpoint are forwarded.public void abortCheckpointOnBarrier(long checkpointId,
CheckpointException cause)
throws IOException
CheckpointableTaskCancelCheckpointMarker.
This requires implementing tasks to forward a CancelCheckpointMarker to their outputs.
abortCheckpointOnBarrier 在接口中 CheckpointableTaskcheckpointId - The ID of the checkpoint to be aborted.cause - The reason why the checkpoint was aborted during alignmentIOExceptionpublic Future<Void> notifyCheckpointCompleteAsync(long checkpointId)
CheckpointableTasknotifyCheckpointCompleteAsync 在接口中 CheckpointableTaskcheckpointId - The ID of the checkpoint that is complete.public Future<Void> notifyCheckpointAbortAsync(long checkpointId, long latestCompletedCheckpointId)
CheckpointableTasknotifyCheckpointAbortAsync 在接口中 CheckpointableTaskcheckpointId - The ID of the checkpoint that is aborted.latestCompletedCheckpointId - The ID of the latest completed checkpoint.public void dispatchOperatorEvent(OperatorID operator, org.apache.flink.util.SerializedValue<OperatorEvent> event) throws org.apache.flink.util.FlinkException
dispatchOperatorEvent 在接口中 CoordinatedTaskorg.apache.flink.util.FlinkExceptionpublic void restore()
throws Exception
TaskInvokableTaskInvokable.invoke() to restore an invokable object for the
last valid state, if it has it.
If TaskInvokable.invoke() is not called after this method for some reason (e.g. task
cancellation); then all resources should be cleaned up by calling TaskInvokable.cleanUp(Throwable)
()} after the method returns.
restore 在接口中 TaskInvokableExceptionpublic boolean isUsingNonBlockingInput()
isUsingNonBlockingInput 在接口中 TaskInvokableInputGate.getNext() is used (as opposed to
InputGate.pollNext(). To be removed together with the DataSet API.Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.