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")) {
149 static std::vector<std::string>
const tmp{
"file:PoolFileCatalog.xml"};
154 throw cms::Exception(
"Incomplete configuration") <<
"Did not find catalogs in event-data section in " <<
m_url;
162 throw cms::Exception(
"Incomplete configuration") <<
"Valid site-local-config not found at " <<
m_url;
167 <<
"Did not find frontier-connect in calib-data section in " <<
m_url;
170 if (servlet.empty()) {
179 while ((serverurl =
m_frontierConnect.find(
"(serverurl=", nextparen)) != std::string::npos) {
184 complexstr.append(servlet);
194 if (
input.substr(0, proto.length()) == proto) {
212 if (endservlet == std::string::npos) {
213 endservlet =
input.rfind(
'/',
input.length());
215 std::string servlet =
input.substr(startservlet, endservlet - startservlet);
216 if ((!servlet.empty()) && (servlet.find_first_of(
":/)[]") == std::string::npos)) {
217 if (servlet ==
"cms_conditions_data") {
264 tinyxml2::XMLDocument
doc;
265 auto loadErr =
doc.LoadFile(
url.c_str());
266 if (loadErr != tinyxml2::XML_SUCCESS) {
295 auto rootElement =
doc.RootElement();
297 for (
auto site = rootElement->FirstChildElement(
"site"); site !=
nullptr;
298 site = site->NextSiblingElement(
"site")) {
304 auto eventData = site->FirstChildElement(
"event-data");
306 auto catalog = eventData->FirstChildElement(
"catalog");
315 auto rfiotype = eventData->FirstChildElement(
"rfiotype");
317 m_rfioType = safe(rfiotype->Attribute(
"value"));
324 auto calibData = site->FirstChildElement(
"calib-data");
327 auto frontierConnect = calibData->FirstChildElement(
"frontier-connect");
336 auto sourceConfig = site->FirstChildElement(
"source-config");
339 auto cacheTempDir = sourceConfig->FirstChildElement(
"cache-temp-dir");
346 auto cacheMinFree = sourceConfig->FirstChildElement(
"cache-min-free");
354 auto cacheHint = sourceConfig->FirstChildElement(
"cache-hint");
361 auto cloneCacheHint = sourceConfig->FirstChildElement(
"clone-cache-hint");
363 if (cloneCacheHint) {
368 auto readHint = sourceConfig->FirstChildElement(
"read-hint");
371 m_readHint = safe(readHint->Attribute(
"value"));
375 auto ttreeCacheSize = sourceConfig->FirstChildElement(
"ttree-cache-size");
377 if (ttreeCacheSize) {
382 auto timeout = sourceConfig->FirstChildElement(
"timeout-in-seconds");
389 auto statsDest = sourceConfig->FirstChildElement(
"statistics-destination");
396 std::string tmpStatisticsInfo = safe(statsDest->Attribute(
"info"));
401 auto prefetching = sourceConfig->FirstChildElement(
"prefetching");
408 auto nativeProtocol = sourceConfig->FirstChildElement(
"native-protocols");
410 if (nativeProtocol) {
411 for (
auto child = nativeProtocol->FirstChildElement();
child !=
nullptr;
424 std::vector<std::string> inputStrings;
428 struct addrinfo *
res;
429 struct addrinfo hints;
430 memset(&hints,
'\0',
sizeof(hints));
431 hints.ai_socktype = SOCK_DGRAM;
432 hints.ai_flags = AI_ADDRCONFIG;
433 hints.ai_family = AF_UNSPEC;
434 int e = getaddrinfo(
host.c_str(),
port.c_str(), &hints, &
res);
444 desc.
setComment(
"Service to translate logical file names to physical file names.");
448 "Specify the file containing the site local config. Empty string will load from default directory.");
453 ->setComment(
"Provide an alternate cache hint for fast cloning.");
460 ->setComment(
"Request ROOT to asynchronously prefetch I/O during computation.");
463 "Provide an alternate network destination for I/O statistics (must be in the form of host:port).");
466 "Provide an alternate listing of statistics to send (comma separated list; current options are 'dn' or "
467 "'nodn'). If left blank, all information is snet (including DNs).");
469 descriptions.
add(
"SiteLocalConfigService", desc);