Class DefaultCompletedCheckpointStore<R extends ResourceVersion<R>>
- All Implemented Interfaces:
CompletedCheckpointStore
CompletedCheckpointStore. Combined with different StateHandleStore, we could persist the completed
checkpoints to various storage.
During recovery, the latest checkpoint is read from StateHandleStore. If there is more
than one, only the latest one is used and older ones are discarded (even if the maximum number of
retained checkpoints is greater than one).
If there is a network partition and multiple JobManagers run concurrent checkpoints for the same program, it is OK to take any valid successful checkpoint as long as the "history" of checkpoints is consistent. Currently, after recovery we start out with only a single checkpoint to circumvent those situations.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCompletedCheckpointStore(int maxNumberOfCheckpointsToRetain, StateHandleStore<CompletedCheckpoint, R> stateHandleStore, CheckpointStoreUtil completedCheckpointStoreUtil, Collection<CompletedCheckpoint> completedCheckpoints, SharedStateRegistry sharedStateRegistry, Executor executor) Creates aDefaultCompletedCheckpointStoreinstance. -
Method Summary
Modifier and TypeMethodDescriptionaddCheckpointAndSubsumeOldestOne(CompletedCheckpoint checkpoint, CheckpointsCleaner checkpointsCleaner, Runnable postCleanup) Synchronously writes the new checkpoints to state handle store and asynchronously removes older ones.Returns allCompletedCheckpointinstances.intReturns the max number of retained checkpoints.intReturns the current number of retained checkpoints.booleanThis method returns whether the completed checkpoint store requires checkpoints to be externalized.voidshutdown(org.apache.flink.api.common.JobStatus jobStatus, CheckpointsCleaner checkpointsCleaner) Shuts down the store.Methods inherited from class org.apache.flink.runtime.checkpoint.AbstractCompleteCheckpointStore
findLowest, getSharedStateRegistry, unregisterUnusedStateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.runtime.checkpoint.CompletedCheckpointStore
getLatestCheckpoint, getLatestCheckpointId
-
Constructor Details
-
Method Details
-
requiresExternalizedCheckpoints
public boolean requiresExternalizedCheckpoints()Description copied from interface:CompletedCheckpointStoreThis method returns whether the completed checkpoint store requires checkpoints to be externalized. Externalized checkpoints have their meta data persisted, which the checkpoint store can exploit (for example by simply pointing the persisted metadata).- Returns:
- True, if the store requires that checkpoints are externalized before being added, false if the store stores the metadata itself.
-
addCheckpointAndSubsumeOldestOne
public CompletedCheckpoint addCheckpointAndSubsumeOldestOne(CompletedCheckpoint checkpoint, CheckpointsCleaner checkpointsCleaner, Runnable postCleanup) throws Exception Synchronously writes the new checkpoints to state handle store and asynchronously removes older ones.- Parameters:
checkpoint- Completed checkpoint to add.- Returns:
- the subsumed oldest completed checkpoint if possible, return null if no checkpoint needs to be discarded on subsume.
- Throws:
PossibleInconsistentStateException- if adding the checkpoint failed and leaving the system in a possibly inconsistent state, i.e. it's uncertain whether the checkpoint metadata was fully written to the underlying systems or not.Exception
-
getAllCheckpoints
Description copied from interface:CompletedCheckpointStoreReturns allCompletedCheckpointinstances.Returns an empty list if no checkpoint has been added yet.
-
getNumberOfRetainedCheckpoints
public int getNumberOfRetainedCheckpoints()Description copied from interface:CompletedCheckpointStoreReturns the current number of retained checkpoints. -
getMaxNumberOfRetainedCheckpoints
public int getMaxNumberOfRetainedCheckpoints()Description copied from interface:CompletedCheckpointStoreReturns the max number of retained checkpoints. -
shutdown
public void shutdown(org.apache.flink.api.common.JobStatus jobStatus, CheckpointsCleaner checkpointsCleaner) throws Exception Description copied from interface:CompletedCheckpointStoreShuts down the store.The job status is forwarded and used to decide whether state should actually be discarded or kept.
SharedStateRegistry.unregisterUnusedState(long)andCheckpointsCleaner.cleanSubsumedCheckpoints(long, java.util.Set<java.lang.Long>, java.lang.Runnable, java.util.concurrent.Executor)should be called here to subsume unused state.- Specified by:
shutdownin interfaceCompletedCheckpointStore- Overrides:
shutdownin classAbstractCompleteCheckpointStore- Parameters:
jobStatus- Job state on shut downcheckpointsCleaner- that will cleanup completed checkpoints if needed- Throws:
Exception
-