use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.
the class JobExceptionsHandlerTest method createExecutionGraphInfo.
// -------- exception history related utility methods for creating the input data --------
private static ExecutionGraphInfo createExecutionGraphInfo(RootExceptionHistoryEntry... historyEntries) {
final ArchivedExecutionGraphBuilder executionGraphBuilder = new ArchivedExecutionGraphBuilder();
final List<RootExceptionHistoryEntry> historyEntryCollection = new ArrayList<>();
for (int i = 0; i < historyEntries.length; i++) {
if (i == 0) {
// first entry is root cause
executionGraphBuilder.setFailureCause(new ErrorInfo(historyEntries[i].getException(), historyEntries[i].getTimestamp()));
}
historyEntryCollection.add(historyEntries[i]);
}
// we have to reverse it to simulate how the Scheduler collects it
Collections.reverse(historyEntryCollection);
return new ExecutionGraphInfo(executionGraphBuilder.build(), historyEntryCollection);
}
use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.
the class JobExceptionsHandlerTest method createAccessExecutionGraph.
private static ExecutionGraphInfo createAccessExecutionGraph(int numTasks) {
Map<JobVertexID, ArchivedExecutionJobVertex> tasks = new HashMap<>();
for (int i = 0; i < numTasks; i++) {
final JobVertexID jobVertexId = new JobVertexID();
tasks.put(jobVertexId, createArchivedExecutionJobVertex(jobVertexId));
}
final Throwable failureCause = new RuntimeException("root cause");
final long failureTimestamp = System.currentTimeMillis();
final List<RootExceptionHistoryEntry> exceptionHistory = Collections.singletonList(new RootExceptionHistoryEntry(failureCause, failureTimestamp, "test task #1", new LocalTaskManagerLocation(), Collections.emptySet()));
return new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setFailureCause(new ErrorInfo(failureCause, failureTimestamp)).setTasks(tasks).build(), exceptionHistory);
}
use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder 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.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder 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.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder 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