Search in sources :

Example 16 with JobCheckpointingSettings

use of org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings in project flink by apache.

the class TestUtils method createJobGraphFromJobVerticesWithCheckpointing.

@Nonnull
public static JobGraph createJobGraphFromJobVerticesWithCheckpointing(SavepointRestoreSettings savepointRestoreSettings, JobVertex... jobVertices) {
    // enable checkpointing which is required to resume from a savepoint
    final CheckpointCoordinatorConfiguration checkpointCoordinatorConfiguration = CheckpointCoordinatorConfiguration.builder().setCheckpointInterval(1000L).setCheckpointTimeout(1000L).setMinPauseBetweenCheckpoints(1000L).setMaxConcurrentCheckpoints(1).setCheckpointRetentionPolicy(CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION).setExactlyOnce(true).setUnalignedCheckpointsEnabled(false).setTolerableCheckpointFailureNumber(0).build();
    final JobCheckpointingSettings checkpointingSettings = new JobCheckpointingSettings(checkpointCoordinatorConfiguration, null);
    return JobGraphBuilder.newStreamingJobGraphBuilder().addJobVertices(Arrays.asList(jobVertices)).setJobCheckpointingSettings(checkpointingSettings).setSavepointRestoreSettings(savepointRestoreSettings).build();
}
Also used : JobCheckpointingSettings(org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings) CheckpointCoordinatorConfiguration(org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration) Nonnull(javax.annotation.Nonnull)

Example 17 with JobCheckpointingSettings

use of org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings in project flink by apache.

the class AdaptiveSchedulerTest method testArchivedCheckpointingSettingsNotNullIfCheckpointingIsEnabled.

