Package org.apache.flink.runtime.state
Class TaskLocalStateStoreImpl
- java.lang.Object
-
- org.apache.flink.runtime.state.TaskLocalStateStoreImpl
-
- All Implemented Interfaces:
OwnedTaskLocalStateStore
,TaskLocalStateStore
- Direct Known Subclasses:
ChangelogTaskLocalStateStore
public class TaskLocalStateStoreImpl extends Object implements OwnedTaskLocalStateStore
Main implementation of aTaskLocalStateStore
.
-
-
Field Summary
Fields Modifier and Type Field Description protected AllocationID
allocationID
AllocationID of the owning slot.protected Executor
discardExecutor
Executor that runs the discarding of released state objects.protected boolean
disposed
Status flag if this store was already discarded.protected JobID
jobID
JobID from the owning subtask.protected JobVertexID
jobVertexID
JobVertexID of the owning subtask.protected LocalRecoveryConfig
localRecoveryConfig
The configured mode for local recovery.protected Object
lock
Lock for synchronisation on the storage map and the discarded status.protected SortedMap<Long,TaskStateSnapshot>
storedTaskStateByCheckpointID
Maps checkpoint ids to local TaskStateSnapshots.protected int
subtaskIndex
Subtask index of the owning subtask.static String
TASK_STATE_SNAPSHOT_FILENAME
-
Constructor Summary
Constructors Constructor Description TaskLocalStateStoreImpl(JobID jobID, AllocationID allocationID, JobVertexID jobVertexID, int subtaskIndex, LocalRecoveryConfig localRecoveryConfig, Executor discardExecutor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abortCheckpoint(long abortedCheckpointId)
Notifies that the checkpoint with the given id was confirmed as aborted.void
confirmCheckpoint(long confirmedCheckpointId)
Notifies that the checkpoint with the given id was confirmed as complete.protected void
deleteDirectory(File directory)
Helper method to delete a directory.CompletableFuture<Void>
dispose()
Disposes the state of all local snapshots managed by this object.protected File
getCheckpointDirectory(long checkpointId)
LocalRecoveryConfig
getLocalRecoveryConfig()
Returns theLocalRecoveryConfig
for this task local state store.protected LocalSnapshotDirectoryProvider
getLocalRecoveryDirectoryProvider()
protected void
pruneCheckpoints(LongPredicate pruningChecker, boolean breakOnceCheckerFalse)
Pruning the useless checkpoints, it should be called only when holding thelock
.void
pruneMatchingCheckpoints(LongPredicate matcher)
Remove all checkpoints from the store that match the given predicate.TaskStateSnapshot
retrieveLocalState(long checkpointID)
Returns the local state that is stored under the given checkpoint id or null if nothing was stored under the id.void
storeLocalState(long checkpointId, TaskStateSnapshot localState)
Stores the local state for the given checkpoint id.String
toString()
-
-
-
Field Detail
-
TASK_STATE_SNAPSHOT_FILENAME
public static final String TASK_STATE_SNAPSHOT_FILENAME
- See Also:
- Constant Field Values
-
jobID
@Nonnull protected final JobID jobID
JobID from the owning subtask.
-
allocationID
@Nonnull protected final AllocationID allocationID
AllocationID of the owning slot.
-
jobVertexID
@Nonnull protected final JobVertexID jobVertexID
JobVertexID of the owning subtask.
-
subtaskIndex
@Nonnegative protected final int subtaskIndex
Subtask index of the owning subtask.
-
localRecoveryConfig
@Nonnull protected final LocalRecoveryConfig localRecoveryConfig
The configured mode for local recovery.
-
discardExecutor
@Nonnull protected final Executor discardExecutor
Executor that runs the discarding of released state objects.
-
lock
@Nonnull protected final Object lock
Lock for synchronisation on the storage map and the discarded status.
-
disposed
protected boolean disposed
Status flag if this store was already discarded.
-
storedTaskStateByCheckpointID
@Nonnull protected final SortedMap<Long,TaskStateSnapshot> storedTaskStateByCheckpointID
Maps checkpoint ids to local TaskStateSnapshots.
-
-
Constructor Detail
-
TaskLocalStateStoreImpl
public TaskLocalStateStoreImpl(@Nonnull JobID jobID, @Nonnull AllocationID allocationID, @Nonnull JobVertexID jobVertexID, @Nonnegative int subtaskIndex, @Nonnull LocalRecoveryConfig localRecoveryConfig, @Nonnull Executor discardExecutor)
-
-
Method Detail
-
storeLocalState
public void storeLocalState(@Nonnegative long checkpointId, @Nullable TaskStateSnapshot localState)
Description copied from interface:TaskLocalStateStore
Stores the local state for the given checkpoint id.- Specified by:
storeLocalState
in interfaceTaskLocalStateStore
- Parameters:
checkpointId
- id for the checkpoint that created the local state that will be stored.localState
- the local state to store.
-
getCheckpointDirectory
protected File getCheckpointDirectory(long checkpointId)
-
getLocalRecoveryDirectoryProvider
protected LocalSnapshotDirectoryProvider getLocalRecoveryDirectoryProvider()
-
retrieveLocalState
@Nullable public TaskStateSnapshot retrieveLocalState(long checkpointID)
Description copied from interface:TaskLocalStateStore
Returns the local state that is stored under the given checkpoint id or null if nothing was stored under the id.- Specified by:
retrieveLocalState
in interfaceTaskLocalStateStore
- Parameters:
checkpointID
- the checkpoint id by which we search for local state.- Returns:
- the local state found for the given checkpoint id. Can be null
-
getLocalRecoveryConfig
@Nonnull public LocalRecoveryConfig getLocalRecoveryConfig()
Description copied from interface:TaskLocalStateStore
Returns theLocalRecoveryConfig
for this task local state store.- Specified by:
getLocalRecoveryConfig
in interfaceTaskLocalStateStore
-
confirmCheckpoint
public void confirmCheckpoint(long confirmedCheckpointId)
Description copied from interface:TaskLocalStateStore
Notifies that the checkpoint with the given id was confirmed as complete. This prunes the checkpoint history and removes all local states with a checkpoint id that is smaller than the newly confirmed checkpoint id.- Specified by:
confirmCheckpoint
in interfaceTaskLocalStateStore
-
abortCheckpoint
public void abortCheckpoint(long abortedCheckpointId)
Description copied from interface:TaskLocalStateStore
Notifies that the checkpoint with the given id was confirmed as aborted. This prunes the checkpoint history and removes states with a checkpoint id that is equal to the newly aborted checkpoint id.- Specified by:
abortCheckpoint
in interfaceTaskLocalStateStore
-
pruneMatchingCheckpoints
public void pruneMatchingCheckpoints(@Nonnull LongPredicate matcher)
Description copied from interface:TaskLocalStateStore
Remove all checkpoints from the store that match the given predicate.- Specified by:
pruneMatchingCheckpoints
in interfaceTaskLocalStateStore
- Parameters:
matcher
- the predicate that selects the checkpoints for pruning.
-
dispose
public CompletableFuture<Void> dispose()
Disposes the state of all local snapshots managed by this object.- Specified by:
dispose
in interfaceOwnedTaskLocalStateStore
-
deleteDirectory
protected void deleteDirectory(File directory) throws IOException
Helper method to delete a directory.- Throws:
IOException
-
pruneCheckpoints
protected void pruneCheckpoints(LongPredicate pruningChecker, boolean breakOnceCheckerFalse)
Pruning the useless checkpoints, it should be called only when holding thelock
.
-
-