Skip to content

Commit

Permalink
handle invalid entries in <data-access>
Browse files Browse the repository at this point in the history
  • Loading branch information
nhduongvn committed Mar 6, 2023
1 parent c388b01 commit f777646
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
9 changes: 5 additions & 4 deletions FWCore/Catalog/src/FileLocator.cc
Expand Up @@ -268,8 +268,8 @@ namespace edm {
//let enforce that site-local-config.xml and storage.json contains valid catalogs in <data-access>, in which site defined in site-local-config.xml <data-access> should be found in storage.json
if (found_site == json.end()) {
cms::Exception ex("FileCatalog");
ex << "Can not find site and volume " << aCatalog.site << ", " << aCatalog.volume << " in " << filename_storage
<< ". Check site-local-config.xml <data-access> and storage.json";
ex << "Can not find storage site \"" << aCatalog.storageSite << "\" and volume \"" << aCatalog.volume
<< "\" in storage.json. Check site-local-config.xml <data-access> and storage.json";
ex.addContext("edm::FileLocator:init()");
throw ex;
}
Expand All @@ -283,8 +283,9 @@ namespace edm {
//let enforce that site-local-config.xml and storage.json contains valid catalogs, in which protocol defined in site-local-config.xml <data-access> should be found in storage.json
if (found_protocol == protocols.end()) {
cms::Exception ex("FileCatalog");
ex << "Can not find protocol " << aCatalog.protocol
<< " in storage.json. Check site-local-config.xml <data-access> and storage.json";
ex << "Can not find protocol \"" << aCatalog.protocol << "\" for the storage site \"" << aCatalog.storageSite
<< "\" and volume \"" << aCatalog.volume
<< "\" in storage.json. Check site-local-config.xml <data-access> and storage.json";
ex.addContext("edm::FileLocator:init()");
throw ex;
}
Expand Down
43 changes: 32 additions & 11 deletions FWCore/Catalog/src/InputFileCatalog.cc
Expand Up @@ -9,6 +9,7 @@

#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <boost/algorithm/string.hpp>

Expand Down Expand Up @@ -57,7 +58,11 @@ namespace edm {
}

edm::CatalogAttributes inputOverride_struct(
tmps[0], tmps[1], tmps[2], tmps[3], tmps[4]); //site, subSite,storageSite,volume,protocol
tmps[0],
tmps[1],
tmps[2],
tmps[3],
tmps[4]); //current-site,current-subSite,desired-data-access-site,desired-data-access-volume,desired-data-access-protocol

overrideFileLocator_ =
std::make_unique<FileLocator>(inputOverride_struct); // propagate_const<T> has no reset() function
Expand All @@ -76,28 +81,44 @@ namespace edm {
std::vector<std::string> const& tmp_dataCatalogs = localconfservice->trivialDataCatalogs();
if (!fileLocators_trivalCatalog_.empty())
fileLocators_trivalCatalog_.clear();

//require the first file locator to success so obvious mistakes in data catalogs, typos for example, can be catched early. Note that tmp_dataCatalogs is not empty at this point. The protection is done inside the trivialDataCatalogs() of SiteLocalConfigService
fileLocators_trivalCatalog_.push_back(std::make_unique<FileLocator>(tmp_dataCatalogs.front()));

for (auto it = tmp_dataCatalogs.begin() + 1; it != tmp_dataCatalogs.end(); ++it) {
//Construct all file locators from data catalogs. If a data catalog is invalid (wrong protocol for example), it is skipped and no file locator is constructed (an exception is thrown out from FileLocator::init).
for (auto it = tmp_dataCatalogs.begin(); it != tmp_dataCatalogs.end(); ++it) {
try {
fileLocators_trivalCatalog_.push_back(std::make_unique<FileLocator>(*it));
} catch (cms::Exception const& e) {
continue;
edm::LogWarning("InputFileCatalog")
<< "Catch an exception while constructing a file locator in InputFileCatalog::init: " << e.what();
if (it != tmp_dataCatalogs.end() - 1) {
std::cout << "\n Skip this catalog" << std::endl;
continue;
} else {
cms::Exception ex("FileCatalog");
ex << "Can not construct a file locator in InputFileCatalog::init";
ex.addContext("Calling edm::InputFileCatalog::init()");
throw ex;
}
}
}
} else if (catType == edm::CatalogType::RucioCatalog) {
std::vector<edm::CatalogAttributes> const& tmp_dataCatalogs = localconfservice->dataCatalogs();
if (!fileLocators_.empty())
fileLocators_.clear();
//require the first file locator to success so obvious mistakes in data catalogs, typos for example, can be catched early. Note that tmp_dataCatalogs is not empty at this point. The protection is done inside the dataCatalogs() of SiteLocalConfigService
fileLocators_.push_back(std::make_unique<FileLocator>(tmp_dataCatalogs.front()));
for (auto it = tmp_dataCatalogs.begin() + 1; it != tmp_dataCatalogs.end(); ++it) {
//Construct all file locators from data catalogs. If a data catalog is invalid (wrong protocol for example), it is skipped and no file locator is constructed (an exception is thrown out from FileLocator::init).
for (auto it = tmp_dataCatalogs.begin(); it != tmp_dataCatalogs.end(); ++it) {
try {
fileLocators_.push_back(std::make_unique<FileLocator>(*it));
} catch (cms::Exception const& e) {
continue;
edm::LogWarning("InputFileCatalog")
<< "Catch an exception while constructing a file locator in InputFileCatalog::init: " << e.what()
<< "Skip this catalog";
if (it != tmp_dataCatalogs.end() - 1) {
continue;
} else {
cms::Exception ex("FileCatalog");
ex << "Can not construct a file locator in InputFileCatalog::init";
ex.addContext("Calling edm::InputFileCatalog::init()");
throw ex;
}
}
}
} else {
Expand Down

0 comments on commit f777646

Please sign in to comment.