Search in sources :

Example 6 with TaskAttemptImpl

use of org.apache.tez.dag.app.dag.impl.TaskAttemptImpl 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 7 with TaskAttemptImpl

use of org.apache.tez.dag.app.dag.impl.TaskAttemptImpl in project tez by apache.

the class TestTaskSchedulerManager method testContainerPreempted.

@Test(timeout = 5000)
public void testContainerPreempted() throws IOException {
    Configuration conf = new Configuration(false);
    schedulerHandler.init(conf);
    schedulerHandler.start();
    String diagnostics = "Container preempted by RM.";
    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.PREEMPTED);
    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 preempted externally. Container preempted by RM.", completedEvent.getDiagnostics());
    assertTrue(completedEvent.isPreempted());
    assertEquals(TaskAttemptTerminationCause.EXTERNAL_PREEMPTION, completedEvent.getTerminationCause());
    Assert.assertFalse(completedEvent.isDiskFailed());
    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)

Aggregations

TezConfiguration (org.apache.tez.dag.api.TezConfiguration)7 TaskAttemptImpl (org.apache.tez.dag.app.dag.impl.TaskAttemptImpl)7 Test (org.junit.Test)6 Configuration (org.apache.hadoop.conf.Configuration)5 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)5 DagInfoImplForTest (org.apache.tez.dag.helpers.DagInfoImplForTest)5 AMContainer (org.apache.tez.dag.app.rm.container.AMContainer)4 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)4 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)3 Event (org.apache.hadoop.yarn.event.Event)3 AMContainerEventCompleted (org.apache.tez.dag.app.rm.container.AMContainerEventCompleted)3 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)2 Resource (org.apache.hadoop.yarn.api.records.Resource)2 TaskLocationHint (org.apache.tez.dag.api.TaskLocationHint)2 DAGClient (org.apache.tez.dag.api.client.DAGClient)2 DAGImpl (org.apache.tez.dag.app.dag.impl.DAGImpl)2 TezVertexID (org.apache.tez.dag.records.TezVertexID)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Credentials (org.apache.hadoop.security.Credentials)1 Container (org.apache.hadoop.yarn.api.records.Container)1