Search in sources :

Example 1 with AMContainer

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

the class TaskSchedulerManager method containerCompleted.

public synchronized void containerCompleted(int schedulerId, Object task, ContainerStatus containerStatus) {
    // SchedulerId isn't used here since no node updates are sent out
    // Inform the Containers about completion.
    AMContainer amContainer = appContext.getAllContainers().get(containerStatus.getContainerId());
    if (amContainer != null) {
        String message = "Container completed. ";
        TaskAttemptTerminationCause errCause = TaskAttemptTerminationCause.CONTAINER_EXITED;
        int exitStatus = containerStatus.getExitStatus();
        if (exitStatus == ContainerExitStatus.PREEMPTED) {
            message = "Container preempted externally. ";
            errCause = TaskAttemptTerminationCause.EXTERNAL_PREEMPTION;
        } else if (exitStatus == ContainerExitStatus.DISKS_FAILED) {
            message = "Container disk failed. ";
            errCause = TaskAttemptTerminationCause.NODE_DISK_ERROR;
        } else if (exitStatus != ContainerExitStatus.SUCCESS) {
            message = "Container failed, exitCode=" + exitStatus + ". ";
        }
        if (containerStatus.getDiagnostics() != null) {
            message += containerStatus.getDiagnostics();
        }
        sendEvent(new AMContainerEventCompleted(amContainer.getContainerId(), exitStatus, message, errCause));
    }
}
Also used : AMContainerEventCompleted(org.apache.tez.dag.app.rm.container.AMContainerEventCompleted) TaskAttemptTerminationCause(org.apache.tez.dag.records.TaskAttemptTerminationCause) AMContainer(org.apache.tez.dag.app.rm.container.AMContainer) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint)

Example 2 with AMContainer

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

the class TestTaskSchedulerManager method testContainerDiskFailed.

@Test(timeout = 5000)
public void testContainerDiskFailed() throws IOException {
    Configuration conf = new Configuration(false);
    schedulerHandler.init(conf);
    schedulerHandler.start();
    String diagnostics = "NM disk failed.";
    TaskAttemptImpl mockTask = mock(TaskAttemptImpl.class);
    ContainerStatus mockStatus = mock(ContainerStatus.class);
    ContainerId mockCId = mock(ContainerId.class);
    AMContainer mockAMContainer = mock(AMContainer.class);
    when(mockAMContainerMap.get(mockCId)).thenReturn(mockAMContainer);
    when(mockAMContainer.getContainerId()).thenReturn(mockCId);
    when(mockStatus.getContainerId()).thenReturn(mockCId);
    when(mockStatus.getDiagnostics()).thenReturn(diagnostics);
    when(mockStatus.getExitStatus()).thenReturn(ContainerExitStatus.DISKS_FAILED);
    schedulerHandler.containerCompleted(0, mockTask, mockStatus);
    assertEquals(1, mockEventHandler.events.size());
    Event event = mockEventHandler.events.get(0);
    assertEquals(AMContainerEventType.C_COMPLETED, event.getType());
    AMContainerEventCompleted completedEvent = (AMContainerEventCompleted) event;
    assertEquals(mockCId, completedEvent.getContainerId());
    assertEquals("Container disk failed. NM disk failed.", completedEvent.getDiagnostics());
    Assert.assertFalse(completedEvent.isPreempted());
    assertTrue(completedEvent.isDiskFailed());
    assertEquals(TaskAttemptTerminationCause.NODE_DISK_ERROR, completedEvent.getTerminationCause());
    schedulerHandler.stop();
    schedulerHandler.close();
}
Also used : AMContainerEventCompleted(org.apache.tez.dag.app.rm.container.AMContainerEventCompleted) ContainerStatus(org.apache.hadoop.yarn.api.records.ContainerStatus) Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) TaskAttemptImpl(org.apache.tez.dag.app.dag.impl.TaskAttemptImpl) Event(org.apache.hadoop.yarn.event.Event) AMContainer(org.apache.tez.dag.app.rm.container.AMContainer) DagInfoImplForTest(org.apache.tez.dag.helpers.DagInfoImplForTest) Test(org.junit.Test)

Example 3 with AMContainer

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

the class TestTaskSchedulerManager method testSimpleAllocate.

