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());
}
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));
}
}
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));
}
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));
}
Aggregations