use of org.apache.flink.runtime.executiongraph.ExecutionGraphCheckpointPlanCalculatorContext in project flink by apache.
the class FailoverStrategyCheckpointCoordinatorTest method testAbortPendingCheckpointsWithTriggerValidation.
/**
* Tests that {@link CheckpointCoordinator#abortPendingCheckpoints(CheckpointException)} called
* on job failover could handle the {@code currentPeriodicTrigger} null case well.
*/
@Test
public void testAbortPendingCheckpointsWithTriggerValidation() throws Exception {
final int maxConcurrentCheckpoints = ThreadLocalRandom.current().nextInt(10) + 1;
ExecutionGraph graph = new CheckpointCoordinatorTestingUtils.CheckpointExecutionGraphBuilder().addJobVertex(new JobVertexID()).setTransitToRunning(false).build();
CheckpointCoordinatorConfiguration checkpointCoordinatorConfiguration = new CheckpointCoordinatorConfiguration(Integer.MAX_VALUE, Integer.MAX_VALUE, 0, maxConcurrentCheckpoints, CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION, true, false, 0, 0);
CheckpointCoordinator checkpointCoordinator = new CheckpointCoordinator(graph.getJobID(), checkpointCoordinatorConfiguration, Collections.emptyList(), new StandaloneCheckpointIDCounter(), new StandaloneCompletedCheckpointStore(1), new MemoryStateBackend(), Executors.directExecutor(), new CheckpointsCleaner(), manualThreadExecutor, mock(CheckpointFailureManager.class), new DefaultCheckpointPlanCalculator(graph.getJobID(), new ExecutionGraphCheckpointPlanCalculatorContext(graph), graph.getVerticesTopologically(), false), new ExecutionAttemptMappingProvider(graph.getAllExecutionVertices()), mock(CheckpointStatsTracker.class));
// switch current execution's state to running to allow checkpoint could be triggered.
graph.transitionToRunning();
graph.getAllExecutionVertices().forEach(task -> task.getCurrentExecutionAttempt().transitionState(ExecutionState.RUNNING));
checkpointCoordinator.startCheckpointScheduler();
assertTrue(checkpointCoordinator.isCurrentPeriodicTriggerAvailable());
// only trigger the periodic scheduling
// we can't trigger all scheduled task, because there is also a cancellation scheduled
manualThreadExecutor.triggerPeriodicScheduledTasks();
manualThreadExecutor.triggerAll();
assertEquals(1, checkpointCoordinator.getNumberOfPendingCheckpoints());
for (int i = 1; i < maxConcurrentCheckpoints; i++) {
checkpointCoordinator.triggerCheckpoint(false);
manualThreadExecutor.triggerAll();
assertEquals(i + 1, checkpointCoordinator.getNumberOfPendingCheckpoints());
assertTrue(checkpointCoordinator.isCurrentPeriodicTriggerAvailable());
}
// as we only support limited concurrent checkpoints, after checkpoint triggered more than
// the limits,
// the currentPeriodicTrigger would been assigned as null.
checkpointCoordinator.triggerCheckpoint(false);
manualThreadExecutor.triggerAll();
assertEquals(maxConcurrentCheckpoints, checkpointCoordinator.getNumberOfPendingCheckpoints());
checkpointCoordinator.abortPendingCheckpoints(new CheckpointException(CheckpointFailureReason.JOB_FAILOVER_REGION));
// after aborting checkpoints, we ensure currentPeriodicTrigger still available.
assertTrue(checkpointCoordinator.isCurrentPeriodicTriggerAvailable());
assertEquals(0, checkpointCoordinator.getNumberOfPendingCheckpoints());
}
use of org.apache.flink.runtime.executiongraph.ExecutionGraphCheckpointPlanCalculatorContext in project flink by apache.
the class CheckpointCoordinatorMasterHooksTest method instantiateCheckpointCoordinator.
private CheckpointCoordinator instantiateCheckpointCoordinator(ExecutionGraph graph, ScheduledExecutor testingScheduledExecutor) {
CheckpointCoordinatorConfiguration chkConfig = new CheckpointCoordinatorConfiguration(10000000L, 600000L, 0L, 1, CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION, true, false, 0, 0);
Executor executor = Executors.directExecutor();
return new CheckpointCoordinator(graph.getJobID(), chkConfig, Collections.emptyList(), new StandaloneCheckpointIDCounter(), new StandaloneCompletedCheckpointStore(10), new MemoryStateBackend(), executor, new CheckpointsCleaner(), testingScheduledExecutor, new CheckpointFailureManager(0, NoOpFailJobCall.INSTANCE), new DefaultCheckpointPlanCalculator(graph.getJobID(), new ExecutionGraphCheckpointPlanCalculatorContext(graph), graph.getVerticesTopologically(), false), new ExecutionAttemptMappingProvider(graph.getAllExecutionVertices()), new CheckpointStatsTracker(1, new DummyMetricGroup()));
}
Aggregations