use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class DefaultExecutionGraphCacheTest method testImmediateCacheInvalidationAfterFailure.
/**
* Tests that a failure in requesting an AccessExecutionGraph from the gateway, will not create
* a cache entry --> another cache request will trigger a new gateway request.
*/
@Test
public void testImmediateCacheInvalidationAfterFailure() throws Exception {
final Time timeout = Time.milliseconds(100L);
final Time timeToLive = Time.hours(1L);
// let's first answer with a JobNotFoundException and then only with the correct result
final CountingRestfulGateway restfulGateway = createCountingRestfulGateway(expectedJobId, FutureUtils.completedExceptionally(new FlinkJobNotFoundException(expectedJobId)), CompletableFuture.completedFuture(expectedExecutionGraphInfo));
try (ExecutionGraphCache executionGraphCache = new DefaultExecutionGraphCache(timeout, timeToLive)) {
CompletableFuture<ExecutionGraphInfo> executionGraphFuture = executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway);
try {
executionGraphFuture.get();
fail("The execution graph future should have been completed exceptionally.");
} catch (ExecutionException ee) {
ee.printStackTrace();
assertTrue(ee.getCause() instanceof FlinkException);
}
CompletableFuture<ExecutionGraphInfo> executionGraphFuture2 = executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway);
assertEquals(expectedExecutionGraphInfo, executionGraphFuture2.get());
}
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class DefaultJobMasterServiceProcessTest method testSuccessOnTerminalState.
@Test
public void testSuccessOnTerminalState() throws Exception {
final CompletableFuture<JobMasterService> jobMasterServiceFuture = new CompletableFuture<>();
DefaultJobMasterServiceProcess serviceProcess = createTestInstance(jobMasterServiceFuture);
jobMasterServiceFuture.complete(new TestingJobMasterService());
ArchivedExecutionGraph archivedExecutionGraph = new ArchivedExecutionGraphBuilder().setState(JobStatus.FINISHED).build();
serviceProcess.jobReachedGloballyTerminalState(new ExecutionGraphInfo(archivedExecutionGraph));
assertThat(serviceProcess.getResultFuture()).isCompletedWithValueMatching(JobManagerRunnerResult::isSuccess).isCompletedWithValueMatching(r -> r.getExecutionGraphInfo().getArchivedExecutionGraph().getState() == JobStatus.FINISHED);
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class JobMaster method jobStatusChanged.
private void jobStatusChanged(final JobStatus newJobStatus) {
validateRunsInMainThread();
if (newJobStatus.isGloballyTerminalState()) {
runAsync(() -> {
Collection<ResultPartitionID> allTracked = partitionTracker.getAllTrackedPartitions().stream().map(d -> d.getShuffleDescriptor().getResultPartitionID()).collect(Collectors.toList());
if (newJobStatus == JobStatus.FINISHED) {
partitionTracker.stopTrackingAndReleaseOrPromotePartitions(allTracked);
} else {
partitionTracker.stopTrackingAndReleasePartitions(allTracked);
}
});
final ExecutionGraphInfo executionGraphInfo = schedulerNG.requestJob();
futureExecutor.execute(() -> jobCompletionActions.jobReachedGloballyTerminalState(executionGraphInfo));
}
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class DispatcherTest method testCacheJobExecutionResult.
/**
* Test that {@link JobResult} is cached when the job finishes.
*/
@Test
public void testCacheJobExecutionResult() throws Exception {
dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(jobId, createdJobManagerRunnerLatch));
final DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
final JobID failedJobId = new JobID();
final JobStatus expectedState = JobStatus.FAILED;
final ExecutionGraphInfo failedExecutionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(failedJobId).setState(expectedState).setFailureCause(new ErrorInfo(new RuntimeException("expected"), 1L)).build());
dispatcher.completeJobExecution(failedExecutionGraphInfo);
assertThat(dispatcherGateway.requestJobStatus(failedJobId, TIMEOUT).get(), equalTo(expectedState));
assertThat(dispatcherGateway.requestExecutionGraphInfo(failedJobId, TIMEOUT).get(), equalTo(failedExecutionGraphInfo));
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class DispatcherTest method testFatalErrorIfRecoveredJobsCannotBeStarted.
/**
* Tests that the {@link Dispatcher} fails fatally if the recovered jobs cannot be started. See
* FLINK-9097.
*/
@Test
public void testFatalErrorIfRecoveredJobsCannotBeStarted() throws Exception {
final FlinkException testException = new FlinkException("Test exception");
jobMasterLeaderElectionService.isLeader(UUID.randomUUID());
final TestingJobMasterServiceLeadershipRunnerFactory jobManagerRunnerFactory = new TestingJobMasterServiceLeadershipRunnerFactory();
dispatcher = createTestingDispatcherBuilder().setJobManagerRunnerFactory(jobManagerRunnerFactory).setRecoveredJobs(Collections.singleton(JobGraphTestUtils.emptyJobGraph())).build();
dispatcher.start();
final TestingFatalErrorHandler fatalErrorHandler = testingFatalErrorHandlerResource.getFatalErrorHandler();
final TestingJobManagerRunner testingJobManagerRunner = jobManagerRunnerFactory.takeCreatedJobManagerRunner();
// Let the initialization of the JobManagerRunner fail
testingJobManagerRunner.completeResultFuture(JobManagerRunnerResult.forInitializationFailure(new ExecutionGraphInfo(ArchivedExecutionGraph.createSparseArchivedExecutionGraph(jobId, jobGraph.getName(), JobStatus.FAILED, testException, jobGraph.getCheckpointingSettings(), 1L)), testException));
final Throwable error = fatalErrorHandler.getErrorFuture().get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
assertThat(ExceptionUtils.findThrowableWithMessage(error, testException.getMessage()).isPresent(), is(true));
fatalErrorHandler.clearError();
}
Aggregations