use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class Dispatcher method cancelJob.
@Override
public CompletableFuture<Acknowledge> cancelJob(JobID jobId, Time timeout) {
Optional<JobManagerRunner> maybeJob = getJobManagerRunner(jobId);
if (maybeJob.isPresent()) {
return maybeJob.get().cancel(timeout);
}
final ExecutionGraphInfo executionGraphInfo = executionGraphInfoStore.get(jobId);
if (executionGraphInfo != null) {
final JobStatus jobStatus = executionGraphInfo.getArchivedExecutionGraph().getState();
if (jobStatus == JobStatus.CANCELED) {
return CompletableFuture.completedFuture(Acknowledge.get());
} else {
return FutureUtils.completedExceptionally(new FlinkJobTerminatedWithoutCancellationException(jobId, jobStatus));
}
}
log.debug("Dispatcher is unable to cancel job {}: not found", jobId);
return FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId));
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class AbstractExecutionGraphHandler method handleRequest.
@Override
protected CompletableFuture<R> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody> request, @Nonnull RestfulGateway gateway) throws RestHandlerException {
JobID jobId = request.getPathParameter(JobIDPathParameter.class);
CompletableFuture<ExecutionGraphInfo> executionGraphFuture = executionGraphCache.getExecutionGraphInfo(jobId, gateway);
return executionGraphFuture.thenApplyAsync(executionGraph -> {
try {
return handleRequest(request, executionGraph);
} catch (RestHandlerException rhe) {
throw new CompletionException(rhe);
}
}, executor).exceptionally(throwable -> {
throwable = ExceptionUtils.stripCompletionException(throwable);
if (throwable instanceof FlinkJobNotFoundException) {
throw new CompletionException(new NotFoundException(String.format("Job %s not found", jobId), throwable));
} else {
throw new CompletionException(throwable);
}
});
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class DispatcherResourceCleanupTest method testErrorHandlingIfJobCannotBeMarkedAsCleanInJobResultStore.
@Test
public void testErrorHandlingIfJobCannotBeMarkedAsCleanInJobResultStore() throws Exception {
final CompletableFuture<JobResultEntry> dirtyJobFuture = new CompletableFuture<>();
final JobResultStore jobResultStore = TestingJobResultStore.builder().withCreateDirtyResultConsumer(dirtyJobFuture::complete).withMarkResultAsCleanConsumer(jobId -> {
throw new IOException("Expected IOException.");
}).build();
final TestingJobManagerRunnerFactory jobManagerRunnerFactory = startDispatcherAndSubmitJob(createTestingDispatcherBuilder().setJobResultStore(jobResultStore), 0);
ArchivedExecutionGraph executionGraph = new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.FINISHED).build();
final TestingJobManagerRunner testingJobManagerRunner = jobManagerRunnerFactory.takeCreatedJobManagerRunner();
testingJobManagerRunner.completeResultFuture(new ExecutionGraphInfo(executionGraph));
final CompletableFuture<? extends Throwable> errorFuture = this.testingFatalErrorHandlerResource.getFatalErrorHandler().getErrorFuture();
try {
final Throwable unexpectedError = errorFuture.get(100, TimeUnit.MILLISECONDS);
fail("No error should have been reported but an " + unexpectedError.getClass() + " was handled.");
} catch (TimeoutException e) {
// expected
}
assertThat(dirtyJobFuture.get().getJobId(), is(jobId));
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class DispatcherResourceCleanupTest method testFatalErrorIfJobCannotBeMarkedDirtyInJobResultStore.
@Test
public void testFatalErrorIfJobCannotBeMarkedDirtyInJobResultStore() throws Exception {
final JobResultStore jobResultStore = TestingJobResultStore.builder().withCreateDirtyResultConsumer(jobResult -> {
throw new IOException("Expected IOException.");
}).build();
final TestingJobManagerRunnerFactory jobManagerRunnerFactory = startDispatcherAndSubmitJob(createTestingDispatcherBuilder().setJobResultStore(jobResultStore), 0);
ArchivedExecutionGraph executionGraph = new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.FINISHED).build();
final TestingJobManagerRunner testingJobManagerRunner = jobManagerRunnerFactory.takeCreatedJobManagerRunner();
testingJobManagerRunner.completeResultFuture(new ExecutionGraphInfo(executionGraph));
final CompletableFuture<? extends Throwable> errorFuture = this.testingFatalErrorHandlerResource.getFatalErrorHandler().getErrorFuture();
assertThat(errorFuture.get(100, TimeUnit.MILLISECONDS), IsInstanceOf.instanceOf(FlinkException.class));
testingFatalErrorHandlerResource.getFatalErrorHandler().clearError();
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class MiniDispatcherTest method testNotTerminationWithoutGloballyTerminalState.
/**
* Tests that in detached mode, the {@link MiniDispatcher} will not complete the future that
* signals job termination if the JobStatus is not globally terminal state.
*/
@Test
public void testNotTerminationWithoutGloballyTerminalState() throws Exception {
final MiniDispatcher miniDispatcher = createMiniDispatcher(ClusterEntrypoint.ExecutionMode.DETACHED);
miniDispatcher.start();
try {
// wait until we have submitted the job
final TestingJobManagerRunner testingJobManagerRunner = testingJobManagerRunnerFactory.takeCreatedJobManagerRunner();
testingJobManagerRunner.completeResultFuture(new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(jobGraph.getJobID()).setState(JobStatus.SUSPENDED).build()));
testingJobManagerRunner.getTerminationFuture().get();
Assertions.assertThat(miniDispatcher.getShutDownFuture()).isNotDone();
} finally {
RpcUtils.terminateRpcEndpoint(miniDispatcher, timeout);
}
}
Aggregations