K - The key by which state is keyed.@Internal public class ChangelogKeyedStateBackend<K> extends Object implements org.apache.flink.runtime.state.CheckpointableKeyedStateBackend<K>, org.apache.flink.api.common.state.CheckpointListener, org.apache.flink.runtime.state.TestableKeyedStateBackend<K>, org.apache.flink.api.common.state.InternalCheckpointListener, org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTarget
KeyedStateBackend that keeps state on the underlying delegated keyed state backend as
well as on the state change log.| Constructor and Description |
|---|
ChangelogKeyedStateBackend(org.apache.flink.runtime.state.AbstractKeyedStateBackend<K> keyedStateBackend,
String subtaskName,
org.apache.flink.api.common.ExecutionConfig executionConfig,
org.apache.flink.runtime.state.ttl.TtlTimeProvider ttlTimeProvider,
org.apache.flink.state.changelog.ChangelogStateBackendMetricGroup metricGroup,
org.apache.flink.runtime.state.changelog.StateChangelogWriter<? extends org.apache.flink.runtime.state.changelog.ChangelogStateHandle> stateChangelogWriter,
Collection<org.apache.flink.runtime.state.changelog.ChangelogStateBackendHandle> initialState,
org.apache.flink.runtime.state.CheckpointStorageWorkerView checkpointStorageWorkerView,
ChangelogStateFactory changelogStateFactory) |
ChangelogKeyedStateBackend(org.apache.flink.runtime.state.AbstractKeyedStateBackend<K> keyedStateBackend,
String subtaskName,
org.apache.flink.api.common.ExecutionConfig executionConfig,
org.apache.flink.runtime.state.ttl.TtlTimeProvider ttlTimeProvider,
org.apache.flink.metrics.MetricGroup metricGroup,
org.apache.flink.runtime.state.changelog.StateChangelogWriter<? extends org.apache.flink.runtime.state.changelog.ChangelogStateHandle> stateChangelogWriter,
Collection<org.apache.flink.runtime.state.changelog.ChangelogStateBackendHandle> initialState,
org.apache.flink.runtime.state.CheckpointStorageWorkerView checkpointStorageWorkerView) |
| Modifier and Type | Method and Description |
|---|---|
<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,
org.apache.flink.runtime.state.KeyedStateFunction<K,S> function) |
void |
close() |
<T extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement & org.apache.flink.runtime.state.PriorityComparable<? super T> & org.apache.flink.runtime.state.Keyed<?>> |
create(String stateName,
org.apache.flink.api.common.typeutils.TypeSerializer<T> byteOrderedElementSerializer) |
<N,SV,SEV,S extends org.apache.flink.api.common.state.State,IS extends S> |
createOrUpdateInternalState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,SV> stateDesc,
org.apache.flink.runtime.state.StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory) |
boolean |
deregisterKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener) |
void |
dispose() |
ChangelogRestoreTarget<K> |
getChangelogRestoreTarget() |
K |
getCurrentKey() |
org.apache.flink.runtime.state.KeyedStateBackend<K> |
getDelegatedKeyedStateBackend(boolean recursive) |
org.apache.flink.runtime.state.KeyGroupRange |
getKeyGroupRange() |
<N> Stream<K> |
getKeys(List<String> states,
N namespace) |
<N> Stream<K> |
getKeys(String state,
N namespace) |
<N> Stream<org.apache.flink.api.java.tuple.Tuple2<K,N>> |
getKeysAndNamespaces(String state) |
org.apache.flink.api.common.typeutils.TypeSerializer<K> |
getKeySerializer() |
<N,S extends org.apache.flink.api.common.state.State,T> |
getOrCreateKeyedState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,T> stateDescriptor) |
<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) |
void |
handleMaterializationFailureOrCancellation(long materializationID,
org.apache.flink.runtime.state.changelog.SequenceNumber upTo,
Throwable cause) |
void |
handleMaterializationResult(org.apache.flink.runtime.state.SnapshotResult<org.apache.flink.runtime.state.KeyedStateHandle> materializedSnapshot,
long materializationID,
org.apache.flink.runtime.state.changelog.SequenceNumber upTo)
This method is not thread safe.
|
Optional<org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationRunnable> |
initMaterialization()
Initialize state materialization so that materialized data can be persisted durably and
included into the checkpoint.
|
boolean |
isSafeToReuseKVState() |
void |
notifyCheckpointAborted(long checkpointId) |
void |
notifyCheckpointComplete(long checkpointId) |
void |
notifyCheckpointSubsumed(long checkpointId) |
int |
numKeyValueStateEntries() |
void |
registerCloseable(Closeable closeable) |
void |
registerKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener) |
org.apache.flink.runtime.state.SavepointResources<K> |
savepoint() |
void |
setCurrentKey(K newKey) |
RunnableFuture<org.apache.flink.runtime.state.SnapshotResult<org.apache.flink.runtime.state.KeyedStateHandle>> |
snapshot(long checkpointId,
long timestamp,
org.apache.flink.runtime.state.CheckpointStreamFactory streamFactory,
org.apache.flink.runtime.checkpoint.CheckpointOptions checkpointOptions) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisStateImmutableInStateBackendpublic ChangelogKeyedStateBackend(org.apache.flink.runtime.state.AbstractKeyedStateBackend<K> keyedStateBackend, String subtaskName, org.apache.flink.api.common.ExecutionConfig executionConfig, org.apache.flink.runtime.state.ttl.TtlTimeProvider ttlTimeProvider, org.apache.flink.metrics.MetricGroup metricGroup, org.apache.flink.runtime.state.changelog.StateChangelogWriter<? extends org.apache.flink.runtime.state.changelog.ChangelogStateHandle> stateChangelogWriter, Collection<org.apache.flink.runtime.state.changelog.ChangelogStateBackendHandle> initialState, org.apache.flink.runtime.state.CheckpointStorageWorkerView checkpointStorageWorkerView)
public ChangelogKeyedStateBackend(org.apache.flink.runtime.state.AbstractKeyedStateBackend<K> keyedStateBackend, String subtaskName, org.apache.flink.api.common.ExecutionConfig executionConfig, org.apache.flink.runtime.state.ttl.TtlTimeProvider ttlTimeProvider, org.apache.flink.state.changelog.ChangelogStateBackendMetricGroup metricGroup, org.apache.flink.runtime.state.changelog.StateChangelogWriter<? extends org.apache.flink.runtime.state.changelog.ChangelogStateHandle> stateChangelogWriter, Collection<org.apache.flink.runtime.state.changelog.ChangelogStateBackendHandle> initialState, org.apache.flink.runtime.state.CheckpointStorageWorkerView checkpointStorageWorkerView, ChangelogStateFactory changelogStateFactory)
public org.apache.flink.runtime.state.KeyGroupRange getKeyGroupRange()
getKeyGroupRange in interface org.apache.flink.runtime.state.CheckpointableKeyedStateBackend<K>public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void setCurrentKey(K newKey)
setCurrentKey in interface org.apache.flink.runtime.state.KeyedStateBackend<K>public K getCurrentKey()
getCurrentKey in interface org.apache.flink.runtime.state.KeyedStateBackend<K>public org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
getKeySerializer in interface org.apache.flink.runtime.state.KeyedStateBackend<K>public <N> Stream<K> getKeys(String state, N namespace)
getKeys in interface org.apache.flink.runtime.state.KeyedStateBackend<K>public <N> Stream<K> getKeys(List<String> states, N namespace)
getKeys in interface org.apache.flink.runtime.state.KeyedStateBackend<K>public <N> Stream<org.apache.flink.api.java.tuple.Tuple2<K,N>> getKeysAndNamespaces(String state)
getKeysAndNamespaces in interface org.apache.flink.runtime.state.KeyedStateBackend<K>public void dispose()
dispose in interface org.apache.flink.runtime.state.KeyedStateBackend<K>dispose in interface org.apache.flink.util.Disposablepublic void registerKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener)
registerKeySelectionListener in interface org.apache.flink.runtime.state.KeyedStateBackend<K>public boolean deregisterKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener)
deregisterKeySelectionListener in interface org.apache.flink.runtime.state.KeyedStateBackend<K>public <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,
org.apache.flink.runtime.state.KeyedStateFunction<K,S> function)
throws Exception
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
@Nonnull public RunnableFuture<org.apache.flink.runtime.state.SnapshotResult<org.apache.flink.runtime.state.KeyedStateHandle>> snapshot(long checkpointId, long timestamp, @Nonnull org.apache.flink.runtime.state.CheckpointStreamFactory streamFactory, @Nonnull org.apache.flink.runtime.checkpoint.CheckpointOptions checkpointOptions) throws Exception
snapshot in interface org.apache.flink.runtime.state.Snapshotable<org.apache.flink.runtime.state.SnapshotResult<org.apache.flink.runtime.state.KeyedStateHandle>>Exception@Nonnull public <T extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement & org.apache.flink.runtime.state.PriorityComparable<? super T> & org.apache.flink.runtime.state.Keyed<?>> org.apache.flink.runtime.state.KeyGroupedInternalPriorityQueue<T> create(@Nonnull String stateName, @Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<T> byteOrderedElementSerializer)
create in interface org.apache.flink.runtime.state.PriorityQueueSetFactory@VisibleForTesting public int numKeyValueStateEntries()
numKeyValueStateEntries in interface org.apache.flink.runtime.state.TestableKeyedStateBackend<K>public boolean isSafeToReuseKVState()
isSafeToReuseKVState in interface org.apache.flink.runtime.state.KeyedStateBackend<K>@Nonnull public org.apache.flink.runtime.state.SavepointResources<K> savepoint() throws Exception
public void notifyCheckpointComplete(long checkpointId)
throws Exception
notifyCheckpointComplete in interface org.apache.flink.api.common.state.CheckpointListenerExceptionpublic void notifyCheckpointAborted(long checkpointId)
throws Exception
notifyCheckpointAborted in interface org.apache.flink.api.common.state.CheckpointListenerExceptionpublic <N,S extends org.apache.flink.api.common.state.State,T> S getOrCreateKeyedState(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
org.apache.flink.api.common.state.StateDescriptor<S,T> stateDescriptor)
throws Exception
@Nonnull public <N,SV,SEV,S extends org.apache.flink.api.common.state.State,IS extends S> IS createOrUpdateInternalState(@Nonnull org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, @Nonnull org.apache.flink.api.common.state.StateDescriptor<S,SV> stateDesc, @Nonnull org.apache.flink.runtime.state.StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory) throws Exception
createOrUpdateInternalState in interface org.apache.flink.runtime.state.KeyedStateFactoryExceptionpublic Optional<org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationRunnable> initMaterialization() throws Exception
This method is not thread safe. It should be called either under a lock or through task mailbox executor.
initMaterialization in interface org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTargetSequenceNumber identifying the latest change in the changelogExceptionpublic void handleMaterializationResult(org.apache.flink.runtime.state.SnapshotResult<org.apache.flink.runtime.state.KeyedStateHandle> materializedSnapshot,
long materializationID,
org.apache.flink.runtime.state.changelog.SequenceNumber upTo)
handleMaterializationResult in interface org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTargetpublic void handleMaterializationFailureOrCancellation(long materializationID,
org.apache.flink.runtime.state.changelog.SequenceNumber upTo,
Throwable cause)
handleMaterializationFailureOrCancellation in interface org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTargetpublic org.apache.flink.runtime.state.KeyedStateBackend<K> getDelegatedKeyedStateBackend(boolean recursive)
getDelegatedKeyedStateBackend in interface org.apache.flink.runtime.state.TestableKeyedStateBackend<K>public void notifyCheckpointSubsumed(long checkpointId)
throws Exception
notifyCheckpointSubsumed in interface org.apache.flink.api.common.state.InternalCheckpointListenerExceptionpublic ChangelogRestoreTarget<K> getChangelogRestoreTarget()
Copyright © 2014–2025 The Apache Software Foundation. All rights reserved.