Beispiel #1
0
        protected internal virtual void RenderData(HtmlBlock.Block html)
        {
            Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html
                                                                                               .Table("#apps").Thead().Tr().Th(".id", "ID").Th(".user", "User").Th(".name", "Name"
                                                                                                                                                                   ).Th(".type", "Application Type").Th(".queue", "Queue").Th(".starttime", "StartTime"
                                                                                                                                                                                                                              ).Th(".finishtime", "FinishTime").Th(".state", "State").Th(".finalstatus", "FinalStatus"
                                                                                                                                                                                                                                                                                         ).Th(".progress", "Progress").Th(".ui", "Tracking UI").().().Tbody();
            StringBuilder appsTableData = new StringBuilder("[\n");

            foreach (ApplicationReport appReport in appReports)
            {
                // TODO: remove the following condition. It is still here because
                // the history side implementation of ApplicationBaseProtocol
                // hasn't filtering capability (YARN-1819).
                if (!reqAppStates.IsEmpty() && !reqAppStates.Contains(appReport.GetYarnApplicationState
                                                                          ()))
                {
                    continue;
                }
                AppInfo app     = new AppInfo(appReport);
                string  percent = string.Format("%.1f", app.GetProgress());
                appsTableData.Append("[\"<a href='").Append(Url("app", app.GetAppId())).Append("'>"
                                                                                               ).Append(app.GetAppId()).Append("</a>\",\"").Append(StringEscapeUtils.EscapeJavaScript
                                                                                                                                                       (StringEscapeUtils.EscapeHtml(app.GetUser()))).Append("\",\"").Append(StringEscapeUtils
                                                                                                                                                                                                                             .EscapeJavaScript(StringEscapeUtils.EscapeHtml(app.GetName()))).Append("\",\"").
                Append(StringEscapeUtils.EscapeJavaScript(StringEscapeUtils.EscapeHtml(app.GetType
                                                                                           ()))).Append("\",\"").Append(StringEscapeUtils.EscapeJavaScript(StringEscapeUtils
                                                                                                                                                           .EscapeHtml(app.GetQueue()))).Append("\",\"").Append(app.GetStartedTime()).Append
                    ("\",\"").Append(app.GetFinishedTime()).Append("\",\"").Append(app.GetAppState()
                                                                                   == null ? Unavailable : app.GetAppState()).Append("\",\"").Append(app.GetFinalAppStatus
                                                                                                                                                         ()).Append("\",\"").Append("<br title='").Append(percent).Append("'> <div class='"
                                                                                                                                                                                                                          ).Append(JQueryUI.CProgressbar).Append("' title='").Append(StringHelper.Join(percent
                                                                                                                                                                                                                                                                                                       , '%')).Append("'> ").Append("<div class='").Append(JQueryUI.CProgressbarValue).
                Append("' style='").Append(StringHelper.Join("width:", percent, '%')).Append("'> </div> </div>"
                                                                                             ).Append("\",\"<a ");
                // Progress bar
                string trackingURL = app.GetTrackingUrl() == null || app.GetTrackingUrl().Equals(
                    Unavailable) ? null : app.GetTrackingUrl();
                string trackingUI = app.GetTrackingUrl() == null || app.GetTrackingUrl().Equals(Unavailable
                                                                                                ) ? "Unassigned" : app.GetAppState() == YarnApplicationState.Finished || app.GetAppState
                                        () == YarnApplicationState.Failed || app.GetAppState() == YarnApplicationState.Killed
                                         ? "History" : "ApplicationMaster";
                appsTableData.Append(trackingURL == null ? "#" : "href='" + trackingURL).Append("'>"
                                                                                                ).Append(trackingUI).Append("</a>\"],\n");
            }
            if (appsTableData[appsTableData.Length - 2] == ',')
            {
                appsTableData.Delete(appsTableData.Length - 2, appsTableData.Length - 1);
            }
            appsTableData.Append("]");
            html.Script().$type("text/javascript").("var appsTableData=" + appsTableData).();
            tbody.().();
        }
