8 #include <xercesc/dom/DOM.hpp>
9 #include <xercesc/parsers/XercesDOMParser.hpp>
11 #include <xercesc/util/XMLString.hpp>
14 #include <boost/algorithm/string.hpp>
16 using namespace xercesc;
34 inline unsigned int _toUInt(XMLCh
const* toTranscode) {
35 std::istringstream iss(
_toString(toTranscode));
36 unsigned int returnValue;
41 inline bool _toBool(XMLCh
const* toTranscode) {
43 if ((value ==
"true") || (value ==
"1"))
48 inline double _toDouble(XMLCh
const* toTranscode) {
49 std::istringstream iss(
_toString(toTranscode));
56 XMLCh* buff = XMLString::transcode(temp.c_str());
62 inline std::string _toParenString(DOMNode
const& nodeToConvert) {
63 std::ostringstream oss;
65 DOMNodeList *childList = nodeToConvert.getChildNodes();
67 unsigned int numNodes = childList->getLength();
68 for (
unsigned int i = 0;
i < numNodes; ++
i) {
69 DOMNode *childNode = childList->item(
i);
70 if (childNode->getNodeType() != DOMNode::ELEMENT_NODE) {
73 DOMElement *
child =
static_cast<DOMElement *
>(childNode);
75 DOMNamedNodeMap *
attributes = child->getAttributes();
76 unsigned int numAttributes = attributes->getLength();
77 for (
unsigned int j = 0;
j < numAttributes; ++
j) {
78 DOMNode *attributeNode = attributes->item(
j);
79 if (attributeNode->getNodeType() != DOMNode::ATTRIBUTE_NODE) {
82 DOMAttr *attribute =
static_cast<DOMAttr *
>(attributeNode);
84 oss <<
"(" <<
_toString(child->getTagName()) <<
95 T& iHolder,
T const*& iPointer) {
106 const std::string SiteLocalConfigService::m_statisticsDefaultPort =
"3334";
108 SiteLocalConfigService::SiteLocalConfigService(
ParameterSet const& pset) :
109 m_url(
"/SITECONF/local/JobConfig/site-local-config.xml"),
111 m_fallbackDataCatalog(),
113 m_rfioType(
"castor"),
123 m_ttreeCacheSize(0U),
128 m_enablePrefetching(
false),
129 m_enablePrefetchingPtr(
nullptr),
132 m_statisticsDestination(),
136 char*
tmp = getenv(
"CMS_PATH");
157 if(pset.
exists(
"debugLevel")) {
176 return "file:PoolFileCatalog.xml";
181 <<
"Did not find catalog in event-data section in " <<
m_url;
193 return "file:PoolFileCatalog.xml";
204 <<
"Valid site-local-config not found at " <<
m_url;
209 <<
"Did not find frontier-connect in calib-data section in " <<
m_url;
221 while ((serverurl =
m_frontierConnect.find(
"(serverurl=", nextparen)) != std::string::npos) {
226 complexstr.append(servlet);
237 if (input.substr(0,proto.length()) == proto) {
255 if (endservlet == std::string::npos) {
256 endservlet = input.rfind(
'/', input.length());
258 std::string servlet = input.substr(startservlet, endservlet - startservlet);
259 if ((servlet !=
"") && (servlet.find_first_of(
":/)[]") == std::string::npos)) {
260 if (servlet ==
"cms_conditions_data") {
315 std::vector<std::string>
const*
320 struct addrinfo
const*
333 std::auto_ptr<XercesDOMParser>
parser(
new XercesDOMParser);
335 parser->setValidationScheme(XercesDOMParser::Val_Auto);
336 parser->setDoNamespaces(
false);
338 parser->parse(url.c_str());
339 DOMDocument*
doc = parser->getDocument();
372 DOMNodeList *sites = doc->getElementsByTagName(
_toDOMS(
"site"));
373 unsigned int numSites = sites->getLength();
374 for (
unsigned int i = 0;
i < numSites; ++
i) {
375 DOMElement *site =
static_cast<DOMElement *
>(sites->item(
i));
382 DOMNodeList *eventDataList = site->getElementsByTagName(
_toDOMS(
"event-data"));
383 if (eventDataList->getLength() > 0) {
384 DOMElement *eventData =
static_cast<DOMElement *
>(eventDataList->item(0));
386 DOMNodeList *catalogs = eventData->getElementsByTagName(
_toDOMS(
"catalog"));
388 if (catalogs->getLength() > 0) {
389 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(0));
393 if (catalogs->getLength() > 1) {
394 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(1));
398 DOMNodeList* rfiotypes = eventData->getElementsByTagName(
_toDOMS(
"rfiotype"));
400 if (rfiotypes->getLength() > 0) {
401 DOMElement* rfiotype =
static_cast<DOMElement *
>(rfiotypes->item(0));
409 DOMNodeList *calibDataList = site->getElementsByTagName(
_toDOMS(
"calib-data"));
411 if (calibDataList->getLength() > 0) {
412 DOMElement *calibData =
static_cast<DOMElement *
>(calibDataList->item(0));
413 DOMNodeList *frontierConnectList = calibData->getElementsByTagName(
_toDOMS(
"frontier-connect"));
415 if (frontierConnectList->getLength() > 0) {
416 DOMElement *
frontierConnect =
static_cast<DOMElement *
>(frontierConnectList->item(0));
423 DOMNodeList *sourceConfigList = site->getElementsByTagName(
_toDOMS(
"source-config"));
425 if (sourceConfigList->getLength() > 0) {
426 DOMElement *sourceConfig =
static_cast<DOMElement *
>(sourceConfigList->item(0));
427 DOMNodeList *cacheTempDirList = sourceConfig->getElementsByTagName(
_toDOMS(
"cache-temp-dir"));
429 if (cacheTempDirList->getLength() > 0) {
430 DOMElement *cacheTempDir =
static_cast<DOMElement *
>(cacheTempDirList->item(0));
435 DOMNodeList *cacheMinFreeList = sourceConfig->getElementsByTagName(
_toDOMS(
"cache-min-free"));
437 if (cacheMinFreeList->getLength() > 0) {
438 DOMElement *cacheMinFree =
static_cast<DOMElement *
>(cacheMinFreeList->item(0));
443 DOMNodeList *cacheHintList = sourceConfig->getElementsByTagName(
_toDOMS(
"cache-hint"));
445 if (cacheHintList->getLength() > 0) {
446 DOMElement *cacheHint =
static_cast<DOMElement *
>(cacheHintList->item(0));
451 DOMNodeList *readHintList = sourceConfig->getElementsByTagName(
_toDOMS(
"read-hint"));
453 if (readHintList->getLength() > 0) {
454 DOMElement *readHint =
static_cast<DOMElement *
>(readHintList->item(0));
459 DOMNodeList *ttreeCacheSizeList = sourceConfig->getElementsByTagName(
_toDOMS(
"ttree-cache-size"));
461 if (ttreeCacheSizeList->getLength() > 0) {
462 DOMElement *ttreeCacheSize =
static_cast<DOMElement *
>(ttreeCacheSizeList->item(0));
467 DOMNodeList *timeoutList = sourceConfig->getElementsByTagName(
_toDOMS(
"timeout-in-seconds"));
469 if (timeoutList->getLength() > 0) {
470 DOMElement *timeout =
static_cast<DOMElement *
>(timeoutList->item(0));
475 DOMNodeList *statsDestList = sourceConfig->getElementsByTagName(
_toDOMS(
"statistics-destination"));
477 if (statsDestList->getLength() > 0) {
478 DOMElement *statsDest =
static_cast<DOMElement *
>(statsDestList->item(0));
482 DOMNodeList *prefetchingList = sourceConfig->getElementsByTagName(
_toDOMS(
"prefetching"));
484 if (prefetchingList->getLength() > 0) {
485 DOMElement *prefetching =
static_cast<DOMElement *
>(prefetchingList->item(0));
490 DOMNodeList *nativeProtocolsList = sourceConfig->getElementsByTagName(
_toDOMS(
"native-protocols"));
492 if (nativeProtocolsList->getLength() > 0) {
493 DOMElement *nativeProtocol =
static_cast<DOMElement *
>(nativeProtocolsList->item(0));
494 DOMNodeList *childList = nativeProtocol->getChildNodes();
496 XMLCh* prefixXMLCh =
_toDOMS(
"prefix");
497 unsigned int numNodes = childList->getLength();
498 for (
unsigned int i = 0;
i < numNodes; ++
i) {
499 DOMNode *childNode = childList->item(
i);
500 if (childNode->getNodeType() != DOMNode::ELEMENT_NODE) {
503 DOMElement *child =
static_cast<DOMElement *
>(childNode);
513 catch (xercesc::DOMException
const&
e) {
519 std::vector<std::string> inputStrings;
523 struct addrinfo *res;
524 struct addrinfo hints;
525 memset(&hints,
'\0',
sizeof(hints));
526 hints.ai_socktype = SOCK_DGRAM;
527 hints.ai_flags = AI_ADDRCONFIG;
528 hints.ai_family = AF_UNSPEC;
529 int e = getaddrinfo(host.c_str(), port.c_str(), &hints, &res);
540 desc.
setComment(
"Service to translate logical file names to physical file names.");
551 ->setComment(
"Request ROOT to asynchronously prefetch I/O during computation.");
553 ->setComment(
"Provide an alternate network destination for I/O statistics (must be in the form of host:port).");
555 descriptions.
add(
"SiteLocalConfigService", desc);
unsigned int const * m_timeoutPtr
std::string const fallbackDataCatalog(void) const
T getUntrackedParameter(std::string const &, T const &) const
std::string const * m_cacheTempDirPtr
std::string m_frontierConnect
void parse(std::string const &url)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
std::string m_fallbackDataCatalog
std::string const rfioType(void) const
double const * m_cacheMinFreePtr
double const * sourceCacheMinFree() const
static const std::string m_statisticsDefaultPort
std::string _toString(const XMLCh *toTranscode)
std::string const dataCatalog(void) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
struct addrinfo const * statisticsDestination() const
std::string m_cacheTempDir
unsigned int m_ttreeCacheSize
std::string const & siteName() const
std::vector< std::string > const * m_nativeProtocolsPtr
static std::string const input
std::string const lookupCalibConnect(std::string const &input) const
~SiteLocalConfigService()
void setComment(std::string const &value)
struct addrinfo * m_statisticsAddrInfo
std::string m_statisticsDestination
std::string const * sourceCacheHint() const
bool const * m_enablePrefetchingPtr
unsigned int m_debugLevel
std::string const * sourceReadHint() const
std::vector< std::string > m_nativeProtocols
unsigned int debugLevel() const
std::string const * m_cacheHintPtr
std::string const * m_readHintPtr
void computeStatisticsDestination()
unsigned int const * m_ttreeCacheSizePtr
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string const * sourceCacheTempDir() const
std::vector< std::vector< double > > tmp
XMLCh * _toDOMS(std::string temp)
unsigned int const * sourceTimeout() const
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
volatile std::atomic< bool > shutdown_flag false
std::string const frontierConnect(std::string const &servlet) const
std::vector< std::string > const * sourceNativeProtocols() const
unsigned int const * sourceTTreeCacheSize() const
bool enablePrefetching() const
std::string m_dataCatalog