Search in sources :

Example 1 with AMSchedulerEventTALaunchRequest

use of org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest in project tez by apache.

the class TestTaskAttempt method testRetriesAtSamePriorityConfig.

@Test(timeout = 5000)
public void testRetriesAtSamePriorityConfig() {
    // Override the test defaults to setup the config change
    TezConfiguration vertexConf = new TezConfiguration();
    vertexConf.setBoolean(TezConfiguration.TEZ_AM_TASK_RESCHEDULE_HIGHER_PRIORITY, false);
    vertexConf.setBoolean(TezConfiguration.TEZ_AM_TASK_RESCHEDULE_RELAXED_LOCALITY, true);
    when(mockVertex.getVertexConfig()).thenReturn(new VertexImpl.VertexConfigImpl(vertexConf));
    // set locality
    Set<String> hosts = new TreeSet<String>();
    hosts.add("host1");
    locationHint = TaskLocationHint.createTaskLocationHint(hosts, null);
    TaskAttemptImpl.ScheduleTaskattemptTransition sta = new TaskAttemptImpl.ScheduleTaskattemptTransition();
    EventHandler eventHandler = mock(EventHandler.class);
    TezTaskID taskID = TezTaskID.getInstance(TezVertexID.getInstance(TezDAGID.getInstance("1", 1, 1), 1), 1);
    TaskAttemptImpl taImpl = new MockTaskAttemptImpl(taskID, 1, eventHandler, mock(TaskCommunicatorManagerInterface.class), new Configuration(), new SystemClock(), mock(TaskHeartbeatHandler.class), appCtx, false, Resource.newInstance(1024, 1), createFakeContainerContext(), false);
    TaskAttemptImpl taImplReScheduled = new MockTaskAttemptImpl(taskID, 1, eventHandler, mock(TaskCommunicatorManagerInterface.class), new Configuration(), new SystemClock(), mock(TaskHeartbeatHandler.class), appCtx, true, Resource.newInstance(1024, 1), createFakeContainerContext(), false);
    ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
    TaskAttemptEventSchedule sEvent = mock(TaskAttemptEventSchedule.class);
    when(sEvent.getPriorityLowLimit()).thenReturn(3);
    when(sEvent.getPriorityHighLimit()).thenReturn(1);
    // Verify priority for a non-retried attempt
    sta.transition(taImpl, sEvent);
    verify(eventHandler, times(1)).handle(arg.capture());
    AMSchedulerEventTALaunchRequest launchEvent = (AMSchedulerEventTALaunchRequest) arg.getValue();
    Assert.assertEquals(2, launchEvent.getPriority());
    Assert.assertEquals(1, launchEvent.getLocationHint().getHosts().size());
    Assert.assertTrue(launchEvent.getLocationHint().getHosts().contains("host1"));
    // Verify priority for a retried attempt is the same
    sta.transition(taImplReScheduled, sEvent);
    verify(eventHandler, times(2)).handle(arg.capture());
    launchEvent = (AMSchedulerEventTALaunchRequest) arg.getValue();
    Assert.assertEquals(2, launchEvent.getPriority());
    Assert.assertNull(launchEvent.getLocationHint());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) SystemClock(org.apache.hadoop.yarn.util.SystemClock) EventHandler(org.apache.hadoop.yarn.event.EventHandler) HistoryEventHandler(org.apache.tez.dag.history.HistoryEventHandler) TaskCommunicatorManagerInterface(org.apache.tez.dag.app.TaskCommunicatorManagerInterface) TezTaskID(org.apache.tez.dag.records.TezTaskID) TreeSet(java.util.TreeSet) AMSchedulerEventTALaunchRequest(org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest) TaskHeartbeatHandler(org.apache.tez.dag.app.TaskHeartbeatHandler) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) TaskAttemptFinishedEvent(org.apache.tez.dag.history.events.TaskAttemptFinishedEvent) TaskEvent(org.apache.tez.dag.app.dag.event.TaskEvent) DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Example 2 with AMSchedulerEventTALaunchRequest

use of org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest in project tez by apache.

the class TestTaskAttempt method testLocalityRequest.

