in shardingsphere-benchmark/src/main/java/org/apache/shardingsphere/benchmark/common/file/xml/BenchmarkConfigJmx.java [118:157]
public static Document getOutputElement(File testPlanFile, String outPutBasePath, int jmeterConcurrencyCount, int jmeterLoopCount){
Element root = null;
Document result = null;
DocumentBuilder documentBuilder = null;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringElementContentWhitespace(true);
try {
documentBuilder = factory.newDocumentBuilder();
result = (Document) documentBuilder.parse(testPlanFile);
root = result.getDocumentElement();
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
String resultCollectorXpath = "//jmeterTestPlan/hashTree/hashTree/hashTree/hashTree/ResultCollector";
NodeList nodeList = (NodeList) xpath.evaluate(resultCollectorXpath, root, XPathConstants.NODESET);
Element resultCollectorElement = (Element) nodeList.item(1);
String stringPropXpath = "./stringProp";
Element stringPropElement = (Element) xpath.evaluate(stringPropXpath, resultCollectorElement, XPathConstants.NODE);
String outputPath = stringPropElement.getTextContent();
outputPath = outputPath.replace("/export/shardingsphere-benchmark/result", outPutBasePath);
stringPropElement.setTextContent(outputPath);
if (testPlanFile.getName().contains("insertupdatedelete") || testPlanFile.getName().contains("select")){
String jmeterLoopXpath = "//jmeterTestPlan/hashTree/hashTree/ThreadGroup/elementProp/stringProp";
String jmeterConcurrencyXpath = "//jmeterTestPlan/hashTree/hashTree/ThreadGroup/stringProp[@name='ThreadGroup.num_threads']";
Element jmeterLoopElement = (Element) xpath.evaluate(jmeterLoopXpath, root, XPathConstants.NODE);
Element jmeterConcurrencyElement = (Element) xpath.evaluate(jmeterConcurrencyXpath, root, XPathConstants.NODE);
jmeterLoopElement.setTextContent("" + jmeterLoopCount);
jmeterConcurrencyElement.setTextContent("" + jmeterConcurrencyCount);
}
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} catch (XPathExpressionException ex) {
ex.printStackTrace();
} catch (SAXException ex) {
ex.printStackTrace();
} finally {
}
return result;
}