17 #include <boost/algorithm/string.hpp>
33 inline std::string _toParenString(tinyxml2::XMLElement
const &nodeToConvert) {
34 std::ostringstream oss;
36 for (
auto child = nodeToConvert.FirstChildElement();
child !=
nullptr;
child =
child->NextSiblingElement()) {
37 for (
auto attribute =
child->FirstAttribute(); attribute !=
nullptr; attribute = attribute->Next()) {
38 oss <<
"(" <<
child->Name() << attribute->Name() <<
"=" << attribute->Value() <<
")";
45 static void overrideFromPSet(
char const *iName,
edm::ParameterSet const &iPSet,
T &iHolder,
T const *&iPointer) {
53 const char *safe(
const char *iCheck) {
54 if (iCheck ==
nullptr) {
62 const char *
tmp = std::getenv(
"CMS_PATH");
66 returnValue +=
"/SITECONF/local/JobConfig/site-local-config.xml";
78 : m_url(pset.getUntrackedParameter<std::
string>(
"siteLocalConfigFileUrl", defaultURL())),
84 m_cacheTempDirPtr(nullptr),
86 m_cacheMinFreePtr(nullptr),
88 m_cacheHintPtr(nullptr),
90 m_cloneCacheHintPtr(nullptr),
92 m_readHintPtr(nullptr),
94 m_ttreeCacheSizePtr(nullptr),
96 m_timeoutPtr(nullptr),
98 m_enablePrefetching(
false),
99 m_enablePrefetchingPtr(nullptr),
101 m_nativeProtocolsPtr(nullptr),
102 m_statisticsDestination(),
103 m_statisticsAddrInfo(nullptr),
104 m_statisticsInfoAvail(
false),
121 std::vector<std::string> tmpStatisticsInfo;
122 std::vector<std::string>
const *tmpStatisticsInfoPtr =
nullptr;
123 overrideFromPSet(
"overrideStatisticsInfo", pset, tmpStatisticsInfo, tmpStatisticsInfoPtr);
124 if (tmpStatisticsInfoPtr) {
127 for (
auto &
entry : tmpStatisticsInfo) {
132 if (pset.
exists(
"debugLevel")) {
135 if (pset.
exists(
"overrideUseLocalConnectString")) {
138 if (pset.
exists(
"overrideLocalConnectPrefix")) {
141 if (pset.
exists(
"overrideLocalConnectSuffix")) {
158 static std::vector<std::string>
const tmp{
"file:PoolFileCatalog.xml"};
163 throw cms::Exception(
"Incomplete configuration") <<
"Did not find catalogs in event-data section in " <<
m_url;
171 throw cms::Exception(
"Incomplete configuration") <<
"Valid site-local-config not found at " <<
m_url;
176 <<
"Did not find frontier-connect in calib-data section in " <<
m_url;
179 if (servlet.empty()) {
188 while ((serverurl =
m_frontierConnect.find(
"(serverurl=", nextparen)) != std::string::npos) {
193 complexstr.append(servlet);
203 if (input.substr(0, proto.length()) == proto) {
221 if (endservlet == std::string::npos) {
222 endservlet = input.rfind(
'/', input.length());
224 std::string servlet = input.substr(startservlet, endservlet - startservlet);
225 if ((!servlet.empty()) && (servlet.find_first_of(
":/)[]") == std::string::npos)) {
226 if (servlet ==
"cms_conditions_data") {
276 tinyxml2::XMLDocument doc;
277 auto loadErr = doc.LoadFile(url.c_str());
278 if (loadErr != tinyxml2::XML_SUCCESS) {
310 auto rootElement = doc.RootElement();
312 for (
auto site = rootElement->FirstChildElement(
"site"); site !=
nullptr;
313 site = site->NextSiblingElement(
"site")) {
319 auto eventData = site->FirstChildElement(
"event-data");
321 auto catalog = eventData->FirstChildElement(
"catalog");
330 auto rfiotype = eventData->FirstChildElement(
"rfiotype");
332 m_rfioType = safe(rfiotype->Attribute(
"value"));
339 auto calibData = site->FirstChildElement(
"calib-data");
342 auto frontierConnect = calibData->FirstChildElement(
"frontier-connect");
347 auto localConnect = calibData->FirstChildElement(
"local-connect");
351 <<
"It is illegal to include both frontier-connect and local-connect in the same XML file";
354 auto connectString = localConnect->FirstChildElement(
"connectString");
365 auto sourceConfig = site->FirstChildElement(
"source-config");
368 auto cacheTempDir = sourceConfig->FirstChildElement(
"cache-temp-dir");
375 auto cacheMinFree = sourceConfig->FirstChildElement(
"cache-min-free");
383 auto cacheHint = sourceConfig->FirstChildElement(
"cache-hint");
390 auto cloneCacheHint = sourceConfig->FirstChildElement(
"clone-cache-hint");
392 if (cloneCacheHint) {
397 auto readHint = sourceConfig->FirstChildElement(
"read-hint");
400 m_readHint = safe(readHint->Attribute(
"value"));
404 auto ttreeCacheSize = sourceConfig->FirstChildElement(
"ttree-cache-size");
406 if (ttreeCacheSize) {
411 auto timeout = sourceConfig->FirstChildElement(
"timeout-in-seconds");
418 auto statsDest = sourceConfig->FirstChildElement(
"statistics-destination");
425 std::string tmpStatisticsInfo = safe(statsDest->Attribute(
"info"));
430 auto prefetching = sourceConfig->FirstChildElement(
"prefetching");
437 auto nativeProtocol = sourceConfig->FirstChildElement(
"native-protocols");
439 if (nativeProtocol) {
440 for (
auto child = nativeProtocol->FirstChildElement();
child !=
nullptr;
453 std::vector<std::string> inputStrings;
457 struct addrinfo *res;
458 struct addrinfo hints;
459 memset(&hints,
'\0',
sizeof(hints));
460 hints.ai_socktype = SOCK_DGRAM;
461 hints.ai_flags = AI_ADDRCONFIG;
462 hints.ai_family = AF_UNSPEC;
463 int e = getaddrinfo(host.c_str(), port.c_str(), &hints, &res);
473 desc.
setComment(
"Service to translate logical file names to physical file names.");
477 "Specify the file containing the site local config. Empty string will load from default directory.");
482 ->setComment(
"Provide an alternate cache hint for fast cloning.");
489 ->setComment(
"Request ROOT to asynchronously prefetch I/O during computation.");
492 "Provide an alternate network destination for I/O statistics (must be in the form of host:port).");
495 "Provide an alternate listing of statistics to send (comma separated list; current options are 'dn' or "
496 "'nodn'). If left blank, all information is snet (including DNs).");
500 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
void parse(std::string const &url)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
double const * m_cacheMinFreePtr
std::string const * m_cloneCacheHintPtr
static const std::string m_statisticsDefaultPort
unsigned int const * sourceTTreeCacheSize() const override
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::vector< std::string > m_dataCatalogs
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
std::string const * sourceCacheTempDir() const override
void setComment(std::string const &value)
std::string m_localConnectPrefix
std::string m_statisticsDestination
edm::propagate_const< struct addrinfo * > m_statisticsAddrInfo
std::vector< std::string > const & dataCatalogs(void) const override
bool const * m_enablePrefetchingPtr
std::string const rfioType(void) const override
std::string const & localConnectPrefix() const override
unsigned int m_debugLevel
std::string const * sourceCacheHint() const override
std::string const * sourceCloneCacheHint() const override
std::string m_localConnectSuffix
std::set< std::string > m_statisticsInfo
bool useLocalConnectString() const override
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
std::string const & localConnectSuffix() const override
unsigned int const * m_ttreeCacheSizePtr
SiteLocalConfigService(ParameterSet const &pset)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const char kEmptyString[1]
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
std::string const frontierConnect(std::string const &servlet) const
bool m_useLocalConnectString
bool m_statisticsInfoAvail
std::string const lookupCalibConnect(std::string const &input) const override
bool enablePrefetching() const override