Package org.apache.flink.runtime.state
Interface SharedStateRegistry
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
SharedStateRegistryImpl
public interface SharedStateRegistry extends AutoCloseable
This registry manages state that is shared across (incremental) checkpoints, and is responsible for deleting shared state that is no longer used in any valid checkpoint.A
SharedStateRegistry
will be deployed in theCheckpointCoordinator
to keep track of usage ofStreamStateHandle
s by a key that (logically) identifies them.
-
-
Field Summary
Fields Modifier and Type Field Description static SharedStateRegistryFactory
DEFAULT_FACTORY
A singleton object for the default implementation of aSharedStateRegistryFactory
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
checkpointCompleted(long checkpointId)
void
registerAll(Iterable<? extends CompositeStateHandle> stateHandles, long checkpointID)
Register given shared states in the registry.void
registerAllAfterRestored(CompletedCheckpoint checkpoint, RecoveryClaimMode mode)
Set the lowest checkpoint ID below which no state is discarded, inclusive.default StreamStateHandle
registerReference(SharedStateRegistryKey registrationKey, StreamStateHandle state, long checkpointID)
Shortcut forregisterReference(SharedStateRegistryKey, StreamStateHandle, long, boolean)
with preventDiscardingCreatedCheckpoint = false.StreamStateHandle
registerReference(SharedStateRegistryKey registrationKey, StreamStateHandle state, long checkpointID, boolean preventDiscardingCreatedCheckpoint)
Register a reference to the given shared state in the registry.Set<Long>
unregisterUnusedState(long lowestCheckpointID)
Unregister state that is not referenced by the given checkpoint ID or any newer.-
Methods inherited from interface java.lang.AutoCloseable
close
-
-
-
-
Field Detail
-
DEFAULT_FACTORY
static final SharedStateRegistryFactory DEFAULT_FACTORY
A singleton object for the default implementation of aSharedStateRegistryFactory
-
-
Method Detail
-
registerReference
default StreamStateHandle registerReference(SharedStateRegistryKey registrationKey, StreamStateHandle state, long checkpointID)
Shortcut forregisterReference(SharedStateRegistryKey, StreamStateHandle, long, boolean)
with preventDiscardingCreatedCheckpoint = false.
-
registerReference
StreamStateHandle registerReference(SharedStateRegistryKey registrationKey, StreamStateHandle state, long checkpointID, boolean preventDiscardingCreatedCheckpoint)
Register a reference to the given shared state in the registry. The registry key should be based on the physical identifier of the state. If there is already a state handle registered under the same key and the 'new' state is not equal to the old one, an exception will be thrown.IMPORTANT: the caller must use the returned state handle instead of the passed one because the registry might replace or update it.
- Parameters:
state
- the shared state for which we register a reference.checkpointID
- which uses the statepreventDiscardingCreatedCheckpoint
- as long as this state is still in use. The "checkpoint that created the state" is recorded on the first state registration.- Returns:
- the state handle registered under the given key. It might differ from the passed state handle, e.g. if it was a placeholder.
-
unregisterUnusedState
Set<Long> unregisterUnusedState(long lowestCheckpointID)
Unregister state that is not referenced by the given checkpoint ID or any newer.- Parameters:
lowestCheckpointID
- which is still valid.- Returns:
- a set of checkpointID which is still in use.
-
registerAll
void registerAll(Iterable<? extends CompositeStateHandle> stateHandles, long checkpointID)
Register given shared states in the registry.NOTE: For state from checkpoints from other jobs or runs (i.e. after recovery), please use
registerAllAfterRestored(CompletedCheckpoint, RecoveryClaimMode)
- Parameters:
stateHandles
- The shared states to register.checkpointID
- which uses the states.
-
registerAllAfterRestored
void registerAllAfterRestored(CompletedCheckpoint checkpoint, RecoveryClaimMode mode)
Set the lowest checkpoint ID below which no state is discarded, inclusive.After recovery from an incremental checkpoint, its state should NOT be discarded, even if
not used
anymore (unless recovering inCLAIM
mode).This should hold for both cases: when recovering from that initial checkpoint; and from any subsequent checkpoint derived from it.
-
checkpointCompleted
void checkpointCompleted(long checkpointId)
-
-