Search in sources :

Example 1 with ContainerFinishData

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

the class FileSystemApplicationHistoryStore method getContainer.

@Override
public ContainerHistoryData getContainer(ContainerId containerId) throws IOException {
    HistoryFileReader hfReader = getHistoryFileReader(containerId.getApplicationAttemptId().getApplicationId());
    try {
        boolean readStartData = false;
        boolean readFinishData = false;
        ContainerHistoryData historyData = ContainerHistoryData.newInstance(containerId, null, null, null, Long.MIN_VALUE, Long.MAX_VALUE, null, Integer.MAX_VALUE, null);
        while ((!readStartData || !readFinishData) && hfReader.hasNext()) {
            HistoryFileReader.Entry entry = hfReader.next();
            if (entry.key.id.equals(containerId.toString())) {
                if (entry.key.suffix.equals(START_DATA_SUFFIX)) {
                    ContainerStartData startData = parseContainerStartData(entry.value);
                    mergeContainerHistoryData(historyData, startData);
                    readStartData = true;
                } else if (entry.key.suffix.equals(FINISH_DATA_SUFFIX)) {
                    ContainerFinishData finishData = parseContainerFinishData(entry.value);
                    mergeContainerHistoryData(historyData, finishData);
                    readFinishData = true;
                }
            }
        }
        if (!readStartData && !readFinishData) {
            return null;
        }
        if (!readStartData) {
            LOG.warn("Start information is missing for container " + containerId);
        }
        if (!readFinishData) {
            LOG.warn("Finish information is missing for container " + containerId);
        }
        LOG.info("Completed reading history information of container " + containerId);
        return historyData;
    } catch (IOException e) {
        LOG.error("Error when reading history file of container " + containerId, e);
        throw e;
    } finally {
        hfReader.close();
    }
}
Also used : ContainerStartData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerStartData) ContainerHistoryData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData) IOException(java.io.IOException) ContainerFinishData(org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerFinishData)

Aggregations

IOException (java.io.IOException)1 ContainerFinishData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerFinishData)1 ContainerHistoryData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData)1 ContainerStartData (org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerStartData)1