Example #1
0
        public virtual AppAttemptsInfo GetAppAttempts(HttpServletRequest req, HttpServletResponse
                                                      res, string appId)
        {
            UserGroupInformation callerUGI = GetUser(req);
            ApplicationId        id        = ParseApplicationId(appId);
            ICollection <ApplicationAttemptReport> appAttemptReports = null;

            try
            {
                if (callerUGI == null)
                {
                    GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.NewInstance
                                                                (id);
                    appAttemptReports = appBaseProt.GetApplicationAttempts(request).GetApplicationAttemptList
                                            ();
                }
                else
                {
                    appAttemptReports = callerUGI.DoAs(new _PrivilegedExceptionAction_260(this, id));
                }
            }
            catch (Exception e)
            {
                RewrapAndThrowException(e);
            }
            AppAttemptsInfo appAttemptsInfo = new AppAttemptsInfo();

            foreach (ApplicationAttemptReport appAttemptReport in appAttemptReports)
            {
                AppAttemptInfo appAttemptInfo = new AppAttemptInfo(appAttemptReport);
                appAttemptsInfo.Add(appAttemptInfo);
            }
            return(appAttemptsInfo);
        }
Example #2
0
        protected override void GenerateApplicationTable(HtmlBlock.Block html, UserGroupInformation
                                                         callerUGI, ICollection <ApplicationAttemptReport> attempts)
        {
            // Application Attempt Table
            Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html
                                                                                               .Table("#attempts").Thead().Tr().Th(".id", "Attempt ID").Th(".started", "Started"
                                                                                                                                                           ).Th(".node", "Node").Th(".logs", "Logs").Th(".blacklistednodes", "Blacklisted Nodes"
                                                                                                                                                                                                        ).().().Tbody();
            RMApp rmApp = this.rm.GetRMContext().GetRMApps()[this.appID];

            if (rmApp == null)
            {
                return;
            }
            StringBuilder attemptsTableData = new StringBuilder("[\n");

            foreach (ApplicationAttemptReport appAttemptReport in attempts)
            {
                RMAppAttempt rmAppAttempt = rmApp.GetRMAppAttempt(appAttemptReport.GetApplicationAttemptId
                                                                      ());
                if (rmAppAttempt == null)
                {
                    continue;
                }
                AppAttemptInfo attemptInfo = new AppAttemptInfo(this.rm, rmAppAttempt, rmApp.GetUser
                                                                    (), WebAppUtils.GetHttpSchemePrefix(conf));
                string blacklistedNodesCount = "N/A";
                ICollection <string> nodes   = RMAppAttemptBlock.GetBlacklistedNodes(rm, rmAppAttempt
                                                                                     .GetAppAttemptId());
                if (nodes != null)
                {
                    blacklistedNodesCount = nodes.Count.ToString();
                }
                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(rmAppAttempt.GetAppAttemptId().ToString()).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>\",").Append("\"").Append
                    (blacklistedNodesCount).Append("\"],\n");
            }
            if (attemptsTableData[attemptsTableData.Length - 2] == ',')
            {
                attemptsTableData.Delete(attemptsTableData.Length - 2, attemptsTableData.Length -
                                         1);
            }
            attemptsTableData.Append("]");
            html.Script().$type("text/javascript").("var attemptsTableData=" + attemptsTableData
                                                    ).();
            tbody.().();
        }
