Search in sources :

Example 6 with ContainerHistoryData

use of org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData in project hadoop by apache.

the class TestRMApplicationHistoryWriter method testWriteContainer.

@Test
public void testWriteContainer() throws Exception {
    RMContainer container = createRMContainer(ContainerId.newContainerId(ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1), 1));
    writer.containerStarted(container);
    ContainerHistoryData containerHD = null;
    for (int i = 0; i < MAX_RETRIES; ++i) {
        containerHD = store.getContainer(ContainerId.newContainerId(ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1), 1));
        if (containerHD != null) {
            break;
        } else {
            Thread.sleep(100);
        }
    }
    Assert.assertNotNull(containerHD);
    Assert.assertEquals(NodeId.newInstance("test host", -100), containerHD.getAssignedNode());
    Assert.assertEquals(Resource.newInstance(-1, -1), containerHD.getAllocatedResource());
    Assert.assertEquals(Priority.UNDEFINED, containerHD.getPriority());
    Assert.assertEquals(0L, container.getCreationTime());
    writer.containerFinished(container);
    for (int i = 0; i < MAX_RETRIES; ++i) {
        containerHD = store.getContainer(ContainerId.newContainerId(ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1), 1));
        if (containerHD.getContainerState() != null) {
            break;
        } else {
            Thread.sleep(100);
        }
    }
    Assert.assertEquals("test diagnostics info", containerHD.getDiagnosticsInfo());
    Assert.assertEquals(-1, containerHD.getContainerExitStatus());
    Assert.assertEquals(ContainerState.COMPLETE, containerHD.getContainerState());
}
Also used : ContainerHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) Test(org.junit.Test)

Example 7 with ContainerHistoryData

use of org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData in project hadoop by apache.

the class TestFileSystemApplicationHistoryStore method testReadHistoryData.

@SuppressWarnings("deprecation")
private void testReadHistoryData(int num, boolean missingContainer, boolean missingApplicationAttempt) throws IOException {
    // read application history data
    Assert.assertEquals(num, store.getAllApplications().size());
    for (int i = 1; i <= num; ++i) {
        ApplicationId appId = ApplicationId.newInstance(0, i);
        ApplicationHistoryData appData = store.getApplication(appId);
        Assert.assertNotNull(appData);
        Assert.assertEquals(appId.toString(), appData.getApplicationName());
        Assert.assertEquals(appId.toString(), appData.getDiagnosticsInfo());
        // read application attempt history data
        Assert.assertEquals(num, store.getApplicationAttempts(appId).size());
        for (int j = 1; j <= num; ++j) {
            ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, j);
            ApplicationAttemptHistoryData attemptData = store.getApplicationAttempt(appAttemptId);
            Assert.assertNotNull(attemptData);
            Assert.assertEquals(appAttemptId.toString(), attemptData.getHost());
            if (missingApplicationAttempt && j == num) {
                Assert.assertNull(attemptData.getDiagnosticsInfo());
                continue;
            } else {
                Assert.assertEquals(appAttemptId.toString(), attemptData.getDiagnosticsInfo());
            }
            // read container history data
            Assert.assertEquals(num, store.getContainers(appAttemptId).size());
            for (int k = 1; k <= num; ++k) {
                ContainerId containerId = ContainerId.newContainerId(appAttemptId, k);
                ContainerHistoryData containerData = store.getContainer(containerId);
                Assert.assertNotNull(containerData);
                Assert.assertEquals(Priority.newInstance(containerId.getId()), containerData.getPriority());
                if (missingContainer && k == num) {
                    Assert.assertNull(containerData.getDiagnosticsInfo());
                } else {
                    Assert.assertEquals(containerId.toString(), containerData.getDiagnosticsInfo());
                }
            }
            ContainerHistoryData masterContainer = store.getAMContainer(appAttemptId);
            Assert.assertNotNull(masterContainer);
            Assert.assertEquals(ContainerId.newContainerId(appAttemptId, 1), masterContainer.getContainerId());
        }
    }
}
Also used : ContainerHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationAttemptHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ApplicationHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationHistoryData)

Example 8 with ContainerHistoryData

use of org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData in project hadoop by apache.

the class TestMemoryApplicationHistoryStore method testReadWriteContainerHistory.

@SuppressWarnings("deprecation")
@Test
public void testReadWriteContainerHistory() throws Exception {
    // Out of order
    ApplicationId appId = ApplicationId.newInstance(0, 1);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
    ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
    try {
        writeContainerFinishData(containerId);
        Assert.fail();
    } catch (IOException e) {
        Assert.assertTrue(e.getMessage().contains("is stored before the start information"));
    }
    // Normal
    writeApplicationAttemptStartData(appAttemptId);
    int numContainers = 5;
    for (int i = 1; i <= numContainers; ++i) {
        containerId = ContainerId.newContainerId(appAttemptId, i);
        writeContainerStartData(containerId);
        writeContainerFinishData(containerId);
    }
    Assert.assertEquals(numContainers, store.getContainers(appAttemptId).size());
    for (int i = 1; i <= numContainers; ++i) {
        containerId = ContainerId.newContainerId(appAttemptId, i);
        ContainerHistoryData data = store.getContainer(containerId);
        Assert.assertNotNull(data);
        Assert.assertEquals(Priority.newInstance(containerId.getId()), data.getPriority());
        Assert.assertEquals(containerId.toString(), data.getDiagnosticsInfo());
    }
    ContainerHistoryData masterContainer = store.getAMContainer(appAttemptId);
    Assert.assertNotNull(masterContainer);
    Assert.assertEquals(ContainerId.newContainerId(appAttemptId, 1), masterContainer.getContainerId());
    writeApplicationAttemptFinishData(appAttemptId);
    // Write again
    containerId = ContainerId.newContainerId(appAttemptId, 1);
    try {
        writeContainerStartData(containerId);
        Assert.fail();
    } catch (IOException e) {
        Assert.assertTrue(e.getMessage().contains("is already stored"));
    }
    try {
        writeContainerFinishData(containerId);
        Assert.fail();
    } catch (IOException e) {
        Assert.assertTrue(e.getMessage().contains("is already stored"));
    }
}
Also used : ContainerHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) IOException(java.io.IOException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Aggregations

ContainerHistoryData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData)8 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)2 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 Test (org.junit.Test)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)1 ContainerReport (org.apache.hadoop.yarn.api.records.ContainerReport)1 ApplicationAttemptHistoryData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData)1 ApplicationHistoryData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationHistoryData)1 ContainerFinishData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerFinishData)1 ContainerStartData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerStartData)1 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)1