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 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.
  • Field Details

    • snapshotCloseableRegistry

      @Nonnull protected final org.apache.flink.core.fs.CloseableRegistry snapshotCloseableRegistry
      Registers streams that can block in I/O during snapshot. Forwards close from taskCancelCloseableRegistry.
  • Constructor Details

    • AsyncSnapshotCallable

      protected AsyncSnapshotCallable()
  • Method Details

    • call

      public T call() throws Exception
      Specified by:
      call in interface Callable<T>
      Throws:
      Exception
    • 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 given CloseableRegistry. The task is unregistered again in FutureTask.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 of callInternal().
    • 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.