コード例 #1
0
        /// <exception cref="System.IO.IOException"/>
        private bool CheckStorageInfoOrSendError(JNStorage storage, HttpServletRequest request
                                                 , HttpServletResponse response)
        {
            int    myNsId                 = storage.GetNamespaceID();
            string myClusterId            = storage.GetClusterID();
            string theirStorageInfoString = StringEscapeUtils.EscapeHtml(request.GetParameter
                                                                             (StorageinfoParam));

            if (theirStorageInfoString != null)
            {
                int theirNsId = StorageInfo.GetNsIdFromColonSeparatedString(theirStorageInfoString
                                                                            );
                string theirClusterId = StorageInfo.GetClusterIdFromColonSeparatedString(theirStorageInfoString
                                                                                         );
                if (myNsId != theirNsId || !myClusterId.Equals(theirClusterId))
                {
                    string msg = "This node has namespaceId '" + myNsId + " and clusterId '" + myClusterId
                                 + "' but the requesting node expected '" + theirNsId + "' and '" + theirClusterId
                                 + "'";
                    response.SendError(HttpServletResponse.ScForbidden, msg);
                    Log.Warn("Received an invalid request file transfer request from " + request.GetRemoteAddr
                                 () + ": " + msg);
                    return(false);
                }
            }
            return(true);
        }
コード例 #2
0
ファイル: RMAppBlock.cs プロジェクト: orf53975/hadoop.net
        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.().();
        }
コード例 #3
0
 private void PrintHeader(PrintWriter @out, string nodeName)
 {
     @out.Write("<html><head>");
     @out.Printf("<title>%s Reconfiguration Utility</title>%n", StringEscapeUtils.EscapeHtml
                     (nodeName));
     @out.Write("</head><body>\n");
     @out.Printf("<h1>%s Reconfiguration Utility</h1>%n", StringEscapeUtils.EscapeHtml
                     (nodeName));
 }
コード例 #4
0
        /// <exception cref="System.IO.IOException"/>
        private void AddResults(IHttpServletRequest request, IHttpServletResponse response)
        {
            string input = request.GetParameter("input");

            if (input == null)
            {
                return;
            }
            input = input.Trim();
            if (input.IsEmpty())
            {
                return;
            }
            PrintWriter @out = response.GetWriter();

            if (input.Length > MaximumQueryLength)
            {
                @out.Print("This query is too long.  If you want to run very long queries, please download and use our <a href=\"http://nlp.stanford.edu/software/CRF-NER.html\">publicly released distribution</a>.");
                return;
            }
            string outputFormat = request.GetParameter("outputFormat");

            if (outputFormat == null || outputFormat.Trim().IsEmpty())
            {
                outputFormat = this.format;
            }
            bool   preserveSpacing;
            string preserveSpacingStr = request.GetParameter("preserveSpacing");

            if (preserveSpacingStr == null || preserveSpacingStr.Trim().IsEmpty())
            {
                preserveSpacing = this.spacing;
            }
            else
            {
                preserveSpacingStr = preserveSpacingStr.Trim();
                preserveSpacing    = bool.ValueOf(preserveSpacingStr);
            }
            string classifier = request.GetParameter("classifier");

            if (classifier == null || classifier.Trim().IsEmpty())
            {
                classifier = this.defaultClassifier;
            }
            response.AddHeader("classifier", classifier);
            response.AddHeader("outputFormat", outputFormat);
            response.AddHeader("preserveSpacing", preserveSpacing.ToString());
            if (outputFormat.Equals("highlighted"))
            {
                OutputHighlighting(@out, ners[classifier], input);
            }
            else
            {
                @out.Print(StringEscapeUtils.EscapeHtml4(ners[classifier].ClassifyToString(input, outputFormat, preserveSpacing)));
            }
        }