Beispiel #2
0
        protected override void Render(HtmlBlock.Block html)
        {
            Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html
                                                                                               .Table("#apps").Thead().Tr().Th(".id", "ID").Th(".user", "User").Th(".name", "Name"
                                                                                                                                                                   ).Th(".type", "Application Type").Th(".queue", "Queue").Th(".fairshare", "Fair Share"
                                                                                                                                                                                                                              ).Th(".starttime", "StartTime").Th(".finishtime", "FinishTime").Th(".state", "State"
                                                                                                                                                                                                                                                                                                 ).Th(".finalstatus", "FinalStatus").Th(".progress", "Progress").Th(".ui", "Tracking UI"
                                                                                                                                                                                                                                                                                                                                                                    ).().().Tbody();
            ICollection <YarnApplicationState> reqAppStates = null;
            string reqStateString = $(YarnWebParams.AppState);

            if (reqStateString != null && !reqStateString.IsEmpty())
            {
                string[] appStateStrings = reqStateString.Split(",");
                reqAppStates = new HashSet <YarnApplicationState>(appStateStrings.Length);
                foreach (string stateString in appStateStrings)
                {
                    reqAppStates.AddItem(YarnApplicationState.ValueOf(stateString));
                }
            }
            StringBuilder appsTableData = new StringBuilder("[\n");

            foreach (RMApp app in apps.Values)
            {
                if (reqAppStates != null && !reqAppStates.Contains(app.CreateApplicationState()))
                {
                    continue;
                }
                AppInfo appInfo = new AppInfo(rm, app, true, WebAppUtils.GetHttpSchemePrefix(conf
                                                                                             ));
                string percent = string.Format("%.1f", appInfo.GetProgress());
                ApplicationAttemptId attemptId = app.GetCurrentAppAttempt().GetAppAttemptId();
                int fairShare = fsinfo.GetAppFairShare(attemptId);
                if (fairShare == FairSchedulerInfo.InvalidFairShare)
                {
                    // FairScheduler#applications don't have the entry. Skip it.
                    continue;
                }
                appsTableData.Append("[\"<a href='").Append(Url("app", appInfo.GetAppId())).Append
                    ("'>").Append(appInfo.GetAppId()).Append("</a>\",\"").Append(StringEscapeUtils.EscapeJavaScript
                                                                                     (StringEscapeUtils.EscapeHtml(appInfo.GetUser()))).Append("\",\"").Append(StringEscapeUtils
                                                                                                                                                               .EscapeJavaScript(StringEscapeUtils.EscapeHtml(appInfo.GetName()))).Append("\",\""
                                                                                                                                                                                                                                          ).Append(StringEscapeUtils.EscapeJavaScript(StringEscapeUtils.EscapeHtml(appInfo
                                                                                                                                                                                                                                                                                                                   .GetApplicationType()))).Append("\",\"").Append(StringEscapeUtils.EscapeJavaScript
                                                                                                                                                                                                                                                                                                                                                                       (StringEscapeUtils.EscapeHtml(appInfo.GetQueue()))).Append("\",\"").Append(fairShare
                                                                                                                                                                                                                                                                                                                                                                                                                                                  ).Append("\",\"").Append(appInfo.GetStartTime()).Append("\",\"").Append(appInfo.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          GetFinishTime()).Append("\",\"").Append(appInfo.GetState()).Append("\",\"").Append
                    (appInfo.GetFinalStatus()).Append("\",\"").Append("<br title='").Append(percent)
                .Append("'> <div class='").Append(JQueryUI.CProgressbar).Append("' title='").Append
                    (StringHelper.Join(percent, '%')).Append("'> ").Append("<div class='").Append(JQueryUI
                                                                                                  .CProgressbarValue).Append("' style='").Append(StringHelper.Join("width:", percent
                                                                                                                                                                   , '%')).Append("'> </div> </div>").Append("\",\"<a href='");
                // Progress bar
                string trackingURL = !appInfo.IsTrackingUrlReady() ? "#" : appInfo.GetTrackingUrlPretty
                                         ();
                appsTableData.Append(trackingURL).Append("'>").Append(appInfo.GetTrackingUI()).Append
                    ("</a>\"],\n");
            }
            if (appsTableData[appsTableData.Length - 2] == ',')
            {
                appsTableData.Delete(appsTableData.Length - 2, appsTableData.Length - 1);
            }
            appsTableData.Append("]");
            html.Script().$type("text/javascript").("var appsTableData=" + appsTableData).();
            tbody.().();
        }