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());
}
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());
}
}
}
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"));
}
}
Aggregations