Search in sources :

Example 1 with ApplicationAttemptStartData

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

the class FileSystemApplicationHistoryStore method getApplicationAttempt.

@Override
public ApplicationAttemptHistoryData getApplicationAttempt(ApplicationAttemptId appAttemptId) throws IOException {
    HistoryFileReader hfReader = getHistoryFileReader(appAttemptId.getApplicationId());
    try {
        boolean readStartData = false;
        boolean readFinishData = false;
        ApplicationAttemptHistoryData historyData = ApplicationAttemptHistoryData.newInstance(appAttemptId, null, -1, null, null, null, FinalApplicationStatus.UNDEFINED, null);
        while ((!readStartData || !readFinishData) && hfReader.hasNext()) {
            HistoryFileReader.Entry entry = hfReader.next();
            if (entry.key.id.equals(appAttemptId.toString())) {
                if (entry.key.suffix.equals(START_DATA_SUFFIX)) {
                    ApplicationAttemptStartData startData = parseApplicationAttemptStartData(entry.value);
                    mergeApplicationAttemptHistoryData(historyData, startData);
                    readStartData = true;
                } else if (entry.key.suffix.equals(FINISH_DATA_SUFFIX)) {
                    ApplicationAttemptFinishData finishData = parseApplicationAttemptFinishData(entry.value);
                    mergeApplicationAttemptHistoryData(historyData, finishData);
                    readFinishData = true;
                }
            }
        }
        if (!readStartData && !readFinishData) {
            return null;
        }
        if (!readStartData) {
            LOG.warn("Start information is missing for application attempt " + appAttemptId);
        }
        if (!readFinishData) {
            LOG.warn("Finish information is missing for application attempt " + appAttemptId);
        }
        LOG.info("Completed reading history information of application attempt " + appAttemptId);
        return historyData;
    } catch (IOException e) {
        LOG.error("Error when reading history file of application attempt" + appAttemptId, e);
        throw e;
    } finally {
        hfReader.close();
    }
}
Also used : ApplicationAttemptStartData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptStartData) ApplicationAttemptHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData) ApplicationAttemptFinishData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptFinishData) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ApplicationAttemptFinishData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptFinishData)1 ApplicationAttemptHistoryData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData)1 ApplicationAttemptStartData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptStartData)1