Search in sources :

Example 1 with ExecutionGraphCheckpointPlanCalculatorContext

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());
}
Also used : JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) MemoryStateBackend(org.apache.flink.runtime.state.memory.MemoryStateBackend) CheckpointCoordinatorConfiguration(org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration) ExecutionGraphCheckpointPlanCalculatorContext(org.apache.flink.runtime.executiongraph.ExecutionGraphCheckpointPlanCalculatorContext) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) Test(org.junit.Test)

Example 2 with ExecutionGraphCheckpointPlanCalculatorContext

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()));
}
Also used : MemoryStateBackend(org.apache.flink.runtime.state.memory.MemoryStateBackend) CheckpointCoordinatorConfiguration(org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration) ExecutionGraphCheckpointPlanCalculatorContext(org.apache.flink.runtime.executiongraph.ExecutionGraphCheckpointPlanCalculatorContext) ManuallyTriggeredScheduledExecutor(org.apache.flink.util.concurrent.ManuallyTriggeredScheduledExecutor) ScheduledExecutor(org.apache.flink.util.concurrent.ScheduledExecutor) Executor(java.util.concurrent.Executor) DummyMetricGroup(org.apache.flink.api.common.eventtime.WatermarkStrategyTest.DummyMetricGroup)

Aggregations

ExecutionGraphCheckpointPlanCalculatorContext (org.apache.flink.runtime.executiongraph.ExecutionGraphCheckpointPlanCalculatorContext)2 CheckpointCoordinatorConfiguration (org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration)2 MemoryStateBackend (org.apache.flink.runtime.state.memory.MemoryStateBackend)2 Executor (java.util.concurrent.Executor)1 DummyMetricGroup (org.apache.flink.api.common.eventtime.WatermarkStrategyTest.DummyMetricGroup)1 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)1 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)1 ManuallyTriggeredScheduledExecutor (org.apache.flink.util.concurrent.ManuallyTriggeredScheduledExecutor)1 ScheduledExecutor (org.apache.flink.util.concurrent.ScheduledExecutor)1 Test (org.junit.Test)1