Search in sources :

Example 1 with TestFailoverStrategyFactory

use of org.apache.flink.runtime.executiongraph.utils.TestFailoverStrategyFactory in project flink by apache.

the class DefaultSchedulerTest method testExceptionHistoryConcurrentRestart.

@Test
public void testExceptionHistoryConcurrentRestart() throws Exception {
    final JobGraph jobGraph = singleJobVertexJobGraph(2);
    final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
    final TestingLogicalSlotBuilder logicalSlotBuilder = new TestingLogicalSlotBuilder();
    logicalSlotBuilder.setTaskManagerLocation(taskManagerLocation);
    executionSlotAllocatorFactory = new TestExecutionSlotAllocatorFactory(logicalSlotBuilder);
    final ReorganizableManuallyTriggeredScheduledExecutor delayExecutor = new ReorganizableManuallyTriggeredScheduledExecutor();
    final TestFailoverStrategyFactory failoverStrategyFactory = new TestFailoverStrategyFactory();
    final DefaultScheduler scheduler = createScheduler(jobGraph, ComponentMainThreadExecutorServiceAdapter.forMainThread(), new PipelinedRegionSchedulingStrategy.Factory(), failoverStrategyFactory, delayExecutor);
    scheduler.startScheduling();
    final ExecutionVertex executionVertex0 = Iterables.get(scheduler.getExecutionGraph().getAllExecutionVertices(), 0);
    final ExecutionVertex executionVertex1 = Iterables.get(scheduler.getExecutionGraph().getAllExecutionVertices(), 1);
    // single-ExecutionVertex failure
    final RuntimeException exception0 = new RuntimeException("failure #0");
    failoverStrategyFactory.setTasksToRestart(executionVertex0.getID());
    final long updateStateTriggeringRestartTimestamp0 = initiateFailure(scheduler, executionVertex0.getCurrentExecutionAttempt().getAttemptId(), exception0);
    // multi-ExecutionVertex failure
    final RuntimeException exception1 = new RuntimeException("failure #1");
    failoverStrategyFactory.setTasksToRestart(executionVertex1.getID(), executionVertex0.getID());
    final long updateStateTriggeringRestartTimestamp1 = initiateFailure(scheduler, executionVertex1.getCurrentExecutionAttempt().getAttemptId(), exception1);
    // there might be a race condition with the delayExecutor if the tasks are scheduled quite
    // close to each other which we want to simulate here
    Collections.reverse(delayExecutor.getCollectedScheduledTasks());
    delayExecutor.triggerNonPeriodicScheduledTasks();
    assertThat(scheduler.getExceptionHistory(), IsIterableWithSize.iterableWithSize(2));
    final Iterator<RootExceptionHistoryEntry> actualExceptionHistory = scheduler.getExceptionHistory().iterator();
    final RootExceptionHistoryEntry entry0 = actualExceptionHistory.next();
    assertThat(entry0, is(ExceptionHistoryEntryMatcher.matchesFailure(exception0, updateStateTriggeringRestartTimestamp0, executionVertex0.getTaskNameWithSubtaskIndex(), executionVertex0.getCurrentAssignedResourceLocation())));
    assertThat(entry0.getConcurrentExceptions(), IsIterableContainingInOrder.contains(ExceptionHistoryEntryMatcher.matchesFailure(exception1, updateStateTriggeringRestartTimestamp1, executionVertex1.getTaskNameWithSubtaskIndex(), executionVertex1.getCurrentAssignedResourceLocation())));
    final RootExceptionHistoryEntry entry1 = actualExceptionHistory.next();
    assertThat(entry1, is(ExceptionHistoryEntryMatcher.matchesFailure(exception1, updateStateTriggeringRestartTimestamp1, executionVertex1.getTaskNameWithSubtaskIndex(), executionVertex1.getCurrentAssignedResourceLocation())));
    assertThat(entry1.getConcurrentExceptions(), IsEmptyIterable.emptyIterable());
}
Also used : RootExceptionHistoryEntry(org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry) TestFailoverStrategyFactory(org.apache.flink.runtime.executiongraph.utils.TestFailoverStrategyFactory) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) ArchivedExecutionVertex(org.apache.flink.runtime.executiongraph.ArchivedExecutionVertex) ExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionVertex) SchedulingExecutionVertex(org.apache.flink.runtime.scheduler.strategy.SchedulingExecutionVertex) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) PipelinedRegionSchedulingStrategy(org.apache.flink.runtime.scheduler.strategy.PipelinedRegionSchedulingStrategy) AdaptiveSchedulerTest(org.apache.flink.runtime.scheduler.adaptive.AdaptiveSchedulerTest) Test(org.junit.Test)

Aggregations

ArchivedExecutionVertex (org.apache.flink.runtime.executiongraph.ArchivedExecutionVertex)1 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)1 TestFailoverStrategyFactory (org.apache.flink.runtime.executiongraph.utils.TestFailoverStrategyFactory)1 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)1 TestingLogicalSlotBuilder (org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder)1 AdaptiveSchedulerTest (org.apache.flink.runtime.scheduler.adaptive.AdaptiveSchedulerTest)1 RootExceptionHistoryEntry (org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry)1 PipelinedRegionSchedulingStrategy (org.apache.flink.runtime.scheduler.strategy.PipelinedRegionSchedulingStrategy)1 SchedulingExecutionVertex (org.apache.flink.runtime.scheduler.strategy.SchedulingExecutionVertex)1 LocalTaskManagerLocation (org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation)1 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)1 Test (org.junit.Test)1