8 #include <xercesc/dom/DOM.hpp> 9 #include <xercesc/parsers/XercesDOMParser.hpp> 14 #include <boost/algorithm/string.hpp> 33 inline std::string _toParenString(DOMNode
const& nodeToConvert) {
34 std::ostringstream oss;
36 DOMNodeList *childList = nodeToConvert.getChildNodes();
38 XMLSize_t numNodes = childList->getLength();
39 for (XMLSize_t
i = 0;
i < numNodes; ++
i) {
40 DOMNode *childNode = childList->item(
i);
41 if (childNode->getNodeType() != DOMNode::ELEMENT_NODE) {
44 DOMElement *
child =
static_cast<DOMElement *
>(childNode);
46 DOMNamedNodeMap *attributes = child->getAttributes();
47 XMLSize_t numAttributes = attributes->getLength();
48 for (XMLSize_t j = 0; j < numAttributes; ++j) {
49 DOMNode *attributeNode = attributes->item(j);
50 if (attributeNode->getNodeType() != DOMNode::ATTRIBUTE_NODE) {
53 DOMAttr *attribute =
static_cast<DOMAttr *
>(attributeNode);
55 oss <<
"(" <<
toString(child->getTagName()) <<
56 toString(attribute->getName()) <<
"=" <<
57 toString(attribute->getValue()) <<
")";
66 T& iHolder,
T const*& iPointer) {
77 const std::string SiteLocalConfigService::m_statisticsDefaultPort =
"3334";
80 m_url(
"/SITECONF/local/JobConfig/site-local-config.xml"),
82 m_fallbackDataCatalog(),
101 m_enablePrefetching(
false),
102 m_enablePrefetchingPtr(
nullptr),
105 m_statisticsDestination(),
107 m_statisticsInfoAvail(
false),
110 char*
tmp = getenv(
"CMS_PATH");
131 std::vector<std::string> tmpStatisticsInfo; std::vector<std::string>
const *tmpStatisticsInfoPtr =
nullptr;
132 overrideFromPSet(
"overrideStatisticsInfo", pset, tmpStatisticsInfo, tmpStatisticsInfoPtr);
133 if (tmpStatisticsInfoPtr) {
139 if(pset.
exists(
"debugLevel")) {
158 return "file:PoolFileCatalog.xml";
163 <<
"Did not find catalog in event-data section in " <<
m_url;
175 return "file:PoolFileCatalog.xml";
186 <<
"Valid site-local-config not found at " <<
m_url;
191 <<
"Did not find frontier-connect in calib-data section in " <<
m_url;
203 while ((serverurl =
m_frontierConnect.find(
"(serverurl=", nextparen)) != std::string::npos) {
208 complexstr.append(servlet);
219 if (input.substr(0,proto.length()) == proto) {
237 if (endservlet == std::string::npos) {
238 endservlet = input.rfind(
'/', input.length());
240 std::string servlet = input.substr(startservlet, endservlet - startservlet);
241 if ((servlet !=
"") && (servlet.find_first_of(
":/)[]") == std::string::npos)) {
242 if (servlet ==
"cms_conditions_data") {
302 std::vector<std::string>
const*
307 struct addrinfo const*
312 std::set<std::string>
const*
326 auto parser = std::make_unique<XercesDOMParser>();
328 parser->setValidationScheme(XercesDOMParser::Val_Auto);
329 parser->setDoNamespaces(
false);
331 parser->parse(url.c_str());
332 DOMDocument*
doc =
parser->getDocument();
365 DOMNodeList *sites = doc->getElementsByTagName(
uStr(
"site").ptr());
366 XMLSize_t numSites = sites->getLength();
367 for (XMLSize_t
i = 0;
i < numSites; ++
i) {
368 DOMElement *site =
static_cast<DOMElement *
>(sites->item(
i));
375 DOMNodeList *eventDataList = site->getElementsByTagName(
uStr(
"event-data").ptr());
376 if (eventDataList->getLength() > 0) {
377 DOMElement *eventData =
static_cast<DOMElement *
>(eventDataList->item(0));
379 DOMNodeList *catalogs = eventData->getElementsByTagName(
uStr(
"catalog").ptr());
381 if (catalogs->getLength() > 0) {
382 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(0));
386 if (catalogs->getLength() > 1) {
387 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(1));
391 DOMNodeList* rfiotypes = eventData->getElementsByTagName(
uStr(
"rfiotype").ptr());
393 if (rfiotypes->getLength() > 0) {
394 DOMElement* rfiotype =
static_cast<DOMElement *
>(rfiotypes->item(0));
402 DOMNodeList *calibDataList = site->getElementsByTagName(
uStr(
"calib-data").ptr());
404 if (calibDataList->getLength() > 0) {
405 DOMElement *calibData =
static_cast<DOMElement *
>(calibDataList->item(0));
406 DOMNodeList *frontierConnectList = calibData->getElementsByTagName(
uStr(
"frontier-connect").ptr());
408 if (frontierConnectList->getLength() > 0) {
409 DOMElement *
frontierConnect =
static_cast<DOMElement *
>(frontierConnectList->item(0));
416 DOMNodeList *sourceConfigList = site->getElementsByTagName(
uStr(
"source-config").ptr());
418 if (sourceConfigList->getLength() > 0) {
419 DOMElement *sourceConfig =
static_cast<DOMElement *
>(sourceConfigList->item(0));
420 DOMNodeList *cacheTempDirList = sourceConfig->getElementsByTagName(
uStr(
"cache-temp-dir").ptr());
422 if (cacheTempDirList->getLength() > 0) {
423 DOMElement *cacheTempDir =
static_cast<DOMElement *
>(cacheTempDirList->item(0));
428 DOMNodeList *cacheMinFreeList = sourceConfig->getElementsByTagName(
uStr(
"cache-min-free").ptr());
430 if (cacheMinFreeList->getLength() > 0) {
431 DOMElement *cacheMinFree =
static_cast<DOMElement *
>(cacheMinFreeList->item(0));
436 DOMNodeList *cacheHintList = sourceConfig->getElementsByTagName(
uStr(
"cache-hint").ptr());
438 if (cacheHintList->getLength() > 0) {
439 DOMElement *cacheHint =
static_cast<DOMElement *
>(cacheHintList->item(0));
444 DOMNodeList *cloneCacheHintList = sourceConfig->getElementsByTagName(
uStr(
"clone-cache-hint").ptr());
446 if (cloneCacheHintList->getLength() > 0) {
447 DOMElement *cloneCacheHint =
static_cast<DOMElement *
>(cloneCacheHintList->item(0));
452 DOMNodeList *readHintList = sourceConfig->getElementsByTagName(
uStr(
"read-hint").ptr());
454 if (readHintList->getLength() > 0) {
455 DOMElement *readHint =
static_cast<DOMElement *
>(readHintList->item(0));
460 DOMNodeList *ttreeCacheSizeList = sourceConfig->getElementsByTagName(
uStr(
"ttree-cache-size").ptr());
462 if (ttreeCacheSizeList->getLength() > 0) {
463 DOMElement *ttreeCacheSize =
static_cast<DOMElement *
>(ttreeCacheSizeList->item(0));
468 DOMNodeList *timeoutList = sourceConfig->getElementsByTagName(
uStr(
"timeout-in-seconds").ptr());
470 if (timeoutList->getLength() > 0) {
471 DOMElement *
timeout =
static_cast<DOMElement *
>(timeoutList->item(0));
476 DOMNodeList *statsDestList = sourceConfig->getElementsByTagName(
uStr(
"statistics-destination").ptr());
478 if (statsDestList->getLength() > 0) {
479 DOMElement *statsDest =
static_cast<DOMElement *
>(statsDestList->item(0));
489 DOMNodeList *prefetchingList = sourceConfig->getElementsByTagName(
uStr(
"prefetching").ptr());
491 if (prefetchingList->getLength() > 0) {
492 DOMElement *prefetching =
static_cast<DOMElement *
>(prefetchingList->item(0));
497 DOMNodeList *nativeProtocolsList = sourceConfig->getElementsByTagName(
uStr(
"native-protocols").ptr());
499 if (nativeProtocolsList->getLength() > 0) {
500 DOMElement *nativeProtocol =
static_cast<DOMElement *
>(nativeProtocolsList->item(0));
501 DOMNodeList *childList = nativeProtocol->getChildNodes();
503 XMLSize_t numNodes = childList->getLength();
504 for (XMLSize_t
i = 0;
i < numNodes; ++
i) {
505 DOMNode *childNode = childList->item(
i);
506 if (childNode->getNodeType() != DOMNode::ELEMENT_NODE) {
509 DOMElement *child =
static_cast<DOMElement *
>(childNode);
519 catch (xercesc::DOMException
const&
e) {
529 std::vector<std::string> inputStrings;
533 struct addrinfo *
res;
534 struct addrinfo hints;
535 memset(&hints,
'\0',
sizeof(hints));
536 hints.ai_socktype = SOCK_DGRAM;
537 hints.ai_flags = AI_ADDRCONFIG;
538 hints.ai_family = AF_UNSPEC;
539 int e = getaddrinfo(host.c_str(), port.c_str(), &hints, &res);
550 desc.
setComment(
"Service to translate logical file names to physical file names.");
556 ->setComment(
"Provide an alternate cache hint for fast cloning.");
563 ->setComment(
"Request ROOT to asynchronously prefetch I/O during computation.");
565 ->setComment(
"Provide an alternate network destination for I/O statistics (must be in the form of host:port).");
567 ->setComment(
"Provide an alternate listing of statistics to send (comma separated list; current options are 'dn' or 'nodn'). If left blank, all information is snet (including DNs).");
569 descriptions.
add(
"SiteLocalConfigService", desc);
unsigned int const * m_timeoutPtr
~SiteLocalConfigService() override
T getUntrackedParameter(std::string const &, T const &) const
std::string const * m_cacheTempDirPtr
std::string m_frontierConnect
unsigned int const * sourceTTreeCacheSize() const override
void parse(std::string const &url)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
std::string m_fallbackDataCatalog
double const * m_cacheMinFreePtr
std::string const fallbackDataCatalog(void) const override
std::string const * m_cloneCacheHintPtr
static const std::string m_statisticsDefaultPort
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::string m_cloneCacheHint
double toDouble(XMLCh const *toTranscode)
std::string m_cacheTempDir
std::string const dataCatalog(void) const override
unsigned int m_ttreeCacheSize
std::vector< std::string > const * m_nativeProtocolsPtr
static std::string const input
std::set< std::string > const * statisticsInfo() const override
void setComment(std::string const &value)
std::string m_statisticsDestination
edm::propagate_const< struct addrinfo * > m_statisticsAddrInfo
bool const * m_enablePrefetchingPtr
unsigned int const * sourceTimeout() const override
std::string const rfioType(void) const override
unsigned int m_debugLevel
unsigned int toUInt(XMLCh const *toTranscode)
std::string const * sourceCloneCacheHint() const override
ZStr< XMLCh > uStr(char const *str)
std::string const & siteName() const override
std::vector< std::string > const * sourceNativeProtocols() const override
std::string const * sourceCacheHint() const override
std::set< std::string > m_statisticsInfo
struct addrinfo const * statisticsDestination() const override
std::vector< std::string > m_nativeProtocols
double const * sourceCacheMinFree() const override
std::string const * sourceReadHint() const override
std::string const lookupCalibConnect(std::string const &input) const override
std::string const * m_cacheHintPtr
std::string const * m_readHintPtr
void computeStatisticsDestination()
bool enablePrefetching() const override
unsigned int const * m_ttreeCacheSizePtr
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< std::vector< double > > tmp
std::string const * sourceCacheTempDir() const override
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
std::string const frontierConnect(std::string const &servlet) const
bool m_statisticsInfoAvail
bool toBool(XMLCh const *toTranscode)
std::string m_dataCatalog
unsigned int debugLevel() const override