@Test(timeout = 5000)
public void testSimpleAllocate() throws Exception {
    Configuration conf = new Configuration(false);
    schedulerHandler.init(conf);
    schedulerHandler.start();
    TaskAttemptImpl mockTaskAttempt = mock(TaskAttemptImpl.class);
    TezTaskAttemptID mockAttemptId = mock(TezTaskAttemptID.class);
    when(mockAttemptId.getId()).thenReturn(0);
    when(mockTaskAttempt.getID()).thenReturn(mockAttemptId);
    Resource resource = Resource.newInstance(1024, 1);
    ContainerContext containerContext = new ContainerContext(new HashMap<String, LocalResource>(), new Credentials(), new HashMap<String, String>(), "");
    int priority = 10;
    TaskLocationHint locHint = TaskLocationHint.createTaskLocationHint(new HashSet<String>(), null);
    ContainerId mockCId = mock(ContainerId.class);
    Container container = mock(Container.class);
    when(container.getId()).thenReturn(mockCId);
    AMContainer mockAMContainer = mock(AMContainer.class);
    when(mockAMContainer.getContainerId()).thenReturn(mockCId);
    when(mockAMContainer.getState()).thenReturn(AMContainerState.IDLE);
    when(mockAMContainerMap.get(mockCId)).thenReturn(mockAMContainer);
    AMSchedulerEventTALaunchRequest lr = new AMSchedulerEventTALaunchRequest(mockAttemptId, resource, null, mockTaskAttempt, locHint, priority, containerContext, 0, 0, 0);
    schedulerHandler.taskAllocated(0, mockTaskAttempt, lr, container);
    assertEquals(1, mockEventHandler.events.size());
    assertTrue(mockEventHandler.events.get(0) instanceof AMContainerEventAssignTA);
    AMContainerEventAssignTA assignEvent = (AMContainerEventAssignTA) mockEventHandler.events.get(0);
    assertEquals(priority, assignEvent.getPriority());
    assertEquals(mockAttemptId, assignEvent.getTaskAttemptId());
}
Also used : AMContainerEventAssignTA(org.apache.tez.dag.app.rm.container.AMContainerEventAssignTA) Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Resource(org.apache.hadoop.yarn.api.records.Resource) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) TaskAttemptImpl(org.apache.tez.dag.app.dag.impl.TaskAttemptImpl) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint) AMContainer(org.apache.tez.dag.app.rm.container.AMContainer) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint) ContainerContext(org.apache.tez.dag.app.ContainerContext) AMContainer(org.apache.tez.dag.app.rm.container.AMContainer) Container(org.apache.hadoop.yarn.api.records.Container) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) Credentials(org.apache.hadoop.security.Credentials) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) DagInfoImplForTest(org.apache.tez.dag.helpers.DagInfoImplForTest) Test(org.junit.Test)

Example 4 with AMContainer

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

the class TestTaskSchedulerManager method testContainerExceededPMem.

@Test(timeout = 5000)
public void testContainerExceededPMem() throws IOException {
    Configuration conf = new Configuration(false);
    schedulerHandler.init(conf);
    schedulerHandler.start();
    String diagnostics = "Exceeded Physical Memory";
    TaskAttemptImpl mockTask = mock(TaskAttemptImpl.class);
    ContainerStatus mockStatus = mock(ContainerStatus.class);
    ContainerId mockCId = mock(ContainerId.class);
    AMContainer mockAMContainer = mock(AMContainer.class);
    when(mockAMContainerMap.get(mockCId)).thenReturn(mockAMContainer);
    when(mockAMContainer.getContainerId()).thenReturn(mockCId);
    when(mockStatus.getContainerId()).thenReturn(mockCId);
    when(mockStatus.getDiagnostics()).thenReturn(diagnostics);
    // use -104 rather than ContainerExitStatus.KILLED_EXCEEDED_PMEM because
    // ContainerExitStatus.KILLED_EXCEEDED_PMEM is only available after hadoop-2.5
    when(mockStatus.getExitStatus()).thenReturn(-104);
    schedulerHandler.containerCompleted(0, mockTask, mockStatus);
    assertEquals(1, mockEventHandler.events.size());
    Event event = mockEventHandler.events.get(0);
    assertEquals(AMContainerEventType.C_COMPLETED, event.getType());
    AMContainerEventCompleted completedEvent = (AMContainerEventCompleted) event;
    assertEquals(mockCId, completedEvent.getContainerId());
    assertEquals("Container failed, exitCode=-104. Exceeded Physical Memory", completedEvent.getDiagnostics());
    Assert.assertFalse(completedEvent.isPreempted());
    Assert.assertFalse(completedEvent.isDiskFailed());
    assertEquals(TaskAttemptTerminationCause.CONTAINER_EXITED, completedEvent.getTerminationCause());
    schedulerHandler.stop();
    schedulerHandler.close();
}
Also used : AMContainerEventCompleted(org.apache.tez.dag.app.rm.container.AMContainerEventCompleted) ContainerStatus(org.apache.hadoop.yarn.api.records.ContainerStatus) Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) TaskAttemptImpl(org.apache.tez.dag.app.dag.impl.TaskAttemptImpl) Event(org.apache.hadoop.yarn.event.Event) AMContainer(org.apache.tez.dag.app.rm.container.AMContainer) DagInfoImplForTest(org.apache.tez.dag.helpers.DagInfoImplForTest) Test(org.junit.Test)

