use of org.apache.hadoop.yarn.api.records.ContainerReport 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.api.records.ContainerReport in project hadoop by apache.
the class ApplicationHistoryManagerOnTimelineStore method getContainers.
@Override
public Map<ContainerId, ContainerReport> getContainers(ApplicationAttemptId appAttemptId) throws YarnException, IOException {
ApplicationReportExt app = getApplication(appAttemptId.getApplicationId(), ApplicationReportField.USER_AND_ACLS);
checkAccess(app);
TimelineEntities entities = timelineDataManager.getEntities(ContainerMetricsConstants.ENTITY_TYPE, new NameValuePair(ContainerMetricsConstants.PARENT_PRIMARIY_FILTER, appAttemptId.toString()), null, null, null, null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser());
Map<ContainerId, ContainerReport> containers = new LinkedHashMap<ContainerId, ContainerReport>();
if (entities != null && entities.getEntities() != null) {
for (TimelineEntity entity : entities.getEntities()) {
ContainerReport container = convertToContainerReport(entity, serverHttpAddress, app.appReport.getUser());
containers.put(container.getContainerId(), container);
}
}
return containers;
}
use of org.apache.hadoop.yarn.api.records.ContainerReport in project hadoop by apache.
the class AppBlock method generateApplicationTable.
protected void generateApplicationTable(Block html, UserGroupInformation callerUGI, Collection<ApplicationAttemptReport> attempts) {
// Application Attempt Table
TBODY<TABLE<Hamlet>> tbody = html.table("#attempts").thead().tr().th(".id", "Attempt ID").th(".started", "Started").th(".node", "Node").th(".logs", "Logs")._()._().tbody();
StringBuilder attemptsTableData = new StringBuilder("[\n");
for (final ApplicationAttemptReport appAttemptReport : attempts) {
AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport);
ContainerReport containerReport;
try {
final GetContainerReportRequest request = GetContainerReportRequest.newInstance(appAttemptReport.getAMContainerId());
if (callerUGI == null) {
containerReport = appBaseProt.getContainerReport(request).getContainerReport();
} else {
containerReport = callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {
@Override
public ContainerReport run() throws Exception {
ContainerReport report = null;
if (request.getContainerId() != null) {
try {
report = appBaseProt.getContainerReport(request).getContainerReport();
} catch (ContainerNotFoundException ex) {
LOG.warn(ex.getMessage());
}
}
return report;
}
});
}
} catch (Exception e) {
String message = "Failed to read the AM container of the application attempt " + appAttemptReport.getApplicationAttemptId() + ".";
LOG.error(message, e);
html.p()._(message)._();
return;
}
long startTime = 0L;
String logsLink = null;
String nodeLink = null;
if (containerReport != null) {
ContainerInfo container = new ContainerInfo(containerReport);
startTime = container.getStartedTime();
logsLink = containerReport.getLogUrl();
nodeLink = containerReport.getNodeHttpAddress();
}
attemptsTableData.append("[\"<a href='").append(url("appattempt", appAttempt.getAppAttemptId())).append("'>").append(appAttempt.getAppAttemptId()).append("</a>\",\"").append(startTime).append("\",\"<a ").append(nodeLink == null ? "#" : "href='" + nodeLink).append("'>").append(nodeLink == null ? "N/A" : StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(nodeLink))).append("</a>\",\"<a ").append(logsLink == null ? "#" : "href='" + logsLink).append("'>").append(logsLink == null ? "N/A" : "Logs").append("</a>\"],\n");
}
if (attemptsTableData.charAt(attemptsTableData.length() - 2) == ',') {
attemptsTableData.delete(attemptsTableData.length() - 2, attemptsTableData.length() - 1);
}
attemptsTableData.append("]");
html.script().$type("text/javascript")._("var attemptsTableData=" + attemptsTableData)._();
tbody._()._();
}
use of org.apache.hadoop.yarn.api.records.ContainerReport in project hadoop by apache.
the class WebServices method getContainer.
public ContainerInfo getContainer(HttpServletRequest req, HttpServletResponse res, String appId, String appAttemptId, String containerId) {
UserGroupInformation callerUGI = getUser(req);
ApplicationId aid = parseApplicationId(appId);
ApplicationAttemptId aaid = parseApplicationAttemptId(appAttemptId);
final ContainerId cid = parseContainerId(containerId);
validateIds(aid, aaid, cid);
ContainerReport container = null;
try {
if (callerUGI == null) {
GetContainerReportRequest request = GetContainerReportRequest.newInstance(cid);
container = appBaseProt.getContainerReport(request).getContainerReport();
} else {
container = callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {
@Override
public ContainerReport run() throws Exception {
GetContainerReportRequest request = GetContainerReportRequest.newInstance(cid);
return appBaseProt.getContainerReport(request).getContainerReport();
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
}
if (container == null) {
throw new NotFoundException("container with id: " + containerId + " not found");
}
return new ContainerInfo(container);
}
use of org.apache.hadoop.yarn.api.records.ContainerReport in project hadoop by apache.
the class RMContainerImpl method createContainerReport.
@Override
public ContainerReport createContainerReport() {
this.readLock.lock();
ContainerReport containerReport = null;
try {
containerReport = ContainerReport.newInstance(this.getContainerId(), this.getAllocatedResource(), this.getAllocatedNode(), this.getAllocatedSchedulerKey().getPriority(), this.getCreationTime(), this.getFinishTime(), this.getDiagnosticsInfo(), this.getLogURL(), this.getContainerExitStatus(), this.getContainerState(), this.getNodeHttpAddress());
} finally {
this.readLock.unlock();
}
return containerReport;
}
Aggregations