@Internal public interface TaskInvokable
The TaskManager first calls the
restore() method when executing a task. If the call
succeeds and the task isn't cancelled then TM proceeds to
invoke(). All operations of
the task happen in these two methods (setting up input output stream readers and writers as well
as the task's core operation).
cleanUp(Throwable) is called (regardless of an failures or cancellations
during the above calls).
Implementations must have a constructor with a single argument of type
Developer note: While constructors cannot be enforced at compile time, we did not yet
venture on the endeavor of introducing factories (it is only an internal API after all, and with
Java 8, one can use
Class::new almost like a factory lambda.
|Modifier and Type||Method and Description|
This method is called when a task is canceled either as a result of a user abort or an execution failure.
Starts the execution.
Checks whether the task should be interrupted during cancellation and if so, execute the specified
This method can be called before
void invoke() throws Exception
This method is called by the task manager when the actual execution of the task starts.
All resources should be cleaned up by calling
cleanUp(Throwable) ()} after the
void restore() throws Exception
invoke()to restore an invokable object for the last valid state, if it has it.
invoke() is not called after this method for some reason (e.g. task
cancellation); then all resources should be cleaned up by calling
()} after the method returns.
void cleanUp(@Nullable Throwable throwable) throws Exception
restore(). This method must be called regardless whether the aforementioned calls succeeded or failed.
throwable- iff failure happened during the execution of
invoke(), null otherwise.
CancelTaskException should not be treated as a failure.
Future<Void> cancel() throws Exception
AbstractInvokableis fully terminated. Note that it may never complete if the invokable is stuck.
InputGate.getNext()is used (as opposed to
InputGate.pollNext(). To be removed together with the DataSet API.
void maybeInterruptOnCancel(Thread toInterrupt, @Nullable String taskName, @Nullable Long timeout)
taskName- optional taskName to log stack trace
timeout- optional timeout to log stack trace
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.