use of org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo 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.server.webapp.dao.AppAttemptInfo in project hadoop by apache.
the class AppAttemptBlock method render.
@Override
protected void render(Block html) {
String attemptid = $(APPLICATION_ATTEMPT_ID);
if (attemptid.isEmpty()) {
puts("Bad request: requires application attempt ID");
return;
}
try {
appAttemptId = ApplicationAttemptId.fromString(attemptid);
} catch (IllegalArgumentException e) {
puts("Invalid application attempt ID: " + attemptid);
return;
}
UserGroupInformation callerUGI = getCallerUGI();
ApplicationAttemptReport appAttemptReport;
try {
final GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(appAttemptId);
if (callerUGI == null) {
appAttemptReport = appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
} else {
appAttemptReport = callerUGI.doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {
@Override
public ApplicationAttemptReport run() throws Exception {
return appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
}
});
}
} catch (Exception e) {
String message = "Failed to read the application attempt " + appAttemptId + ".";
LOG.error(message, e);
html.p()._(message)._();
return;
}
if (appAttemptReport == null) {
puts("Application Attempt not found: " + attemptid);
return;
}
boolean exceptionWhenGetContainerReports = false;
Collection<ContainerReport> containers = null;
try {
final GetContainersRequest request = GetContainersRequest.newInstance(appAttemptId);
if (callerUGI == null) {
containers = appBaseProt.getContainers(request).getContainerList();
} else {
containers = callerUGI.doAs(new PrivilegedExceptionAction<Collection<ContainerReport>>() {
@Override
public Collection<ContainerReport> run() throws Exception {
return appBaseProt.getContainers(request).getContainerList();
}
});
}
} catch (RuntimeException e) {
// have this block to suppress the findbugs warning
exceptionWhenGetContainerReports = true;
} catch (Exception e) {
exceptionWhenGetContainerReports = true;
}
AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport);
setTitle(join("Application Attempt ", attemptid));
String node = "N/A";
if (appAttempt.getHost() != null && appAttempt.getRpcPort() >= 0 && appAttempt.getRpcPort() < 65536) {
node = appAttempt.getHost() + ":" + appAttempt.getRpcPort();
}
generateOverview(appAttemptReport, containers, appAttempt, node);
if (exceptionWhenGetContainerReports) {
html.p()._("Sorry, Failed to get containers for application attempt" + attemptid + ".")._();
return;
}
createAttemptHeadRoomTable(html);
html._(InfoBlock.class);
createTablesForAttemptMetrics(html);
// Container Table
TBODY<TABLE<Hamlet>> tbody = html.table("#containers").thead().tr().th(".id", "Container ID").th(".node", "Node").th(".exitstatus", "Container Exit Status").th(".logs", "Logs")._()._().tbody();
StringBuilder containersTableData = new StringBuilder("[\n");
for (ContainerReport containerReport : containers) {
ContainerInfo container = new ContainerInfo(containerReport);
containersTableData.append("[\"<a href='").append(url("container", container.getContainerId())).append("'>").append(container.getContainerId()).append("</a>\",\"<a ").append(container.getNodeHttpAddress() == null ? "#" : "href='" + container.getNodeHttpAddress()).append("'>").append(container.getNodeHttpAddress() == null ? "N/A" : StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(container.getNodeHttpAddress()))).append("</a>\",\"").append(container.getContainerExitStatus()).append("\",\"<a href='").append(container.getLogUrl() == null ? "#" : container.getLogUrl()).append("'>").append(container.getLogUrl() == null ? "N/A" : "Logs").append("</a>\"],\n");
}
if (containersTableData.charAt(containersTableData.length() - 2) == ',') {
containersTableData.delete(containersTableData.length() - 2, containersTableData.length() - 1);
}
containersTableData.append("]");
html.script().$type("text/javascript")._("var containersTableData=" + containersTableData)._();
tbody._()._();
}
use of org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo in project hadoop by apache.
the class WebServices method getAppAttempt.
public AppAttemptInfo getAppAttempt(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);
ApplicationAttemptReport appAttempt = null;
try {
if (callerUGI == null) {
GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(aaid);
appAttempt = appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
} else {
appAttempt = callerUGI.doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {
@Override
public ApplicationAttemptReport run() throws Exception {
GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(aaid);
return appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
}
if (appAttempt == null) {
throw new NotFoundException("app attempt with id: " + appAttemptId + " not found");
}
return new AppAttemptInfo(appAttempt);
}
use of org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo in project hadoop by apache.
the class WebServices method getAppAttempts.
public AppAttemptsInfo getAppAttempts(HttpServletRequest req, HttpServletResponse res, String appId) {
UserGroupInformation callerUGI = getUser(req);
final ApplicationId id = parseApplicationId(appId);
Collection<ApplicationAttemptReport> appAttemptReports = null;
try {
if (callerUGI == null) {
GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(id);
appAttemptReports = appBaseProt.getApplicationAttempts(request).getApplicationAttemptList();
} else {
appAttemptReports = callerUGI.doAs(new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>>() {
@Override
public Collection<ApplicationAttemptReport> run() throws Exception {
GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(id);
return appBaseProt.getApplicationAttempts(request).getApplicationAttemptList();
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
}
AppAttemptsInfo appAttemptsInfo = new AppAttemptsInfo();
if (appAttemptReports == null) {
return appAttemptsInfo;
}
for (ApplicationAttemptReport appAttemptReport : appAttemptReports) {
AppAttemptInfo appAttemptInfo = new AppAttemptInfo(appAttemptReport);
appAttemptsInfo.add(appAttemptInfo);
}
return appAttemptsInfo;
}
Aggregations