use of org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest 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.protocolrecords.GetContainerReportRequest in project hadoop by apache.
the class TestApplicationHistoryClientService method testContainerNotFound.
@Test
public void testContainerNotFound() throws IOException, YarnException {
ApplicationId appId = ApplicationId.newInstance(0, 1);
ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
ContainerId containerId = ContainerId.newContainerId(appAttemptId, MAX_APPS + 1);
GetContainerReportRequest request = GetContainerReportRequest.newInstance(containerId);
try {
@SuppressWarnings("unused") GetContainerReportResponse response = clientService.getContainerReport(request);
} catch (ContainerNotFoundException e) {
//This exception is expected
Assert.assertTrue(e.getMessage().contains("doesn't exist in the timeline store"));
} catch (Exception e) {
Assert.fail("Undesired exception caught");
}
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest 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);
}
Aggregations