Package org.apache.flink.runtime.state
Class SharedStateRegistryImpl
- java.lang.Object
-
- org.apache.flink.runtime.state.SharedStateRegistryImpl
-
- All Implemented Interfaces:
AutoCloseable
,SharedStateRegistry
@Internal public class SharedStateRegistryImpl extends Object implements SharedStateRegistry
SharedStateRegistry
implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SharedStateRegistryImpl.EmptyDiscardStateObjectForRegister
An object with empty discardState for registering.
-
Field Summary
-
Fields inherited from interface org.apache.flink.runtime.state.SharedStateRegistry
DEFAULT_FACTORY
-
-
Constructor Summary
Constructors Constructor Description SharedStateRegistryImpl()
Default uses direct executor to delete unreferenced stateSharedStateRegistryImpl(Executor asyncDisposalExecutor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkpointCompleted(long checkpointId)
void
close()
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.StreamStateHandle
registerReference(SharedStateRegistryKey registrationKey, StreamStateHandle newHandle, long checkpointID, boolean preventDiscardingCreatedCheckpoint)
Register a reference to the given shared state in the registry.String
toString()
Set<Long>
unregisterUnusedState(long lowestCheckpointID)
Unregister state that is not referenced by the given checkpoint ID or any newer.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.flink.runtime.state.SharedStateRegistry
registerReference
-
-
-
-
Constructor Detail
-
SharedStateRegistryImpl
public SharedStateRegistryImpl()
Default uses direct executor to delete unreferenced state
-
SharedStateRegistryImpl
public SharedStateRegistryImpl(Executor asyncDisposalExecutor)
-
-
Method Detail
-
registerReference
public StreamStateHandle registerReference(SharedStateRegistryKey registrationKey, StreamStateHandle newHandle, long checkpointID, boolean preventDiscardingCreatedCheckpoint)
Description copied from interface:SharedStateRegistry
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.
- Specified by:
registerReference
in interfaceSharedStateRegistry
newHandle
- 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
public Set<Long> unregisterUnusedState(long lowestCheckpointID)
Description copied from interface:SharedStateRegistry
Unregister state that is not referenced by the given checkpoint ID or any newer.- Specified by:
unregisterUnusedState
in interfaceSharedStateRegistry
- Parameters:
lowestCheckpointID
- which is still valid.- Returns:
- a set of checkpointID which is still in use.
-
registerAll
public void registerAll(Iterable<? extends CompositeStateHandle> stateHandles, long checkpointID)
Description copied from interface:SharedStateRegistry
Register given shared states in the registry.NOTE: For state from checkpoints from other jobs or runs (i.e. after recovery), please use
SharedStateRegistry.registerAllAfterRestored(CompletedCheckpoint, RecoveryClaimMode)
- Specified by:
registerAll
in interfaceSharedStateRegistry
- Parameters:
stateHandles
- The shared states to register.checkpointID
- which uses the states.
-
registerAllAfterRestored
public void registerAllAfterRestored(CompletedCheckpoint checkpoint, RecoveryClaimMode mode)
Description copied from interface:SharedStateRegistry
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.
- Specified by:
registerAllAfterRestored
in interfaceSharedStateRegistry
-
checkpointCompleted
public void checkpointCompleted(long checkpointId)
- Specified by:
checkpointCompleted
in interfaceSharedStateRegistry
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-