Search in sources :

Example 1 with MockRequest

use of org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest in project hive by apache.

the class TestTaskExecutorService method testPreemptionStateOnTaskMoveToFinishableState.

@Test(timeout = 10000)
public void testPreemptionStateOnTaskMoveToFinishableState() throws InterruptedException {
    MockRequest r1 = createMockRequest(1, 1, 100, 200, false, 20000l);
    TaskExecutorServiceForTest taskExecutorService = new TaskExecutorServiceForTest(1, 2, ShortestJobFirstComparator.class.getName(), true);
    taskExecutorService.init(new Configuration());
    taskExecutorService.start();
    try {
        Scheduler.SubmissionState submissionState = taskExecutorService.schedule(r1);
        assertEquals(Scheduler.SubmissionState.ACCEPTED, submissionState);
        awaitStartAndSchedulerRun(r1, taskExecutorService);
        TaskWrapper taskWrapper = taskExecutorService.preemptionQueue.peek();
        assertNotNull(taskWrapper);
        assertTrue(taskWrapper.isInPreemptionQueue());
        // Now notify the executorService that the task has moved to finishable state.
        taskWrapper.finishableStateUpdated(true);
        TaskWrapper taskWrapper2 = taskExecutorService.preemptionQueue.peek();
        assertNull(taskWrapper2);
        assertFalse(taskWrapper.isInPreemptionQueue());
        r1.complete();
        r1.awaitEnd();
    } finally {
        taskExecutorService.shutDown(false);
    }
}
Also used : ShortestJobFirstComparator(org.apache.hadoop.hive.llap.daemon.impl.comparator.ShortestJobFirstComparator) TaskExecutorTestHelpers.createTaskWrapper(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.createTaskWrapper) TaskWrapper(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorService.TaskWrapper) Configuration(org.apache.hadoop.conf.Configuration) TaskExecutorTestHelpers.createMockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.createMockRequest) MockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest) Test(org.junit.Test)

Example 2 with MockRequest

use of org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest in project hive by apache.

the class TestTaskExecutorService method testFinishablePreemptsNonFinishable.

@Test(timeout = 20000)
public void testFinishablePreemptsNonFinishable() throws InterruptedException {
    MockRequest r1 = createMockRequest(1, 1, 100, 200, false, 50000000l, false);
    MockRequest r2 = createMockRequest(2, 1, 100, 200, true, 10000000l, false);
    testPreemptionHelper(r1, r2, true);
    r1 = createMockRequest(1, 1, 100, 200, false, 5000l, true);
    r2 = createMockRequest(2, 1, 100, 200, true, 1000l, true);
    testPreemptionHelper(r1, r2, true);
    // No preemption with ducks reversed.
    r1 = createMockRequest(1, 1, 100, 200, false, 500l, true);
    r2 = createMockRequest(2, 1, 100, 200, true, 1000l, false);
    testPreemptionHelper(r1, r2, false);
}
Also used : TaskExecutorTestHelpers.createMockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.createMockRequest) MockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest) Test(org.junit.Test)

Example 3 with MockRequest

use of org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest in project hive by apache.

the class TestTaskExecutorService method testPreemptionStateOnTaskFlagChanges.

