public virtual ContainersInfo GetContainers(HttpServletRequest req, HttpServletResponse res, string appId, string appAttemptId) { UserGroupInformation callerUGI = GetUser(req); ApplicationId aid = ParseApplicationId(appId); ApplicationAttemptId aaid = ParseApplicationAttemptId(appAttemptId); ValidateIds(aid, aaid, null); ICollection <ContainerReport> containerReports = null; try { if (callerUGI == null) { GetContainersRequest request = GetContainersRequest.NewInstance(aaid); containerReports = appBaseProt.GetContainers(request).GetContainerList(); } else { containerReports = callerUGI.DoAs(new _PrivilegedExceptionAction_332(this, aaid)); } } catch (Exception e) { RewrapAndThrowException(e); } ContainersInfo containersInfo = new ContainersInfo(); foreach (ContainerReport containerReport in containerReports) { ContainerInfo containerInfo = new ContainerInfo(containerReport); containersInfo.Add(containerInfo); } return(containersInfo); }
protected override void Render(HtmlBlock.Block html) { string attemptid = $(YarnWebParams.ApplicationAttemptId); if (attemptid.IsEmpty()) { Puts("Bad request: requires application attempt ID"); return; } try { appAttemptId = ConverterUtils.ToApplicationAttemptId(attemptid); } catch (ArgumentException) { Puts("Invalid application attempt ID: " + attemptid); return; } UserGroupInformation callerUGI = GetCallerUGI(); ApplicationAttemptReport appAttemptReport; try { GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.NewInstance (appAttemptId); if (callerUGI == null) { appAttemptReport = appBaseProt.GetApplicationAttemptReport(request).GetApplicationAttemptReport (); } else { appAttemptReport = callerUGI.DoAs(new _PrivilegedExceptionAction_85(this, request )); } } 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; } bool exceptionWhenGetContainerReports = false; ICollection <ContainerReport> containers = null; try { GetContainersRequest request = GetContainersRequest.NewInstance(appAttemptId); if (callerUGI == null) { containers = appBaseProt.GetContainers(request).GetContainerList(); } else { containers = callerUGI.DoAs(new _PrivilegedExceptionAction_115(this, request)); } } catch (RuntimeException) { // have this block to suppress the findbugs warning exceptionWhenGetContainerReports = true; } catch (Exception) { exceptionWhenGetContainerReports = true; } AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport); SetTitle(StringHelper.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.(typeof(InfoBlock)); CreateTablesForAttemptMetrics(html); // Container Table Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.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"); foreach (ContainerReport containerReport in 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[containersTableData.Length - 2] == ',') { containersTableData.Delete(containersTableData.Length - 2, containersTableData.Length - 1); } containersTableData.Append("]"); html.Script().$type("text/javascript").("var containersTableData=" + containersTableData ).(); tbody.().(); }