YARN-3544. Got back AM logs link on the RM web UI for a completed app. Contributed by Xuan Gong.

(cherry picked from commit 21bf2cdcb77f69abc906e6cd401a8fb221f250e9)
(cherry picked from commit c9ee316045)
This commit is contained in:
Zhijie Shen 2015-04-29 17:12:52 -07:00 committed by Vinod Kumar Vavilapalli
parent 7af5d6b4ba
commit d57c3f0a26
2 changed files with 30 additions and 55 deletions

View File

@ -220,6 +220,9 @@ Release 2.6.1 - 2015-09-09
YARN-3248. Display count of nodes blacklisted by apps in the web UI. YARN-3248. Display count of nodes blacklisted by apps in the web UI.
(Varun Vasudev via xgong) (Varun Vasudev via xgong)
YARN-3544. Got back AM logs link on the RM web UI for a completed app.
(Xuan Gong via zjshen)
Release 2.6.0 - 2014-11-18 Release 2.6.0 - 2014-11-18
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -20,7 +20,6 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP; import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP;
import java.security.PrivilegedExceptionAction;
import java.util.Collection; import java.util.Collection;
import java.util.Set; import java.util.Set;
@ -29,36 +28,35 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppAttemptInfo;
import org.apache.hadoop.yarn.server.webapp.AppBlock; import org.apache.hadoop.yarn.server.webapp.AppBlock;
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.util.resource.Resources; import org.apache.hadoop.yarn.util.resource.Resources;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
import org.apache.hadoop.yarn.webapp.view.InfoBlock; import org.apache.hadoop.yarn.webapp.view.InfoBlock;
import com.google.inject.Inject; import com.google.inject.Inject;
//import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
public class RMAppBlock extends AppBlock{ public class RMAppBlock extends AppBlock{
private static final Log LOG = LogFactory.getLog(RMAppBlock.class); private static final Log LOG = LogFactory.getLog(RMAppBlock.class);
private final ResourceManager rm; private final ResourceManager rm;
private final Configuration conf;
@Inject @Inject
RMAppBlock(ViewContext ctx, Configuration conf, ResourceManager rm) { RMAppBlock(ViewContext ctx, Configuration conf, ResourceManager rm) {
super(rm.getClientRMService(), ctx, conf); super(rm.getClientRMService(), ctx, conf);
this.conf = conf;
this.rm = rm; this.rm = rm;
} }
@ -120,67 +118,41 @@ public class RMAppBlock extends AppBlock{
.th(".started", "Started").th(".node", "Node").th(".logs", "Logs") .th(".started", "Started").th(".node", "Node").th(".logs", "Logs")
.th(".blacklistednodes", "Blacklisted Nodes")._()._().tbody(); .th(".blacklistednodes", "Blacklisted Nodes")._()._().tbody();
StringBuilder attemptsTableData = new StringBuilder("[\n"); RMApp rmApp = this.rm.getRMContext().getRMApps().get(this.appID);
for (final ApplicationAttemptReport appAttemptReport : attempts) { if (rmApp == null) {
AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport);
ContainerReport containerReport = null;
try {
// AM container is always the first container of the attempt
final GetContainerReportRequest request =
GetContainerReportRequest.newInstance(ContainerId.newContainerId(
appAttemptReport.getApplicationAttemptId(), 1));
if (callerUGI == null) {
containerReport =
appBaseProt.getContainerReport(request).getContainerReport();
} else {
containerReport = callerUGI.doAs(
new PrivilegedExceptionAction<ContainerReport>() {
@Override
public ContainerReport run() throws Exception {
ContainerReport report = 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; return;
} }
long startTime = 0L; StringBuilder attemptsTableData = new StringBuilder("[\n");
String logsLink = null; for (final ApplicationAttemptReport appAttemptReport : attempts) {
String nodeLink = null; RMAppAttempt rmAppAttempt =
if (containerReport != null) { rmApp.getRMAppAttempt(appAttemptReport.getApplicationAttemptId());
ContainerInfo container = new ContainerInfo(containerReport); if (rmAppAttempt == null) {
startTime = container.getStartedTime(); continue;
logsLink = containerReport.getLogUrl();
nodeLink = containerReport.getNodeHttpAddress();
} }
AppAttemptInfo attemptInfo =
new AppAttemptInfo(this.rm, rmAppAttempt, rmApp.getUser());
String blacklistedNodesCount = "N/A"; String blacklistedNodesCount = "N/A";
Set<String> nodes = RMAppAttemptBlock.getBlacklistedNodes(rm, Set<String> nodes =
ConverterUtils.toApplicationAttemptId(appAttempt.getAppAttemptId())); RMAppAttemptBlock.getBlacklistedNodes(rm,
rmAppAttempt.getAppAttemptId());
if(nodes != null) { if(nodes != null) {
blacklistedNodesCount = String.valueOf(nodes.size()); blacklistedNodesCount = String.valueOf(nodes.size());
} }
// AppAttemptID numerical value parsed by parseHadoopID in // AppAttemptID numerical value parsed by parseHadoopID in
// yarn.dt.plugins.js // yarn.dt.plugins.js
String nodeLink = attemptInfo.getNodeHttpAddress();
if (nodeLink != null) {
nodeLink = WebAppUtils.getHttpSchemePrefix(conf) + nodeLink;
}
String logsLink = attemptInfo.getLogsLink();
attemptsTableData attemptsTableData
.append("[\"<a href='") .append("[\"<a href='")
.append(url("appattempt", appAttempt.getAppAttemptId())) .append(url("appattempt", rmAppAttempt.getAppAttemptId().toString()))
.append("'>") .append("'>")
.append(appAttempt.getAppAttemptId()) .append(String.valueOf(rmAppAttempt.getAppAttemptId()))
.append("</a>\",\"") .append("</a>\",\"")
.append(startTime) .append(attemptInfo.getStartTime())
.append("\",\"<a ") .append("\",\"<a ")
.append(nodeLink == null ? "#" : "href='" + nodeLink) .append(nodeLink == null ? "#" : "href='" + nodeLink)
.append("'>") .append("'>")