Package org.apache.flink.state.changelog
Class ChangelogKeyedStateBackend<K>
java.lang.Object
org.apache.flink.state.changelog.ChangelogKeyedStateBackend<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,org.apache.flink.runtime.state.CheckpointableKeyedStateBackend<K>,org.apache.flink.runtime.state.KeyedStateBackend<K>,org.apache.flink.runtime.state.KeyedStateFactory,org.apache.flink.runtime.state.PriorityQueueSetFactory,org.apache.flink.runtime.state.Snapshotable<org.apache.flink.runtime.state.SnapshotResult<org.apache.flink.runtime.state.KeyedStateHandle>>,org.apache.flink.runtime.state.TestableKeyedStateBackend<K>,org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTarget,org.apache.flink.util.Disposable
@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
A
KeyedStateBackend that keeps state on the underlying delegated keyed state backend as
well as on the state change log.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.flink.runtime.state.KeyedStateBackend
org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K extends Object> -
Field Summary
Fields inherited from interface org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTarget
NO_OP -
Constructor Summary
ConstructorsConstructorDescriptionChangelogKeyedStateBackend(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) 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) -
Method Summary
Modifier and TypeMethodDescription<N,S extends org.apache.flink.api.common.state.State, T>
voidapplyToAllKeys(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) voidclose()<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(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>
IScreateOrUpdateInternalState(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) booleanderegisterKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener) voiddispose()org.apache.flink.runtime.state.KeyedStateBackend<K>getDelegatedKeyedStateBackend(boolean recursive) org.apache.flink.runtime.state.KeyGroupRangegetKeysAndNamespaces(String state) org.apache.flink.api.common.typeutils.TypeSerializer<K><N,S extends org.apache.flink.api.common.state.State, T>
SgetOrCreateKeyedState(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>
SgetPartitionedState(N namespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.StateDescriptor<S, ?> stateDescriptor) voidhandleMaterializationFailureOrCancellation(long materializationID, org.apache.flink.runtime.state.changelog.SequenceNumber upTo, Throwable cause) voidhandleMaterializationResult(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>Initialize state materialization so that materialized data can be persisted durably and included into the checkpoint.booleanvoidnotifyCheckpointAborted(long checkpointId) voidnotifyCheckpointComplete(long checkpointId) voidnotifyCheckpointSubsumed(long checkpointId) intvoidregisterCloseable(Closeable closeable) voidregisterKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener) org.apache.flink.runtime.state.SavepointResources<K>voidsetCurrentKey(K newKey) voidsetCurrentKeyAndKeyGroup(K newKey, int newKeyGroupIndex) 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) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.runtime.state.KeyedStateFactory
createOrUpdateInternalState, createOrUpdateInternalStateMethods inherited from interface org.apache.flink.runtime.state.PriorityQueueSetFactory
create
-
Constructor Details
-
ChangelogKeyedStateBackend
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.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) -
ChangelogKeyedStateBackend
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)
-
-
Method Details
-
getKeyGroupRange
public org.apache.flink.runtime.state.KeyGroupRange getKeyGroupRange()- Specified by:
getKeyGroupRangein interfaceorg.apache.flink.runtime.state.CheckpointableKeyedStateBackend<K>
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
setCurrentKey
- Specified by:
setCurrentKeyin interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
getCurrentKey
- Specified by:
getCurrentKeyin interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
setCurrentKeyAndKeyGroup
- Specified by:
setCurrentKeyAndKeyGroupin interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
getKeySerializer
- Specified by:
getKeySerializerin interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
getKeys
- Specified by:
getKeysin interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
getKeysAndNamespaces
- Specified by:
getKeysAndNamespacesin interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
dispose
public void dispose()- Specified by:
disposein interfaceorg.apache.flink.util.Disposable- Specified by:
disposein interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
registerKeySelectionListener
public void registerKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener) - Specified by:
registerKeySelectionListenerin interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
deregisterKeySelectionListener
public boolean deregisterKeySelectionListener(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener) - Specified by:
deregisterKeySelectionListenerin interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
applyToAllKeys
public <N,S extends org.apache.flink.api.common.state.State, void applyToAllKeysT> (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, throws ExceptionS> function) -
getPartitionedState
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 -
snapshot
@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 -
create
@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) - Specified by:
createin interfaceorg.apache.flink.runtime.state.PriorityQueueSetFactory
-
numKeyValueStateEntries
@VisibleForTesting public int numKeyValueStateEntries()- Specified by:
numKeyValueStateEntriesin interfaceorg.apache.flink.runtime.state.TestableKeyedStateBackend<K>
-
isSafeToReuseKVState
public boolean isSafeToReuseKVState()- Specified by:
isSafeToReuseKVStatein interfaceorg.apache.flink.runtime.state.KeyedStateBackend<K>
-
savepoint
-
notifyCheckpointComplete
- Specified by:
notifyCheckpointCompletein interfaceorg.apache.flink.api.common.state.CheckpointListener- Throws:
Exception
-
notifyCheckpointAborted
- Specified by:
notifyCheckpointAbortedin interfaceorg.apache.flink.api.common.state.CheckpointListener- Throws:
Exception
-
getOrCreateKeyedState
public <N,S extends org.apache.flink.api.common.state.State, S getOrCreateKeyedStateT> (org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.StateDescriptor<S, T> stateDescriptor) throws Exception -
createOrUpdateInternalState
@Nonnull public <N,SV, IS createOrUpdateInternalStateSEV, S extends org.apache.flink.api.common.state.State, IS extends S> (@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- Specified by:
createOrUpdateInternalStatein interfaceorg.apache.flink.runtime.state.KeyedStateFactory- Throws:
Exception
-
registerCloseable
-
initMaterialization
public Optional<org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationRunnable> initMaterialization() throws ExceptionInitialize state materialization so that materialized data can be persisted durably and included into the checkpoint.This method is not thread safe. It should be called either under a lock or through task mailbox executor.
- Specified by:
initMaterializationin interfaceorg.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTarget- Returns:
- a tuple of - future snapshot result from the underlying state backend - a
SequenceNumberidentifying the latest change in the changelog - Throws:
Exception
-
handleMaterializationResult
public 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. It should be called either under a lock or through task mailbox executor.- Specified by:
handleMaterializationResultin interfaceorg.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTarget
-
handleMaterializationFailureOrCancellation
public void handleMaterializationFailureOrCancellation(long materializationID, org.apache.flink.runtime.state.changelog.SequenceNumber upTo, Throwable cause) - Specified by:
handleMaterializationFailureOrCancellationin interfaceorg.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTarget
-
getDelegatedKeyedStateBackend
public org.apache.flink.runtime.state.KeyedStateBackend<K> getDelegatedKeyedStateBackend(boolean recursive) - Specified by:
getDelegatedKeyedStateBackendin interfaceorg.apache.flink.runtime.state.TestableKeyedStateBackend<K>
-
notifyCheckpointSubsumed
- Specified by:
notifyCheckpointSubsumedin interfaceorg.apache.flink.api.common.state.InternalCheckpointListener- Throws:
Exception
-
getChangelogRestoreTarget
-