@Test
public void testReadWriteApplicationAttemptHistory() throws Exception {
// Out of order
ApplicationId appId = ApplicationId.newInstance(0, 1);
ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1);
try {
writeApplicationAttemptFinishData(appAttemptId);
Assert.fail();
} catch (IOException e) {
Assert.assertTrue(e.getMessage().contains(
"is stored before the start information"));
}
// Normal
int numAppAttempts = 5;
writeApplicationStartData(appId);
for (int i = 1; i <= numAppAttempts; ++i) {
appAttemptId = ApplicationAttemptId.newInstance(appId, i);
writeApplicationAttemptStartData(appAttemptId);
writeApplicationAttemptFinishData(appAttemptId);
}
Assert.assertEquals(numAppAttempts, store.getApplicationAttempts(appId)
.size());
for (int i = 1; i <= numAppAttempts; ++i) {
appAttemptId = ApplicationAttemptId.newInstance(appId, i);
ApplicationAttemptHistoryData data =
store.getApplicationAttempt(appAttemptId);
Assert.assertNotNull(data);
Assert.assertEquals(appAttemptId.toString(), data.getHost());
Assert.assertEquals(appAttemptId.toString(), data.getDiagnosticsInfo());
}
writeApplicationFinishData(appId);
// Write again
appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
try {