Search in sources :

Example 1 with CheckpointScheduling

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

the class Executing method stopWithSavepoint.

CompletableFuture<String> stopWithSavepoint(@Nullable final String targetDirectory, boolean terminate, SavepointFormatType formatType) {
    final ExecutionGraph executionGraph = getExecutionGraph();
    StopWithSavepointTerminationManager.checkSavepointActionPreconditions(executionGraph.getCheckpointCoordinator(), targetDirectory, executionGraph.getJobID(), getLogger());
    getLogger().info("Triggering stop-with-savepoint for job {}.", executionGraph.getJobID());
    CheckpointScheduling schedulingProvider = new CheckpointSchedulingProvider(executionGraph);
    schedulingProvider.stopCheckpointScheduler();
    final CompletableFuture<String> savepointFuture = executionGraph.getCheckpointCoordinator().triggerSynchronousSavepoint(terminate, targetDirectory, formatType).thenApply(CompletedCheckpoint::getExternalPointer);
    return context.goToStopWithSavepoint(executionGraph, getExecutionGraphHandler(), getOperatorCoordinatorHandler(), schedulingProvider, savepointFuture, getFailures());
}
Also used : CompletedCheckpoint(org.apache.flink.runtime.checkpoint.CompletedCheckpoint) ArchivedExecutionGraph(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) CheckpointScheduling(org.apache.flink.runtime.checkpoint.CheckpointScheduling)

Example 2 with CheckpointScheduling

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

the class StopWithSavepointTest method testRestartOnTaskFailureAfterSavepointCompletion.

@Test
public void testRestartOnTaskFailureAfterSavepointCompletion() throws Exception {
    try (MockStopWithSavepointContext ctx = new MockStopWithSavepointContext()) {
        CheckpointScheduling mockStopWithSavepointOperations = new MockCheckpointScheduling();
        CompletableFuture<String> savepointFuture = new CompletableFuture<>();
        StateTrackingMockExecutionGraph executionGraph = new StateTrackingMockExecutionGraph();
        StopWithSavepoint sws = createStopWithSavepoint(ctx, mockStopWithSavepointOperations, executionGraph, savepointFuture);
        ctx.setStopWithSavepoint(sws);
        ctx.setHowToHandleFailure(failure -> FailureResult.canRestart(failure, Duration.ZERO));
        ctx.setExpectRestarting(assertNonNull());
        // 1. complete savepoint future
        savepointFuture.complete(SAVEPOINT_PATH);
        ctx.triggerExecutors();
        // 2. fail task
        Exception exception = new RuntimeException();
        TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
        executionGraph.registerExecution(execution);
        TaskExecutionStateTransition taskExecutionStateTransition = ExecutingTest.createFailingStateTransition(execution.getAttemptId(), exception);
        assertThat(sws.updateTaskExecutionState(taskExecutionStateTransition), is(true));
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) FlinkException(org.apache.flink.util.FlinkException) CompletableFuture(java.util.concurrent.CompletableFuture) CheckpointScheduling(org.apache.flink.runtime.checkpoint.CheckpointScheduling) Test(org.junit.Test)

Example 3 with CheckpointScheduling

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

the class StopWithSavepointTest method testExceptionalSavepointCompletionLeadsToExceptionalOperationFutureCompletion.

@Test
public void testExceptionalSavepointCompletionLeadsToExceptionalOperationFutureCompletion() throws Exception {
    MockStopWithSavepointContext ctx = new MockStopWithSavepointContext();
    CheckpointScheduling mockStopWithSavepointOperations = new MockCheckpointScheduling();
    CompletableFuture<String> savepointFuture = new CompletableFuture<>();
    StopWithSavepoint sws = createStopWithSavepoint(ctx, mockStopWithSavepointOperations, savepointFuture);
    ctx.setStopWithSavepoint(sws);
    ctx.setExpectExecuting(assertNonNull());
    savepointFuture.completeExceptionally(new RuntimeException("Test error"));
    ctx.close();
    assertThat(sws.getOperationFuture().isCompletedExceptionally(), is(true));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) CheckpointScheduling(org.apache.flink.runtime.checkpoint.CheckpointScheduling) Test(org.junit.Test)

Example 4 with CheckpointScheduling

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

the class StopWithSavepointTest method testErrorCreatingSavepointLeadsToTransitionToExecutingState.

@Test
public void testErrorCreatingSavepointLeadsToTransitionToExecutingState() throws Exception {
    MockStopWithSavepointContext ctx = new MockStopWithSavepointContext();
    CheckpointScheduling mockStopWithSavepointOperations = new MockCheckpointScheduling();
    CompletableFuture<String> savepointFuture = new CompletableFuture<>();
    StopWithSavepoint sws = createStopWithSavepoint(ctx, mockStopWithSavepointOperations, savepointFuture);
    ctx.setStopWithSavepoint(sws);
    ctx.setExpectExecuting(executingArguments -> assertThat(executingArguments.getExecutionGraph().getState(), is(JobStatus.RUNNING)));
    savepointFuture.completeExceptionally(new RuntimeException("Test error"));
    ctx.close();
    assertThat(sws.getOperationFuture().isCompletedExceptionally(), is(true));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) CheckpointScheduling(org.apache.flink.runtime.checkpoint.CheckpointScheduling) Test(org.junit.Test)

Aggregations

CheckpointScheduling (org.apache.flink.runtime.checkpoint.CheckpointScheduling)4 CompletableFuture (java.util.concurrent.CompletableFuture)3 Test (org.junit.Test)3 CompletedCheckpoint (org.apache.flink.runtime.checkpoint.CompletedCheckpoint)1 ArchivedExecutionGraph (org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph)1 ErrorInfo (org.apache.flink.runtime.executiongraph.ErrorInfo)1 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)1 TaskExecutionStateTransition (org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition)1 TestingAccessExecution (org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution)1 FlinkException (org.apache.flink.util.FlinkException)1