/// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        public virtual void VerifyNodeContainerInfoGeneric(Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container
                                                           cont, string id, string state, string user, int exitCode, string diagnostics, string
                                                           nodeId, int totalMemoryNeededMB, int totalVCoresNeeded, string logsLink)
        {
            WebServicesTestUtils.CheckStringMatch("id", cont.GetContainerId().ToString(), id);
            WebServicesTestUtils.CheckStringMatch("state", cont.GetContainerState().ToString(
                                                      ), state);
            WebServicesTestUtils.CheckStringMatch("user", cont.GetUser().ToString(), user);
            NUnit.Framework.Assert.AreEqual("exitCode wrong", 0, exitCode);
            WebServicesTestUtils.CheckStringMatch("diagnostics", "testing", diagnostics);
            WebServicesTestUtils.CheckStringMatch("nodeId", nmContext.GetNodeId().ToString(),
                                                  nodeId);
            NUnit.Framework.Assert.AreEqual("totalMemoryNeededMB wrong", YarnConfiguration.DefaultRmSchedulerMinimumAllocationMb
                                            , totalMemoryNeededMB);
            NUnit.Framework.Assert.AreEqual("totalVCoresNeeded wrong", YarnConfiguration.DefaultRmSchedulerMinimumAllocationVcores
                                            , totalVCoresNeeded);
            string shortLink = StringHelper.Ujoin("containerlogs", cont.GetContainerId().ToString
                                                      (), cont.GetUser());

            NUnit.Framework.Assert.IsTrue("containerLogsLink wrong", logsLink.Contains(shortLink
                                                                                       ));
        }
Exemplo n.º 2
0
        public ContainerInfo(Context nmContext, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container
                             container, string requestUri, string pathPrefix)
        {
            // JAXB needs this
            this.id     = container.GetContainerId().ToString();
            this.nodeId = nmContext.GetNodeId().ToString();
            ContainerStatus containerData = container.CloneAndGetContainerStatus();

            this.exitCode   = containerData.GetExitStatus();
            this.exitStatus = (this.exitCode == ContainerExitStatus.Invalid) ? "N/A" : exitCode
                              .ToString();
            this.state       = container.GetContainerState().ToString();
            this.diagnostics = containerData.GetDiagnostics();
            if (this.diagnostics == null || this.diagnostics.IsEmpty())
            {
                this.diagnostics = string.Empty;
            }
            this.user = container.GetUser();
            Resource res = container.GetResource();

            if (res != null)
            {
                this.totalMemoryNeededMB = res.GetMemory();
                this.totalVCoresNeeded   = res.GetVirtualCores();
            }
            this.containerLogsShortLink = StringHelper.Ujoin("containerlogs", this.id, container
                                                             .GetUser());
            if (requestUri == null)
            {
                requestUri = string.Empty;
            }
            if (pathPrefix == null)
            {
                pathPrefix = string.Empty;
            }
            this.containerLogsLink = StringHelper.Join(requestUri, pathPrefix, this.containerLogsShortLink
                                                       );
        }