@Test(timeout = 5000)
public void testLocalityRequest() {
    TaskAttemptImpl.ScheduleTaskattemptTransition sta = new TaskAttemptImpl.ScheduleTaskattemptTransition();
    EventHandler eventHandler = mock(EventHandler.class);
    Set<String> hosts = new TreeSet<String>();
    hosts.add("host1");
    hosts.add("host2");
    hosts.add("host3");
    locationHint = TaskLocationHint.createTaskLocationHint(hosts, null);
    TezTaskID taskID = TezTaskID.getInstance(TezVertexID.getInstance(TezDAGID.getInstance("1", 1, 1), 1), 1);
    TaskAttemptImpl taImpl = new MockTaskAttemptImpl(taskID, 1, eventHandler, mock(TaskCommunicatorManagerInterface.class), new Configuration(), new SystemClock(), mock(TaskHeartbeatHandler.class), appCtx, false, Resource.newInstance(1024, 1), createFakeContainerContext(), false);
    TaskAttemptEventSchedule sEvent = mock(TaskAttemptEventSchedule.class);
    sta.transition(taImpl, sEvent);
    ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
    verify(eventHandler, times(1)).handle(arg.capture());
    if (!(arg.getAllValues().get(0) instanceof AMSchedulerEventTALaunchRequest)) {
        fail("Second event not of type " + AMSchedulerEventTALaunchRequest.class.getName());
    }
    // TODO Move the Rack request check to the client after TEZ-125 is fixed.
    Set<String> requestedRacks = taImpl.taskRacks;
    assertEquals(1, requestedRacks.size());
    assertEquals(3, taImpl.taskHosts.size());
    for (int i = 0; i < 3; i++) {
        String host = ("host" + (i + 1));
        assertEquals(host, true, taImpl.taskHosts.contains(host));
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) SystemClock(org.apache.hadoop.yarn.util.SystemClock) EventHandler(org.apache.hadoop.yarn.event.EventHandler) HistoryEventHandler(org.apache.tez.dag.history.HistoryEventHandler) TaskCommunicatorManagerInterface(org.apache.tez.dag.app.TaskCommunicatorManagerInterface) TezTaskID(org.apache.tez.dag.records.TezTaskID) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint) TreeSet(java.util.TreeSet) AMSchedulerEventTALaunchRequest(org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest) TaskHeartbeatHandler(org.apache.tez.dag.app.TaskHeartbeatHandler) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) TaskAttemptFinishedEvent(org.apache.tez.dag.history.events.TaskAttemptFinishedEvent) TaskEvent(org.apache.tez.dag.app.dag.event.TaskEvent) DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule) Test(org.junit.Test)

Example 3 with AMSchedulerEventTALaunchRequest

use of org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest in project tez by apache.

the class TestVertexImpl method testPickupDagLocalResourceOnScheduleTask.

@Test(timeout = 5000)
public void testPickupDagLocalResourceOnScheduleTask() {
    initAllVertices(VertexState.INITED);
    VertexImpl v1 = vertices.get("vertex1");
    startVertex(v1);
    TezTaskAttemptID taskAttemptId0 = TezTaskAttemptID.getInstance(v1.getTask(0).getTaskId(), 0);
    TaskAttemptImpl ta0 = (TaskAttemptImpl) v1.getTask(0).getAttempt(taskAttemptId0);
    ta0.handle(new TaskAttemptEventSchedule(taskAttemptId0, 1, 1));
    dispatcher.await();
    Assert.assertEquals(1, amSchedulerEventDispatcher.events.size());
    AMSchedulerEventTALaunchRequest launchRequestEvent = (AMSchedulerEventTALaunchRequest) amSchedulerEventDispatcher.events.get(0);
    Map<String, LocalResource> localResourceMap = launchRequestEvent.getContainerContext().getLocalResources();
    Assert.assertTrue(localResourceMap.containsKey("dag lr"));
    Assert.assertTrue(localResourceMap.containsKey("vertex lr"));
}
Also used : AMSchedulerEventTALaunchRequest(org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule) ByteString(com.google.protobuf.ByteString) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) PlanLocalResource(org.apache.tez.dag.api.records.DAGProtos.PlanLocalResource) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) VertexManagerPluginForTest(org.apache.tez.test.VertexManagerPluginForTest) Test(org.junit.Test) GraceShuffleVertexManagerForTest(org.apache.tez.test.GraceShuffleVertexManagerForTest) StateChangeNotifierForTest(org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest) EdgeManagerForTest(org.apache.tez.test.EdgeManagerForTest)

Example 4 with AMSchedulerEventTALaunchRequest

use of org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest in project tez by apache.

the class TestTaskAttempt method testPriority.

