|
@@ -20,16 +20,25 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
|
|
|
|
|
|
import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP;
|
|
|
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
+import org.apache.commons.lang.StringEscapeUtils;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
|
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
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.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.webapp.dao.AppAttemptInfo;
|
|
|
import org.apache.hadoop.yarn.server.webapp.AppBlock;
|
|
|
import org.apache.hadoop.yarn.util.resource.Resources;
|
|
|
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.TABLE;
|
|
|
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
|
|
|
+import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
|
|
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
|
|
|
|
|
|
import com.google.inject.Inject;
|
|
@@ -37,11 +46,13 @@ import com.google.inject.Inject;
|
|
|
public class RMAppBlock extends AppBlock{
|
|
|
|
|
|
private final ResourceManager rm;
|
|
|
+ private final Configuration conf;
|
|
|
|
|
|
@Inject
|
|
|
RMAppBlock(ViewContext ctx, Configuration conf, ResourceManager rm) {
|
|
|
super(rm.getClientRMService(), ctx, conf);
|
|
|
this.rm = rm;
|
|
|
+ this.conf = conf;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -91,4 +102,57 @@ public class RMAppBlock extends AppBlock{
|
|
|
appMetrics == null ? "N/A" : appMetrics.getVcoreSeconds()));
|
|
|
pdiv._();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void createApplicationAttemptTable(Block html,
|
|
|
+ Collection<ApplicationAttemptReport> attempts) {
|
|
|
+ TBODY<TABLE<Hamlet>> tbody =
|
|
|
+ html.table("#attempts").thead().tr().th(".id", "Attempt ID")
|
|
|
+ .th(".started", "Started").th(".node", "Node").th(".logs", "Logs")
|
|
|
+ ._()._().tbody();
|
|
|
+ RMApp rmApp = this.rm.getRMContext().getRMApps().get(this.appID);
|
|
|
+ if (rmApp == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ StringBuilder attemptsTableData = new StringBuilder("[\n");
|
|
|
+ for (final ApplicationAttemptReport appAttemptReport : attempts) {
|
|
|
+ RMAppAttempt rmAppAttempt =
|
|
|
+ rmApp.getRMAppAttempt(appAttemptReport.getApplicationAttemptId());
|
|
|
+ if (rmAppAttempt == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ AppAttemptInfo attemptInfo =
|
|
|
+ new AppAttemptInfo(rmAppAttempt, rmApp.getUser());
|
|
|
+ String nodeLink = attemptInfo.getNodeHttpAddress();
|
|
|
+ if (nodeLink != null) {
|
|
|
+ nodeLink = WebAppUtils.getHttpSchemePrefix(conf) + nodeLink;
|
|
|
+ }
|
|
|
+ String logsLink = attemptInfo.getLogsLink();
|
|
|
+ attemptsTableData
|
|
|
+ .append("[\"<a href='")
|
|
|
+ .append(url("appattempt", rmAppAttempt.getAppAttemptId().toString()))
|
|
|
+ .append("'>")
|
|
|
+ .append(String.valueOf(rmAppAttempt.getAppAttemptId()))
|
|
|
+ .append("</a>\",\"")
|
|
|
+ .append(attemptInfo.getStartTime())
|
|
|
+ .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._()._();
|
|
|
+ }
|
|
|
}
|