use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class ExecutingTest method testFailureReportedViaUpdateTaskExecutionStateCausesRestart.
@Test
public void testFailureReportedViaUpdateTaskExecutionStateCausesRestart() throws Exception {
try (MockExecutingContext ctx = new MockExecutingContext()) {
StateTrackingMockExecutionGraph returnsFailedStateExecutionGraph = new StateTrackingMockExecutionGraph();
Executing exec = new ExecutingStateBuilder().setExecutionGraph(returnsFailedStateExecutionGraph).build(ctx);
ctx.setHowToHandleFailure((failure) -> FailureResult.canRestart(failure, Duration.ZERO));
ctx.setExpectRestarting(assertNonNull());
Exception exception = new RuntimeException();
TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
returnsFailedStateExecutionGraph.registerExecution(execution);
TaskExecutionStateTransition taskExecutionStateTransition = createFailingStateTransition(execution.getAttemptId(), exception);
exec.updateTaskExecutionState(taskExecutionStateTransition);
}
}
use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class ExecutingTest method testFalseReportsViaUpdateTaskExecutionStateAreIgnored.
@Test
public void testFalseReportsViaUpdateTaskExecutionStateAreIgnored() throws Exception {
try (MockExecutingContext ctx = new MockExecutingContext()) {
MockExecutionGraph returnsFailedStateExecutionGraph = new MockExecutionGraph(false, Collections::emptyList);
Executing exec = new ExecutingStateBuilder().setExecutionGraph(returnsFailedStateExecutionGraph).build(ctx);
Exception exception = new RuntimeException();
TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
returnsFailedStateExecutionGraph.registerExecution(execution);
TaskExecutionStateTransition taskExecutionStateTransition = createFailingStateTransition(execution.getAttemptId(), exception);
exec.updateTaskExecutionState(taskExecutionStateTransition);
ctx.assertNoStateTransition();
}
}
use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class UpdateSchedulerNgOnInternalFailuresListener method notifyTaskFailure.
@Override
public void notifyTaskFailure(final ExecutionAttemptID attemptId, final Throwable t, final boolean cancelTask, final boolean releasePartitions) {
final TaskExecutionState state = new TaskExecutionState(attemptId, ExecutionState.FAILED, t);
schedulerNg.updateTaskExecutionState(new TaskExecutionStateTransition(state, cancelTask, releasePartitions));
}
use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class AdaptiveSchedulerTest method testExceptionHistoryWithTaskConcurrentFailure.
@Test
public void testExceptionHistoryWithTaskConcurrentFailure() throws Exception {
final Exception expectedException1 = new Exception("Expected Local Exception 1");
final Exception expectedException2 = new Exception("Expected Local Exception 2");
BiConsumer<AdaptiveScheduler, List<ExecutionAttemptID>> testLogic = (scheduler, attemptIds) -> {
final ExecutionAttemptID attemptId = attemptIds.remove(0);
final ExecutionAttemptID attemptId2 = attemptIds.remove(0);
scheduler.updateTaskExecutionState(new TaskExecutionStateTransition(new TaskExecutionState(attemptId, ExecutionState.FAILED, expectedException1)));
scheduler.updateTaskExecutionState(new TaskExecutionStateTransition(new TaskExecutionState(attemptId2, ExecutionState.FAILED, expectedException2)));
};
final Iterable<RootExceptionHistoryEntry> entries = runExceptionHistoryTests(testLogic);
assertThat(entries).hasSize(1);
final RootExceptionHistoryEntry failure = entries.iterator().next();
assertThat(failure.getException().deserializeError(classLoader)).isEqualTo(expectedException1);
final Iterable<ExceptionHistoryEntry> concurrentExceptions = failure.getConcurrentExceptions();
final List<Throwable> foundExceptions = IterableUtils.toStream(concurrentExceptions).map(ExceptionHistoryEntry::getException).map(exception -> exception.deserializeError(classLoader)).collect(Collectors.toList());
// In the future, concurrent local failures should be stored.
assertThat(foundExceptions).isEmpty();
}
use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class AdaptiveSchedulerTest method runExceptionHistoryTests.
private Iterable<RootExceptionHistoryEntry> runExceptionHistoryTests(BiConsumer<AdaptiveScheduler, List<ExecutionAttemptID>> testLogic, Consumer<AdaptiveSchedulerBuilder> setupScheduler, Consumer<JobGraph> setupJobGraph) throws Exception {
final int numAvailableSlots = 4;
final JobGraph jobGraph = createJobGraph();
setupJobGraph.accept(jobGraph);
RunFailedJobListener listener = new RunFailedJobListener();
List<ExecutionAttemptID> cancelledTasks = new ArrayList<>();
final CompletedCheckpointStore completedCheckpointStore = new StandaloneCompletedCheckpointStore(1);
final CheckpointIDCounter checkpointIDCounter = new StandaloneCheckpointIDCounter();
final CheckpointsCleaner checkpointCleaner = new CheckpointsCleaner();
TestingCheckpointRecoveryFactory checkpointRecoveryFactory = new TestingCheckpointRecoveryFactory(completedCheckpointStore, checkpointIDCounter);
final DefaultDeclarativeSlotPool declarativeSlotPool = createDeclarativeSlotPool(jobGraph.getJobID());
final Configuration configuration = new Configuration();
configuration.set(JobManagerOptions.RESOURCE_WAIT_TIMEOUT, Duration.ofMillis(1L));
AdaptiveSchedulerBuilder builder = new AdaptiveSchedulerBuilder(jobGraph, singleThreadMainThreadExecutor).setJobMasterConfiguration(configuration).setDeclarativeSlotPool(declarativeSlotPool).setCheckpointRecoveryFactory(checkpointRecoveryFactory).setCheckpointCleaner(checkpointCleaner).setJobStatusListener(listener);
setupScheduler.accept(builder);
final AdaptiveScheduler scheduler = builder.build();
final SubmissionBufferingTaskManagerGateway taskManagerGateway = new SubmissionBufferingTaskManagerGateway(numAvailableSlots);
taskManagerGateway.setCancelConsumer(cancelledTasks::add);
singleThreadMainThreadExecutor.execute(() -> {
scheduler.startScheduling();
offerSlots(declarativeSlotPool, createSlotOffersForResourceRequirements(ResourceCounter.withResource(ResourceProfile.UNKNOWN, numAvailableSlots)), taskManagerGateway);
});
listener.waitForRunning();
CompletableFuture<Iterable<ArchivedExecutionVertex>> vertexFuture = new CompletableFuture<>();
singleThreadMainThreadExecutor.execute(() -> vertexFuture.complete(scheduler.requestJob().getArchivedExecutionGraph().getAllExecutionVertices()));
final Iterable<ArchivedExecutionVertex> executionVertices = vertexFuture.get();
final List<ExecutionAttemptID> attemptIds = IterableUtils.toStream(executionVertices).map(ArchivedExecutionVertex::getCurrentExecutionAttempt).map(ArchivedExecution::getAttemptId).collect(Collectors.toList());
CompletableFuture<Void> runTestLogicFuture = CompletableFuture.runAsync(() -> testLogic.accept(scheduler, attemptIds), singleThreadMainThreadExecutor);
runTestLogicFuture.get();
Consumer<ExecutionAttemptID> canceller = attemptId -> scheduler.updateTaskExecutionState(new TaskExecutionStateTransition(new TaskExecutionState(attemptId, ExecutionState.CANCELED, null)));
CompletableFuture<Void> cancelFuture = CompletableFuture.runAsync(() -> cancelledTasks.forEach(canceller), singleThreadMainThreadExecutor);
cancelFuture.get();
listener.waitForTerminal();
return scheduler.requestJob().getExceptionHistory();
}
Aggregations