use of org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo in project hadoop by apache.
the class ContainerBlock method render.
@Override
protected void render(Block html) {
String containerid = $(CONTAINER_ID);
if (containerid.isEmpty()) {
puts("Bad request: requires container ID");
return;
}
ContainerId containerId = null;
try {
containerId = ContainerId.fromString(containerid);
} catch (IllegalArgumentException e) {
puts("Invalid container ID: " + containerid);
return;
}
UserGroupInformation callerUGI = getCallerUGI();
ContainerReport containerReport = null;
try {
final GetContainerReportRequest request = GetContainerReportRequest.newInstance(containerId);
if (callerUGI == null) {
containerReport = appBaseProt.getContainerReport(request).getContainerReport();
} else {
containerReport = callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {
@Override
public ContainerReport run() throws Exception {
return appBaseProt.getContainerReport(request).getContainerReport();
}
});
}
} catch (Exception e) {
String message = "Failed to read the container " + containerid + ".";
LOG.error(message, e);
html.p()._(message)._();
return;
}
if (containerReport == null) {
puts("Container not found: " + containerid);
return;
}
ContainerInfo container = new ContainerInfo(containerReport);
setTitle(join("Container ", containerid));
info("Container Overview")._("Container State:", container.getContainerState() == null ? UNAVAILABLE : container.getContainerState())._("Exit Status:", container.getContainerExitStatus())._("Node:", container.getNodeHttpAddress() == null ? "#" : container.getNodeHttpAddress(), container.getNodeHttpAddress() == null ? "N/A" : container.getNodeHttpAddress())._("Priority:", container.getPriority())._("Started:", Times.format(container.getStartedTime()))._("Elapsed:", StringUtils.formatTime(Times.elapsed(container.getStartedTime(), container.getFinishedTime())))._("Resource:", container.getAllocatedMB() + " Memory, " + container.getAllocatedVCores() + " VCores")._("Logs:", container.getLogUrl() == null ? "#" : container.getLogUrl(), container.getLogUrl() == null ? "N/A" : "Logs")._("Diagnostics:", container.getDiagnosticsInfo() == null ? "" : container.getDiagnosticsInfo());
html._(InfoBlock.class);
}
use of org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo in project hadoop by apache.
the class WebServices method getContainers.
public ContainersInfo getContainers(HttpServletRequest req, HttpServletResponse res, String appId, String appAttemptId) {
UserGroupInformation callerUGI = getUser(req);
ApplicationId aid = parseApplicationId(appId);
final ApplicationAttemptId aaid = parseApplicationAttemptId(appAttemptId);
validateIds(aid, aaid, null);
Collection<ContainerReport> containerReports = null;
try {
if (callerUGI == null) {
GetContainersRequest request = GetContainersRequest.newInstance(aaid);
containerReports = appBaseProt.getContainers(request).getContainerList();
} else {
containerReports = callerUGI.doAs(new PrivilegedExceptionAction<Collection<ContainerReport>>() {
@Override
public Collection<ContainerReport> run() throws Exception {
GetContainersRequest request = GetContainersRequest.newInstance(aaid);
return appBaseProt.getContainers(request).getContainerList();
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
}
ContainersInfo containersInfo = new ContainersInfo();
if (containerReports == null) {
return containersInfo;
}
for (ContainerReport containerReport : containerReports) {
ContainerInfo containerInfo = new ContainerInfo(containerReport);
containersInfo.add(containerInfo);
}
return containersInfo;
}
Aggregations