K - Type of the key by which state is keyed.public abstract class AbstractKeyedStateBackend<K> extends Object implements CheckpointableKeyedStateBackend<K>, org.apache.flink.api.common.state.InternalCheckpointListener, TestableKeyedStateBackend<K>, InternalKeyContext<K>
Snapshotable.snapshot(long, long, CheckpointStreamFactory, CheckpointOptions).| 限定符和类型 | 类和说明 |
|---|---|
static interface |
AbstractKeyedStateBackend.PartitionStateFactory |
KeyedStateBackend.KeySelectionListener<K>| 限定符和类型 | 字段和说明 |
|---|---|
protected org.apache.flink.core.fs.CloseableRegistry |
cancelStreamRegistry
Registry for all opened streams, so they can be closed if the task using this backend is
closed.
|
protected InternalKeyContext<K> |
keyContext
The key context for this backend.
|
protected StreamCompressionDecorator |
keyGroupCompressionDecorator
Decorates the input and output streams to write key-groups compressed.
|
protected KeyGroupRange |
keyGroupRange
Range of key-groups for which this backend is responsible.
|
protected org.apache.flink.api.common.typeutils.TypeSerializer<K> |
keySerializer
The key serializer.
|
protected TaskKvStateRegistry |
kvStateRegistry
KvStateRegistry helper for this task.
|
protected LatencyTrackingStateConfig |
latencyTrackingStateConfig |
protected int |
numberOfKeyGroups
The number of key-groups aka max parallelism.
|
protected TtlTimeProvider |
ttlTimeProvider |
protected ClassLoader |
userCodeClassLoader |
| 限定符 | 构造器和说明 |
|---|---|
protected |
AbstractKeyedStateBackend(AbstractKeyedStateBackend<K> abstractKeyedStateBackend) |
|
AbstractKeyedStateBackend(TaskKvStateRegistry kvStateRegistry,
org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
ClassLoader userCodeClassLoader,
org.apache.flink.api.common.ExecutionConfig executionConfig,
TtlTimeProvider ttlTimeProvider,
LatencyTrackingStateConfig latencyTrackingStateConfig,
org.apache.flink.core.fs.CloseableRegistry cancelStreamRegistry,
InternalKeyContext<K> keyContext) |
|
AbstractKeyedStateBackend(TaskKvStateRegistry kvStateRegistry,
org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
ClassLoader userCodeClassLoader,
org.apache.flink.api.common.ExecutionConfig executionConfig,
TtlTimeProvider ttlTimeProvider,
LatencyTrackingStateConfig latencyTrackingStateConfig,
org.apache.flink.core.fs.CloseableRegistry cancelStreamRegistry,
StreamCompressionDecorator keyGroupCompressionDecorator,
InternalKeyContext<K> keyContext) |
| 限定符和类型 | 方法和说明 |
|---|---|
<N,S extends org.apache.flink.api.common.state.State,T> |
applyToAllKeys(N namespace,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.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. |
<N,S extends org.apache.flink.api.common.state.State,T> |
applyToAllKeys(N namespace,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,T> stateDescriptor,
KeyedStateFunction<K,S> function,
AbstractKeyedStateBackend.PartitionStateFactory partitionStateFactory) |
void |
close() |
boolean |
deregisterKeySelectionListener(KeyedStateBackend.KeySelectionListener<K> listener)
Stop calling listener registered in
KeyedStateBackend.registerKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K>). |
void |
dispose()
Closes the state backend, releasing all internal resources, but does not delete any
persistent checkpoint data.
|
K |
getCurrentKey()
Used by states to access the current key.
|
int |
getCurrentKeyGroupIndex()
Returns the key-group to which the current key belongs.
|
InternalKeyContext<K> |
getKeyContext() |
StreamCompressionDecorator |
getKeyGroupCompressionDecorator() |
KeyGroupRange |
getKeyGroupRange()
Returns the key groups which this state backend is responsible for.
|
org.apache.flink.api.common.typeutils.TypeSerializer<K> |
getKeySerializer() |
LatencyTrackingStateConfig |
getLatencyTrackingStateConfig() |
int |
getNumberOfKeyGroups()
Returns the number of key-groups aka max parallelism.
|
<N,S extends org.apache.flink.api.common.state.State,V> |
getOrCreateKeyedState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,V> stateDescriptor)
Creates or retrieves a keyed state backed by this state backend.
|
<N,S extends org.apache.flink.api.common.state.State> |
getPartitionedState(N namespace,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)
TODO: NOTE: This method does a lot of work caching / retrieving states just to update the
namespace.
|
void |
notifyCheckpointSubsumed(long checkpointId) |
int |
numKeyValueStatesByName() |
void |
publishQueryableStateIfEnabled(org.apache.flink.api.common.state.StateDescriptor<?,?> stateDescriptor,
InternalKvState<?,?,?> kvState) |
void |
registerKeySelectionListener(KeyedStateBackend.KeySelectionListener<K> listener)
State backend will call
KeyedStateBackend.KeySelectionListener.keySelected(K) when key context is switched
if supported. |
boolean |
requiresLegacySynchronousTimerSnapshots(SnapshotType checkpointType) |
void |
setCurrentKey(K newKey)
Sets the current key that is used for partitioned state.
|
void |
setCurrentKeyGroupIndex(int currentKeyGroupIndex)
Set current key group index of the context.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsavepointsnapshotnotifyCheckpointAborted, notifyCheckpointCompletegetDelegatedKeyedStateBackend, numKeyValueStateEntriesgetKeys, getKeysAndNamespaces, isSafeToReuseKVState, isStateImmutableInStateBackendcreateOrUpdateInternalState, createOrUpdateInternalState, createOrUpdateInternalStatecreate, createprotected final org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer
protected final int numberOfKeyGroups
protected final KeyGroupRange keyGroupRange
protected final TaskKvStateRegistry kvStateRegistry
protected org.apache.flink.core.fs.CloseableRegistry cancelStreamRegistry
protected final ClassLoader userCodeClassLoader
protected final TtlTimeProvider ttlTimeProvider
protected final LatencyTrackingStateConfig latencyTrackingStateConfig
protected final StreamCompressionDecorator keyGroupCompressionDecorator
protected final InternalKeyContext<K> keyContext
public AbstractKeyedStateBackend(TaskKvStateRegistry kvStateRegistry, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, ClassLoader userCodeClassLoader, org.apache.flink.api.common.ExecutionConfig executionConfig, TtlTimeProvider ttlTimeProvider, LatencyTrackingStateConfig latencyTrackingStateConfig, org.apache.flink.core.fs.CloseableRegistry cancelStreamRegistry, InternalKeyContext<K> keyContext)
public AbstractKeyedStateBackend(TaskKvStateRegistry kvStateRegistry, org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, ClassLoader userCodeClassLoader, org.apache.flink.api.common.ExecutionConfig executionConfig, TtlTimeProvider ttlTimeProvider, LatencyTrackingStateConfig latencyTrackingStateConfig, org.apache.flink.core.fs.CloseableRegistry cancelStreamRegistry, StreamCompressionDecorator keyGroupCompressionDecorator, InternalKeyContext<K> keyContext)
protected AbstractKeyedStateBackend(AbstractKeyedStateBackend<K> abstractKeyedStateBackend)
public void notifyCheckpointSubsumed(long checkpointId)
throws Exception
notifyCheckpointSubsumed 在接口中 org.apache.flink.api.common.state.InternalCheckpointListenerExceptionpublic void dispose()
dispose 在接口中 KeyedStateBackend<K>dispose 在接口中 org.apache.flink.util.Disposablepublic void setCurrentKey(K newKey)
KeyedStateBackendsetCurrentKey 在接口中 InternalKeyContext<K>setCurrentKey 在接口中 KeyedStateBackend<K>newKey - The new current key.KeyedStateBackendpublic void registerKeySelectionListener(KeyedStateBackend.KeySelectionListener<K> listener)
KeyedStateBackendKeyedStateBackend.KeySelectionListener.keySelected(K) when key context is switched
if supported.registerKeySelectionListener 在接口中 KeyedStateBackend<K>public boolean deregisterKeySelectionListener(KeyedStateBackend.KeySelectionListener<K> listener)
KeyedStateBackendKeyedStateBackend.registerKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K>).deregisterKeySelectionListener 在接口中 KeyedStateBackend<K>public org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
getKeySerializer 在接口中 KeyedStateBackend<K>KeyedStateBackendpublic K getCurrentKey()
InternalKeyContextgetCurrentKey 在接口中 InternalKeyContext<K>getCurrentKey 在接口中 KeyedStateBackend<K>KeyedStateBackendpublic int getCurrentKeyGroupIndex()
InternalKeyContextgetCurrentKeyGroupIndex 在接口中 InternalKeyContext<K>KeyedStateBackendpublic int getNumberOfKeyGroups()
InternalKeyContextgetNumberOfKeyGroups 在接口中 InternalKeyContext<K>KeyedStateBackendpublic KeyGroupRange getKeyGroupRange()
CheckpointableKeyedStateBackendgetKeyGroupRange 在接口中 CheckpointableKeyedStateBackend<K>getKeyGroupRange 在接口中 InternalKeyContext<K>KeyedStateBackendpublic <N,S extends org.apache.flink.api.common.state.State,T> void applyToAllKeys(N namespace,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,T> stateDescriptor,
KeyedStateFunction<K,S> function)
throws Exception
KeyedStateBackendKeyedStateFunction to the state with the provided StateDescriptor of all the currently active keys.applyToAllKeys 在接口中 KeyedStateBackend<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.ExceptionKeyedStateBackendpublic <N,S extends org.apache.flink.api.common.state.State,T> void applyToAllKeys(N namespace,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,T> stateDescriptor,
KeyedStateFunction<K,S> function,
AbstractKeyedStateBackend.PartitionStateFactory partitionStateFactory)
throws Exception
Exceptionpublic <N,S extends org.apache.flink.api.common.state.State,V> S getOrCreateKeyedState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,V> stateDescriptor)
throws Exception
KeyedStateBackendgetOrCreateKeyedState 在接口中 KeyedStateBackend<K>N - The type of the namespace.S - The type of the state.namespaceSerializer - The serializer used for the namespace type of the statestateDescriptor - The identifier for the state. This contains name and can create a
default state value.Exception - Exceptions may occur during initialization of the state and should be
forwarded.KeyedStateBackendpublic void publishQueryableStateIfEnabled(org.apache.flink.api.common.state.StateDescriptor<?,?> stateDescriptor,
InternalKvState<?,?,?> kvState)
public <N,S extends org.apache.flink.api.common.state.State> S getPartitionedState(N namespace,
org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,?> stateDescriptor)
throws Exception
getPartitionedState 在接口中 KeyedStateBackend<K>N - The type of the namespace.S - The type of the state.stateDescriptor - The identifier for the state. This contains name and can create a
default state value.Exception - Exceptions may occur during initialization of the state and should be
forwarded.KeyedStateBackendpublic void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableIOExceptionpublic LatencyTrackingStateConfig getLatencyTrackingStateConfig()
@VisibleForTesting public StreamCompressionDecorator getKeyGroupCompressionDecorator()
@VisibleForTesting public int numKeyValueStatesByName()
public boolean requiresLegacySynchronousTimerSnapshots(SnapshotType checkpointType)
public InternalKeyContext<K> getKeyContext()
public void setCurrentKeyGroupIndex(int currentKeyGroupIndex)
InternalKeyContextsetCurrentKeyGroupIndex 在接口中 InternalKeyContext<K>currentKeyGroupIndex - the current key group index to set to.Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.