// Copyright (c) 2008 Michael Miceli and Christopher Miceli // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include "../utils/defines.hpp" #include "ConfigFileParser.hpp" #include "../xmlParser/xmlParser.h" using namespace MapReduce::Master; ConfigFileParser::ConfigFileParser() { } ConfigFileParser::ConfigFileParser(std::string cfgFilePath, MapReduce::LogWriter &log) : cfgFilePath_(cfgFilePath), log_(&log) { parse_(); } SessionDescription ConfigFileParser::getSessionDescription() { return sessionDesc_; } std::vector ConfigFileParser::getExecutableList() { return binDescList_; } std::vector ConfigFileParser::getFileList() { return fileDescList_; } std::vector ConfigFileParser::getTargetHostList() { return targetHostList_; } std::string ConfigFileParser::getOutputPrefix() { return outputPrefix_; } std::string ConfigFileParser::getMasterAddress() { return masterAddress_; } void ConfigFileParser::parse_(void) { std::string tmp(""); XMLNode xMainNode=XMLNode::openFileHelper(cfgFilePath_.c_str(),"MRDL"); xMainNode = xMainNode.getChildNode("MapReduceSession"); // parse the TaskFarmingSession node if( NULL != xMainNode.getAttribute("name") ) sessionDesc_.name = xMainNode.getAttribute("name"); if( NULL != xMainNode.getAttribute("version") ) sessionDesc_.version = xMainNode.getAttribute("version"); if( NULL != xMainNode.getAttribute("user") ) sessionDesc_.user = xMainNode.getAttribute("user"); if( NULL != xMainNode.getAttribute("priority") ) sessionDesc_.priority = xMainNode.getAttribute("priority"); if( NULL != xMainNode.getAttribute("experimentID") ) sessionDesc_.experimentID = xMainNode.getAttribute("experimentID"); if( NULL != xMainNode.getAttribute("eventLevel") ) sessionDesc_.eventLevel = xMainNode.getAttribute("eventLevel"); // parse the OrchestratorDB section XMLNode xNode = xMainNode.getChildNode("OrchestratorDB").getChildNode("Host"); if( NULL != xNode.getText()) sessionDesc_.orchestrator = xNode.getText(); else { std::string message("XML Parser: Orchestrator section not found"); std::cerr << "[Error] " << message << std::endl; throw xmlParser::exception(message); } // parse the TargetHosts section xNode = xMainNode.getChildNode("TargetHosts"); int n=xNode.nChildNode("Host"); for(int i=0; iwrite(message, LOGLEVEL_ERROR); } xNode = xMainNode.getChildNode("ApplicationBinaries"); int m=xNode.nChildNode("BinaryImage"); for(int i=0; i