@Test
public void testArchivedCheckpointingSettingsNotNullIfCheckpointingIsEnabled() throws Exception {
    final JobGraph jobGraph = createJobGraph();
    jobGraph.setSnapshotSettings(new JobCheckpointingSettings(CheckpointCoordinatorConfiguration.builder().build(), null));
    final ArchivedExecutionGraph archivedExecutionGraph = new AdaptiveSchedulerBuilder(jobGraph, mainThreadExecutor).build().getArchivedExecutionGraph(JobStatus.INITIALIZING, null);
    ArchivedExecutionGraphTest.assertContainsCheckpointSettings(archivedExecutionGraph);
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobGraphTestUtils.streamingJobGraph(org.apache.flink.runtime.jobgraph.JobGraphTestUtils.streamingJobGraph) JobCheckpointingSettings(org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings) ArchivedExecutionGraph(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph) Test(org.junit.Test) ArchivedExecutionGraphTest(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraphTest) DefaultSchedulerTest(org.apache.flink.runtime.scheduler.DefaultSchedulerTest)

Example 18 with JobCheckpointingSettings

use of org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings in project flink by apache.

the class AdaptiveSchedulerTest method testCloseShutsDownCheckpointingComponents.

@Test
public void testCloseShutsDownCheckpointingComponents() throws Exception {
    final CompletableFuture<JobStatus> completedCheckpointStoreShutdownFuture = new CompletableFuture<>();
    final CompletedCheckpointStore completedCheckpointStore = TestingCompletedCheckpointStore.createStoreWithShutdownCheckAndNoCompletedCheckpoints(completedCheckpointStoreShutdownFuture);
    final CompletableFuture<JobStatus> checkpointIdCounterShutdownFuture = new CompletableFuture<>();
    final CheckpointIDCounter checkpointIdCounter = TestingCheckpointIDCounter.createStoreWithShutdownCheckAndNoStartAction(checkpointIdCounterShutdownFuture);
    final JobGraph jobGraph = createJobGraph();
    // checkpointing components are only created if checkpointing is enabled
    jobGraph.setSnapshotSettings(new JobCheckpointingSettings(CheckpointCoordinatorConfiguration.builder().build(), null));
    final AdaptiveScheduler scheduler = new AdaptiveSchedulerBuilder(jobGraph, singleThreadMainThreadExecutor).setCheckpointRecoveryFactory(new TestingCheckpointRecoveryFactory(completedCheckpointStore, checkpointIdCounter)).build();
    singleThreadMainThreadExecutor.execute(() -> {
        scheduler.startScheduling();
        // transition into the FAILED state
        scheduler.handleGlobalFailure(new FlinkException("Test exception"));
        scheduler.closeAsync();
    });
    assertThat(completedCheckpointStoreShutdownFuture.get()).isEqualTo(JobStatus.FAILED);
    assertThat(checkpointIdCounterShutdownFuture.get()).isEqualTo(JobStatus.FAILED);
}
Also used : JobStatus(org.apache.flink.api.common.JobStatus) CompletableFuture(java.util.concurrent.CompletableFuture) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobGraphTestUtils.streamingJobGraph(org.apache.flink.runtime.jobgraph.JobGraphTestUtils.streamingJobGraph) JobCheckpointingSettings(org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings) CheckpointIDCounter(org.apache.flink.runtime.checkpoint.CheckpointIDCounter) StandaloneCheckpointIDCounter(org.apache.flink.runtime.checkpoint.StandaloneCheckpointIDCounter) TestingCheckpointIDCounter(org.apache.flink.runtime.checkpoint.TestingCheckpointIDCounter) TestingCheckpointRecoveryFactory(org.apache.flink.runtime.checkpoint.TestingCheckpointRecoveryFactory) FlinkException(org.apache.flink.util.FlinkException) TestingCompletedCheckpointStore(org.apache.flink.runtime.checkpoint.TestingCompletedCheckpointStore) StandaloneCompletedCheckpointStore(org.apache.flink.runtime.checkpoint.StandaloneCompletedCheckpointStore) CompletedCheckpointStore(org.apache.flink.runtime.checkpoint.CompletedCheckpointStore) Test(org.junit.Test) ArchivedExecutionGraphTest(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraphTest) DefaultSchedulerTest(org.apache.flink.runtime.scheduler.DefaultSchedulerTest)

Example 19 with JobCheckpointingSettings

use of org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings in project flink by apache.

the class JobMasterStopWithSavepointITCase method setUpJobGraph.

private void setUpJobGraph(final Class<? extends TaskInvokable> invokable, final RestartStrategies.RestartStrategyConfiguration restartStrategy) throws Exception {
    finishingLatch = new OneShotLatch();
    invokeLatch = new CountDownLatch(PARALLELISM);
    numberOfRestarts = new CountDownLatch(2);
    checkpointsToWaitFor = new CountDownLatch(10);
    syncSavepointId.set(-1);
    savepointDirectory = temporaryFolder.newFolder().toPath();
    Assume.assumeTrue("ClusterClient is not an instance of MiniClusterClient", MINI_CLUSTER_RESOURCE.getClusterClient() instanceof MiniClusterClient);
    clusterClient = (MiniClusterClient) MINI_CLUSTER_RESOURCE.getClusterClient();
    final ExecutionConfig config = new ExecutionConfig();
    config.setRestartStrategy(restartStrategy);
    final JobVertex vertex = new JobVertex("testVertex");
    vertex.setInvokableClass(invokable);
    vertex.setParallelism(PARALLELISM);
    final JobCheckpointingSettings jobCheckpointingSettings = new JobCheckpointingSettings(new CheckpointCoordinatorConfiguration(CHECKPOINT_INTERVAL, 60_000, 10, 1, CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION, true, false, 0, 0), null);
    jobGraph = JobGraphBuilder.newStreamingJobGraphBuilder().setExecutionConfig(config).addJobVertex(vertex).setJobCheckpointingSettings(jobCheckpointingSettings).build();
    clusterClient.submitJob(jobGraph).get();
    assertTrue(invokeLatch.await(60, TimeUnit.SECONDS));
    waitForJob();
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) JobCheckpointingSettings(org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings) CheckpointCoordinatorConfiguration(org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) CountDownLatch(java.util.concurrent.CountDownLatch) MiniClusterClient(org.apache.flink.client.program.MiniClusterClient)

Example 20 with JobCheckpointingSettings

use of org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings in project flink by apache.

the class JobMasterTriggerSavepointITCase method setUpWithCheckpointInterval.

private void setUpWithCheckpointInterval(long checkpointInterval) throws Exception {
    invokeLatch = new CountDownLatch(1);
    triggerCheckpointLatch = new CountDownLatch(1);
    savepointDirectory = temporaryFolder.newFolder().toPath();
    Assume.assumeTrue("ClusterClient is not an instance of MiniClusterClient", MINI_CLUSTER_RESOURCE.getClusterClient() instanceof MiniClusterClient);
    clusterClient = (MiniClusterClient) MINI_CLUSTER_RESOURCE.getClusterClient();
    final JobVertex vertex = new JobVertex("testVertex");
    vertex.setInvokableClass(NoOpBlockingInvokable.class);
    vertex.setParallelism(1);
    final JobCheckpointingSettings jobCheckpointingSettings = new JobCheckpointingSettings(new CheckpointCoordinatorConfiguration(checkpointInterval, 60_000, 10, 1, CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION, true, false, 0, 0), null);
    jobGraph = JobGraphBuilder.newStreamingJobGraphBuilder().addJobVertex(vertex).setJobCheckpointingSettings(jobCheckpointingSettings).build();
    clusterClient.submitJob(jobGraph).get();
    assertTrue(invokeLatch.await(60, TimeUnit.SECONDS));
    waitForJob();
}
Also used : JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) JobCheckpointingSettings(org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings) CheckpointCoordinatorConfiguration(org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration) CountDownLatch(java.util.concurrent.CountDownLatch) MiniClusterClient(org.apache.flink.client.program.MiniClusterClient)

Aggregations

JobCheckpointingSettings (org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings)20 CheckpointCoordinatorConfiguration (org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration)15 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)11 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)11 Test (org.junit.Test)7 IOException (java.io.IOException)5 JobID (org.apache.flink.api.common.JobID)4 CheckpointStorage (org.apache.flink.runtime.state.CheckpointStorage)4 StateBackend (org.apache.flink.runtime.state.StateBackend)4 Duration (java.time.Duration)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)3 JobStatus (org.apache.flink.api.common.JobStatus)3 Configuration (org.apache.flink.configuration.Configuration)3 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 BlockingQueue (java.util.concurrent.BlockingQueue)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2