コード例 #5
0
        /*
         * (non-Javadoc)
         * @see org.apache.hadoop.yarn.webapp.view.HtmlBlock#render(org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block)
         */
        protected override void Render(HtmlBlock.Block html)
        {
            Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html
                                                                                               .H2("Retired Jobs").Table("#jobs").Thead().Tr().Th("Submit Time").Th("Start Time"
                                                                                                                                                                    ).Th("Finish Time").Th(".id", "Job ID").Th(".name", "Name").Th("User").Th("Queue"
                                                                                                                                                                                                                                              ).Th(".state", "State").Th("Maps Total").Th("Maps Completed").Th("Reduces Total"
                                                                                                                                                                                                                                                                                                               ).Th("Reduces Completed").().().Tbody();
            Log.Info("Getting list of all Jobs.");
            // Write all the data into a JavaScript array of arrays for JQuery
            // DataTables to display
            StringBuilder jobsTableData = new StringBuilder("[\n");

            foreach (Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job j in appContext.GetAllJobs().
                     Values)
            {
                JobInfo job = new JobInfo(j);
                jobsTableData.Append("[\"").Append(dateFormat.Format(Sharpen.Extensions.CreateDate
                                                                         (job.GetSubmitTime()))).Append("\",\"").Append(dateFormat.Format(Sharpen.Extensions.CreateDate
                                                                                                                                              (job.GetStartTime()))).Append("\",\"").Append(dateFormat.Format(Sharpen.Extensions.CreateDate
                                                                                                                                                                                                                  (job.GetFinishTime()))).Append("\",\"").Append("<a href='").Append(Url("job", job
                                                                                                                                                                                                                                                                                         .GetId())).Append("'>").Append(job.GetId()).Append("</a>\",\"").Append(StringEscapeUtils
                                                                                                                                                                                                                                                                                                                                                                .EscapeJavaScript(StringEscapeUtils.EscapeHtml(job.GetName()))).Append("\",\"").
                Append(StringEscapeUtils.EscapeJavaScript(StringEscapeUtils.EscapeHtml(job.GetUserName
                                                                                           ()))).Append("\",\"").Append(StringEscapeUtils.EscapeJavaScript(StringEscapeUtils
                                                                                                                                                           .EscapeHtml(job.GetQueueName()))).Append("\",\"").Append(job.GetState()).Append(
                    "\",\"").Append(job.GetMapsTotal().ToString()).Append("\",\"").Append(job.GetMapsCompleted
                                                                                              ().ToString()).Append("\",\"").Append(job.GetReducesTotal().ToString()).Append("\",\""
                                                                                                                                                                             ).Append(job.GetReducesCompleted().ToString()).Append("\"],\n");
            }
            //Remove the last comma and close off the array of arrays
            if (jobsTableData[jobsTableData.Length - 2] == ',')
            {
                jobsTableData.Delete(jobsTableData.Length - 2, jobsTableData.Length - 1);
            }
            jobsTableData.Append("]");
            html.Script().$type("text/javascript").("var jobsTableData=" + jobsTableData).();
            tbody.().Tfoot().Tr().Th().Input("search_init").$type(HamletSpec.InputType.text).
            $name("submit_time").$value("Submit Time").().().Th().Input("search_init").$type
                (HamletSpec.InputType.text).$name("start_time").$value("Start Time").().().Th().
            Input("search_init").$type(HamletSpec.InputType.text).$name("finish_time").$value
                ("Finish Time").().().Th().Input("search_init").$type(HamletSpec.InputType.text)
            .$name("start_time").$value("Job ID").().().Th().Input("search_init").$type(HamletSpec.InputType
                                                                                        .text).$name("start_time").$value("Name").().().Th().Input("search_init").$type(
                HamletSpec.InputType.text).$name("start_time").$value("User").().().Th().Input("search_init"
                                                                                               ).$type(HamletSpec.InputType.text).$name("start_time").$value("Queue").().().Th(
                ).Input("search_init").$type(HamletSpec.InputType.text).$name("start_time").$value
                ("State").().().Th().Input("search_init").$type(HamletSpec.InputType.text).$name
                ("start_time").$value("Maps Total").().().Th().Input("search_init").$type(HamletSpec.InputType
                                                                                          .text).$name("start_time").$value("Maps Completed").().().Th().Input("search_init"
                                                                                                                                                               ).$type(HamletSpec.InputType.text).$name("start_time").$value("Reduces Total").(
                ).().Th().Input("search_init").$type(HamletSpec.InputType.text).$name("start_time"
                                                                                      ).$value("Reduces Completed").().().().().();
        }
コード例 #6
0
ファイル: AppsBlock.cs プロジェクト: orf53975/hadoop.net
        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.().();
        }
コード例 #7
0
ファイル: Graph.cs プロジェクト: orf53975/hadoop.net
 private static string WrapSafeString(string label)
 {
     if (label.IndexOf(',') >= 0)
     {
         if (label.Length > 14)
         {
             label = label.ReplaceAll(",", ",\n");
         }
     }
     label = "\"" + StringEscapeUtils.EscapeJava(label) + "\"";
     return(label);
 }
コード例 #8
0
        private static void OutputHighlighting(PrintWriter @out, CRFClassifier <ICoreMap> classifier, string input)
        {
            ICollection <string> labels               = classifier.Labels();
            string background                         = classifier.BackgroundSymbol();
            IList <IList <ICoreMap> >   sentences     = classifier.Classify(input);
            IDictionary <string, Color> tagToColorMap = NERGUI.MakeTagToColorMap(labels, background);
            StringBuilder result                      = new StringBuilder();
            int           lastEndOffset               = 0;

            foreach (IList <ICoreMap> sentence in sentences)
            {
                foreach (ICoreMap word in sentence)
                {
                    int    beginOffset = word.Get(typeof(CoreAnnotations.CharacterOffsetBeginAnnotation));
                    int    endOffset   = word.Get(typeof(CoreAnnotations.CharacterOffsetEndAnnotation));
                    string answer      = word.Get(typeof(CoreAnnotations.AnswerAnnotation));
                    if (beginOffset > lastEndOffset)
                    {
                        result.Append(StringEscapeUtils.EscapeHtml4(Sharpen.Runtime.Substring(input, lastEndOffset, beginOffset)));
                    }
                    // Add a color bar for any tagged words
                    if (!background.Equals(answer))
                    {
                        Color color = tagToColorMap[answer];
                        result.Append("<span style=\"color:#ffffff;background:" + NERGUI.ColorToHTML(color) + "\">");
                    }
                    result.Append(StringEscapeUtils.EscapeHtml4(Sharpen.Runtime.Substring(input, beginOffset, endOffset)));
                    // Turn off the color bar
                    if (!background.Equals(answer))
                    {
                        result.Append("</span>");
                    }
                    lastEndOffset = endOffset;
                }
            }
            if (lastEndOffset < input.Length)
            {
                result.Append(StringEscapeUtils.EscapeHtml4(Sharpen.Runtime.Substring(input, lastEndOffset)));
            }
            result.Append("<br><br>");
            result.Append("Potential tags:");
            foreach (KeyValuePair <string, Color> stringColorEntry in tagToColorMap)
            {
                result.Append("<br>&nbsp;&nbsp;");
                Color color = stringColorEntry.Value;
                result.Append("<span style=\"color:#ffffff;background:" + NERGUI.ColorToHTML(color) + "\">");
                result.Append(StringEscapeUtils.EscapeHtml4(stringColorEntry.Key));
                result.Append("</span>");
            }
            @out.Print(result);
        }
