Package org.apache.flink.runtime.state
Interface AsyncKeyedStateBackend<K>
- All Superinterfaces:
AsyncExecutionController.SwitchContextListener<K>,AutoCloseable,org.apache.flink.api.common.state.CheckpointListener,Closeable,org.apache.flink.util.Disposable,org.apache.flink.api.common.state.InternalCheckpointListener,PriorityQueueSetFactory,Snapshotable<SnapshotResult<KeyedStateHandle>>
- All Known Implementing Classes:
AsyncKeyedStateBackendAdaptor
@Internal
public interface AsyncKeyedStateBackend<K>
extends Snapshotable<SnapshotResult<KeyedStateHandle>>, org.apache.flink.api.common.state.InternalCheckpointListener, PriorityQueueSetFactory, org.apache.flink.util.Disposable, Closeable, AsyncExecutionController.SwitchContextListener<K>
An async keyed state backend provides methods supporting to access keyed state asynchronously and
in batch.
-
Method Summary
Modifier and TypeMethodDescriptionCreates aStateExecutorwhich supports to execute a batch of state requests asynchronously.<N,S extends InternalKeyedState, SV>
ScreateStateInternal(N defaultNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.v2.StateDescriptor<SV> stateDesc) Creates and returns a new state for internal usage.voiddispose()Returns the key groups which this state backend is responsible for.<N,S extends org.apache.flink.api.common.state.v2.State, SV>
SgetOrCreateKeyedState(N defaultNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.v2.StateDescriptor<SV> stateDesc) Creates or retrieves a keyed state backed by this state backend.default booleanWhether it's safe to reuse key-values from the state-backend, e.g for the purpose of optimization.default booleanrequiresLegacySynchronousTimerSnapshots(SnapshotType checkpointType) Whether the keyed state backend requires legacy synchronous timer snapshots.voidsetup(StateRequestHandler stateRequestHandler) Initializes with some contexts.default voidswitchContext(RecordContext<K> context) By default, a state backend does nothing when a key is switched in async processing.Methods inherited from interface org.apache.flink.api.common.state.CheckpointListener
notifyCheckpointAborted, notifyCheckpointCompleteMethods inherited from interface org.apache.flink.api.common.state.InternalCheckpointListener
notifyCheckpointSubsumedMethods inherited from interface org.apache.flink.runtime.state.PriorityQueueSetFactory
create, createMethods inherited from interface org.apache.flink.runtime.state.Snapshotable
snapshot
-
Method Details
-
setup
Initializes with some contexts.- Parameters:
stateRequestHandler- which handles state request.
-
getOrCreateKeyedState
<N,S extends org.apache.flink.api.common.state.v2.State, S getOrCreateKeyedStateSV> (N defaultNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.v2.StateDescriptor<SV> stateDesc) throws Exception Creates or retrieves a keyed state backed by this state backend.- 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.- Returns:
- A new key/value state backed by this backend.
- Throws:
Exception- Exceptions may occur during initialization of the state and should be forwarded.
-
createStateInternal
@Nonnull <N,S extends InternalKeyedState, S createStateInternalSV> (@Nonnull N defaultNamespace, @Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, @Nonnull org.apache.flink.api.common.state.v2.StateDescriptor<SV> stateDesc) throws Exception Creates and returns a new state for internal usage.- 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
Creates 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.- Returns:
- a
StateExecutorwhich supports to execute a batch of state requests asynchronously.
-
getKeyGroupRange
KeyGroupRange getKeyGroupRange()Returns the key groups which this state backend is responsible for. -
switchContext
By default, a state backend does nothing when a key is switched in async processing.- Specified by:
switchContextin interfaceAsyncExecutionController.SwitchContextListener<K>
-
requiresLegacySynchronousTimerSnapshots
Whether the keyed state backend requires legacy synchronous timer snapshots.- Parameters:
checkpointType-- Returns:
- true as default in case of AsyncKeyedStateBackend
-
isSafeToReuseKVState
default boolean isSafeToReuseKVState()Whether it's safe to reuse key-values from the state-backend, e.g for the purpose of optimization.NOTE: this method should not be used to check for
InternalPriorityQueue, as the priority queue could be stored on different locations, e.g ForSt state-backend could store that on JVM heap if configuring HEAP as the time-service factory.- Returns:
- returns ture if safe to reuse the key-values from the state-backend.
-
dispose
void dispose()- Specified by:
disposein interfaceorg.apache.flink.util.Disposable
-