Beispiel #1
0
            /// <summary>create a summary of the application's runtime.</summary>
            /// <param name="app">
            ///
            /// <see cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Rmapp.RMApp"/>
            /// whose summary is to be created, cannot
            /// be <code>null</code>.
            /// </param>
            public static RMAppManager.ApplicationSummary.SummaryBuilder CreateAppSummary(RMApp
                                                                                          app)
            {
                string       trackingUrl = "N/A";
                string       host        = "N/A";
                RMAppAttempt attempt     = app.GetCurrentAppAttempt();

                if (attempt != null)
                {
                    trackingUrl = attempt.GetTrackingUrl();
                    host        = attempt.GetHost();
                }
                RMAppMetrics metrics = app.GetRMAppMetrics();

                RMAppManager.ApplicationSummary.SummaryBuilder summary = new RMAppManager.ApplicationSummary.SummaryBuilder
                                                                             ().Add("appId", app.GetApplicationId()).Add("name", app.GetName()).Add("user", app
                                                                                                                                                    .GetUser()).Add("queue", app.GetQueue()).Add("state", app.GetState()).Add("trackingUrl"
                                                                                                                                                                                                                              , trackingUrl).Add("appMasterHost", host).Add("startTime", app.GetStartTime()).Add
                                                                             ("finishTime", app.GetFinishTime()).Add("finalStatus", app.GetFinalApplicationStatus
                                                                                                                         ()).Add("memorySeconds", metrics.GetMemorySeconds()).Add("vcoreSeconds", metrics
                                                                                                                                                                                  .GetVcoreSeconds()).Add("preemptedAMContainers", metrics.GetNumAMContainersPreempted
                                                                                                                                                                                                              ()).Add("preemptedNonAMContainers", metrics.GetNumNonAMContainersPreempted()).Add
                                                                             ("preemptedResources", metrics.GetResourcePreempted()).Add("applicationType", app
                                                                                                                                        .GetApplicationType());
                return(summary);
            }
Beispiel #2
0
        public virtual void TestEscapeApplicationSummary()
        {
            RMApp app = Org.Mockito.Mockito.Mock <RMAppImpl>();

            Org.Mockito.Mockito.When(app.GetApplicationId()).ThenReturn(ApplicationId.NewInstance
                                                                            (100L, 1));
            Org.Mockito.Mockito.When(app.GetName()).ThenReturn("Multiline\n\n\r\rAppName");
            Org.Mockito.Mockito.When(app.GetUser()).ThenReturn("Multiline\n\n\r\rUserName");
            Org.Mockito.Mockito.When(app.GetQueue()).ThenReturn("Multiline\n\n\r\rQueueName");
            Org.Mockito.Mockito.When(app.GetState()).ThenReturn(RMAppState.Running);
            Org.Mockito.Mockito.When(app.GetApplicationType()).ThenReturn("MAPREDUCE");
            RMAppMetrics metrics = new RMAppMetrics(Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                    .NewInstance(1234, 56), 10, 1, 16384, 64);

            Org.Mockito.Mockito.When(app.GetRMAppMetrics()).ThenReturn(metrics);
            RMAppManager.ApplicationSummary.SummaryBuilder summary = RMAppManager.ApplicationSummary
                                                                     .CreateAppSummary(app);
            string msg = summary.ToString();

            Log.Info("summary: " + msg);
            NUnit.Framework.Assert.IsFalse(msg.Contains("\n"));
            NUnit.Framework.Assert.IsFalse(msg.Contains("\r"));
            string escaped = "\\n\\n\\r\\r";

            NUnit.Framework.Assert.IsTrue(msg.Contains("Multiline" + escaped + "AppName"));
            NUnit.Framework.Assert.IsTrue(msg.Contains("Multiline" + escaped + "UserName"));
            NUnit.Framework.Assert.IsTrue(msg.Contains("Multiline" + escaped + "QueueName"));
            NUnit.Framework.Assert.IsTrue(msg.Contains("memorySeconds=16384"));
            NUnit.Framework.Assert.IsTrue(msg.Contains("vcoreSeconds=64"));
            NUnit.Framework.Assert.IsTrue(msg.Contains("preemptedAMContainers=1"));
            NUnit.Framework.Assert.IsTrue(msg.Contains("preemptedNonAMContainers=10"));
            NUnit.Framework.Assert.IsTrue(msg.Contains("preemptedResources=<memory:1234\\, vCores:56>"
                                                       ));
            NUnit.Framework.Assert.IsTrue(msg.Contains("applicationType=MAPREDUCE"));
        }
Beispiel #3
0
 internal virtual RMAppManager.ApplicationSummary.SummaryBuilder Add(RMAppManager.ApplicationSummary.SummaryBuilder
                                                                     summary)
 {
     if (buffer.Length > 0)
     {
         buffer.Append(StringUtils.Comma);
     }
     buffer.Append(summary.buffer);
     return(this);
 }