コード例 #9
0
ファイル: MethodSourceWriter.cs プロジェクト: Neo4Net/Neo4Net
 public override void Constant(object value)
 {
     if (value == null)
     {
         Append("null");
     }
     else if (value is string)
     {
         Append("\"").Append(StringEscapeUtils.escapeJava(( string )value)).Append('"');
     }
     else if (value is int?)
     {
         Append(value.ToString());
     }
     else if (value is long?)
     {
         Append(value.ToString()).Append('L');
     }
     else if (value is double?)
     {
         double?doubleValue = ( double? )value;
         if (double.IsNaN(doubleValue))
         {
             Append("Double.NaN");
         }
         else if (doubleValue == double.PositiveInfinity)
         {
             Append("Double.POSITIVE_INFINITY");
         }
         else if (doubleValue == double.NegativeInfinity)
         {
             Append("Double.NEGATIVE_INFINITY");
         }
         else
         {
             Append(value.ToString());
         }
     }
     else if (value is bool?)
     {
         Append(value.ToString());
     }
     else
     {
         throw new System.NotSupportedException(value.GetType() + " constants");
     }
 }
コード例 #10
0
            protected override void Render(HtmlBlock.Block html)
            {
                if (!IsValidRequest())
                {
                    html.H2($(Title));
                    return;
                }
                Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html
                                                                                                   .Table("#attempts").Thead().Tr().Th(".id", "Attempt").Th(".progress", "Progress"
                                                                                                                                                            ).Th(".state", "State").Th(".status", "Status").Th(".node", "Node").Th(".logs",
                                                                                                                                                                                                                                   "Logs").Th(".tsh", "Started").Th(".tsh", "Finished").Th(".tsh", "Elapsed").Th(".note"
                                                                                                                                                                                                                                                                                                                 , "Note").().().Tbody();
                // Write all the data into a JavaScript array of arrays for JQuery
                // DataTables to display
                StringBuilder attemptsTableData = new StringBuilder("[\n");

                foreach (TaskAttempt attempt in GetTaskAttempts())
                {
                    TaskAttemptInfo ta           = new TaskAttemptInfo(attempt, true);
                    string          progress     = StringHelper.Percent(ta.GetProgress() / 100);
                    string          nodeHttpAddr = ta.GetNode();
                    string          diag         = ta.GetNote() == null ? string.Empty : ta.GetNote();
                    attemptsTableData.Append("[\"").Append(ta.GetId()).Append("\",\"").Append(progress
                                                                                              ).Append("\",\"").Append(ta.GetState().ToString()).Append("\",\"").Append(StringEscapeUtils
                                                                                                                                                                        .EscapeJavaScript(StringEscapeUtils.EscapeHtml(ta.GetStatus()))).Append("\",\"")
                    .Append(nodeHttpAddr == null ? "N/A" : "<a class='nodelink' href='" + MRWebAppUtil
                            .GetYARNWebappScheme() + nodeHttpAddr + "'>" + nodeHttpAddr + "</a>").Append("\",\""
                                                                                                         ).Append(ta.GetAssignedContainerId() == null ? "N/A" : "<a class='logslink' href='"
                                                                                                                  + Url(MRWebAppUtil.GetYARNWebappScheme(), nodeHttpAddr, "node", "containerlogs"
                                                                                                                        , ta.GetAssignedContainerIdStr(), app.GetJob().GetUserName()) + "'>logs</a>").Append
                        ("\",\"").Append(ta.GetStartTime()).Append("\",\"").Append(ta.GetFinishTime()).Append
                        ("\",\"").Append(ta.GetElapsedTime()).Append("\",\"").Append(StringEscapeUtils.EscapeJavaScript
                                                                                         (StringEscapeUtils.EscapeHtml(diag))).Append("\"],\n");
                }
                //Remove the last comma and close off the array of arrays
                if (attemptsTableData[attemptsTableData.Length - 2] == ',')
                {
                    attemptsTableData.Delete(attemptsTableData.Length - 2, attemptsTableData.Length -
                                             1);
                }
                attemptsTableData.Append("]");
                html.Script().$type("text/javascript").("var attemptsTableData=" + attemptsTableData
                                                        ).();
                tbody.().();
            }
