use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.
the class CommonTestUtils method waitForAllTaskRunning.
public static void waitForAllTaskRunning(SupplierWithException<AccessExecutionGraph, Exception> executionGraphSupplier, Deadline timeout, boolean allowFinished) throws Exception {
Predicate<AccessExecutionVertex> subtaskPredicate = task -> {
switch(task.getExecutionState()) {
case RUNNING:
return true;
case FINISHED:
if (allowFinished) {
return true;
} else {
throw new RuntimeException("Sub-Task finished unexpectedly" + task);
}
default:
return false;
}
};
waitUntilCondition(() -> {
final AccessExecutionGraph graph = executionGraphSupplier.get();
if (graph.getState().isGloballyTerminalState()) {
final ErrorInfo failureInfo = graph.getFailureInfo();
fail(format("Graph is in globally terminal state (%s)", graph.getState()), failureInfo != null ? failureInfo.getException() : null);
}
return graph.getState() == JobStatus.RUNNING && graph.getAllVertices().values().stream().allMatch(jobVertex -> Arrays.stream(jobVertex.getTaskVertices()).allMatch(subtaskPredicate));
}, timeout);
}
use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.
the class DispatcherTest method testRetrieveJobResultAfterSubmissionOfFailedJob.
@Test
public void testRetrieveJobResultAfterSubmissionOfFailedJob() throws Exception {
dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(jobId, createdJobManagerRunnerLatch));
final DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
final JobID failedJobId = new JobID();
final String failedJobName = "test";
final CompletableFuture<Acknowledge> submitFuture = dispatcherGateway.submitFailedJob(failedJobId, failedJobName, new RuntimeException("Test exception."));
submitFuture.get();
final ArchivedExecutionGraph archivedExecutionGraph = dispatcherGateway.requestJob(failedJobId, TIMEOUT).get();
Assertions.assertThat(archivedExecutionGraph.getJobID()).isEqualTo(failedJobId);
Assertions.assertThat(archivedExecutionGraph.getJobName()).isEqualTo(failedJobName);
Assertions.assertThat(archivedExecutionGraph.getState()).isEqualTo(JobStatus.FAILED);
Assertions.assertThat(archivedExecutionGraph.getFailureInfo()).isNotNull().extracting(ErrorInfo::getException).extracting(e -> e.deserializeError(Thread.currentThread().getContextClassLoader())).satisfies(exception -> Assertions.assertThat(exception).isInstanceOf(RuntimeException.class).hasMessage("Test exception."));
}
use of org.apache.flink.runtime.executiongraph.ErrorInfo 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.executiongraph.ErrorInfo in project flink by apache.
the class JobExceptionsHandlerTest method createArchivedExecutionJobVertex.
private static ArchivedExecutionJobVertex createArchivedExecutionJobVertex(JobVertexID jobVertexID) {
final StringifiedAccumulatorResult[] emptyAccumulators = new StringifiedAccumulatorResult[0];
final long[] timestamps = new long[ExecutionState.values().length];
final ExecutionState expectedState = ExecutionState.RUNNING;
final LocalTaskManagerLocation assignedResourceLocation = new LocalTaskManagerLocation();
final AllocationID allocationID = new AllocationID();
final int subtaskIndex = 1;
final int attempt = 2;
return new ArchivedExecutionJobVertex(new ArchivedExecutionVertex[] { new ArchivedExecutionVertex(subtaskIndex, "test task", new ArchivedExecution(new StringifiedAccumulatorResult[0], null, new ExecutionAttemptID(), attempt, expectedState, new ErrorInfo(new RuntimeException("error"), System.currentTimeMillis()), assignedResourceLocation, allocationID, subtaskIndex, timestamps), new EvictingBoundedList<>(0)) }, jobVertexID, jobVertexID.toString(), 1, 1, ResourceProfile.UNKNOWN, emptyAccumulators);
}
use of org.apache.flink.runtime.executiongraph.ErrorInfo 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);
}
Aggregations