use of org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry in project flink by apache.
the class ExecutionGraphInfoTest method testExecutionGraphHistoryBeingDerivedFromFailedExecutionGraph.
@Test
public void testExecutionGraphHistoryBeingDerivedFromFailedExecutionGraph() {
final ArchivedExecutionGraph executionGraph = ArchivedExecutionGraph.createSparseArchivedExecutionGraph(new JobID(), "test job name", JobStatus.FAILED, new RuntimeException("Expected RuntimeException"), null, System.currentTimeMillis());
final ExecutionGraphInfo executionGraphInfo = new ExecutionGraphInfo(executionGraph);
final ErrorInfo failureInfo = executionGraphInfo.getArchivedExecutionGraph().getFailureInfo();
final RootExceptionHistoryEntry actualEntry = Iterables.getOnlyElement(executionGraphInfo.getExceptionHistory());
assertThat(failureInfo).isNotNull();
assertThat(failureInfo.getException()).isEqualTo(actualEntry.getException());
assertThat(failureInfo.getTimestamp()).isEqualTo(actualEntry.getTimestamp());
assertThat(actualEntry.isGlobal()).isTrue();
assertThat(actualEntry.getFailingTaskName()).isNull();
assertThat(actualEntry.getTaskManagerLocation()).isNull();
}
use of org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry in project flink by apache.
the class DefaultSchedulerTest method testExceptionHistoryWithRestartableFailure.
@Test
public void testExceptionHistoryWithRestartableFailure() {
final JobGraph jobGraph = singleNonParallelJobVertexJobGraph();
final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
final TestingLogicalSlotBuilder logicalSlotBuilder = new TestingLogicalSlotBuilder();
logicalSlotBuilder.setTaskManagerLocation(taskManagerLocation);
executionSlotAllocatorFactory = new TestExecutionSlotAllocatorFactory(logicalSlotBuilder);
final DefaultScheduler scheduler = createSchedulerAndStartScheduling(jobGraph);
// initiate restartable failure
final ArchivedExecutionVertex taskFailureExecutionVertex = Iterables.getOnlyElement(scheduler.requestJob().getArchivedExecutionGraph().getAllExecutionVertices());
final RuntimeException restartableException = new RuntimeException("restartable exception");
final long updateStateTriggeringRestartTimestamp = initiateFailure(scheduler, taskFailureExecutionVertex.getCurrentExecutionAttempt().getAttemptId(), restartableException);
taskRestartExecutor.triggerNonPeriodicScheduledTask();
// initiate job failure
testRestartBackoffTimeStrategy.setCanRestart(false);
final ExecutionAttemptID failingAttemptId = Iterables.getOnlyElement(scheduler.requestJob().getArchivedExecutionGraph().getAllExecutionVertices()).getCurrentExecutionAttempt().getAttemptId();
final RuntimeException failingException = new RuntimeException("failing exception");
final long updateStateTriggeringJobFailureTimestamp = initiateFailure(scheduler, failingAttemptId, failingException);
final Iterable<RootExceptionHistoryEntry> actualExceptionHistory = scheduler.getExceptionHistory();
// assert restarted attempt
assertThat(actualExceptionHistory, IsIterableContainingInOrder.contains(ExceptionHistoryEntryMatcher.matchesFailure(restartableException, updateStateTriggeringRestartTimestamp, taskFailureExecutionVertex.getTaskNameWithSubtaskIndex(), taskFailureExecutionVertex.getCurrentAssignedResourceLocation()), ExceptionHistoryEntryMatcher.matchesGlobalFailure(failingException, updateStateTriggeringJobFailureTimestamp)));
}
use of org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry 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.scheduler.exceptionhistory.RootExceptionHistoryEntry in project flink by apache.
the class JobExceptionsHandlerTest method testWithExceptionHistory.
@Test
public void testWithExceptionHistory() throws HandlerRequestException {
final RootExceptionHistoryEntry rootCause = fromGlobalFailure(new RuntimeException("exception #0"), System.currentTimeMillis());
final RootExceptionHistoryEntry otherFailure = new RootExceptionHistoryEntry(new RuntimeException("exception #1"), System.currentTimeMillis(), "task name", new LocalTaskManagerLocation(), Collections.emptySet());
final ExecutionGraphInfo executionGraphInfo = createExecutionGraphInfo(rootCause, otherFailure);
final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 10);
final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
assertThat(response.getExceptionHistory().getEntries(), contains(historyContainsGlobalFailure(rootCause.getException(), rootCause.getTimestamp()), historyContainsJobExceptionInfo(otherFailure.getException(), otherFailure.getTimestamp(), otherFailure.getFailingTaskName(), JobExceptionsHandler.toString(otherFailure.getTaskManagerLocation()))));
assertFalse(response.getExceptionHistory().isTruncated());
}
use of org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry 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);
}
Aggregations