コード例 #11
0
ファイル: HamletImpl.cs プロジェクト: orf53975/hadoop.net
 protected internal virtual void _p(bool quote, params object[] args)
 {
     this.CloseAttrs();
     foreach (object s in args)
     {
         if (!this.opts.Contains(HamletImpl.EOpt.Pre))
         {
             this._enclosing.Indent(this.opts);
         }
         [email protected](quote ? StringEscapeUtils.EscapeHtml(s.ToString()) : s
                                    .ToString());
         if (!this.opts.Contains(HamletImpl.EOpt.Inline) && !this.opts.Contains(HamletImpl.EOpt
                                                                                .Pre))
         {
             [email protected]();
         }
     }
 }
コード例 #12
0
        protected internal virtual void InitDataTables(IList <string> list)
        {
            string defaultInit   = "{bJQueryUI: true, sPaginationType: 'full_numbers'}";
            string stateSaveInit = "bStateSave : true, " + "\"fnStateSave\": function (oSettings, oData) { "
                                   + " data = oData.aoSearchCols;" + "for(i =0 ; i < data.length; i ++) {" + "data[i].sSearch = \"\""
                                   + "}" + " sessionStorage.setItem( oSettings.sTableId, JSON.stringify(oData) ); }, "
                                   + "\"fnStateLoad\": function (oSettings) { " + "return JSON.parse( sessionStorage.getItem(oSettings.sTableId) );}, ";

            foreach (string id in StringHelper.Split($(DatatablesId)))
            {
                if (Html.IsValidId(id))
                {
                    string init = $(InitID(Datatables, id));
                    if (init.IsEmpty())
                    {
                        init = defaultInit;
                    }
                    // for inserting stateSaveInit
                    int pos = init.IndexOf('{') + 1;
                    init = new StringBuilder(init).Insert(pos, stateSaveInit).ToString();
                    list.AddItem(StringHelper.Join(id, "DataTable =  $('#", id, "').dataTable(", init
                                                   , ").fnSetFilteringDelay(188);"));
                    string postInit = $(PostInitID(Datatables, id));
                    if (!postInit.IsEmpty())
                    {
                        list.AddItem(postInit);
                    }
                }
            }
            string selector = $(DatatablesSelector);

            if (!selector.IsEmpty())
            {
                string init = $(InitSelector(Datatables));
                if (init.IsEmpty())
                {
                    init = defaultInit;
                }
                int pos = init.IndexOf('{') + 1;
                init = new StringBuilder(init).Insert(pos, stateSaveInit).ToString();
                list.AddItem(StringHelper.Join("  $('", StringEscapeUtils.EscapeJavaScript(selector
                                                                                           ), "').dataTable(", init, ").fnSetFilteringDelay(288);"));
            }
        }
コード例 #13
0
        /// <summary>Print configuration options that can be changed.</summary>
        private void PrintConf(PrintWriter @out, Reconfigurable reconf)
        {
            Configuration oldConf = reconf.GetConf();
            Configuration newConf = new Configuration();
            ICollection <ReconfigurationUtil.PropertyChange> changes = ReconfigurationUtil.GetChangedProperties
                                                                           (newConf, oldConf);
            bool changeOK = true;

            @out.WriteLine("<form action=\"\" method=\"post\">");
            @out.WriteLine("<table border=\"1\">");
            @out.WriteLine("<tr><th>Property</th><th>Old value</th>");
            @out.WriteLine("<th>New value </th><th></th></tr>");
            foreach (ReconfigurationUtil.PropertyChange c in changes)
            {
                @out.Write("<tr><td>");
                if (!reconf.IsPropertyReconfigurable(c.prop))
                {
                    @out.Write("<font color=\"red\">" + StringEscapeUtils.EscapeHtml(c.prop) + "</font>"
                               );
                    changeOK = false;
                }
                else
                {
                    @out.Write(StringEscapeUtils.EscapeHtml(c.prop));
                    @out.Write("<input type=\"hidden\" name=\"" + StringEscapeUtils.EscapeHtml(c.prop
                                                                                               ) + "\" value=\"" + StringEscapeUtils.EscapeHtml(c.newVal) + "\"/>");
                }
                @out.Write("</td><td>" + (c.oldVal == null ? "<it>default</it>" : StringEscapeUtils
                                          .EscapeHtml(c.oldVal)) + "</td><td>" + (c.newVal == null ? "<it>default</it>" :
                                                                                  StringEscapeUtils.EscapeHtml(c.newVal)) + "</td>");
                @out.Write("</tr>\n");
            }
            @out.WriteLine("</table>");
            if (!changeOK)
            {
                @out.WriteLine("<p><font color=\"red\">WARNING: properties marked red" + " will not be changed until the next restart.</font></p>"
                               );
            }
            @out.WriteLine("<input type=\"submit\" value=\"Apply\" />");
            @out.WriteLine("</form>");
        }
コード例 #14
0
        /// <exception cref="System.IO.IOException"/>
        private static void OutputByWriter(IConsumer <StringWriter> printer, PrintWriter @out)
        {
            StringWriter output = new StringWriter();

            printer.Accept(output);
            output.Flush();
            string escapedXml = StringEscapeUtils.EscapeHtml4(output.ToString());

            string[] lines = escapedXml.Split("\n");
            @out.Print("<div><pre>");
            foreach (string line in lines)
            {
                int numSpaces = 0;
                while (numSpaces < line.Length && line[numSpaces] == ' ')
                {
                    @out.Print("&nbsp;");
                    ++numSpaces;
                }
                @out.Print(Sharpen.Runtime.Substring(line, numSpaces));
                @out.Print("\n");
            }
            @out.Print("</pre></div>");
        }