@Test(timeout = 5000)
public void testPriority() {
    TaskAttemptImpl.ScheduleTaskattemptTransition sta = new TaskAttemptImpl.ScheduleTaskattemptTransition();
    EventHandler eventHandler = mock(EventHandler.class);
    TezTaskID taskID = TezTaskID.getInstance(TezVertexID.getInstance(TezDAGID.getInstance("1", 1, 1), 1), 1);
    TaskAttemptImpl taImpl = new MockTaskAttemptImpl(taskID, 1, eventHandler, mock(TaskCommunicatorManagerInterface.class), new Configuration(), new SystemClock(), mock(TaskHeartbeatHandler.class), appCtx, false, Resource.newInstance(1024, 1), createFakeContainerContext(), false);
    TaskAttemptImpl taImplReScheduled = new MockTaskAttemptImpl(taskID, 1, eventHandler, mock(TaskCommunicatorManagerInterface.class), new Configuration(), new SystemClock(), mock(TaskHeartbeatHandler.class), appCtx, true, Resource.newInstance(1024, 1), createFakeContainerContext(), false);
    ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
    TaskAttemptEventSchedule sEvent = mock(TaskAttemptEventSchedule.class);
    when(sEvent.getPriorityLowLimit()).thenReturn(3);
    when(sEvent.getPriorityHighLimit()).thenReturn(1);
    sta.transition(taImpl, sEvent);
    verify(eventHandler, times(1)).handle(arg.capture());
    AMSchedulerEventTALaunchRequest launchEvent = (AMSchedulerEventTALaunchRequest) arg.getValue();
    Assert.assertEquals(2, launchEvent.getPriority());
    sta.transition(taImplReScheduled, sEvent);
    verify(eventHandler, times(2)).handle(arg.capture());
    launchEvent = (AMSchedulerEventTALaunchRequest) arg.getValue();
    Assert.assertEquals(1, launchEvent.getPriority());
    when(sEvent.getPriorityLowLimit()).thenReturn(6);
    when(sEvent.getPriorityHighLimit()).thenReturn(4);
    sta.transition(taImpl, sEvent);
    verify(eventHandler, times(3)).handle(arg.capture());
    launchEvent = (AMSchedulerEventTALaunchRequest) arg.getValue();
    Assert.assertEquals(5, launchEvent.getPriority());
    sta.transition(taImplReScheduled, sEvent);
    verify(eventHandler, times(4)).handle(arg.capture());
    launchEvent = (AMSchedulerEventTALaunchRequest) arg.getValue();
    Assert.assertEquals(4, launchEvent.getPriority());
    when(sEvent.getPriorityLowLimit()).thenReturn(5);
    when(sEvent.getPriorityHighLimit()).thenReturn(5);
    sta.transition(taImpl, sEvent);
    verify(eventHandler, times(5)).handle(arg.capture());
    launchEvent = (AMSchedulerEventTALaunchRequest) arg.getValue();
    Assert.assertEquals(5, launchEvent.getPriority());
    sta.transition(taImplReScheduled, sEvent);
    verify(eventHandler, times(6)).handle(arg.capture());
    launchEvent = (AMSchedulerEventTALaunchRequest) arg.getValue();
    Assert.assertEquals(5, launchEvent.getPriority());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) SystemClock(org.apache.hadoop.yarn.util.SystemClock) EventHandler(org.apache.hadoop.yarn.event.EventHandler) HistoryEventHandler(org.apache.tez.dag.history.HistoryEventHandler) TaskCommunicatorManagerInterface(org.apache.tez.dag.app.TaskCommunicatorManagerInterface) TezTaskID(org.apache.tez.dag.records.TezTaskID) AMSchedulerEventTALaunchRequest(org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest) TaskHeartbeatHandler(org.apache.tez.dag.app.TaskHeartbeatHandler) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) TaskAttemptFinishedEvent(org.apache.tez.dag.history.events.TaskAttemptFinishedEvent) TaskEvent(org.apache.tez.dag.app.dag.event.TaskEvent) DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule) Test(org.junit.Test)

Example 5 with AMSchedulerEventTALaunchRequest

use of org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest in project tez by apache.

the class TestTaskAttempt method testHostResolveAttempt.

