use of org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest in project hive by apache.
the class TestTaskExecutorService method runPreemptionGraceTest.
private void runPreemptionGraceTest(MockRequest victim1, MockRequest victim2, int time) throws InterruptedException {
MockRequest preemptor = createMockRequest(3, 1, 100, 100, true, 20000l, false);
victim1.setSleepAfterKill();
victim2.setSleepAfterKill();
ControlledClock clock = new ControlledClock(new SystemClock());
clock.setTime(0);
TaskExecutorServiceForTest taskExecutorService = new TaskExecutorServiceForTest(2, 3, ShortestJobFirstComparator.class.getName(), true, clock);
taskExecutorService.init(new Configuration());
taskExecutorService.start();
try {
taskExecutorService.schedule(victim1);
awaitStartAndSchedulerRun(victim1, taskExecutorService);
taskExecutorService.schedule(victim2);
awaitStartAndSchedulerRun(victim2, taskExecutorService);
taskExecutorService.schedule(preemptor);
// Wait for scheduling to run a few times.
taskExecutorService.waitForScheduleRuns(5);
clock.setTime(time);
// Wait for scheduling to run a few times.
taskExecutorService.waitForScheduleRuns(5);
victim1.unblockKill();
victim2.unblockKill();
preemptor.complete();
preemptor.awaitEnd();
TaskExecutorServiceForTest.InternalCompletionListenerForTest icl3 = taskExecutorService.getInternalCompletionListenerForTest(preemptor.getRequestId());
icl3.awaitCompletion();
} finally {
taskExecutorService.shutDown(false);
}
}
use of org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest in project hive by apache.
the class TestTaskExecutorService method testWaitQueueAcceptAfterAMTaskReport.
// Tests wait queue behaviour for fragments which have reported to the AM, but have not given up their executor slot.
@Test(timeout = 10000)
public void testWaitQueueAcceptAfterAMTaskReport() throws InterruptedException {
TaskExecutorServiceForTest taskExecutorService = new TaskExecutorServiceForTest(1, 2, ShortestJobFirstComparator.class.getName(), true);
// Fourth is lower priority as a result of canFinish being set to false.
MockRequest r1 = createMockRequest(1, 1, 100, 200, true, 20000l, false);
MockRequest r2 = createMockRequest(2, 1, 1, 200, 2000, true, 20000l, false);
MockRequest r3 = createMockRequest(3, 1, 2, 300, 420, true, 20000l, false);
MockRequest r4 = createMockRequest(4, 1, 3, 400, 510, false, 20000l, false);
taskExecutorService.init(new Configuration());
taskExecutorService.start();
try {
Scheduler.SubmissionState submissionState;
submissionState = taskExecutorService.schedule(r1);
assertEquals(Scheduler.SubmissionState.ACCEPTED, submissionState);
r1.awaitStart();
submissionState = taskExecutorService.schedule(r2);
assertEquals(Scheduler.SubmissionState.ACCEPTED, submissionState);
submissionState = taskExecutorService.schedule(r3);
assertEquals(Scheduler.SubmissionState.ACCEPTED, submissionState);
submissionState = taskExecutorService.schedule(r4);
assertEquals(Scheduler.SubmissionState.REJECTED, submissionState);
// Mark a fragment as completing, but don't actually complete it yet.
// The wait queue should now have capacity to accept one more fragment.
taskExecutorService.fragmentCompleting(r1.getRequestId(), SchedulerFragmentCompletingListener.State.SUCCESS);
submissionState = taskExecutorService.schedule(r4);
assertEquals(Scheduler.SubmissionState.ACCEPTED, submissionState);
assertEquals(3, taskExecutorService.waitQueue.size());
assertEquals(1, taskExecutorService.completingFragmentMap.size());
r1.complete();
r1.awaitEnd();
// r2 can only start once 1 fragment has completed. the map should be clear at this point.
awaitStartAndSchedulerRun(r2, taskExecutorService);
assertEquals(0, taskExecutorService.completingFragmentMap.size());
} finally {
taskExecutorService.shutDown(false);
}
}
Aggregations