/// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/> /// <exception cref="System.Exception"/> public virtual void VerifyClusterMetricsXML(string xml) { DocumentBuilderFactory dbf = DocumentBuilderFactory.NewInstance(); DocumentBuilder db = dbf.NewDocumentBuilder(); InputSource @is = new InputSource(); @is.SetCharacterStream(new StringReader(xml)); Document dom = db.Parse(@is); NodeList nodes = dom.GetElementsByTagName("clusterMetrics"); NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.GetLength ()); for (int i = 0; i < nodes.GetLength(); i++) { Element element = (Element)nodes.Item(i); VerifyClusterMetrics(WebServicesTestUtils.GetXmlInt(element, "appsSubmitted"), WebServicesTestUtils .GetXmlInt(element, "appsCompleted"), WebServicesTestUtils.GetXmlInt(element, "reservedMB" ), WebServicesTestUtils.GetXmlInt(element, "availableMB"), WebServicesTestUtils. GetXmlInt(element, "allocatedMB"), WebServicesTestUtils.GetXmlInt(element, "reservedVirtualCores" ), WebServicesTestUtils.GetXmlInt(element, "availableVirtualCores"), WebServicesTestUtils .GetXmlInt(element, "allocatedVirtualCores"), WebServicesTestUtils.GetXmlInt(element , "totalVirtualCores"), WebServicesTestUtils.GetXmlInt(element, "containersAllocated" ), WebServicesTestUtils.GetXmlInt(element, "totalMB"), WebServicesTestUtils.GetXmlInt (element, "totalNodes"), WebServicesTestUtils.GetXmlInt(element, "lostNodes"), WebServicesTestUtils .GetXmlInt(element, "unhealthyNodes"), WebServicesTestUtils.GetXmlInt(element, "decommissionedNodes" ), WebServicesTestUtils.GetXmlInt(element, "rebootedNodes"), WebServicesTestUtils .GetXmlInt(element, "activeNodes")); } }
/// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/> /// <exception cref="System.Exception"/> public virtual void VerifyContainersInfoXML(NodeList nodes, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container cont) { for (int i = 0; i < nodes.GetLength(); i++) { Element element = (Element)nodes.Item(i); VerifyNodeContainerInfoGeneric(cont, WebServicesTestUtils.GetXmlString(element, "id" ), WebServicesTestUtils.GetXmlString(element, "state"), WebServicesTestUtils.GetXmlString (element, "user"), WebServicesTestUtils.GetXmlInt(element, "exitCode"), WebServicesTestUtils .GetXmlString(element, "diagnostics"), WebServicesTestUtils.GetXmlString(element , "nodeId"), WebServicesTestUtils.GetXmlInt(element, "totalMemoryNeededMB"), WebServicesTestUtils .GetXmlInt(element, "totalVCoresNeeded"), WebServicesTestUtils.GetXmlString(element , "containerLogsLink")); } }
/// <exception cref="System.Exception"/> public virtual void VerifySubQueueXML(Element qElem, string q, float parentAbsCapacity , float parentAbsMaxCapacity) { NodeList children = qElem.GetChildNodes(); bool hasSubQueues = false; for (int j = 0; j < children.GetLength(); j++) { Element qElem2 = (Element)children.Item(j); if (qElem2.GetTagName().Equals("queues")) { NodeList qListInfos = qElem2.GetChildNodes(); if (qListInfos.GetLength() > 0) { hasSubQueues = true; } } } TestRMWebServicesCapacitySched.QueueInfo qi = (hasSubQueues) ? new TestRMWebServicesCapacitySched.QueueInfo (this) : new TestRMWebServicesCapacitySched.LeafQueueInfo(this); qi.capacity = WebServicesTestUtils.GetXmlFloat(qElem, "capacity"); qi.usedCapacity = WebServicesTestUtils.GetXmlFloat(qElem, "usedCapacity"); qi.maxCapacity = WebServicesTestUtils.GetXmlFloat(qElem, "maxCapacity"); qi.absoluteCapacity = WebServicesTestUtils.GetXmlFloat(qElem, "absoluteCapacity"); qi.absoluteMaxCapacity = WebServicesTestUtils.GetXmlFloat(qElem, "absoluteMaxCapacity" ); qi.absoluteUsedCapacity = WebServicesTestUtils.GetXmlFloat(qElem, "absoluteUsedCapacity" ); qi.numApplications = WebServicesTestUtils.GetXmlInt(qElem, "numApplications"); qi.queueName = WebServicesTestUtils.GetXmlString(qElem, "queueName"); qi.state = WebServicesTestUtils.GetXmlString(qElem, "state"); VerifySubQueueGeneric(q, qi, parentAbsCapacity, parentAbsMaxCapacity); if (hasSubQueues) { for (int j_1 = 0; j_1 < children.GetLength(); j_1++) { Element qElem2 = (Element)children.Item(j_1); if (qElem2.GetTagName().Equals("queues")) { NodeList qListInfos = qElem2.GetChildNodes(); for (int k = 0; k < qListInfos.GetLength(); k++) { Element qElem3 = (Element)qListInfos.Item(k); string qName3 = WebServicesTestUtils.GetXmlString(qElem3, "queueName"); string q3 = q + "." + qName3; VerifySubQueueXML(qElem3, q3, qi.absoluteCapacity, qi.absoluteMaxCapacity); } } } } else { TestRMWebServicesCapacitySched.LeafQueueInfo lqi = (TestRMWebServicesCapacitySched.LeafQueueInfo )qi; lqi.numActiveApplications = WebServicesTestUtils.GetXmlInt(qElem, "numActiveApplications" ); lqi.numPendingApplications = WebServicesTestUtils.GetXmlInt(qElem, "numPendingApplications" ); lqi.numContainers = WebServicesTestUtils.GetXmlInt(qElem, "numContainers"); lqi.maxApplications = WebServicesTestUtils.GetXmlInt(qElem, "maxApplications"); lqi.maxApplicationsPerUser = WebServicesTestUtils.GetXmlInt(qElem, "maxApplicationsPerUser" ); lqi.userLimit = WebServicesTestUtils.GetXmlInt(qElem, "userLimit"); lqi.userLimitFactor = WebServicesTestUtils.GetXmlFloat(qElem, "userLimitFactor"); VerifyLeafQueueGeneric(q, lqi); } }
/// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/> /// <exception cref="System.Exception"/> public virtual void VerifyNodesXML(NodeList nodes, MockNM nm) { for (int i = 0; i < nodes.GetLength(); i++) { Element element = (Element)nodes.Item(i); VerifyNodeInfoGeneric(nm, WebServicesTestUtils.GetXmlString(element, "state"), WebServicesTestUtils .GetXmlString(element, "rack"), WebServicesTestUtils.GetXmlString(element, "id") , WebServicesTestUtils.GetXmlString(element, "nodeHostName"), WebServicesTestUtils .GetXmlString(element, "nodeHTTPAddress"), WebServicesTestUtils.GetXmlLong(element , "lastHealthUpdate"), WebServicesTestUtils.GetXmlString(element, "healthReport" ), WebServicesTestUtils.GetXmlInt(element, "numContainers"), WebServicesTestUtils .GetXmlLong(element, "usedMemoryMB"), WebServicesTestUtils.GetXmlLong(element, "availMemoryMB" ), WebServicesTestUtils.GetXmlLong(element, "usedVirtualCores"), WebServicesTestUtils .GetXmlLong(element, "availableVirtualCores"), WebServicesTestUtils.GetXmlString (element, "version")); } }
/// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/> /// <exception cref="System.Exception"/> public virtual void VerifySchedulerFifoXML(string xml) { DocumentBuilderFactory dbf = DocumentBuilderFactory.NewInstance(); DocumentBuilder db = dbf.NewDocumentBuilder(); InputSource @is = new InputSource(); @is.SetCharacterStream(new StringReader(xml)); Document dom = db.Parse(@is); NodeList nodesSched = dom.GetElementsByTagName("scheduler"); NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodesSched.GetLength ()); NodeList nodes = dom.GetElementsByTagName("schedulerInfo"); NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.GetLength ()); for (int i = 0; i < nodes.GetLength(); i++) { Element element = (Element)nodes.Item(i); VerifyClusterSchedulerFifoGeneric(WebServicesTestUtils.GetXmlAttrString(element, "xsi:type"), WebServicesTestUtils.GetXmlString(element, "qstate"), WebServicesTestUtils .GetXmlFloat(element, "capacity"), WebServicesTestUtils.GetXmlFloat(element, "usedCapacity" ), WebServicesTestUtils.GetXmlInt(element, "minQueueMemoryCapacity"), WebServicesTestUtils .GetXmlInt(element, "maxQueueMemoryCapacity"), WebServicesTestUtils.GetXmlInt(element , "numNodes"), WebServicesTestUtils.GetXmlInt(element, "usedNodeCapacity"), WebServicesTestUtils .GetXmlInt(element, "availNodeCapacity"), WebServicesTestUtils.GetXmlInt(element , "totalNodeCapacity"), WebServicesTestUtils.GetXmlInt(element, "numContainers") ); } }