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"),
125 m_ttreeCacheSize(0U),
130 m_enablePrefetching(
false),
131 m_enablePrefetchingPtr(
nullptr),
134 m_statisticsDestination(),
136 m_statisticsInfoAvail(
false),
139 char*
tmp = getenv(
"CMS_PATH");
160 std::vector<std::string> tmpStatisticsInfo; std::vector<std::string>
const *tmpStatisticsInfoPtr =
nullptr;
161 overrideFromPSet(
"overrideStatisticsInfo", pset, tmpStatisticsInfo, tmpStatisticsInfoPtr);
162 if (tmpStatisticsInfoPtr) {
168 if(pset.
exists(
"debugLevel")) {
187 return "file:PoolFileCatalog.xml";
192 <<
"Did not find catalog in event-data section in " <<
m_url;
204 return "file:PoolFileCatalog.xml";
215 <<
"Valid site-local-config not found at " <<
m_url;
220 <<
"Did not find frontier-connect in calib-data section in " <<
m_url;
232 while ((serverurl =
m_frontierConnect.find(
"(serverurl=", nextparen)) != std::string::npos) {
237 complexstr.append(servlet);
248 if (input.substr(0,proto.length()) == proto) {
266 if (endservlet == std::string::npos) {
267 endservlet = input.rfind(
'/', input.length());
269 std::string servlet = input.substr(startservlet, endservlet - startservlet);
270 if ((servlet !=
"") && (servlet.find_first_of(
":/)[]") == std::string::npos)) {
271 if (servlet ==
"cms_conditions_data") {
331 std::vector<std::string>
const*
336 struct addrinfo
const*
341 std::set<std::string>
const*
354 std::auto_ptr<XercesDOMParser>
parser(
new XercesDOMParser);
356 parser->setValidationScheme(XercesDOMParser::Val_Auto);
357 parser->setDoNamespaces(
false);
359 parser->parse(url.c_str());
360 DOMDocument*
doc = parser->getDocument();
393 DOMNodeList *
sites = doc->getElementsByTagName(
_toDOMS(
"site"));
394 unsigned int numSites = sites->getLength();
395 for (
unsigned int i = 0;
i < numSites; ++
i) {
396 DOMElement *site =
static_cast<DOMElement *
>(sites->item(
i));
403 DOMNodeList *eventDataList = site->getElementsByTagName(
_toDOMS(
"event-data"));
404 if (eventDataList->getLength() > 0) {
405 DOMElement *eventData =
static_cast<DOMElement *
>(eventDataList->item(0));
407 DOMNodeList *catalogs = eventData->getElementsByTagName(
_toDOMS(
"catalog"));
409 if (catalogs->getLength() > 0) {
410 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(0));
414 if (catalogs->getLength() > 1) {
415 DOMElement *
catalog =
static_cast<DOMElement *
>(catalogs->item(1));
419 DOMNodeList* rfiotypes = eventData->getElementsByTagName(
_toDOMS(
"rfiotype"));
421 if (rfiotypes->getLength() > 0) {
422 DOMElement* rfiotype =
static_cast<DOMElement *
>(rfiotypes->item(0));
430 DOMNodeList *calibDataList = site->getElementsByTagName(
_toDOMS(
"calib-data"));
432 if (calibDataList->getLength() > 0) {
433 DOMElement *calibData =
static_cast<DOMElement *
>(calibDataList->item(0));
434 DOMNodeList *frontierConnectList = calibData->getElementsByTagName(
_toDOMS(
"frontier-connect"));
436 if (frontierConnectList->getLength() > 0) {
437 DOMElement *
frontierConnect =
static_cast<DOMElement *
>(frontierConnectList->item(0));
444 DOMNodeList *sourceConfigList = site->getElementsByTagName(
_toDOMS(
"source-config"));
446 if (sourceConfigList->getLength() > 0) {
447 DOMElement *sourceConfig =
static_cast<DOMElement *
>(sourceConfigList->item(0));
448 DOMNodeList *cacheTempDirList = sourceConfig->getElementsByTagName(
_toDOMS(
"cache-temp-dir"));
450 if (cacheTempDirList->getLength() > 0) {
451 DOMElement *cacheTempDir =
static_cast<DOMElement *
>(cacheTempDirList->item(0));
456 DOMNodeList *cacheMinFreeList = sourceConfig->getElementsByTagName(
_toDOMS(
"cache-min-free"));
458 if (cacheMinFreeList->getLength() > 0) {
459 DOMElement *cacheMinFree =
static_cast<DOMElement *
>(cacheMinFreeList->item(0));
464 DOMNodeList *cacheHintList = sourceConfig->getElementsByTagName(
_toDOMS(
"cache-hint"));
466 if (cacheHintList->getLength() > 0) {
467 DOMElement *cacheHint =
static_cast<DOMElement *
>(cacheHintList->item(0));
472 DOMNodeList *cloneCacheHintList = sourceConfig->getElementsByTagName(
_toDOMS(
"clone-cache-hint"));
474 if (cloneCacheHintList->getLength() > 0) {
475 DOMElement *cloneCacheHint =
static_cast<DOMElement *
>(cloneCacheHintList->item(0));
480 DOMNodeList *readHintList = sourceConfig->getElementsByTagName(
_toDOMS(
"read-hint"));
482 if (readHintList->getLength() > 0) {
483 DOMElement *readHint =
static_cast<DOMElement *
>(readHintList->item(0));
488 DOMNodeList *ttreeCacheSizeList = sourceConfig->getElementsByTagName(
_toDOMS(
"ttree-cache-size"));
490 if (ttreeCacheSizeList->getLength() > 0) {
491 DOMElement *ttreeCacheSize =
static_cast<DOMElement *
>(ttreeCacheSizeList->item(0));
496 DOMNodeList *timeoutList = sourceConfig->getElementsByTagName(
_toDOMS(
"timeout-in-seconds"));
498 if (timeoutList->getLength() > 0) {
499 DOMElement *timeout =
static_cast<DOMElement *
>(timeoutList->item(0));
504 DOMNodeList *statsDestList = sourceConfig->getElementsByTagName(
_toDOMS(
"statistics-destination"));
506 if (statsDestList->getLength() > 0) {
507 DOMElement *statsDest =
static_cast<DOMElement *
>(statsDestList->item(0));
517 DOMNodeList *prefetchingList = sourceConfig->getElementsByTagName(
_toDOMS(
"prefetching"));
519 if (prefetchingList->getLength() > 0) {
520 DOMElement *prefetching =
static_cast<DOMElement *
>(prefetchingList->item(0));
525 DOMNodeList *nativeProtocolsList = sourceConfig->getElementsByTagName(
_toDOMS(
"native-protocols"));
527 if (nativeProtocolsList->getLength() > 0) {
528 DOMElement *nativeProtocol =
static_cast<DOMElement *
>(nativeProtocolsList->item(0));
529 DOMNodeList *childList = nativeProtocol->getChildNodes();
531 XMLCh* prefixXMLCh =
_toDOMS(
"prefix");
532 unsigned int numNodes = childList->getLength();
533 for (
unsigned int i = 0;
i < numNodes; ++
i) {
534 DOMNode *childNode = childList->item(
i);
535 if (childNode->getNodeType() != DOMNode::ELEMENT_NODE) {
538 DOMElement *child =
static_cast<DOMElement *
>(childNode);
548 catch (xercesc::DOMException
const&
e) {
554 std::vector<std::string> inputStrings;
558 struct addrinfo *res;
559 struct addrinfo hints;
560 memset(&hints,
'\0',
sizeof(hints));
561 hints.ai_socktype = SOCK_DGRAM;
562 hints.ai_flags = AI_ADDRCONFIG;
563 hints.ai_family = AF_UNSPEC;
564 int e = getaddrinfo(host.c_str(), port.c_str(), &hints, &res);
575 desc.
setComment(
"Service to translate logical file names to physical file names.");
581 ->setComment(
"Provide an alternate cache hint for fast cloning.");
588 ->setComment(
"Request ROOT to asynchronously prefetch I/O during computation.");
590 ->setComment(
"Provide an alternate network destination for I/O statistics (must be in the form of host:port).");
592 ->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).");
594 descriptions.
add(
"SiteLocalConfigService", desc);
unsigned int const * m_timeoutPtr
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
double const * m_cacheMinFreePtr
std::string const * m_cloneCacheHintPtr
static const std::string m_statisticsDefaultPort
unsigned int const * sourceTTreeCacheSize() const override
std::string _toString(const XMLCh *toTranscode)
std::string const & siteName() const override
bool exists(std::string const ¶meterName) const
checks if a parameter exists
struct addrinfo const * statisticsDestination() const override
std::string m_cloneCacheHint
std::string const fallbackDataCatalog(void) const override
std::string m_cacheTempDir
std::string const * sourceReadHint() const override
unsigned int m_ttreeCacheSize
std::vector< std::string > const * m_nativeProtocolsPtr
static std::string const input
~SiteLocalConfigService()
std::string const * sourceCacheTempDir() const override
void setComment(std::string const &value)
struct addrinfo * m_statisticsAddrInfo
std::string m_statisticsDestination
bool const * m_enablePrefetchingPtr
std::string const rfioType(void) const override
unsigned int m_debugLevel
std::string const * sourceCacheHint() const override
std::string const * sourceCloneCacheHint() const override
std::set< std::string > m_statisticsInfo
std::vector< std::string > const * sourceNativeProtocols() const override
std::vector< std::string > m_nativeProtocols
unsigned int const * sourceTimeout() const override
double const * sourceCacheMinFree() const override
std::string const * m_cacheHintPtr
std::string const * m_readHintPtr
void computeStatisticsDestination()
std::set< std::string > const * statisticsInfo() const override
unsigned int debugLevel() const override
unsigned int const * m_ttreeCacheSizePtr
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< std::vector< double > > tmp
XMLCh * _toDOMS(std::string temp)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
volatile std::atomic< bool > shutdown_flag false
std::string const frontierConnect(std::string const &servlet) const
bool m_statisticsInfoAvail
std::string const lookupCalibConnect(std::string const &input) const override
bool enablePrefetching() const override
std::string const dataCatalog(void) const override
std::string m_dataCatalog