Search in sources :

Example 1 with MonotonicClock

use of org.apache.hadoop.hive.llap.tezplugins.helpers.MonotonicClock in project hive by apache.

the class TestLlapTaskSchedulerService method testTaskInfoDelay.

@Test(timeout = 10000)
public void testTaskInfoDelay() {
    LlapTaskSchedulerService.LocalityDelayConf localityDelayConf1 = new LlapTaskSchedulerService.LocalityDelayConf(3000);
    ControlledClock clock = new ControlledClock(new MonotonicClock());
    clock.setTime(clock.getTime());
    // With a timeout of 3000.
    LlapTaskSchedulerService.TaskInfo taskInfo = new LlapTaskSchedulerService.TaskInfo(localityDelayConf1, clock, new Object(), new Object(), mock(Priority.class), mock(Resource.class), null, null, clock.getTime());
    assertFalse(taskInfo.shouldForceLocality());
    assertEquals(3000, taskInfo.getDelay(TimeUnit.MILLISECONDS));
    assertTrue(taskInfo.shouldDelayForLocality(clock.getTime()));
    clock.setTime(clock.getTime() + 500);
    assertEquals(2500, taskInfo.getDelay(TimeUnit.MILLISECONDS));
    assertTrue(taskInfo.shouldDelayForLocality(clock.getTime()));
    clock.setTime(clock.getTime() + 2500);
    assertEquals(0, taskInfo.getDelay(TimeUnit.MILLISECONDS));
    assertFalse(taskInfo.shouldDelayForLocality(clock.getTime()));
    // No locality delay
    LlapTaskSchedulerService.LocalityDelayConf localityDelayConf2 = new LlapTaskSchedulerService.LocalityDelayConf(0);
    taskInfo = new LlapTaskSchedulerService.TaskInfo(localityDelayConf2, clock, new Object(), new Object(), mock(Priority.class), mock(Resource.class), null, null, clock.getTime());
    assertFalse(taskInfo.shouldDelayForLocality(clock.getTime()));
    assertFalse(taskInfo.shouldForceLocality());
    assertTrue(taskInfo.getDelay(TimeUnit.MILLISECONDS) < 0);
    // Force locality
    LlapTaskSchedulerService.LocalityDelayConf localityDelayConf3 = new LlapTaskSchedulerService.LocalityDelayConf(-1);
    taskInfo = new LlapTaskSchedulerService.TaskInfo(localityDelayConf3, clock, new Object(), new Object(), mock(Priority.class), mock(Resource.class), null, null, clock.getTime());
    assertTrue(taskInfo.shouldDelayForLocality(clock.getTime()));
    assertTrue(taskInfo.shouldForceLocality());
    assertFalse(taskInfo.getDelay(TimeUnit.MILLISECONDS) < 0);
}
Also used : Priority(org.apache.hadoop.yarn.api.records.Priority) Resource(org.apache.hadoop.yarn.api.records.Resource) ControlledClock(org.apache.hadoop.hive.llap.testhelpers.ControlledClock) MonotonicClock(org.apache.hadoop.hive.llap.tezplugins.helpers.MonotonicClock) Test(org.junit.Test)

Example 2 with MonotonicClock

use of org.apache.hadoop.hive.llap.tezplugins.helpers.MonotonicClock in project hive by apache.

the class TestLlapTaskSchedulerService method testLocalityDelayTaskOrdering.

@Test(timeout = 10000)
public void testLocalityDelayTaskOrdering() throws InterruptedException, IOException {
    LlapTaskSchedulerService.LocalityDelayConf localityDelayConf = new LlapTaskSchedulerService.LocalityDelayConf(3000);
    ControlledClock clock = new ControlledClock(new MonotonicClock());
    clock.setTime(clock.getTime());
    DelayQueue<LlapTaskSchedulerService.TaskInfo> delayedQueue = new DelayQueue<>();
    LlapTaskSchedulerService.TaskInfo taskInfo1 = new LlapTaskSchedulerService.TaskInfo(localityDelayConf, clock, new Object(), new Object(), mock(Priority.class), mock(Resource.class), null, null, clock.getTime());
    clock.setTime(clock.getTime() + 1000);
    LlapTaskSchedulerService.TaskInfo taskInfo2 = new LlapTaskSchedulerService.TaskInfo(localityDelayConf, clock, new Object(), new Object(), mock(Priority.class), mock(Resource.class), null, null, clock.getTime());
    delayedQueue.add(taskInfo1);
    delayedQueue.add(taskInfo2);
    assertEquals(taskInfo1, delayedQueue.peek());
}
Also used : Priority(org.apache.hadoop.yarn.api.records.Priority) Resource(org.apache.hadoop.yarn.api.records.Resource) ControlledClock(org.apache.hadoop.hive.llap.testhelpers.ControlledClock) MonotonicClock(org.apache.hadoop.hive.llap.tezplugins.helpers.MonotonicClock) DelayQueue(java.util.concurrent.DelayQueue) Test(org.junit.Test)

Aggregations

ControlledClock (org.apache.hadoop.hive.llap.testhelpers.ControlledClock)2 MonotonicClock (org.apache.hadoop.hive.llap.tezplugins.helpers.MonotonicClock)2 Priority (org.apache.hadoop.yarn.api.records.Priority)2 Resource (org.apache.hadoop.yarn.api.records.Resource)2 Test (org.junit.Test)2 DelayQueue (java.util.concurrent.DelayQueue)1