コード例 #15
0
        /// <exception cref="System.IO.IOException"/>
        private void AddResults(IHttpServletRequest request, IHttpServletResponse response)
        {
            // if we can't handle UTF-8, need to do something like this...
            //String originalQuery = request.getParameter("q");
            //String query = WebappUtil.convertString(originalQuery);
            string query      = request.GetParameter("q");
            string dateString = request.GetParameter("d");
            // TODO: this always returns true...
            bool        dateError      = !pipeline.IsDateOkay(dateString);
            bool        includeOffsets = ParseBoolean(request.GetParameter("includeOffsets"));
            PrintWriter @out           = response.GetWriter();

            if (dateError)
            {
                @out.Println("<br><br>Warning: unparseable date " + StringEscapeUtils.EscapeHtml4(dateString));
            }
            if (!StringUtils.IsNullOrEmpty(query))
            {
                Properties props         = GetTimeAnnotatorProperties(request);
                string     annotatorType = request.GetParameter("annotator");
                if (annotatorType == null)
                {
                    annotatorType = "sutime";
                }
                IAnnotator timeAnnotator = pipeline.GetTimeAnnotator(annotatorType, props);
                if (timeAnnotator != null)
                {
                    Annotation anno = pipeline.Process(query, dateString, timeAnnotator);
                    @out.Println("<h3>Annotated Text</h3> <em>(tagged using " + annotatorType + "</em>)");
                    DisplayAnnotation(@out, query, anno, includeOffsets);
                }
                else
                {
                    @out.Println("<br><br>Error creating annotator for " + StringEscapeUtils.EscapeHtml4(annotatorType));
                }
            }
        }
コード例 #16
0
        protected internal virtual void InitDialogs(IList <string> list)
        {
            string defaultInit = "{autoOpen: false, show: transfer, hide: explode}";

            foreach (string id in StringHelper.Split($(DialogId)))
            {
                if (Html.IsValidId(id))
                {
                    string init = $(InitID(Dialog, id));
                    if (init.IsEmpty())
                    {
                        init = defaultInit;
                    }
                    string opener = $(StringHelper.Djoin(Dialog, id, "opener"));
                    list.AddItem(StringHelper.Join("  $('#", id, "').dialog(", init, ");"));
                    if (!opener.IsEmpty() && Html.IsValidId(opener))
                    {
                        list.AddItem(StringHelper.Join("  $('#", opener, "').click(function() { ", "$('#"
                                                       , id, "').dialog('open'); return false; });"));
                    }
                }
            }
            string selector = $(DialogSelector);

            if (!selector.IsEmpty())
            {
                string init = $(InitSelector(Dialog));
                if (init.IsEmpty())
                {
                    init = defaultInit;
                }
                list.AddItem(StringHelper.Join("  $('", StringEscapeUtils.EscapeJavaScript(selector
                                                                                           ), "').click(function() { $(this).children('.dialog').dialog(", init, "); return false; });"
                                               ));
            }
        }
コード例 #17
0
ファイル: AppBlock.cs プロジェクト: orf53975/hadoop.net
        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.().();
        }
コード例 #18
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.().();
        }
