Package org.apache.flink.runtime.state
Class AsyncSnapshotCallable<T>
java.lang.Object
org.apache.flink.runtime.state.AsyncSnapshotCallable<T>
- Type Parameters:
T- type of the result.
- All Implemented Interfaces:
Callable<T>
Base class that outlines the strategy for asynchronous snapshots. Implementations of this class
are typically instantiated with resources that have been created in the synchronous part of a
snapshot. Then, the implementation of
callInternal() is invoked in the asynchronous
part. All resources created by this methods should be released by the end of the method. If the
created resources are Closeable objects and can block in calls (e.g. in/output streams),
they should be registered with the snapshot's CloseableRegistry so that the can be closed
and unblocked on cancellation. After callInternal() ended, logAsyncSnapshotComplete(long) is called. In that method, implementations can emit log
statements about the duration. At the very end, this class calls cleanupProvidedResources(). The implementation of this method should release all provided
resources that have been passed into the snapshot from the synchronous part of the snapshot.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassFutureTaskthat wraps aAsyncSnapshotCallableand connects it with cancellation and closing. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.flink.core.fs.CloseableRegistryRegisters streams that can block in I/O during snapshot. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall()protected abstract TThis method implements the (async) snapshot logic.protected voidcancel()protected abstract voidThis method implements the cleanup of resources that have been passed in (from the sync part).protected voidlogAsyncSnapshotComplete(long startTime) This method is invoked after completion of the snapshot and can be overridden to output a logging about the duration of the async part.toAsyncSnapshotFutureTask(org.apache.flink.core.fs.CloseableRegistry taskRegistry) Creates a future task from this and registers it with the givenCloseableRegistry.
-
Field Details
-
snapshotCloseableRegistry
@Nonnull protected final org.apache.flink.core.fs.CloseableRegistry snapshotCloseableRegistryRegisters streams that can block in I/O during snapshot. Forwards close from taskCancelCloseableRegistry.
-
-
Constructor Details
-
AsyncSnapshotCallable
protected AsyncSnapshotCallable()
-
-
Method Details
-
call
-
cancel
@VisibleForTesting protected void cancel() -
toAsyncSnapshotFutureTask
public AsyncSnapshotCallable<T>.AsyncSnapshotTask toAsyncSnapshotFutureTask(@Nonnull org.apache.flink.core.fs.CloseableRegistry taskRegistry) throws IOException Creates a future task from this and registers it with the givenCloseableRegistry. The task is unregistered again inFutureTask.done().- Throws:
IOException
-
callInternal
This method implements the (async) snapshot logic. Resources aquired within this method should be released at the end of the method.- Throws:
Exception
-
cleanupProvidedResources
protected abstract void cleanupProvidedResources()This method implements the cleanup of resources that have been passed in (from the sync part). Called after the end ofcallInternal(). -
logAsyncSnapshotComplete
protected void logAsyncSnapshotComplete(long startTime) This method is invoked after completion of the snapshot and can be overridden to output a logging about the duration of the async part.
-