T
- type of the result.public abstract class AsyncSnapshotCallable<T> extends Object implements Callable<T>
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.Modifier and Type | Class and Description |
---|---|
class |
AsyncSnapshotCallable.AsyncSnapshotTask
FutureTask that wraps a AsyncSnapshotCallable and connects it with
cancellation and closing. |
Modifier and Type | Field and Description |
---|---|
protected CloseableRegistry |
snapshotCloseableRegistry
Registers streams that can block in I/O during snapshot.
|
Modifier | Constructor and Description |
---|---|
protected |
AsyncSnapshotCallable() |
Modifier and Type | Method and Description |
---|---|
T |
call() |
protected abstract T |
callInternal()
This method implements the (async) snapshot logic.
|
protected void |
cancel() |
protected abstract void |
cleanupProvidedResources()
This method implements the cleanup of resources that have been passed in (from the sync
part).
|
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.
|
AsyncSnapshotCallable.AsyncSnapshotTask |
toAsyncSnapshotFutureTask(CloseableRegistry taskRegistry)
Creates a future task from this and registers it with the given
CloseableRegistry . |
@Nonnull protected final CloseableRegistry snapshotCloseableRegistry
@VisibleForTesting protected void cancel()
public AsyncSnapshotCallable.AsyncSnapshotTask toAsyncSnapshotFutureTask(@Nonnull CloseableRegistry taskRegistry) throws IOException
CloseableRegistry
.
The task is unregistered again in FutureTask.done()
.IOException
protected abstract T callInternal() throws Exception
Exception
protected abstract void cleanupProvidedResources()
callInternal()
.protected void logAsyncSnapshotComplete(long startTime)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.