use of org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData in project hadoop by apache.
the class FileSystemApplicationHistoryStore method getContainers.
@Override
public Map<ContainerId, ContainerHistoryData> getContainers(ApplicationAttemptId appAttemptId) throws IOException {
Map<ContainerId, ContainerHistoryData> historyDataMap = new HashMap<ContainerId, ContainerHistoryData>();
HistoryFileReader hfReader = getHistoryFileReader(appAttemptId.getApplicationId());
try {
while (hfReader.hasNext()) {
HistoryFileReader.Entry entry = hfReader.next();
if (entry.key.id.startsWith(ConverterUtils.CONTAINER_PREFIX)) {
ContainerId containerId = ContainerId.fromString(entry.key.id);
if (containerId.getApplicationAttemptId().equals(appAttemptId)) {
ContainerHistoryData historyData = historyDataMap.get(containerId);
if (historyData == null) {
historyData = ContainerHistoryData.newInstance(containerId, null, null, null, Long.MIN_VALUE, Long.MAX_VALUE, null, Integer.MAX_VALUE, null);
historyDataMap.put(containerId, historyData);
}
if (entry.key.suffix.equals(START_DATA_SUFFIX)) {
mergeContainerHistoryData(historyData, parseContainerStartData(entry.value));
} else if (entry.key.suffix.equals(FINISH_DATA_SUFFIX)) {
mergeContainerHistoryData(historyData, parseContainerFinishData(entry.value));
}
}
}
}
LOG.info("Completed reading history information of all containers" + " of application attempt " + appAttemptId);
} catch (IOException e) {
LOG.info("Error when reading history information of some containers" + " of application attempt " + appAttemptId);
} finally {
hfReader.close();
}
return historyDataMap;
}
use of org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData 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();
}
}
use of org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData in project hadoop by apache.
the class ApplicationHistoryManagerImpl method getContainers.
@Override
public Map<ContainerId, ContainerReport> getContainers(ApplicationAttemptId appAttemptId) throws IOException {
ApplicationReport app = getApplication(appAttemptId.getApplicationId());
Map<ContainerId, ContainerHistoryData> histData = historyStore.getContainers(appAttemptId);
HashMap<ContainerId, ContainerReport> containersReport = new HashMap<ContainerId, ContainerReport>();
for (Entry<ContainerId, ContainerHistoryData> entry : histData.entrySet()) {
containersReport.put(entry.getKey(), convertToContainerReport(entry.getValue(), app == null ? null : app.getUser()));
}
return containersReport;
}
use of org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData in project hadoop by apache.
the class MemoryApplicationHistoryStore method containerFinished.
@Override
public void containerFinished(ContainerFinishData containerFinish) throws IOException {
ConcurrentMap<ContainerId, ContainerHistoryData> subMap = getSubMap(containerFinish.getContainerId().getApplicationAttemptId());
ContainerHistoryData data = subMap.get(containerFinish.getContainerId());
if (data == null) {
throw new IOException("The finish information of container " + containerFinish.getContainerId() + " is stored before" + " the start information.");
}
// the finish information is already recorded
if (data.getContainerState() != null) {
throw new IOException("The finish information of container " + containerFinish.getContainerId() + " is already stored.");
}
data.setFinishTime(containerFinish.getFinishTime());
data.setDiagnosticsInfo(containerFinish.getDiagnosticsInfo());
data.setContainerExitStatus(containerFinish.getContainerExitStatus());
data.setContainerState(containerFinish.getContainerState());
}
use of org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData in project hadoop by apache.
the class MemoryApplicationHistoryStore method containerStarted.
@Override
public void containerStarted(ContainerStartData containerStart) throws IOException {
ConcurrentMap<ContainerId, ContainerHistoryData> subMap = getSubMap(containerStart.getContainerId().getApplicationAttemptId());
ContainerHistoryData oldData = subMap.putIfAbsent(containerStart.getContainerId(), ContainerHistoryData.newInstance(containerStart.getContainerId(), containerStart.getAllocatedResource(), containerStart.getAssignedNode(), containerStart.getPriority(), containerStart.getStartTime(), Long.MAX_VALUE, null, Integer.MAX_VALUE, null));
if (oldData != null) {
throw new IOException("The start information of container " + containerStart.getContainerId() + " is already stored.");
}
}
Aggregations