Class 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 Detail

      • snapshotCloseableRegistry

        @Nonnull
        protected final CloseableRegistry snapshotCloseableRegistry
        Registers streams that can block in I/O during snapshot. Forwards close from taskCancelCloseableRegistry.
    • Constructor Detail

      • AsyncSnapshotCallable

        protected AsyncSnapshotCallable()
    • Method Detail

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