private void processBootDataset (Document document) { // Read and convert the bootstrap dataset XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); try { // we want all the children of the bootstrap node XPathExpression exp = xPath.compile("/powertac-bootstrap-data/bootstrap/*"); NodeList nodes = (NodeList)exp.evaluate(document, XPathConstants.NODESET); log.info("Found " + nodes.getLength() + " bootstrap nodes"); // Each node is a bootstrap data item for (int i = 0; i < nodes.getLength(); i++) { String xml = nodeToString(nodes.item(i)); add(messageConverter.fromXML(xml)); } } catch (XPathExpressionException xee) { log.error("runOnce: Error reading config file: " + xee.toString()); } }
public void readBootRecord (URL bootUrl) Document document = getDocument(bootUrl); XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); NodeList nodes = (NodeList) exp.evaluate(document, XPathConstants.NODESET); String xml = nodeToString(nodes.item(0)); bootstrapCompetition = (Competition) messageConverter.fromXML(xml); add(bootstrapCompetition); for (CustomerInfo cust: bootstrapCompetition.getCustomers()) add(cust); if (null != nodes && nodes.getLength() > 0) { xml = nodeToString(nodes.item(0)); bootState = (Properties) messageConverter.fromXML(xml); System.out.println("Error reading boot dataset: " + xee.toString()); processBootDataset(document);
/** Adds a list of objects to the repo. */ public void add (List<Object> items) { for (Object item: items) { add(item); } }
private void processBootstrapRecord () List<Object> usage = bootstrapDataRepo.getData(CustomerBootstrapData.class); if (null == usage || 0 == usage.size()) {
@Override public void run () { cc.setAuthorizedBrokerList(brokers); cc.setInputQueueName(inputQueueName); Document document = getDocument(bootUrl); if (document != null) { if (preGame(document)) { bootstrapDataRepo.add(processBootDataset(document)); cc.runOnce(false); nextGameId(); } } } };
if (!bootstrapMode) { log.info("Published configuration: {}", published.toString()); List<Object> bootstrapDataset = bootstrapDataRepo.getData(); brokerProxyService.broadcastMessages(bootstrapDataset);