use of org.apache.hadoop.yarn.api.records.ContainerReport in project hadoop by apache.
the class GetContainersResponsePBImpl method initLocalContainerList.
// Once this is called. containerList will never be null - until a getProto
// is called.
private void initLocalContainerList() {
if (this.containerList != null) {
return;
}
GetContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
List<ContainerReportProto> list = p.getContainersList();
containerList = new ArrayList<ContainerReport>();
for (ContainerReportProto c : list) {
containerList.add(convertFromProtoFormat(c));
}
}
use of org.apache.hadoop.yarn.api.records.ContainerReport in project hadoop by apache.
the class TestApplicationHistoryClientService method testContainers.
@Test
public void testContainers() throws IOException, YarnException {
ApplicationId appId = ApplicationId.newInstance(0, 1);
ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 2);
GetContainersRequest request = GetContainersRequest.newInstance(appAttemptId);
GetContainersResponse response = clientService.getContainers(request);
List<ContainerReport> containers = response.getContainerList();
Assert.assertNotNull(containers);
Assert.assertEquals(containerId, containers.get(0).getContainerId());
Assert.assertEquals(containerId1, containers.get(1).getContainerId());
}
use of org.apache.hadoop.yarn.api.records.ContainerReport in project hadoop by apache.
the class TestApplicationHistoryClientService method testContainerReport.
@Test
public void testContainerReport() throws IOException, YarnException {
ApplicationId appId = ApplicationId.newInstance(0, 1);
ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
GetContainerReportRequest request = GetContainerReportRequest.newInstance(containerId);
GetContainerReportResponse response = clientService.getContainerReport(request);
ContainerReport container = response.getContainerReport();
Assert.assertNotNull(container);
Assert.assertEquals(containerId, container.getContainerId());
Assert.assertEquals("http://0.0.0.0:8188/applicationhistory/logs/" + "test host:100/container_0_0001_01_000001/" + "container_0_0001_01_000001/user1", container.getLogUrl());
}
use of org.apache.hadoop.yarn.api.records.ContainerReport in project hadoop by apache.
the class TestApplicationHistoryManagerOnTimelineStore method testGetContainers.
@Test
public void testGetContainers() throws Exception {
final ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1);
Collection<ContainerReport> containers;
if (callerUGI == null) {
containers = historyManager.getContainers(appAttemptId).values();
} else {
try {
containers = callerUGI.doAs(new PrivilegedExceptionAction<Collection<ContainerReport>>() {
@Override
public Collection<ContainerReport> run() throws Exception {
return historyManager.getContainers(appAttemptId).values();
}
});
if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) {
// The exception is expected
Assert.fail();
}
} catch (AuthorizationException e) {
if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) {
// The exception is expected
return;
}
throw e;
}
}
Assert.assertNotNull(containers);
Assert.assertEquals(SCALE, containers.size());
}
use of org.apache.hadoop.yarn.api.records.ContainerReport in project hadoop by apache.
the class LogsCLI method printContainerInfoFromRunningApplication.
private int printContainerInfoFromRunningApplication(ContainerLogsRequest options, LogCLIHelpers logCliHelper) throws YarnException, IOException, ClientHandlerException, UniformInterfaceException, JSONException {
String containerIdStr = options.getContainerId();
String nodeIdStr = options.getNodeId();
List<ContainerReport> reports = getContainerReportsFromRunningApplication(options);
List<ContainerReport> filteredReports = filterContainersInfo(options, reports);
if (filteredReports.isEmpty()) {
// if we specify the containerId as well as NodeAddress
String nodeHttpAddress = null;
if (options.getContainerId() != null && !options.getContainerId().isEmpty()) {
nodeHttpAddress = getNodeHttpAddressFromRMWebString(options);
}
if (nodeHttpAddress != null) {
outputContainerLogMeta(options.getContainerId(), options.getNodeId(), nodeHttpAddress);
return 0;
} else {
int result = logCliHelper.printAContainerLogMetadata(options, System.out, System.err);
if (result == -1) {
StringBuilder sb = new StringBuilder();
if (containerIdStr != null && !containerIdStr.isEmpty()) {
sb.append("Trying to get container with ContainerId: " + containerIdStr + "\n");
}
if (nodeIdStr != null && !nodeIdStr.isEmpty()) {
sb.append("Trying to get container from NodeManager: " + nodeIdStr + "\n");
}
sb.append("Can not find any matched containers for the application: " + options.getAppId());
System.err.println(sb.toString());
}
return result;
}
}
for (ContainerReport report : filteredReports) {
String nodeId = report.getAssignedNode().toString();
String nodeHttpAddress = report.getNodeHttpAddress().replaceFirst(WebAppUtils.getHttpSchemePrefix(getConf()), "");
String containerId = report.getContainerId().toString();
outputContainerLogMeta(containerId, nodeId, nodeHttpAddress);
}
return 0;
}
Aggregations