Skip to content

Commit

Permalink
Matti reviews 1
Browse files Browse the repository at this point in the history
  • Loading branch information
nhduongvn committed Aug 11, 2023
1 parent 6abadbf commit 05b57b1
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 10 deletions.
7 changes: 4 additions & 3 deletions FWCore/Catalog/interface/FileLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ namespace edm {

void init_trivialCatalog(std::string const& catUrl, unsigned iCatalog);

//void ruleBuilder(std::string prefix, Rule& rule);
void parseRuleTrivialCatalog(tinyxml2::XMLElement* ruleNode, ProtocolRules& rules);
//using data-access
void init(edm::CatalogAttributes const& input_dataCatalog,
Expand All @@ -70,8 +69,10 @@ namespace edm {

std::string m_fileType;
std::string m_filename;
std::vector<std::string>
m_protocols; //not sure why a vector is used while it seems this vector has only one element?
//TFC allows more than one protocols provided in a catalog, separated by a comma
//In new Rucio storage description, only one protocol is provided in a catalog
//This variable can be simplified in the future
std::vector<std::string> m_protocols;
std::string m_destination;
};
} // namespace edm
Expand Down
5 changes: 3 additions & 2 deletions FWCore/Catalog/src/FileLocator.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "FWCore/Catalog/interface/FileLocator.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/Exception.h"

#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
Expand Down Expand Up @@ -301,9 +302,9 @@ namespace edm {
//now convert prefix to a rule and save it
else {
Rule rule;
rule.pathMatch.assign("(/.*)"); //require lfn start with "/"
rule.pathMatch.assign("/?(.*)");
rule.destinationMatch.assign(".*");
rule.result = prefixTmp + "$1";
rule.result = prefixTmp + "/$1";
rule.chain = kEmptyString;
m_directRules[protName].emplace_back(std::move(rule));
}
Expand Down
42 changes: 38 additions & 4 deletions FWCore/Catalog/test/FileLocator_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ TEST_CASE("FileLocator with Rucio data catalog", "[filelocatorRucioDataCatalog]"
aCatalog.volume = "FNAL_dCache_EOS";
aCatalog.protocol = "XRootD";
tmp.push_back(aCatalog);
//catalog for testing chained "rules"
aCatalog.site = "T1_US_FNAL";
aCatalog.subSite = "T1_US_FNAL";
aCatalog.storageSite = "T1_US_FNAL";
aCatalog.volume = "FNAL_dCache_EOS";
aCatalog.protocol = "root";
tmp.push_back(aCatalog);

//create the services
edm::ServiceToken tempToken(
Expand All @@ -81,15 +88,19 @@ TEST_CASE("FileLocator with Rucio data catalog", "[filelocatorRucioDataCatalog]"

SECTION("prefix") {
edm::ServiceRegistry::Operate operate(tempToken);
edm::CatalogAttributes tmp_cat; //empty catalog
edm::FileLocator fl(tmp_cat, 0, full_file_name); //use the first catalog provided by site local config
//empty catalog
edm::CatalogAttributes tmp_cat;
//use the first catalog provided by site local config
edm::FileLocator fl(tmp_cat, 0, full_file_name);
CHECK("root://cmsxrootd.fnal.gov/store/group/bha/bho" ==
fl.pfn("/store/group/bha/bho", edm::CatalogType::RucioCatalog));
}
SECTION("rule") {
edm::ServiceRegistry::Operate operate(tempToken);
edm::CatalogAttributes tmp_cat; //empty catalog
edm::FileLocator fl(tmp_cat, 1, full_file_name); //use the second catalog provided by site local config
//empty catalog
edm::CatalogAttributes tmp_cat;
//use the second catalog provided by site local config
edm::FileLocator fl(tmp_cat, 1, full_file_name);
const std::array<const char*, 7> lfn = {{"/bha/bho",
"bha",
"file:bha",
Expand All @@ -103,6 +114,29 @@ TEST_CASE("FileLocator with Rucio data catalog", "[filelocatorRucioDataCatalog]"
CHECK("" == fl.pfn(file, edm::CatalogType::RucioCatalog));
}
}
SECTION("chainedrule") {
edm::ServiceRegistry::Operate operate(tempToken);
//empty catalog
edm::CatalogAttributes tmp_cat;
//use the third catalog provided by site local config above
edm::FileLocator fl(tmp_cat, 2, full_file_name);
const std::array<const char*, 7> lfn = {{"/bha/bho",
"bha",
"file:bha",
"file:/bha/bho",
"/castor/cern.ch/cms/bha/bho",
"rfio:/castor/cern.ch/cms/bha/bho",
"rfio:/bha/bho"}};
//one level chain between "root" and "second" protocols (see storage.json)
CHECK("root://host.domain//pnfs/cms/store/group/bha/bho" ==
fl.pfn("/store/group/bha/bho", edm::CatalogType::RucioCatalog));
//two levels chain between "root", "second" and "first" (see storage.json)
CHECK("root://host.domain//pnfs/cms/store/user/AAA/bho" ==
fl.pfn("/store/user/aaa/bho", edm::CatalogType::RucioCatalog));
for (auto file : lfn) {
CHECK("" == fl.pfn(file, edm::CatalogType::RucioCatalog));
}
}
}

TEST_CASE("FileLocator", "[filelocator]") {
Expand Down
34 changes: 33 additions & 1 deletion FWCore/Catalog/test/storage.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,39 @@
"pfn": "root://cmsdcadisk.fnal.gov//dcache/uscmsdisk/store/$1"
}
]
}
},
{
"protocol": "first",
"rules": [
{ "lfn": "/+store/user/aaa/(.*)",
"pfn": "/store/user/AAA/$1"
},
{ "lfn": "/+(.*)",
"pfn": "$1"
}
]
},
{
"protocol": "second",
"rules": [
{ "lfn": "/+store/user/(.*)",
"pfn": "/cms/store/user/$1",
"chain": "first"
},
{ "lfn": "/+store/(.*)",
"pfn": "/cms/store/$1"
}
]
},
{
"protocol": "root",
"rules": [
{ "lfn": "/+(.*)",
"pfn": "root://host.domain//pnfs/$1",
"chain": "second"
}
]
}
],
"type": "DISK",
"rse": "T1_US_FNAL_Disk",
Expand Down

0 comments on commit 05b57b1

Please sign in to comment.