Beispiel #1
0
        public virtual void TestContainerReport()
        {
            ApplicationId             appId        = ApplicationId.NewInstance(0, 1);
            ApplicationAttemptId      appAttemptId = ApplicationAttemptId.NewInstance(appId, 1);
            ContainerId               containerId  = ContainerId.NewContainerId(appAttemptId, 1);
            GetContainerReportRequest request      = GetContainerReportRequest.NewInstance(containerId
                                                                                           );
            GetContainerReportResponse response  = clientService.GetContainerReport(request);
            ContainerReport            container = response.GetContainerReport();

            NUnit.Framework.Assert.IsNotNull(container);
            NUnit.Framework.Assert.AreEqual(containerId, container.GetContainerId());
            NUnit.Framework.Assert.AreEqual("http://0.0.0.0:8188/applicationhistory/logs/" +
                                            "test host:100/container_0_0001_01_000001/" + "container_0_0001_01_000001/user1"
                                            , container.GetLogUrl());
        }
Beispiel #2
0
 public ContainerInfo(ContainerReport container)
 {
     // JAXB needs this
     containerId = container.GetContainerId().ToString();
     if (container.GetAllocatedResource() != null)
     {
         allocatedMB     = container.GetAllocatedResource().GetMemory();
         allocatedVCores = container.GetAllocatedResource().GetVirtualCores();
     }
     if (container.GetAssignedNode() != null)
     {
         assignedNodeId = container.GetAssignedNode().ToString();
     }
     priority            = container.GetPriority().GetPriority();
     startedTime         = container.GetCreationTime();
     finishedTime        = container.GetFinishTime();
     elapsedTime         = Times.Elapsed(startedTime, finishedTime);
     diagnosticsInfo     = container.GetDiagnosticsInfo();
     logUrl              = container.GetLogUrl();
     containerExitStatus = container.GetContainerExitStatus();
     containerState      = container.GetContainerState();
     nodeHttpAddress     = container.GetNodeHttpAddress();
 }
Beispiel #3
0
        /// <summary>Prints the container report for an container id.</summary>
        /// <param name="containerId"/>
        /// <returns>exitCode</returns>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        private int PrintContainerReport(string containerId)
        {
            ContainerReport containerReport = null;

            try
            {
                containerReport = client.GetContainerReport((ConverterUtils.ToContainerId(containerId
                                                                                          )));
            }
            catch (ApplicationNotFoundException)
            {
                sysout.WriteLine("Application for Container with id '" + containerId + "' doesn't exist in RM or Timeline Server."
                                 );
                return(-1);
            }
            catch (ApplicationAttemptNotFoundException)
            {
                sysout.WriteLine("Application Attempt for Container with id '" + containerId + "' doesn't exist in RM or Timeline Server."
                                 );
                return(-1);
            }
            catch (ContainerNotFoundException)
            {
                sysout.WriteLine("Container with id '" + containerId + "' doesn't exist in RM or Timeline Server."
                                 );
                return(-1);
            }
            // Use PrintWriter.println, which uses correct platform line ending.
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintWriter           containerReportStr = new PrintWriter(new OutputStreamWriter(baos, Sharpen.Extensions.GetEncoding
                                                                                                  ("UTF-8")));

            if (containerReport != null)
            {
                containerReportStr.WriteLine("Container Report : ");
                containerReportStr.Write("\tContainer-Id : ");
                containerReportStr.WriteLine(containerReport.GetContainerId());
                containerReportStr.Write("\tStart-Time : ");
                containerReportStr.WriteLine(containerReport.GetCreationTime());
                containerReportStr.Write("\tFinish-Time : ");
                containerReportStr.WriteLine(containerReport.GetFinishTime());
                containerReportStr.Write("\tState : ");
                containerReportStr.WriteLine(containerReport.GetContainerState());
                containerReportStr.Write("\tLOG-URL : ");
                containerReportStr.WriteLine(containerReport.GetLogUrl());
                containerReportStr.Write("\tHost : ");
                containerReportStr.WriteLine(containerReport.GetAssignedNode());
                containerReportStr.Write("\tNodeHttpAddress : ");
                containerReportStr.WriteLine(containerReport.GetNodeHttpAddress() == null ? "N/A"
                                         : containerReport.GetNodeHttpAddress());
                containerReportStr.Write("\tDiagnostics : ");
                containerReportStr.Write(containerReport.GetDiagnosticsInfo());
            }
            else
            {
                containerReportStr.Write("Container with id '" + containerId + "' doesn't exist in Timeline Server."
                                         );
                containerReportStr.Close();
                sysout.WriteLine(baos.ToString("UTF-8"));
                return(-1);
            }
            containerReportStr.Close();
            sysout.WriteLine(baos.ToString("UTF-8"));
            return(0);
        }