use of org.w3c.dom.NodeList in project hadoop by apache.
the class TestRMWebServices method verifyClusterInfoXML.
public void verifyClusterInfoXML(String xml) throws JSONException, Exception {
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("clusterInfo");
assertEquals("incorrect number of elements", 1, nodes.getLength());
for (int i = 0; i < nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);
verifyClusterGeneric(WebServicesTestUtils.getXmlLong(element, "id"), WebServicesTestUtils.getXmlLong(element, "startedOn"), WebServicesTestUtils.getXmlString(element, "state"), WebServicesTestUtils.getXmlString(element, "haState"), WebServicesTestUtils.getXmlString(element, "haZooKeeperConnectionState"), WebServicesTestUtils.getXmlString(element, "hadoopVersionBuiltOn"), WebServicesTestUtils.getXmlString(element, "hadoopBuildVersion"), WebServicesTestUtils.getXmlString(element, "hadoopVersion"), WebServicesTestUtils.getXmlString(element, "resourceManagerVersionBuiltOn"), WebServicesTestUtils.getXmlString(element, "resourceManagerBuildVersion"), WebServicesTestUtils.getXmlString(element, "resourceManagerVersion"));
}
}
use of org.w3c.dom.NodeList in project hadoop by apache.
the class TestRMWebServicesAppsModification method validateGetNewApplicationXMLResponse.
protected String validateGetNewApplicationXMLResponse(String response) throws ParserConfigurationException, IOException, SAXException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(response));
Document dom = db.parse(is);
NodeList nodes = dom.getElementsByTagName("NewApplication");
assertEquals("incorrect number of elements", 1, nodes.getLength());
Element element = (Element) nodes.item(0);
String appId = WebServicesTestUtils.getXmlString(element, "application-id");
assertTrue(!appId.isEmpty());
NodeList maxResourceNodes = element.getElementsByTagName("maximum-resource-capability");
assertEquals(1, maxResourceNodes.getLength());
Element maxResourceCapability = (Element) maxResourceNodes.item(0);
long memory = WebServicesTestUtils.getXmlLong(maxResourceCapability, "memory");
long vCores = WebServicesTestUtils.getXmlLong(maxResourceCapability, "vCores");
assertTrue(memory != 0);
assertTrue(vCores != 0);
return appId;
}
use of org.w3c.dom.NodeList in project hadoop by apache.
the class TestRMWebServicesAppsModification method verifyAppQueueXML.
protected static void verifyAppQueueXML(ClientResponse response, String queue) throws ParserConfigurationException, IOException, SAXException {
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
String xml = response.getEntity(String.class);
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("appqueue");
assertEquals("incorrect number of elements", 1, nodes.getLength());
Element element = (Element) nodes.item(0);
String responseQueue = WebServicesTestUtils.getXmlString(element, "queue");
assertEquals(queue, responseQueue);
}
use of org.w3c.dom.NodeList in project hadoop by apache.
the class TestRMWebServicesForCSWithPartitions method verifyQueueBInfoXML.
private void verifyQueueBInfoXML(Element queueElem) {
assertEquals("Invalid default Label expression", LABEL_LX, WebServicesTestUtils.getXmlString(queueElem, "defaultNodeLabelExpression"));
NodeList children = queueElem.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
Element queueChildElem = (Element) children.item(j);
if (queueChildElem.getTagName().equals(CAPACITIES)) {
NodeList capacitiesListInfos = queueChildElem.getChildNodes();
assertEquals("incorrect number of partitions", 2, capacitiesListInfos.getLength());
for (int k = 0; k < capacitiesListInfos.getLength(); k++) {
Element partitionCapacitiesInfo = (Element) capacitiesListInfos.item(k);
String partitionName = WebServicesTestUtils.getXmlString(partitionCapacitiesInfo, "partitionName");
switch(partitionName) {
case LABEL_LX:
verifyPartitionCapacityInfoXML(partitionCapacitiesInfo, 30, 0, 100, 30, 0, 100);
break;
case DEFAULT_PARTITION:
verifyPartitionCapacityInfoXML(partitionCapacitiesInfo, 30, 0, 50, 30, 0, 50);
break;
default:
Assert.fail("Unexpected partition" + partitionName);
}
}
} else if (queueChildElem.getTagName().equals("resources")) {
verifyResourceUsageInfoXML(queueChildElem);
}
}
assertEquals("Node Labels are not matching", LABEL_LX, WebServicesTestUtils.getXmlString(queueElem, "nodeLabels"));
}
use of org.w3c.dom.NodeList in project hadoop by apache.
the class TestRMWebServicesForCSWithPartitions method verifyQcCapacitiesInfoXML.
private void verifyQcCapacitiesInfoXML(Element partitionCapacitiesElem, float lxCaps, float lxMaxCaps, float lxAbsCaps, float lxAbsMaxCaps, float lyCaps, float lyMaxCaps, float lyAbsCaps, float lyAbsMaxCaps, float defCaps, float defMaxCaps, float defAbsCaps, float defAbsMaxCaps) {
NodeList capacitiesListInfos = partitionCapacitiesElem.getChildNodes();
assertEquals("incorrect number of partitions", 3, capacitiesListInfos.getLength());
for (int k = 0; k < capacitiesListInfos.getLength(); k++) {
Element partitionCapacitiesInfo = (Element) capacitiesListInfos.item(k);
String partitionName = WebServicesTestUtils.getXmlString(partitionCapacitiesInfo, "partitionName");
switch(partitionName) {
case LABEL_LX:
verifyPartitionCapacityInfoXML(partitionCapacitiesInfo, lxCaps, 0, lxMaxCaps, lxAbsCaps, 0, lxAbsMaxCaps);
break;
case LABEL_LY:
verifyPartitionCapacityInfoXML(partitionCapacitiesInfo, lyCaps, 0, lyMaxCaps, lyAbsCaps, 0, lyAbsMaxCaps);
break;
case DEFAULT_PARTITION:
verifyPartitionCapacityInfoXML(partitionCapacitiesInfo, defCaps, 0, defMaxCaps, defAbsCaps, 0, defAbsMaxCaps);
break;
default:
Assert.fail("Unexpected partition" + partitionName);
}
}
}
Aggregations