Search in sources :

Example 6 with ApplicationAttemptHistoryData

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

the class TestRMApplicationHistoryWriter method testWriteApplicationAttempt.

@Test
public void testWriteApplicationAttempt() throws Exception {
    RMAppAttempt appAttempt = createRMAppAttempt(ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1));
    writer.applicationAttemptStarted(appAttempt);
    ApplicationAttemptHistoryData appAttemptHD = null;
    for (int i = 0; i < MAX_RETRIES; ++i) {
        appAttemptHD = store.getApplicationAttempt(ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1));
        if (appAttemptHD != null) {
            break;
        } else {
            Thread.sleep(100);
        }
    }
    Assert.assertNotNull(appAttemptHD);
    Assert.assertEquals("test host", appAttemptHD.getHost());
    Assert.assertEquals(-100, appAttemptHD.getRPCPort());
    Assert.assertEquals(ContainerId.newContainerId(ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1), 1), appAttemptHD.getMasterContainerId());
    writer.applicationAttemptFinished(appAttempt, RMAppAttemptState.FINISHED);
    for (int i = 0; i < MAX_RETRIES; ++i) {
        appAttemptHD = store.getApplicationAttempt(ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1));
        if (appAttemptHD.getYarnApplicationAttemptState() != null) {
            break;
        } else {
            Thread.sleep(100);
        }
    }
    Assert.assertEquals("test diagnostics info", appAttemptHD.getDiagnosticsInfo());
    Assert.assertEquals("test url", appAttemptHD.getTrackingURL());
    Assert.assertEquals(FinalApplicationStatus.UNDEFINED, appAttemptHD.getFinalApplicationStatus());
    Assert.assertEquals(YarnApplicationAttemptState.FINISHED, appAttemptHD.getYarnApplicationAttemptState());
}
Also used : RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) ApplicationAttemptHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData) Test(org.junit.Test)

Example 7 with ApplicationAttemptHistoryData

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

the class MemoryApplicationHistoryStore method applicationAttemptFinished.

@Override
public void applicationAttemptFinished(ApplicationAttemptFinishData appAttemptFinish) throws IOException {
    ConcurrentMap<ApplicationAttemptId, ApplicationAttemptHistoryData> subMap = getSubMap(appAttemptFinish.getApplicationAttemptId().getApplicationId());
    ApplicationAttemptHistoryData data = subMap.get(appAttemptFinish.getApplicationAttemptId());
    if (data == null) {
        throw new IOException("The finish information of application attempt " + appAttemptFinish.getApplicationAttemptId() + " is stored before" + " the start information.");
    }
    // if the finish information is already recorded
    if (data.getYarnApplicationAttemptState() != null) {
        throw new IOException("The finish information of application attempt " + appAttemptFinish.getApplicationAttemptId() + " is already stored.");
    }
    data.setTrackingURL(appAttemptFinish.getTrackingURL());
    data.setDiagnosticsInfo(appAttemptFinish.getDiagnosticsInfo());
    data.setFinalApplicationStatus(appAttemptFinish.getFinalApplicationStatus());
    data.setYarnApplicationAttemptState(appAttemptFinish.getYarnApplicationAttemptState());
}
Also used : ApplicationAttemptHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) IOException(java.io.IOException)

Example 8 with ApplicationAttemptHistoryData

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

the class MemoryApplicationHistoryStore method applicationAttemptStarted.

@Override
public void applicationAttemptStarted(ApplicationAttemptStartData appAttemptStart) throws IOException {
    ConcurrentMap<ApplicationAttemptId, ApplicationAttemptHistoryData> subMap = getSubMap(appAttemptStart.getApplicationAttemptId().getApplicationId());
    ApplicationAttemptHistoryData oldData = subMap.putIfAbsent(appAttemptStart.getApplicationAttemptId(), ApplicationAttemptHistoryData.newInstance(appAttemptStart.getApplicationAttemptId(), appAttemptStart.getHost(), appAttemptStart.getRPCPort(), appAttemptStart.getMasterContainerId(), null, null, null, null));
    if (oldData != null) {
        throw new IOException("The start information of application attempt " + appAttemptStart.getApplicationAttemptId() + " is already stored.");
    }
}
Also used : ApplicationAttemptHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) IOException(java.io.IOException)

Example 9 with ApplicationAttemptHistoryData

use of org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData 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)

Aggregations

ApplicationAttemptHistoryData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData)9 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)7 IOException (java.io.IOException)5 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)1 ApplicationAttemptFinishData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptFinishData)1 ApplicationAttemptStartData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptStartData)1 ApplicationHistoryData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationHistoryData)1 ContainerHistoryData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData)1 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)1