K
- The key by which state is keyed.public class HeapKeyedStateBackend<K> extends AbstractKeyedStateBackend<K>
AbstractKeyedStateBackend
that keeps state on the Java Heap and will serialize state to
streams provided by a CheckpointStreamFactory
upon checkpointing.KeyedStateBackend.KeySelectionListener<K>
cancelStreamRegistry, keyContext, keyGroupCompressionDecorator, keyGroupRange, keySerializer, kvStateRegistry, numberOfKeyGroups, ttlTimeProvider, userCodeClassLoader
Constructor and Description |
---|
HeapKeyedStateBackend(TaskKvStateRegistry kvStateRegistry,
TypeSerializer<K> keySerializer,
ClassLoader userCodeClassLoader,
ExecutionConfig executionConfig,
TtlTimeProvider ttlTimeProvider,
CloseableRegistry cancelStreamRegistry,
StreamCompressionDecorator keyGroupCompressionDecorator,
Map<String,StateTable<K,?,?>> registeredKVStates,
Map<String,HeapPriorityQueueSnapshotRestoreWrapper> registeredPQStates,
LocalRecoveryConfig localRecoveryConfig,
HeapPriorityQueueSetFactory priorityQueueSetFactory,
org.apache.flink.runtime.state.heap.HeapSnapshotStrategy<K> snapshotStrategy,
InternalKeyContext<K> keyContext) |
Modifier and Type | Method and Description |
---|---|
<N,S extends State,T> |
applyToAllKeys(N namespace,
TypeSerializer<N> namespaceSerializer,
StateDescriptor<S,T> stateDescriptor,
KeyedStateFunction<K,S> function)
Applies the provided
KeyedStateFunction to the state with the provided
StateDescriptor of all the currently active keys. |
<T extends HeapPriorityQueueElement & PriorityComparable & Keyed> |
create(String stateName,
TypeSerializer<T> byteOrderedElementSerializer)
Creates a
KeyGroupedInternalPriorityQueue . |
<N,SV,SEV,S extends State,IS extends S> |
createInternalState(TypeSerializer<N> namespaceSerializer,
StateDescriptor<S,SV> stateDesc,
StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory)
Creates and returns a new
InternalKvState . |
<N> java.util.stream.Stream<K> |
getKeys(String state,
N namespace) |
LocalRecoveryConfig |
getLocalRecoveryConfig() |
void |
notifyCheckpointComplete(long checkpointId)
This method is called as a notification once a distributed checkpoint has been completed.
|
int |
numKeyValueStateEntries()
Returns the total number of state entries across all keys/namespaces.
|
int |
numKeyValueStateEntries(Object namespace)
Returns the total number of state entries across all keys for the given namespace.
|
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 given
CheckpointStreamFactory and
returns a @RunnableFuture that gives a state handle to the snapshot. |
boolean |
supportsAsynchronousSnapshots() |
String |
toString() |
close, deregisterKeySelectionListener, dispose, getCurrentKey, getCurrentKeyGroupIndex, getKeyGroupCompressionDecorator, getKeyGroupRange, getKeySerializer, getNumberOfKeyGroups, getOrCreateKeyedState, getPartitionedState, registerKeySelectionListener, requiresLegacySynchronousTimerSnapshots, setCurrentKey
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createInternalState
public HeapKeyedStateBackend(TaskKvStateRegistry kvStateRegistry, TypeSerializer<K> keySerializer, ClassLoader userCodeClassLoader, ExecutionConfig executionConfig, TtlTimeProvider ttlTimeProvider, CloseableRegistry cancelStreamRegistry, StreamCompressionDecorator keyGroupCompressionDecorator, Map<String,StateTable<K,?,?>> registeredKVStates, Map<String,HeapPriorityQueueSnapshotRestoreWrapper> registeredPQStates, LocalRecoveryConfig localRecoveryConfig, HeapPriorityQueueSetFactory priorityQueueSetFactory, org.apache.flink.runtime.state.heap.HeapSnapshotStrategy<K> snapshotStrategy, InternalKeyContext<K> keyContext)
@Nonnull public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T> create(@Nonnull String stateName, @Nonnull TypeSerializer<T> byteOrderedElementSerializer)
PriorityQueueSetFactory
KeyGroupedInternalPriorityQueue
.T
- type of the stored elements.stateName
- unique name for associated with this queue.byteOrderedElementSerializer
- a serializer that with a format that is lexicographically ordered in
alignment with elementPriorityComparator.public <N> java.util.stream.Stream<K> getKeys(String state, N namespace)
state
- State variable for which existing keys will be returned.namespace
- Namespace for which existing keys will be returned.@Nonnull public <N,SV,SEV,S extends State,IS extends S> IS createInternalState(@Nonnull TypeSerializer<N> namespaceSerializer, @Nonnull StateDescriptor<S,SV> stateDesc, @Nonnull StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory) throws Exception
KeyedStateFactory
InternalKvState
.N
- The type of the namespace.SV
- The type of the stored state value.SEV
- The type of the stored state value or entry for collection types (list or map).S
- The type of the public API state.IS
- The type of internal state.namespaceSerializer
- TypeSerializer for the state namespace.stateDesc
- The StateDescriptor
that contains the name of the state.snapshotTransformFactory
- factory of state snapshot transformer.Exception
@Nonnull public RunnableFuture<SnapshotResult<KeyedStateHandle>> snapshot(long checkpointId, long timestamp, @Nonnull CheckpointStreamFactory streamFactory, @Nonnull CheckpointOptions checkpointOptions) throws IOException
SnapshotStrategy
CheckpointStreamFactory
and
returns a @RunnableFuture
that 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.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.StateObject
.IOException
public void notifyCheckpointComplete(long checkpointId)
CheckpointListener
checkpointId
- The ID of the checkpoint that has been completed.public <N,S extends State,T> void applyToAllKeys(N namespace, TypeSerializer<N> namespaceSerializer, StateDescriptor<S,T> stateDescriptor, KeyedStateFunction<K,S> function) throws Exception
KeyedStateBackend
KeyedStateFunction
to the state with the provided
StateDescriptor
of all the currently active keys.applyToAllKeys
in interface KeyedStateBackend<K>
applyToAllKeys
in class AbstractKeyedStateBackend<K>
N
- The type of the namespace.S
- The type of the state.namespace
- the namespace of the state.namespaceSerializer
- the serializer for the namespace.stateDescriptor
- the descriptor of the state to which the function is going to be applied.function
- the function to be applied to the keyed state.Exception
KeyedStateBackend
@VisibleForTesting public int numKeyValueStateEntries()
numKeyValueStateEntries
in class AbstractKeyedStateBackend<K>
@VisibleForTesting public int numKeyValueStateEntries(Object namespace)
public boolean supportsAsynchronousSnapshots()
supportsAsynchronousSnapshots
in class AbstractKeyedStateBackend<K>
@VisibleForTesting public LocalRecoveryConfig getLocalRecoveryConfig()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.