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>
public abstract class AsyncSnapshotCallable<T> extends Object implements 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 ofcallInternal()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 areCloseableobjects and can block in calls (e.g. in/output streams), they should be registered with the snapshot'sCloseableRegistryso that the can be closed and unblocked on cancellation. AftercallInternal()ended,logAsyncSnapshotComplete(long)is called. In that method, implementations can emit log statements about the duration. At the very end, this class callscleanupProvidedResources(). 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 Classes Modifier and Type Class Description classAsyncSnapshotCallable.AsyncSnapshotTaskFutureTaskthat wraps aAsyncSnapshotCallableand connects it with cancellation and closing.
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.flink.core.fs.CloseableRegistrysnapshotCloseableRegistryRegisters streams that can block in I/O during snapshot.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAsyncSnapshotCallable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Tcall()protected abstract TcallInternal()This method implements the (async) snapshot logic.protected voidcancel()protected abstract voidcleanupProvidedResources()This 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.AsyncSnapshotCallable.AsyncSnapshotTasktoAsyncSnapshotFutureTask(org.apache.flink.core.fs.CloseableRegistry taskRegistry)Creates a future task from this and registers it with the givenCloseableRegistry.
-
-
-
Method Detail
-
cancel
@VisibleForTesting protected void cancel()
-
toAsyncSnapshotFutureTask
public AsyncSnapshotCallable.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
protected abstract T callInternal() throws Exception
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.
-
-