@Test(timeout = 10000)
public void testPreemptionStateOnTaskFlagChanges() throws InterruptedException {
    MockRequest r1 = createMockRequest(1, 1, 100, 200, false, 20000l, false);
    MockRequest r2 = createMockRequest(2, 1, 100, 200, true, 2000000l, true);
    TaskExecutorServiceForTest taskExecutorService = new TaskExecutorServiceForTest(1, 2, ShortestJobFirstComparator.class.getName(), true);
    taskExecutorService.init(new Configuration());
    taskExecutorService.start();
    try {
        String fragmentId = r1.getRequestId();
        Scheduler.SubmissionState submissionState = taskExecutorService.schedule(r1);
        assertEquals(Scheduler.SubmissionState.ACCEPTED, submissionState);
        awaitStartAndSchedulerRun(r1, taskExecutorService);
        TaskWrapper taskWrapper = taskExecutorService.preemptionQueue.peek();
        assertNotNull(taskWrapper);
        assertTrue(taskWrapper.isInPreemptionQueue());
        // Now notify the executorService that the task has moved to finishable state.
        r1.setCanUpdateFinishable();
        taskWrapper.finishableStateUpdated(true);
        TaskWrapper taskWrapper2 = taskExecutorService.preemptionQueue.peek();
        assertNotNull(taskWrapper2);
        assertTrue(taskWrapper.isInPreemptionQueue());
        // And got a duck.
        boolean result = taskExecutorService.updateFragment(fragmentId, true);
        assertTrue(result);
        taskWrapper2 = taskExecutorService.preemptionQueue.peek();
        assertNull(taskWrapper2);
        assertFalse(taskWrapper.isInPreemptionQueue());
        r1.complete();
        r1.awaitEnd();
        // Now start with everything and test losing stuff.
        fragmentId = r2.getRequestId();
        submissionState = taskExecutorService.schedule(r2);
        assertEquals(Scheduler.SubmissionState.ACCEPTED, submissionState);
        awaitStartAndSchedulerRun(r2, taskExecutorService);
        taskWrapper = taskExecutorService.preemptionQueue.peek();
        assertNull(taskWrapper);
        // Lost the duck.
        result = taskExecutorService.updateFragment(fragmentId, false);
        assertTrue(result);
        taskWrapper = taskExecutorService.preemptionQueue.peek();
        assertNotNull(taskWrapper);
        assertTrue(taskWrapper.isInPreemptionQueue());
        // Gained it again.
        result = taskExecutorService.updateFragment(fragmentId, true);
        assertTrue(result);
        taskWrapper2 = taskExecutorService.preemptionQueue.peek();
        assertNull(taskWrapper2);
        assertFalse(taskWrapper.isInPreemptionQueue());
        // Now lost a finishable state.
        r2.setCanUpdateFinishable();
        taskWrapper.finishableStateUpdated(false);
        taskWrapper2 = taskExecutorService.preemptionQueue.peek();
        assertNotNull(taskWrapper2);
        assertTrue(taskWrapper.isInPreemptionQueue());
        r2.complete();
        r2.awaitEnd();
    } finally {
        taskExecutorService.shutDown(false);
    }
}
Also used : ShortestJobFirstComparator(org.apache.hadoop.hive.llap.daemon.impl.comparator.ShortestJobFirstComparator) TaskExecutorTestHelpers.createTaskWrapper(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.createTaskWrapper) TaskWrapper(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorService.TaskWrapper) Configuration(org.apache.hadoop.conf.Configuration) TaskExecutorTestHelpers.createMockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.createMockRequest) MockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest) Test(org.junit.Test)

Example 4 with MockRequest

use of org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest in project hive by apache.

the class TestTaskExecutorService method testWaitQueuePreemption.

@Test(timeout = 10000)
public void testWaitQueuePreemption() throws InterruptedException {
    MockRequest r1 = createMockRequest(1, 1, 100, 200, true, 20000l, false);
    MockRequest r2 = createMockRequest(2, 1, 1, 200, 330, false, 20000l, false);
    MockRequest r3 = createMockRequest(3, 2, 2, 300, 420, false, 20000l, false);
    MockRequest r4 = createMockRequest(4, 1, 3, 400, 510, false, 20000l, false);
    MockRequest r5 = createMockRequest(5, 1, 500, 610, true, 20000l, false);
    testWaitQueuePreemptionHelper(r1, r2, r3, r4, r5);
}
Also used : TaskExecutorTestHelpers.createMockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.createMockRequest) MockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest) Test(org.junit.Test)

Example 5 with MockRequest

use of org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest in project hive by apache.

the class TestTaskExecutorService method testWaitQueuePreemptionDucks.

@Test(timeout = 10000)
public void testWaitQueuePreemptionDucks() throws InterruptedException {
    // Throw in some canFinish variations just for fun.
    MockRequest r1 = createMockRequest(1, 1, 100, 200, false, 20000l, true);
    MockRequest r2 = createMockRequest(2, 1, 1, 200, 330, true, 20000l, false);
    MockRequest r3 = createMockRequest(3, 2, 2, 300, 420, true, 20000l, false);
    MockRequest r4 = createMockRequest(4, 1, 3, 400, 510, false, 20000l, false);
    MockRequest r5 = createMockRequest(5, 1, 500, 610, false, 20000l, true);
    testWaitQueuePreemptionHelper(r1, r2, r3, r4, r5);
}
Also used : TaskExecutorTestHelpers.createMockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.createMockRequest) MockRequest(org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest) Test(org.junit.Test)

Aggregations

MockRequest (org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.MockRequest)12 TaskExecutorTestHelpers.createMockRequest (org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.createMockRequest)12 Test (org.junit.Test)11 Configuration (org.apache.hadoop.conf.Configuration)6 ShortestJobFirstComparator (org.apache.hadoop.hive.llap.daemon.impl.comparator.ShortestJobFirstComparator)6 TaskWrapper (org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorService.TaskWrapper)3 TaskExecutorTestHelpers.createTaskWrapper (org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorTestHelpers.createTaskWrapper)3 ControlledClock (org.apache.hadoop.hive.llap.testhelpers.ControlledClock)1 SystemClock (org.apache.hadoop.yarn.util.SystemClock)1