Example #3
0
        protected override void GenerateOverview(ApplicationAttemptReport appAttemptReport
                                                 , ICollection <ContainerReport> containers, AppAttemptInfo appAttempt, string node
                                                 )
        {
            string blacklistedNodes    = "-";
            ICollection <string> nodes = GetBlacklistedNodes(rm, GetRMAppAttempt().GetAppAttemptId
                                                                 ());

            if (nodes != null)
            {
                if (!nodes.IsEmpty())
                {
                    blacklistedNodes = StringUtils.Join(nodes, ", ");
                }
            }
            Info("Application Attempt Overview").("Application Attempt State:", appAttempt.GetAppAttemptState
                                                      () == null ? Unavailable : appAttempt.GetAppAttemptState()).("AM Container:", appAttempt
                                                                                                                   .GetAmContainerId() == null || containers == null || !HasAMContainer(appAttemptReport
                                                                                                                                                                                        .GetAMContainerId(), containers) ? null : Root_url("container", appAttempt.GetAmContainerId
                                                                                                                                                                                                                                               ()), appAttempt.GetAmContainerId().ToString()).("Node:", node).("Tracking URL:",
                                                                                                                                                                                                                                                                                                               appAttempt.GetTrackingUrl() == null || appAttempt.GetTrackingUrl().Equals(Unavailable
                                                                                                                                                                                                                                                                                                                                                                                         ) ? null : Root_url(appAttempt.GetTrackingUrl()), appAttempt.GetTrackingUrl() ==
                                                                                                                                                                                                                                                                                                               null || appAttempt.GetTrackingUrl().Equals(Unavailable) ? "Unassigned" : appAttempt
                                                                                                                                                                                                                                                                                                               .GetAppAttemptState() == YarnApplicationAttemptState.Finished || appAttempt.GetAppAttemptState
                                                                                                                                                                                                                                                                                                                   () == YarnApplicationAttemptState.Failed || appAttempt.GetAppAttemptState() == YarnApplicationAttemptState
                                                                                                                                                                                                                                                                                                               .Killed ? "History" : "ApplicationMaster").("Diagnostics Info:", appAttempt.GetDiagnosticsInfo
                                                                                                                                                                                                                                                                                                                                                               () == null ? string.Empty : appAttempt.GetDiagnosticsInfo()).("Blacklisted Nodes:"
                                                                                                                                                                                                                                                                                                                                                                                                                             , blacklistedNodes);
        }
Example #4
0
        protected internal virtual void GenerateApplicationTable(HtmlBlock.Block html, UserGroupInformation
                                                                 callerUGI, ICollection <ApplicationAttemptReport> attempts)
        {
            // Application Attempt Table
            Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.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");

            foreach (ApplicationAttemptReport appAttemptReport in attempts)
            {
                AppAttemptInfo  appAttempt = new AppAttemptInfo(appAttemptReport);
                ContainerReport containerReport;
                try
                {
                    GetContainerReportRequest request = GetContainerReportRequest.NewInstance(appAttemptReport
                                                                                              .GetAMContainerId());
                    if (callerUGI == null)
                    {
                        containerReport = appBaseProt.GetContainerReport(request).GetContainerReport();
                    }
                    else
                    {
                        containerReport = callerUGI.DoAs(new _PrivilegedExceptionAction_242(this, request
                                                                                            ));
                    }
                }
                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[attemptsTableData.Length - 2] == ',')
            {
                attemptsTableData.Delete(attemptsTableData.Length - 2, attemptsTableData.Length -
                                         1);
            }
            attemptsTableData.Append("]");
            html.Script().$type("text/javascript").("var attemptsTableData=" + attemptsTableData
                                                    ).();
            tbody.().();
        }
Example #5
0
        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.().();
        }
Example #6
0
 protected internal virtual void GenerateOverview(ApplicationAttemptReport appAttemptReport
                                                  , ICollection <ContainerReport> containers, AppAttemptInfo appAttempt, string node
                                                  )
 {
     Info("Application Attempt Overview").("Application Attempt State:", appAttempt.GetAppAttemptState
                                               () == null ? Unavailable : appAttempt.GetAppAttemptState()).("AM Container:", appAttempt
                                                                                                            .GetAmContainerId() == null || containers == null || !HasAMContainer(appAttemptReport
                                                                                                                                                                                 .GetAMContainerId(), containers) ? null : Root_url("container", appAttempt.GetAmContainerId
                                                                                                                                                                                                                                        ()), appAttempt.GetAmContainerId().ToString()).("Node:", node).("Tracking URL:",
                                                                                                                                                                                                                                                                                                        appAttempt.GetTrackingUrl() == null || appAttempt.GetTrackingUrl().Equals(Unavailable
                                                                                                                                                                                                                                                                                                                                                                                  ) ? null : Root_url(appAttempt.GetTrackingUrl()), appAttempt.GetTrackingUrl() ==
                                                                                                                                                                                                                                                                                                        null || appAttempt.GetTrackingUrl().Equals(Unavailable) ? "Unassigned" : appAttempt
                                                                                                                                                                                                                                                                                                        .GetAppAttemptState() == YarnApplicationAttemptState.Finished || appAttempt.GetAppAttemptState
                                                                                                                                                                                                                                                                                                            () == YarnApplicationAttemptState.Failed || appAttempt.GetAppAttemptState() == YarnApplicationAttemptState
                                                                                                                                                                                                                                                                                                        .Killed ? "History" : "ApplicationMaster").("Diagnostics Info:", appAttempt.GetDiagnosticsInfo
                                                                                                                                                                                                                                                                                                                                                        () == null ? string.Empty : appAttempt.GetDiagnosticsInfo());
 }