Class AsyncKeyedStateBackendAdaptor<K>
- java.lang.Object
-
- org.apache.flink.runtime.state.v2.adaptor.AsyncKeyedStateBackendAdaptor<K>
-
- Type Parameters:
K- The key by which state is keyed.
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.flink.api.common.state.CheckpointListener,org.apache.flink.api.common.state.InternalCheckpointListener,AsyncExecutionController.SwitchContextListener<K>,AsyncKeyedStateBackend<K>,Snapshotable<SnapshotResult<KeyedStateHandle>>,org.apache.flink.util.Disposable
public class AsyncKeyedStateBackendAdaptor<K> extends Object implements AsyncKeyedStateBackend<K>
A adaptor that transformsKeyedStateBackendintoAsyncKeyedStateBackend.
-
-
Constructor Summary
Constructors Constructor Description AsyncKeyedStateBackendAdaptor(CheckpointableKeyedStateBackend<K> keyedStateBackend)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()<N,S extends org.apache.flink.api.common.state.v2.State,SV>
ScreateState(N defaultNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, StateDescriptor<SV> stateDesc)Creates and returns a new state.StateExecutorcreateStateExecutor()Creates aStateExecutorwhich supports to execute a batch of state requests asynchronously.voiddispose()voidnotifyCheckpointAborted(long checkpointId)voidnotifyCheckpointComplete(long checkpointId)voidnotifyCheckpointSubsumed(long checkpointId)voidsetup(StateRequestHandler stateRequestHandler)Initializes with some contexts.RunnableFuture<SnapshotResult<KeyedStateHandle>>snapshot(long checkpointId, long timestamp, CheckpointStreamFactory streamFactory, CheckpointOptions checkpointOptions)Operation that writes a snapshot into a stream that is provided by the givenCheckpointStreamFactoryand returns a @RunnableFuturethat gives a state handle to the snapshot.voidswitchContext(RecordContext<K> context)By default, a state backend does nothing when a key is switched in async processing.
-
-
-
Constructor Detail
-
AsyncKeyedStateBackendAdaptor
public AsyncKeyedStateBackendAdaptor(CheckpointableKeyedStateBackend<K> keyedStateBackend)
-
-
Method Detail
-
setup
public void setup(@Nonnull StateRequestHandler stateRequestHandler)Description copied from interface:AsyncKeyedStateBackendInitializes with some contexts.- Specified by:
setupin interfaceAsyncKeyedStateBackend<K>- Parameters:
stateRequestHandler- which handles state request.
-
createState
@Nonnull public <N,S extends org.apache.flink.api.common.state.v2.State,SV> S createState(@Nonnull N defaultNamespace, @Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, @Nonnull StateDescriptor<SV> stateDesc) throws ExceptionDescription copied from interface:AsyncKeyedStateBackendCreates and returns a new state.- Specified by:
createStatein interfaceAsyncKeyedStateBackend<K>- Type Parameters:
N- the type of namespace for partitioning.S- The type of the public API state.SV- The type of the stored state value.- Parameters:
defaultNamespace- the default namespace for this state.namespaceSerializer- the serializer for namespace.stateDesc- TheStateDescriptorthat contains the name of the state.- Throws:
Exception- Exceptions may occur during initialization of the state.
-
createStateExecutor
@Nonnull public StateExecutor createStateExecutor()
Description copied from interface:AsyncKeyedStateBackendCreates aStateExecutorwhich supports to execute a batch of state requests asynchronously.Notice that the
AsyncKeyedStateBackendis responsible for shutting down the StateExecutors created by itself when they are no longer in use.- Specified by:
createStateExecutorin interfaceAsyncKeyedStateBackend<K>- Returns:
- a
StateExecutorwhich supports to execute a batch of state requests asynchronously.
-
switchContext
public void switchContext(RecordContext<K> context)
Description copied from interface:AsyncKeyedStateBackendBy default, a state backend does nothing when a key is switched in async processing.- Specified by:
switchContextin interfaceAsyncExecutionController.SwitchContextListener<K>- Specified by:
switchContextin interfaceAsyncKeyedStateBackend<K>
-
dispose
public void dispose()
- Specified by:
disposein interfaceAsyncKeyedStateBackend<K>- Specified by:
disposein interfaceorg.apache.flink.util.Disposable
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
notifyCheckpointComplete
public void notifyCheckpointComplete(long checkpointId) throws Exception- Specified by:
notifyCheckpointCompletein interfaceorg.apache.flink.api.common.state.CheckpointListener- Throws:
Exception
-
notifyCheckpointAborted
public void notifyCheckpointAborted(long checkpointId) throws Exception- Specified by:
notifyCheckpointAbortedin interfaceorg.apache.flink.api.common.state.CheckpointListener- Throws:
Exception
-
notifyCheckpointSubsumed
public void notifyCheckpointSubsumed(long checkpointId) throws Exception- Specified by:
notifyCheckpointSubsumedin interfaceorg.apache.flink.api.common.state.InternalCheckpointListener- Throws:
Exception
-
snapshot
@Nonnull public RunnableFuture<SnapshotResult<KeyedStateHandle>> snapshot(long checkpointId, long timestamp, @Nonnull CheckpointStreamFactory streamFactory, @Nonnull CheckpointOptions checkpointOptions) throws Exception
Description copied from interface:SnapshotableOperation that writes a snapshot into a stream that is provided by the givenCheckpointStreamFactoryand returns a @RunnableFuturethat gives a state handle to the snapshot. It is up to the implementation if the operation is performed synchronous or asynchronous. In the later case, the returned Runnable must be executed first before obtaining the handle.- Specified by:
snapshotin interfaceSnapshotable<K>- Parameters:
checkpointId- The ID of the checkpoint.timestamp- The timestamp of the checkpoint.streamFactory- The factory that we can use for writing our state to streams.checkpointOptions- Options for how to perform this checkpoint.- Returns:
- A runnable future that will yield a
StateObject. - Throws:
Exception
-
-