Пример #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.().();
        }
Пример #2
0
        protected override void Render(HtmlBlock.Block html)
        {
            string webUiType = $(YarnWebParams.WebUiType);
            string aid       = $(YarnWebParams.ApplicationId);

            if (aid.IsEmpty())
            {
                Puts("Bad request: requires Application ID");
                return;
            }
            try
            {
                appID = Apps.ToAppID(aid);
            }
            catch (Exception)
            {
                Puts("Invalid Application ID: " + aid);
                return;
            }
            UserGroupInformation callerUGI = GetCallerUGI();
            ApplicationReport    appReport;

            try
            {
                GetApplicationReportRequest request = GetApplicationReportRequest.NewInstance(appID
                                                                                              );
                if (callerUGI == null)
                {
                    appReport = appBaseProt.GetApplicationReport(request).GetApplicationReport();
                }
                else
                {
                    appReport = callerUGI.DoAs(new _PrivilegedExceptionAction_99(this, request));
                }
            }
            catch (Exception e)
            {
                string message = "Failed to read the application " + appID + ".";
                Log.Error(message, e);
                html.P().(message).();
                return;
            }
            if (appReport == null)
            {
                Puts("Application not found: " + aid);
                return;
            }
            AppInfo app = new AppInfo(appReport);

            SetTitle(StringHelper.Join("Application ", aid));
            if (webUiType != null && webUiType.Equals(YarnWebParams.RmWebUi) && conf.GetBoolean
                    (YarnConfiguration.RmWebappUiActionsEnabled, YarnConfiguration.DefaultRmWebappUiActionsEnabled
                    ))
            {
                // Application Kill
                html.Div().Button().$onclick("confirmAction()").B("Kill Application").().();
                StringBuilder script = new StringBuilder();
                script.Append("function confirmAction() {").Append(" b = confirm(\"Are you sure?\");"
                                                                   ).Append(" if (b == true) {").Append(" $.ajax({").Append(" type: 'PUT',").Append
                    (" url: '/ws/v1/cluster/apps/").Append(aid).Append("/state',").Append(" contentType: 'application/json',"
                                                                                          ).Append(" data: '{\"state\":\"KILLED\"}',").Append(" dataType: 'json'").Append(
                    " }).done(function(data){").Append(" setTimeout(function(){").Append(" location.href = '/cluster/app/"
                                                                                         ).Append(aid).Append("';").Append(" }, 1000);").Append(" }).fail(function(data){"
                                                                                                                                                ).Append(" console.log(data);").Append(" });").Append(" }").Append("}");
                html.Script().$type("text/javascript").(script.ToString()).();
            }
            Info("Application Overview").("User:"******"Name:", app.GetName()).("Application Type:"
                                                                                            , app.GetType()).("Application Tags:", app.GetApplicationTags() == null ? string.Empty
                                 : app.GetApplicationTags()).("YarnApplicationState:", app.GetAppState() == null
                                 ? Unavailable : ClarifyAppState(app.GetAppState())).("FinalStatus Reported by AM:"
                                                                                      , ClairfyAppFinalStatus(app.GetFinalAppStatus())).("Started:", Times.Format(app.
                                                                                                                                                                  GetStartedTime())).("Elapsed:", StringUtils.FormatTime(Times.Elapsed(app.GetStartedTime
                                                                                                                                                                                                                                           (), app.GetFinishedTime()))).("Tracking URL:", app.GetTrackingUrl() == null || app
                                                                                                                                                                                                                                                                         .GetTrackingUrl().Equals(Unavailable) ? null : Root_url(app.GetTrackingUrl()), app
                                                                                                                                                                                                                                                                         .GetTrackingUrl() == null || app.GetTrackingUrl().Equals(Unavailable) ? "Unassigned"
                                 : app.GetAppState() == YarnApplicationState.Finished || app.GetAppState() == YarnApplicationState
                                                                                                                                                                                                                                                                         .Failed || app.GetAppState() == YarnApplicationState.Killed ? "History" : "ApplicationMaster"
                                                                                                                                                                                                                                                                         ).("Diagnostics:", app.GetDiagnosticsInfo() == null ? string.Empty : app.GetDiagnosticsInfo
                                                                                                                                                                                                                                                                                ());
            ICollection <ApplicationAttemptReport> attempts;

            try
            {
                GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.NewInstance
                                                            (appID);
                if (callerUGI == null)
                {
                    attempts = appBaseProt.GetApplicationAttempts(request).GetApplicationAttemptList(
                        );
                }
                else
                {
                    attempts = callerUGI.DoAs(new _PrivilegedExceptionAction_196(this, request));
                }
            }
            catch (Exception e)
            {
                string message = "Failed to read the attempts of the application " + appID + ".";
                Log.Error(message, e);
                html.P().(message).();
                return;
            }
            CreateApplicationMetricsTable(html);
            html.(typeof(InfoBlock));
            GenerateApplicationTable(html, callerUGI, attempts);
        }