コード例 #19
0
        private static void DisplayAnnotation(PrintWriter @out, string query, Annotation anno, bool includeOffsets)
        {
            IList <ICoreMap> timexAnns = anno.Get(typeof(TimeAnnotations.TimexAnnotations));
            IList <string>   pieces    = new List <string>();
            IList <bool>     tagged    = new List <bool>();
            int previousEnd            = 0;

            foreach (ICoreMap timexAnn in timexAnns)
            {
                int begin = timexAnn.Get(typeof(CoreAnnotations.CharacterOffsetBeginAnnotation));
                int end   = timexAnn.Get(typeof(CoreAnnotations.CharacterOffsetEndAnnotation));
                if (begin >= previousEnd)
                {
                    pieces.Add(Sharpen.Runtime.Substring(query, previousEnd, begin));
                    tagged.Add(false);
                    pieces.Add(Sharpen.Runtime.Substring(query, begin, end));
                    tagged.Add(true);
                    previousEnd = end;
                }
            }
            if (previousEnd < query.Length)
            {
                pieces.Add(Sharpen.Runtime.Substring(query, previousEnd));
                tagged.Add(false);
            }
            @out.Println("<table id='Annotated'><tr><td>");
            for (int i = 0; i < pieces.Count; ++i)
            {
                if (tagged[i])
                {
                    @out.Print("<span style=\"background-color: #FF8888\">");
                    @out.Print(StringEscapeUtils.EscapeHtml4(pieces[i]));
                    @out.Print("</span>");
                }
                else
                {
                    @out.Print(StringEscapeUtils.EscapeHtml4(pieces[i]));
                }
            }
            @out.Println("</td></tr></table>");
            @out.Println("<h3>Temporal Expressions</h3>");
            if (timexAnns.Count > 0)
            {
                @out.Println("<table>");
                @out.Println("<tr><th>Text</th><th>Value</th>");
                if (includeOffsets)
                {
                    @out.Println("<th>Char Begin</th><th>Char End</th><th>Token Begin</th><th>Token End</th>");
                }
                @out.Println("<th>Timex3 Tag</th></tr>");
                foreach (ICoreMap timexAnn_1 in timexAnns)
                {
                    @out.Println("<tr>");
                    Timex timex = timexAnn_1.Get(typeof(TimeAnnotations.TimexAnnotation));
                    int   begin = timexAnn_1.Get(typeof(CoreAnnotations.CharacterOffsetBeginAnnotation));
                    int   end   = timexAnn_1.Get(typeof(CoreAnnotations.CharacterOffsetEndAnnotation));
                    @out.Print("<td>" + StringEscapeUtils.EscapeHtml4(Sharpen.Runtime.Substring(query, begin, end)) + "</td>");
                    @out.Print("<td>" + ((timex.Value() != null) ? StringEscapeUtils.EscapeHtml4(timex.Value()) : string.Empty) + "</td>");
                    if (includeOffsets)
                    {
                        @out.Print("<td>" + begin + "</td>");
                        @out.Print("<td>" + end + "</td>");
                        @out.Print("<td>" + timexAnn_1.Get(typeof(CoreAnnotations.TokenBeginAnnotation)) + "</td>");
                        @out.Print("<td>" + timexAnn_1.Get(typeof(CoreAnnotations.TokenEndAnnotation)) + "</td>");
                    }
                    @out.Print("<td>" + StringEscapeUtils.EscapeHtml4(timex.ToString()) + "</td>");
                    @out.Println("</tr>");
                }
                @out.Println("</table>");
            }
            else
            {
                @out.Println("<em>No temporal expressions.</em>");
            }
            @out.Println("<h3>POS Tags</h3>");
            @out.Println("<table><tr><td>");
            foreach (ICoreMap sentence in anno.Get(typeof(CoreAnnotations.SentencesAnnotation)))
            {
                IList <CoreLabel> tokens = sentence.Get(typeof(CoreAnnotations.TokensAnnotation));
                foreach (CoreLabel token in tokens)
                {
                    string tokenOutput = StringEscapeUtils.EscapeHtml4(token.Word() + "/" + token.Tag());
                    @out.Print(tokenOutput + " ");
                }
                @out.Println("<br>");
            }
            @out.Println("</td></tr></table>");
        }
コード例 #20
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.().();
        }
コード例 #21
0
ファイル: TasksBlock.cs プロジェクト: orf53975/hadoop.net
        protected override void Render(HtmlBlock.Block html)
        {
            if (app.GetJob() == null)
            {
                html.H2($(Title));
                return;
            }
            TaskType type   = null;
            string   symbol = $(AMParams.TaskType);

            if (!symbol.IsEmpty())
            {
                type = MRApps.TaskType(symbol);
            }
            Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = html
                                                                                               .Table("#tasks").Thead().Tr().Th("Task").Th("Progress").Th("Status").Th("State")
                                                                                               .Th("Start Time").Th("Finish Time").Th("Elapsed Time").().().Tbody();
            StringBuilder tasksTableData = new StringBuilder("[\n");

            foreach (Task task in app.GetJob().GetTasks().Values)
            {
                if (type != null && task.GetType() != type)
                {
                    continue;
                }
                string taskStateStr = $(AMParams.TaskState);
                if (taskStateStr == null || taskStateStr.Trim().Equals(string.Empty))
                {
                    taskStateStr = "ALL";
                }
                if (!Sharpen.Runtime.EqualsIgnoreCase(taskStateStr, "ALL"))
                {
                    try
                    {
                        // get stateUI enum
                        MRApps.TaskStateUI stateUI = MRApps.TaskState(taskStateStr);
                        if (!stateUI.CorrespondsTo(task.GetState()))
                        {
                            continue;
                        }
                    }
                    catch (ArgumentException)
                    {
                        continue;
                    }
                }
                // not supported state, ignore
                TaskInfo info = new TaskInfo(task);
                string   tid  = info.GetId();
                string   pct  = StringHelper.Percent(info.GetProgress() / 100);
                tasksTableData.Append("[\"<a href='").Append(Url("task", tid)).Append("'>").Append
                    (tid).Append("</a>\",\"").Append("<br title='").Append(pct).Append("'> <div class='"
                                                                                       ).Append(JQueryUI.CProgressbar).Append("' title='").Append(StringHelper.Join(pct
                                                                                                                                                                    , '%')).Append("'> ").Append("<div class='").Append(JQueryUI.CProgressbarValue).
                Append("' style='").Append(StringHelper.Join("width:", pct, '%')).Append("'> </div> </div>\",\""
                                                                                         ).Append(StringEscapeUtils.EscapeJavaScript(StringEscapeUtils.EscapeHtml(info.GetStatus
                                                                                                                                                                      ()))).Append("\",\"").Append(info.GetState()).Append("\",\"").Append(info.GetStartTime
                                                                                                                                                                                                                                               ()).Append("\",\"").Append(info.GetFinishTime()).Append("\",\"").Append(info.GetElapsedTime
                                                                                                                                                                                                                                                                                                                           ()).Append("\"],\n");
            }
            //Progress bar
            //Remove the last comma and close off the array of arrays
            if (tasksTableData[tasksTableData.Length - 2] == ',')
            {
                tasksTableData.Delete(tasksTableData.Length - 2, tasksTableData.Length - 1);
            }
            tasksTableData.Append("]");
            html.Script().$type("text/javascript").("var tasksTableData=" + tasksTableData).(
                );
            tbody.().();
        }
