Search in sources :

Example 1 with ExecutionAttemptMappingProvider

use of org.apache.flink.runtime.checkpoint.ExecutionAttemptMappingProvider in project flink by apache.

the class DefaultExecutionGraph method enableCheckpointing.

@Override
public void enableCheckpointing(CheckpointCoordinatorConfiguration chkConfig, List<MasterTriggerRestoreHook<?>> masterHooks, CheckpointIDCounter checkpointIDCounter, CompletedCheckpointStore checkpointStore, StateBackend checkpointStateBackend, CheckpointStorage checkpointStorage, CheckpointStatsTracker statsTracker, CheckpointsCleaner checkpointsCleaner) {
    checkState(state == JobStatus.CREATED, "Job must be in CREATED state");
    checkState(checkpointCoordinator == null, "checkpointing already enabled");
    final Collection<OperatorCoordinatorCheckpointContext> operatorCoordinators = buildOpCoordinatorCheckpointContexts();
    checkpointStatsTracker = checkNotNull(statsTracker, "CheckpointStatsTracker");
    checkpointCoordinatorConfiguration = checkNotNull(chkConfig, "CheckpointCoordinatorConfiguration");
    CheckpointFailureManager failureManager = new CheckpointFailureManager(chkConfig.getTolerableCheckpointFailureNumber(), new CheckpointFailureManager.FailJobCallback() {

        @Override
        public void failJob(Throwable cause) {
            getJobMasterMainThreadExecutor().execute(() -> failGlobal(cause));
        }

        @Override
        public void failJobDueToTaskFailure(Throwable cause, ExecutionAttemptID failingTask) {
            getJobMasterMainThreadExecutor().execute(() -> failGlobalIfExecutionIsStillRunning(cause, failingTask));
        }
    });
    checkState(checkpointCoordinatorTimer == null);
    checkpointCoordinatorTimer = Executors.newSingleThreadScheduledExecutor(new DispatcherThreadFactory(Thread.currentThread().getThreadGroup(), "Checkpoint Timer"));
    // create the coordinator that triggers and commits checkpoints and holds the state
    checkpointCoordinator = new CheckpointCoordinator(jobInformation.getJobId(), chkConfig, operatorCoordinators, checkpointIDCounter, checkpointStore, checkpointStorage, ioExecutor, checkpointsCleaner, new ScheduledExecutorServiceAdapter(checkpointCoordinatorTimer), failureManager, createCheckpointPlanCalculator(chkConfig.isEnableCheckpointsAfterTasksFinish()), new ExecutionAttemptMappingProvider(getAllExecutionVertices()), checkpointStatsTracker);
    // register the master hooks on the checkpoint coordinator
    for (MasterTriggerRestoreHook<?> hook : masterHooks) {
        if (!checkpointCoordinator.addMasterHook(hook)) {
            LOG.warn("Trying to register multiple checkpoint hooks with the name: {}", hook.getIdentifier());
        }
    }
    if (checkpointCoordinator.isPeriodicCheckpointingConfigured()) {
        // the periodic checkpoint scheduler is activated and deactivated as a result of
        // job status changes (running -> on, all other states -> off)
        registerJobStatusListener(checkpointCoordinator.createActivatorDeactivator());
    }
    this.stateBackendName = checkpointStateBackend.getClass().getSimpleName();
    this.checkpointStorageName = checkpointStorage.getClass().getSimpleName();
}
Also used : OperatorCoordinatorCheckpointContext(org.apache.flink.runtime.checkpoint.OperatorCoordinatorCheckpointContext) ExecutionAttemptMappingProvider(org.apache.flink.runtime.checkpoint.ExecutionAttemptMappingProvider) DispatcherThreadFactory(org.apache.flink.runtime.taskmanager.DispatcherThreadFactory) ScheduledExecutorServiceAdapter(org.apache.flink.util.concurrent.ScheduledExecutorServiceAdapter) CheckpointCoordinator(org.apache.flink.runtime.checkpoint.CheckpointCoordinator) CheckpointFailureManager(org.apache.flink.runtime.checkpoint.CheckpointFailureManager)

Aggregations

CheckpointCoordinator (org.apache.flink.runtime.checkpoint.CheckpointCoordinator)1 CheckpointFailureManager (org.apache.flink.runtime.checkpoint.CheckpointFailureManager)1 ExecutionAttemptMappingProvider (org.apache.flink.runtime.checkpoint.ExecutionAttemptMappingProvider)1 OperatorCoordinatorCheckpointContext (org.apache.flink.runtime.checkpoint.OperatorCoordinatorCheckpointContext)1 DispatcherThreadFactory (org.apache.flink.runtime.taskmanager.DispatcherThreadFactory)1 ScheduledExecutorServiceAdapter (org.apache.flink.util.concurrent.ScheduledExecutorServiceAdapter)1