Example 5 with AMContainer

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

the class TestTaskSchedulerManager method testContainerInternalPreempted.

@Test(timeout = 5000)
public void testContainerInternalPreempted() throws IOException, ServicePluginException {
    Configuration conf = new Configuration(false);
    schedulerHandler.init(conf);
    schedulerHandler.start();
    AMContainer mockAmContainer = mock(AMContainer.class);
    when(mockAmContainer.getTaskSchedulerIdentifier()).thenReturn(0);
    when(mockAmContainer.getContainerLauncherIdentifier()).thenReturn(0);
    when(mockAmContainer.getTaskCommunicatorIdentifier()).thenReturn(0);
    ContainerId mockCId = mock(ContainerId.class);
    verify(mockTaskScheduler, times(0)).deallocateContainer((ContainerId) any());
    when(mockAMContainerMap.get(mockCId)).thenReturn(mockAmContainer);
    schedulerHandler.preemptContainer(0, mockCId);
    verify(mockTaskScheduler, times(1)).deallocateContainer(mockCId);
    assertEquals(1, mockEventHandler.events.size());
    Event event = mockEventHandler.events.get(0);
    assertEquals(AMContainerEventType.C_COMPLETED, event.getType());
    AMContainerEventCompleted completedEvent = (AMContainerEventCompleted) event;
    assertEquals(mockCId, completedEvent.getContainerId());
    assertEquals("Container preempted internally", completedEvent.getDiagnostics());
    assertTrue(completedEvent.isPreempted());
    Assert.assertFalse(completedEvent.isDiskFailed());
    assertEquals(TaskAttemptTerminationCause.INTERNAL_PREEMPTION, completedEvent.getTerminationCause());
    schedulerHandler.stop();
    schedulerHandler.close();
}
Also used : AMContainerEventCompleted(org.apache.tez.dag.app.rm.container.AMContainerEventCompleted) Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) Event(org.apache.hadoop.yarn.event.Event) AMContainer(org.apache.tez.dag.app.rm.container.AMContainer) DagInfoImplForTest(org.apache.tez.dag.helpers.DagInfoImplForTest) Test(org.junit.Test)

Aggregations

AMContainer (org.apache.tez.dag.app.rm.container.AMContainer)8 Configuration (org.apache.hadoop.conf.Configuration)6 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)6 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)6 AMContainerEventCompleted (org.apache.tez.dag.app.rm.container.AMContainerEventCompleted)6 DagInfoImplForTest (org.apache.tez.dag.helpers.DagInfoImplForTest)5 Test (org.junit.Test)5 Event (org.apache.hadoop.yarn.event.Event)4 TaskAttemptImpl (org.apache.tez.dag.app.dag.impl.TaskAttemptImpl)4 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)3 Credentials (org.apache.hadoop.security.Credentials)2 Container (org.apache.hadoop.yarn.api.records.Container)2 TaskLocationHint (org.apache.tez.dag.api.TaskLocationHint)2 TezUncheckedException (org.apache.tez.dag.api.TezUncheckedException)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ApplicationAccessType (org.apache.hadoop.yarn.api.records.ApplicationAccessType)1 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1