@Test(timeout = 5000)
public // TODO Move to the client post TEZ-125.
void testHostResolveAttempt() throws Exception {
    TaskAttemptImpl.ScheduleTaskattemptTransition sta = new TaskAttemptImpl.ScheduleTaskattemptTransition();
    EventHandler eventHandler = mock(EventHandler.class);
    String[] hosts = new String[] { "127.0.0.1", "host2", "host3" };
    Set<String> resolved = new TreeSet<String>(Arrays.asList(new String[] { "host1", "host2", "host3" }));
    locationHint = TaskLocationHint.createTaskLocationHint(new TreeSet<String>(Arrays.asList(hosts)), null);
    TezTaskID taskID = TezTaskID.getInstance(TezVertexID.getInstance(TezDAGID.getInstance("1", 1, 1), 1), 1);
    TaskAttemptImpl taImpl = new MockTaskAttemptImpl(taskID, 1, eventHandler, mock(TaskCommunicatorManagerInterface.class), new Configuration(), new SystemClock(), mock(TaskHeartbeatHandler.class), appCtx, false, Resource.newInstance(1024, 1), createFakeContainerContext(), false);
    TaskAttemptImpl spyTa = spy(taImpl);
    when(spyTa.resolveHosts(hosts)).thenReturn(resolved.toArray(new String[3]));
    TaskAttemptEventSchedule mockTAEvent = mock(TaskAttemptEventSchedule.class);
    sta.transition(spyTa, mockTAEvent);
    verify(spyTa).resolveHosts(hosts);
    ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
    verify(eventHandler, times(1)).handle(arg.capture());
    if (!(arg.getAllValues().get(0) instanceof AMSchedulerEventTALaunchRequest)) {
        fail("Second Event not of type ContainerRequestEvent");
    }
    Map<String, Boolean> expected = new HashMap<String, Boolean>();
    expected.put("host1", true);
    expected.put("host2", true);
    expected.put("host3", true);
    Set<String> requestedHosts = spyTa.taskHosts;
    for (String h : requestedHosts) {
        expected.remove(h);
    }
    assertEquals(0, expected.size());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) SystemClock(org.apache.hadoop.yarn.util.SystemClock) HashMap(java.util.HashMap) EventHandler(org.apache.hadoop.yarn.event.EventHandler) HistoryEventHandler(org.apache.tez.dag.history.HistoryEventHandler) TaskCommunicatorManagerInterface(org.apache.tez.dag.app.TaskCommunicatorManagerInterface) TezTaskID(org.apache.tez.dag.records.TezTaskID) TreeSet(java.util.TreeSet) AMSchedulerEventTALaunchRequest(org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest) TaskHeartbeatHandler(org.apache.tez.dag.app.TaskHeartbeatHandler) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) TaskAttemptFinishedEvent(org.apache.tez.dag.history.events.TaskAttemptFinishedEvent) TaskEvent(org.apache.tez.dag.app.dag.event.TaskEvent) DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) InputReadErrorEvent(org.apache.tez.runtime.api.events.InputReadErrorEvent) TaskAttemptEvent(org.apache.tez.dag.app.dag.event.TaskAttemptEvent) Event(org.apache.hadoop.yarn.event.Event) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) TaskAttemptEventSchedule(org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule) Test(org.junit.Test)

Aggregations

TaskAttemptEventSchedule (org.apache.tez.dag.app.dag.event.TaskAttemptEventSchedule)5 AMSchedulerEventTALaunchRequest (org.apache.tez.dag.app.rm.AMSchedulerEventTALaunchRequest)5 Test (org.junit.Test)5 Configuration (org.apache.hadoop.conf.Configuration)4 Event (org.apache.hadoop.yarn.event.Event)4 EventHandler (org.apache.hadoop.yarn.event.EventHandler)4 SystemClock (org.apache.hadoop.yarn.util.SystemClock)4 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)4 TaskCommunicatorManagerInterface (org.apache.tez.dag.app.TaskCommunicatorManagerInterface)4 TaskHeartbeatHandler (org.apache.tez.dag.app.TaskHeartbeatHandler)4 DAGEvent (org.apache.tez.dag.app.dag.event.DAGEvent)4 TaskAttemptEvent (org.apache.tez.dag.app.dag.event.TaskAttemptEvent)4 TaskEvent (org.apache.tez.dag.app.dag.event.TaskEvent)4 DAGHistoryEvent (org.apache.tez.dag.history.DAGHistoryEvent)4 HistoryEventHandler (org.apache.tez.dag.history.HistoryEventHandler)4 TaskAttemptFinishedEvent (org.apache.tez.dag.history.events.TaskAttemptFinishedEvent)4 TezTaskID (org.apache.tez.dag.records.TezTaskID)4 InputReadErrorEvent (org.apache.tez.runtime.api.events.InputReadErrorEvent)4 TaskStatusUpdateEvent (org.apache.tez.runtime.api.events.TaskStatusUpdateEvent)4 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)4