コード例 #22
0
ファイル: HsTaskPage.cs プロジェクト: orf53975/hadoop.net
            protected override void Render(HtmlBlock.Block html)
            {
                if (!IsValidRequest())
                {
                    html.H2($(Title));
                    return;
                }
                TaskType type   = null;
                string   symbol = $(AMParams.TaskType);

                if (!symbol.IsEmpty())
                {
                    type = MRApps.TaskType(symbol);
                }
                else
                {
                    type = app.GetTask().GetType();
                }
                Hamlet.TR <Hamlet.THEAD <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> >
                           > headRow = html.Table("#attempts").Thead().Tr();
                headRow.Th(".id", "Attempt").Th(".state", "State").Th(".status", "Status").Th(".node"
                                                                                              , "Node").Th(".logs", "Logs").Th(".tsh", "Start Time");
                if (type == TaskType.Reduce)
                {
                    headRow.Th("Shuffle Finish Time");
                    headRow.Th("Merge Finish Time");
                }
                headRow.Th("Finish Time");
                //Attempt
                if (type == TaskType.Reduce)
                {
                    headRow.Th("Elapsed Time Shuffle");
                    //Attempt
                    headRow.Th("Elapsed Time Merge");
                    //Attempt
                    headRow.Th("Elapsed Time Reduce");
                }
                //Attempt
                headRow.Th("Elapsed Time").Th(".note", "Note");
                Hamlet.TBODY <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> > tbody = headRow
                                                                                                   .().().Tbody();
                // Write all the data into a JavaScript array of arrays for JQuery
                // DataTables to display
                StringBuilder attemptsTableData = new StringBuilder("[\n");

                foreach (TaskAttempt attempt in GetTaskAttempts())
                {
                    TaskAttemptInfo ta                 = new TaskAttemptInfo(attempt, false);
                    string          taid               = ta.GetId();
                    string          nodeHttpAddr       = ta.GetNode();
                    string          containerIdString  = ta.GetAssignedContainerIdStr();
                    string          nodeIdString       = attempt.GetAssignedContainerMgrAddress();
                    string          nodeRackName       = ta.GetRack();
                    long            attemptStartTime   = ta.GetStartTime();
                    long            shuffleFinishTime  = -1;
                    long            sortFinishTime     = -1;
                    long            attemptFinishTime  = ta.GetFinishTime();
                    long            elapsedShuffleTime = -1;
                    long            elapsedSortTime    = -1;
                    long            elapsedReduceTime  = -1;
                    if (type == TaskType.Reduce)
                    {
                        shuffleFinishTime  = attempt.GetShuffleFinishTime();
                        sortFinishTime     = attempt.GetSortFinishTime();
                        elapsedShuffleTime = Times.Elapsed(attemptStartTime, shuffleFinishTime, false);
                        elapsedSortTime    = Times.Elapsed(shuffleFinishTime, sortFinishTime, false);
                        elapsedReduceTime  = Times.Elapsed(sortFinishTime, attemptFinishTime, false);
                    }
                    long attemptElapsed = Times.Elapsed(attemptStartTime, attemptFinishTime, false);
                    int  sortId         = attempt.GetID().GetId() + (attempt.GetID().GetTaskId().GetId() * 10000
                                                                     );
                    attemptsTableData.Append("[\"").Append(sortId + " ").Append(taid).Append("\",\"")
                    .Append(ta.GetState()).Append("\",\"").Append(StringEscapeUtils.EscapeJavaScript
                                                                      (StringEscapeUtils.EscapeHtml(ta.GetStatus()))).Append("\",\"").Append("<a class='nodelink' href='"
                                                                                                                                             + MRWebAppUtil.GetYARNWebappScheme() + nodeHttpAddr + "'>").Append(nodeRackName
                                                                                                                                                                                                                + "/" + nodeHttpAddr + "</a>\",\"").Append("<a class='logslink' href='").Append
                        (Url("logs", nodeIdString, containerIdString, taid, app.GetJob().GetUserName()))
                    .Append("'>logs</a>\",\"").Append(attemptStartTime).Append("\",\"");
                    if (type == TaskType.Reduce)
                    {
                        attemptsTableData.Append(shuffleFinishTime).Append("\",\"").Append(sortFinishTime
                                                                                           ).Append("\",\"");
                    }
                    attemptsTableData.Append(attemptFinishTime).Append("\",\"");
                    if (type == TaskType.Reduce)
                    {
                        attemptsTableData.Append(elapsedShuffleTime).Append("\",\"").Append(elapsedSortTime
                                                                                            ).Append("\",\"").Append(elapsedReduceTime).Append("\",\"");
                    }
                    attemptsTableData.Append(attemptElapsed).Append("\",\"").Append(StringEscapeUtils
                                                                                    .EscapeJavaScript(StringEscapeUtils.EscapeHtml(ta.GetNote()))).Append("\"],\n");
                }
                //Remove the last comma and close off the array of arrays
                if (attemptsTableData[attemptsTableData.Length - 2] == ',')
                {
                    attemptsTableData.Delete(attemptsTableData.Length - 2, attemptsTableData.Length -
                                             1);
                }
                attemptsTableData.Append("]");
                html.Script().$type("text/javascript").("var attemptsTableData=" + attemptsTableData
                                                        ).();
                Hamlet.TR <Hamlet.TFOOT <Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> >
                           > footRow = tbody.().Tfoot().Tr();
                footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("attempt_name"
                                                                                         ).$value("Attempt").().().Th().Input("search_init").$type(HamletSpec.InputType.text
                                                                                                                                                   ).$name("attempt_state").$value("State").().().Th().Input("search_init").$type(HamletSpec.InputType
                                                                                                                                                                                                                                  .text).$name("attempt_status").$value("Status").().().Th().Input("search_init").
                $type(HamletSpec.InputType.text).$name("attempt_node").$value("Node").().().Th()
                .Input("search_init").$type(HamletSpec.InputType.text).$name("attempt_node").$value
                    ("Logs").().().Th().Input("search_init").$type(HamletSpec.InputType.text).$name(
                    "attempt_start_time").$value("Start Time").().();
                if (type == TaskType.Reduce)
                {
                    footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("shuffle_time"
                                                                                             ).$value("Shuffle Time").().();
                    footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("merge_time"
                                                                                             ).$value("Merge Time").().();
                }
                footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("attempt_finish"
                                                                                         ).$value("Finish Time").().();
                if (type == TaskType.Reduce)
                {
                    footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("elapsed_shuffle_time"
                                                                                             ).$value("Elapsed Shuffle Time").().();
                    footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("elapsed_merge_time"
                                                                                             ).$value("Elapsed Merge Time").().();
                    footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("elapsed_reduce_time"
                                                                                             ).$value("Elapsed Reduce Time").().();
                }
                footRow.Th().Input("search_init").$type(HamletSpec.InputType.text).$name("attempt_elapsed"
                                                                                         ).$value("Elapsed Time").().().Th().Input("search_init").$type(HamletSpec.InputType
                                                                                                                                                        .text).$name("note").$value("Note").().();
                footRow.().().();
            }
