public class CheckpointCoordinator extends Object
Constructor and Description |
---|
CheckpointCoordinator(JobID job,
long baseInterval,
long checkpointTimeout,
long minPauseBetweenCheckpoints,
int maxConcurrentCheckpointAttempts,
CheckpointRetentionPolicy retentionPolicy,
ExecutionVertex[] tasksToTrigger,
ExecutionVertex[] tasksToWaitFor,
ExecutionVertex[] tasksToCommitTo,
CheckpointIDCounter checkpointIDCounter,
CompletedCheckpointStore completedCheckpointStore,
StateBackend checkpointStateBackend,
Executor executor,
SharedStateRegistryFactory sharedStateRegistryFactory) |
Modifier and Type | Method and Description |
---|---|
boolean |
addMasterHook(MasterTriggerRestoreHook<?> hook)
Adds the given master hook to the checkpoint coordinator.
|
JobStatusListener |
createActivatorDeactivator() |
void |
failUnacknowledgedPendingCheckpointsFor(ExecutionAttemptID executionAttemptId,
Throwable cause)
Fails all pending checkpoints which have not been acknowledged by the given execution
attempt id.
|
CheckpointIDCounter |
getCheckpointIdCounter() |
CheckpointStorage |
getCheckpointStorage() |
CompletedCheckpointStore |
getCheckpointStore() |
long |
getCheckpointTimeout() |
int |
getNumberOfPendingCheckpoints() |
int |
getNumberOfRegisteredMasterHooks()
Gets the number of currently register master hooks.
|
int |
getNumberOfRetainedSuccessfulCheckpoints() |
Map<Long,PendingCheckpoint> |
getPendingCheckpoints() |
List<CompletedCheckpoint> |
getSuccessfulCheckpoints() |
boolean |
isPeriodicCheckpointingConfigured()
Returns whether periodic checkpointing has been configured.
|
boolean |
isShutdown() |
boolean |
receiveAcknowledgeMessage(AcknowledgeCheckpoint message)
Receives an AcknowledgeCheckpoint message and returns whether the
message was associated with a pending checkpoint.
|
void |
receiveDeclineMessage(DeclineCheckpoint message)
Receives a
DeclineCheckpoint message for a pending checkpoint. |
boolean |
restoreLatestCheckpointedState(Map<JobVertexID,ExecutionJobVertex> tasks,
boolean errorIfNoCheckpoint,
boolean allowNonRestoredState)
Restores the latest checkpointed state.
|
boolean |
restoreSavepoint(String savepointPointer,
boolean allowNonRestored,
Map<JobVertexID,ExecutionJobVertex> tasks,
ClassLoader userClassLoader)
Restore the state with given savepoint.
|
void |
setCheckpointStatsTracker(CheckpointStatsTracker statsTracker)
Sets the checkpoint stats tracker.
|
void |
shutdown(JobStatus jobStatus)
Shuts down the checkpoint coordinator.
|
void |
startCheckpointScheduler() |
void |
stopCheckpointScheduler() |
boolean |
triggerCheckpoint(long timestamp,
boolean isPeriodic)
Triggers a new standard checkpoint and uses the given timestamp as the checkpoint
timestamp.
|
CheckpointTriggerResult |
triggerCheckpoint(long timestamp,
CheckpointProperties props,
String externalSavepointLocation,
boolean isPeriodic) |
CompletableFuture<CompletedCheckpoint> |
triggerSavepoint(long timestamp,
String targetLocation)
Triggers a savepoint with the given savepoint directory as a target.
|
public CheckpointCoordinator(JobID job, long baseInterval, long checkpointTimeout, long minPauseBetweenCheckpoints, int maxConcurrentCheckpointAttempts, CheckpointRetentionPolicy retentionPolicy, ExecutionVertex[] tasksToTrigger, ExecutionVertex[] tasksToWaitFor, ExecutionVertex[] tasksToCommitTo, CheckpointIDCounter checkpointIDCounter, CompletedCheckpointStore completedCheckpointStore, StateBackend checkpointStateBackend, Executor executor, SharedStateRegistryFactory sharedStateRegistryFactory)
public boolean addMasterHook(MasterTriggerRestoreHook<?> hook)
MasterTriggerRestoreHook.getIdentifier()
).hook
- The hook to add.public int getNumberOfRegisteredMasterHooks()
public void setCheckpointStatsTracker(@Nullable CheckpointStatsTracker statsTracker)
statsTracker
- The checkpoint stats tracker.public void shutdown(JobStatus jobStatus) throws Exception
After this method has been called, the coordinator does not accept and further messages and cannot trigger any further checkpoints.
Exception
public boolean isShutdown()
public CompletableFuture<CompletedCheckpoint> triggerSavepoint(long timestamp, @Nullable String targetLocation)
timestamp
- The timestamp for the savepoint.targetLocation
- Target location for the savepoint, optional. If null, the
state backend's configured default will be used.IllegalStateException
- If no savepoint directory has been
specified and no default savepoint directory has been
configuredpublic boolean triggerCheckpoint(long timestamp, boolean isPeriodic)
timestamp
- The timestamp for the checkpoint.isPeriodic
- Flag indicating whether this triggered checkpoint is
periodic. If this flag is true, but the periodic scheduler is disabled,
the checkpoint will be declined.true
if triggering the checkpoint succeeded.@VisibleForTesting public CheckpointTriggerResult triggerCheckpoint(long timestamp, CheckpointProperties props, @Nullable String externalSavepointLocation, boolean isPeriodic)
public void receiveDeclineMessage(DeclineCheckpoint message)
DeclineCheckpoint
message for a pending checkpoint.message
- Checkpoint decline from the task managerpublic boolean receiveAcknowledgeMessage(AcknowledgeCheckpoint message) throws CheckpointException
message
- Checkpoint ack from the task managerCheckpointException
- If the checkpoint cannot be added to the completed checkpoint store.public void failUnacknowledgedPendingCheckpointsFor(ExecutionAttemptID executionAttemptId, Throwable cause)
executionAttemptId
- for which to discard unacknowledged pending checkpointscause
- of the failurepublic boolean restoreLatestCheckpointedState(Map<JobVertexID,ExecutionJobVertex> tasks, boolean errorIfNoCheckpoint, boolean allowNonRestoredState) throws Exception
tasks
- Map of job vertices to restore. State for these vertices is
restored via Execution.setInitialState(JobManagerTaskRestore)
.errorIfNoCheckpoint
- Fail if no completed checkpoint is available to
restore from.allowNonRestoredState
- Allow checkpoint state that cannot be mapped
to any job vertex in tasks.true
if state was restored, false
otherwise.IllegalStateException
- If the CheckpointCoordinator is shut down.IllegalStateException
- If no completed checkpoint is available and
the failIfNoCheckpoint
flag has been set.IllegalStateException
- If the checkpoint contains state that cannot be
mapped to any job vertex in tasks
and the
allowNonRestoredState
flag has not been set.IllegalStateException
- If the max parallelism changed for an operator
that restores state from this checkpoint.IllegalStateException
- If the parallelism changed for an operator
that restores non-partitioned state from this
checkpoint.Exception
public boolean restoreSavepoint(String savepointPointer, boolean allowNonRestored, Map<JobVertexID,ExecutionJobVertex> tasks, ClassLoader userClassLoader) throws Exception
savepointPointer
- The pointer to the savepoint.allowNonRestored
- True if allowing checkpoint state that cannot be
mapped to any job vertex in tasks.tasks
- Map of job vertices to restore. State for these
vertices is restored via
Execution.setInitialState(JobManagerTaskRestore)
.userClassLoader
- The class loader to resolve serialized classes in
legacy savepoint versions.Exception
public int getNumberOfPendingCheckpoints()
public int getNumberOfRetainedSuccessfulCheckpoints()
public Map<Long,PendingCheckpoint> getPendingCheckpoints()
public List<CompletedCheckpoint> getSuccessfulCheckpoints() throws Exception
Exception
public CheckpointStorage getCheckpointStorage()
public CompletedCheckpointStore getCheckpointStore()
public CheckpointIDCounter getCheckpointIdCounter()
public long getCheckpointTimeout()
public boolean isPeriodicCheckpointingConfigured()
true
if periodic checkpoints have been configured.public void startCheckpointScheduler()
public void stopCheckpointScheduler()
public JobStatusListener createActivatorDeactivator()
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.