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()) <<
toString(attribute->getName()) <<
"=" 56 <<
toString(attribute->getValue()) <<
")";
63 static void overrideFromPSet(
char const *iName,
edm::ParameterSet const &iPSet,
T &iHolder,
T const *&iPointer) {
74 const std::string SiteLocalConfigService::m_statisticsDefaultPort =
"3334";
77 : m_url(
"/SITECONF/local/JobConfig/site-local-config.xml"),
79 m_fallbackDataCatalog(),
98 m_enablePrefetching(
false),
99 m_enablePrefetchingPtr(
nullptr),
102 m_statisticsDestination(),
104 m_statisticsInfoAvail(
false),
106 char *
tmp = getenv(
"CMS_PATH");
127 std::vector<std::string> tmpStatisticsInfo;
128 std::vector<std::string>
const *tmpStatisticsInfoPtr =
nullptr;
129 overrideFromPSet(
"overrideStatisticsInfo", pset, tmpStatisticsInfo, tmpStatisticsInfoPtr);
130 if (tmpStatisticsInfoPtr) {
133 for (
auto &
entry : tmpStatisticsInfo) {
138 if (pset.
exists(
"debugLevel")) {
155 return "file:PoolFileCatalog.xml";
159 throw cms::Exception(
"Incomplete configuration") <<
"Did not find catalog in event-data section in " <<
m_url;
170 return "file:PoolFileCatalog.xml";
179 throw cms::Exception(
"Incomplete configuration") <<
"Valid site-local-config not found at " <<
m_url;
184 <<
"Did not find frontier-connect in calib-data section in " <<
m_url;
187 if (servlet.empty()) {
196 while ((serverurl =
m_frontierConnect.find(
"(serverurl=", nextparen)) != std::string::npos) {
201 complexstr.append(servlet);
211 if (input.substr(0, proto.length()) == proto) {
229 if (endservlet == std::string::npos) {
230 endservlet = input.rfind(
'/', input.length());
232 std::string servlet = input.substr(startservlet, endservlet - startservlet);
233 if ((!servlet.empty()) && (servlet.find_first_of(
":/)[]") == std::string::npos)) {
234 if (servlet ==
"cms_conditions_data") {
283 auto parser = std::make_unique<XercesDOMParser>();
285 parser->setValidationScheme(XercesDOMParser::Val_Auto);
286 parser->setDoNamespaces(
false);
288 parser->parse(url.c_str());
289 DOMDocument *
doc =
parser->getDocument();
322 DOMNodeList *sites = doc->getElementsByTagName(
uStr(
"site").ptr());
323 XMLSize_t numSites = sites->getLength();
324 for (XMLSize_t
i = 0;
i < numSites; ++
i) {
325 DOMElement *site =
static_cast<DOMElement *
>(sites->item(
i));
332 DOMNodeList *eventDataList = site->getElementsByTagName(
uStr(
"event-data").ptr());
333 if (eventDataList->getLength() > 0) {
334 DOMElement *eventData =
static_cast<DOMElement *
>(eventDataList->item(0));
336 DOMNodeList *catalogs = eventData->getElementsByTagName(
uStr(
"catalog").ptr());
338 if (catalogs->getLength() > 0) {
339 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(0));
343 if (catalogs->getLength() > 1) {
344 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(1));
348 DOMNodeList *rfiotypes = eventData->getElementsByTagName(
uStr(
"rfiotype").ptr());
350 if (rfiotypes->getLength() > 0) {
351 DOMElement *rfiotype =
static_cast<DOMElement *
>(rfiotypes->item(0));
359 DOMNodeList *calibDataList = site->getElementsByTagName(
uStr(
"calib-data").ptr());
361 if (calibDataList->getLength() > 0) {
362 DOMElement *calibData =
static_cast<DOMElement *
>(calibDataList->item(0));
363 DOMNodeList *frontierConnectList = calibData->getElementsByTagName(
uStr(
"frontier-connect").ptr());
365 if (frontierConnectList->getLength() > 0) {
366 DOMElement *
frontierConnect =
static_cast<DOMElement *
>(frontierConnectList->item(0));
373 DOMNodeList *sourceConfigList = site->getElementsByTagName(
uStr(
"source-config").ptr());
375 if (sourceConfigList->getLength() > 0) {
376 DOMElement *sourceConfig =
static_cast<DOMElement *
>(sourceConfigList->item(0));
377 DOMNodeList *cacheTempDirList = sourceConfig->getElementsByTagName(
uStr(
"cache-temp-dir").ptr());
379 if (cacheTempDirList->getLength() > 0) {
380 DOMElement *cacheTempDir =
static_cast<DOMElement *
>(cacheTempDirList->item(0));
385 DOMNodeList *cacheMinFreeList = sourceConfig->getElementsByTagName(
uStr(
"cache-min-free").ptr());
387 if (cacheMinFreeList->getLength() > 0) {
388 DOMElement *cacheMinFree =
static_cast<DOMElement *
>(cacheMinFreeList->item(0));
393 DOMNodeList *cacheHintList = sourceConfig->getElementsByTagName(
uStr(
"cache-hint").ptr());
395 if (cacheHintList->getLength() > 0) {
396 DOMElement *cacheHint =
static_cast<DOMElement *
>(cacheHintList->item(0));
401 DOMNodeList *cloneCacheHintList = sourceConfig->getElementsByTagName(
uStr(
"clone-cache-hint").ptr());
403 if (cloneCacheHintList->getLength() > 0) {
404 DOMElement *cloneCacheHint =
static_cast<DOMElement *
>(cloneCacheHintList->item(0));
409 DOMNodeList *readHintList = sourceConfig->getElementsByTagName(
uStr(
"read-hint").ptr());
411 if (readHintList->getLength() > 0) {
412 DOMElement *readHint =
static_cast<DOMElement *
>(readHintList->item(0));
417 DOMNodeList *ttreeCacheSizeList = sourceConfig->getElementsByTagName(
uStr(
"ttree-cache-size").ptr());
419 if (ttreeCacheSizeList->getLength() > 0) {
420 DOMElement *ttreeCacheSize =
static_cast<DOMElement *
>(ttreeCacheSizeList->item(0));
425 DOMNodeList *timeoutList = sourceConfig->getElementsByTagName(
uStr(
"timeout-in-seconds").ptr());
427 if (timeoutList->getLength() > 0) {
428 DOMElement *
timeout =
static_cast<DOMElement *
>(timeoutList->item(0));
433 DOMNodeList *statsDestList = sourceConfig->getElementsByTagName(
uStr(
"statistics-destination").ptr());
435 if (statsDestList->getLength() > 0) {
436 DOMElement *statsDest =
static_cast<DOMElement *
>(statsDestList->item(0));
446 DOMNodeList *prefetchingList = sourceConfig->getElementsByTagName(
uStr(
"prefetching").ptr());
448 if (prefetchingList->getLength() > 0) {
449 DOMElement *prefetching =
static_cast<DOMElement *
>(prefetchingList->item(0));
454 DOMNodeList *nativeProtocolsList = sourceConfig->getElementsByTagName(
uStr(
"native-protocols").ptr());
456 if (nativeProtocolsList->getLength() > 0) {
457 DOMElement *nativeProtocol =
static_cast<DOMElement *
>(nativeProtocolsList->item(0));
458 DOMNodeList *childList = nativeProtocol->getChildNodes();
460 XMLSize_t numNodes = childList->getLength();
461 for (XMLSize_t
i = 0;
i < numNodes; ++
i) {
462 DOMNode *childNode = childList->item(
i);
463 if (childNode->getNodeType() != DOMNode::ELEMENT_NODE) {
466 DOMElement *child =
static_cast<DOMElement *
>(childNode);
475 }
catch (xercesc::DOMException
const &
e) {
484 std::vector<std::string> inputStrings;
488 struct addrinfo *
res;
489 struct addrinfo hints;
490 memset(&hints,
'\0',
sizeof(hints));
491 hints.ai_socktype = SOCK_DGRAM;
492 hints.ai_flags = AI_ADDRCONFIG;
493 hints.ai_family = AF_UNSPEC;
494 int e = getaddrinfo(host.c_str(), port.c_str(), &hints, &res);
504 desc.
setComment(
"Service to translate logical file names to physical file names.");
510 ->setComment(
"Provide an alternate cache hint for fast cloning.");
517 ->setComment(
"Request ROOT to asynchronously prefetch I/O during computation.");
520 "Provide an alternate network destination for I/O statistics (must be in the form of host:port).");
523 "Provide an alternate listing of statistics to send (comma separated list; current options are 'dn' or " 524 "'nodn'). If left blank, all information is snet (including DNs).");
526 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 toString(const std::pair< T, T > &aT)
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