コード例 #23
0
        /// <summary>Apply configuratio changes after admin has approved them.</summary>
        /// <exception cref="Org.Apache.Hadoop.Conf.ReconfigurationException"/>
        private void ApplyChanges(PrintWriter @out, Reconfigurable reconf, HttpServletRequest
                                  req)
        {
            Configuration        oldConf = reconf.GetConf();
            Configuration        newConf = new Configuration();
            Enumeration <string> @params = GetParams(req);

            lock (oldConf)
            {
                while (@params.MoveNext())
                {
                    string rawParam = @params.Current;
                    string param    = StringEscapeUtils.UnescapeHtml(rawParam);
                    string value    = StringEscapeUtils.UnescapeHtml(req.GetParameter(rawParam));
                    if (value != null)
                    {
                        if (value.Equals(newConf.GetRaw(param)) || value.Equals("default") || value.Equals
                                ("null") || value.IsEmpty())
                        {
                            if ((value.Equals("default") || value.Equals("null") || value.IsEmpty()) && oldConf
                                .GetRaw(param) != null)
                            {
                                @out.WriteLine("<p>Changed \"" + StringEscapeUtils.EscapeHtml(param) + "\" from \""
                                               + StringEscapeUtils.EscapeHtml(oldConf.GetRaw(param)) + "\" to default</p>");
                                reconf.ReconfigureProperty(param, null);
                            }
                            else
                            {
                                if (!value.Equals("default") && !value.Equals("null") && !value.IsEmpty() && (oldConf
                                                                                                              .GetRaw(param) == null || !oldConf.GetRaw(param).Equals(value)))
                                {
                                    // change from default or value to different value
                                    if (oldConf.GetRaw(param) == null)
                                    {
                                        @out.WriteLine("<p>Changed \"" + StringEscapeUtils.EscapeHtml(param) + "\" from default to \""
                                                       + StringEscapeUtils.EscapeHtml(value) + "\"</p>");
                                    }
                                    else
                                    {
                                        @out.WriteLine("<p>Changed \"" + StringEscapeUtils.EscapeHtml(param) + "\" from \""
                                                       + StringEscapeUtils.EscapeHtml(oldConf.GetRaw(param)) + "\" to \"" + StringEscapeUtils
                                                       .EscapeHtml(value) + "\"</p>");
                                    }
                                    reconf.ReconfigureProperty(param, value);
                                }
                                else
                                {
                                    Log.Info("property " + param + " unchanged");
                                }
                            }
                        }
                        else
                        {
                            // parameter value != newConf value
                            @out.WriteLine("<p>\"" + StringEscapeUtils.EscapeHtml(param) + "\" not changed because value has changed from \""
                                           + StringEscapeUtils.EscapeHtml(value) + "\" to \"" + StringEscapeUtils.EscapeHtml
                                               (newConf.GetRaw(param)) + "\" since approval</p>");
                        }
                    }
                }
            }
        }