-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New developments using multiple data catalogs provided in site-local-config.xml #28911
Changes from 18 commits
ab29b03
e8cfe9a
a45a231
f2c7d33
c053bd7
37d0fe6
938a4d5
4203178
7cbb30b
54906c6
7985c47
58f7886
adc942c
d5ebf47
a895875
c4c99ef
cad7695
0ceff5b
9072f1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,7 +425,7 @@ DQMRootSource::DQMRootSource(edm::ParameterSet const& iPSet, const edm::InputSou | |
m_fileMetadatas(std::vector<FileMetadata>()) { | ||
edm::sortAndRemoveOverlaps(m_lumisToProcess); | ||
|
||
if (m_catalog.fileNames().empty()) { | ||
if (m_catalog.fileNames(0).empty()) { | ||
m_nextItemType = edm::InputSource::IsStop; | ||
} else { | ||
m_treeReaders[kIntIndex].reset(new TreeSimpleReader<Long64_t>(MonitorElementData::Kind::INT, m_rescope)); | ||
|
@@ -464,110 +464,80 @@ edm::InputSource::ItemType DQMRootSource::getNextItemType() { return m_nextItemT | |
|
||
// We will read the metadata of all files and fill m_fileMetadatas vector | ||
std::unique_ptr<edm::FileBlock> DQMRootSource::readFile_() { | ||
const int numFiles = m_catalog.fileNames().size(); | ||
const int numFiles = m_catalog.fileNames(0).size(); | ||
m_openFiles.reserve(numFiles); | ||
|
||
for (auto& fileitem : m_catalog.fileCatalogItems()) { | ||
const auto& filename = fileitem.fileName(); | ||
const auto& fallbackname = fileitem.fallbackFileName(); | ||
bool hasFallback = !fallbackname.empty() && fallbackname != filename; | ||
TFile* file; | ||
std::list<std::string> originalInfo; | ||
|
||
// Try to open a file | ||
try { | ||
file = TFile::Open(filename.c_str()); | ||
|
||
// Exception will be trapped so we pull it out ourselves | ||
std::exception_ptr e = edm::threadLocalException::getException(); | ||
if (e != std::exception_ptr()) { | ||
edm::threadLocalException::setException(std::exception_ptr()); | ||
std::rethrow_exception(e); | ||
} | ||
|
||
} catch (cms::Exception const& e) { | ||
file = nullptr; // is there anything we need to free? | ||
if (!hasFallback) { | ||
if (m_skipBadFiles) { | ||
continue; | ||
} else { | ||
edm::Exception ex(edm::errors::FileOpenError, "", e); | ||
ex.addContext("Opening DQM Root file"); | ||
ex << "\nInput file " << filename << " was not found, could not be opened, or is corrupted.\n"; | ||
throw ex; | ||
} | ||
} | ||
originalInfo = e.additionalInfo(); // save in case of fallback error | ||
} | ||
|
||
// Check if a file is usable | ||
if (file && !file->IsZombie()) { | ||
logFileAction("Successfully opened file ", filename.c_str()); | ||
} else { | ||
if (!hasFallback) { | ||
if (!m_skipBadFiles) { | ||
edm::Exception ex(edm::errors::FileOpenError); | ||
ex << "Input file " << filename.c_str() << " could not be opened.\n"; | ||
ex.addContext("Opening DQM Root file"); | ||
throw ex; | ||
} | ||
} | ||
if (file) { | ||
delete file; | ||
file = nullptr; | ||
} | ||
} | ||
|
||
if (!file && hasFallback) { | ||
logFileAction(" Initiating request to open fallback file ", fallbackname.c_str()); | ||
std::list<std::string> exInfo; | ||
//loop over names of a file, each of them corresponds to a data catalog | ||
bool isGoodFile(true); | ||
//get all names of a file, each of them corresponds to a data catalog | ||
const std::vector<std::string>& fNames = fileitem.fileNames(); | ||
for (std::vector<std::string>::const_iterator it = fNames.begin(); it != fNames.end(); ++it) { | ||
// Try to open a file | ||
try { | ||
{ | ||
TDirectory::TContext contextEraser; | ||
file = TFile::Open(fallbackname.c_str()); | ||
} | ||
file = TFile::Open(it->c_str()); | ||
|
||
// Exception will be trapped so we pull it out ourselves | ||
std::exception_ptr e = edm::threadLocalException::getException(); | ||
if (e != std::exception_ptr()) { | ||
edm::threadLocalException::setException(std::exception_ptr()); | ||
std::rethrow_exception(e); | ||
} | ||
|
||
} catch (cms::Exception const& e) { | ||
file = nullptr; // is there anything we need to free? | ||
if (m_skipBadFiles) { | ||
continue; | ||
} else { | ||
edm::Exception ex(edm::errors::FileOpenError, "", e); | ||
ex.addContext("Opening DQM Root file"); | ||
ex << "\nInput file " << filename << " and fallback input file " << fallbackname | ||
<< " were not found, could not be opened, or are corrupted.\n"; | ||
for (auto const& s : originalInfo) { | ||
ex.addAdditionalInfo(s); | ||
file = nullptr; // is there anything we need to free? | ||
if (std::next(it) == fNames.end()) { //last name corresponding to the last data catalog to try | ||
if (!m_skipBadFiles) { | ||
edm::Exception ex(edm::errors::FileOpenError, "", e); | ||
ex.addContext("Opening DQM Root file"); | ||
ex << "\nInput file " << it->c_str() << " was not found, could not be opened, or is corrupted.\n"; | ||
//report previous exceptions when use other names to open file | ||
for (auto const& s : exInfo) | ||
ex.addAdditionalInfo(s); | ||
throw ex; | ||
} | ||
throw ex; | ||
isGoodFile = false; | ||
} | ||
// save in case of error when trying next name | ||
for (auto const& s : e.additionalInfo()) | ||
exInfo.push_back(s); | ||
} | ||
if (not file->IsZombie()) { | ||
logFileAction(" Successfully opened fallback file ", fallbackname.c_str()); | ||
|
||
// Check if a file is usable | ||
if (file && !file->IsZombie()) { | ||
logFileAction("Successfully opened file ", it->c_str()); | ||
break; | ||
} else { | ||
if (m_skipBadFiles) { | ||
continue; | ||
} else { | ||
edm::Exception ex(edm::errors::FileOpenError); | ||
ex << "Input file " << filename << " and fallback input file " << fallbackname << " could not be opened.\n"; | ||
ex.addContext("Opening DQM Root file"); | ||
for (auto const& s : originalInfo) { | ||
ex.addAdditionalInfo(s); | ||
if (std::next(it) == fNames.end()) { | ||
if (!m_skipBadFiles) { | ||
edm::Exception ex(edm::errors::FileOpenError); | ||
ex << "Input file " << it->c_str() << " could not be opened.\n"; | ||
ex.addContext("Opening DQM Root file"); | ||
//report previous exceptions when use other names to open file | ||
for (auto const& s : exInfo) | ||
ex.addAdditionalInfo(s); | ||
throw ex; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this also need for (auto const& s : originalInfo) {
ex.addAdditionalInfo(s);
} ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added, please see above links |
||
} | ||
throw ex; | ||
isGoodFile = false; | ||
} | ||
if (file) { | ||
delete file; | ||
file = nullptr; | ||
} | ||
} | ||
} | ||
} //end loop over names of the file | ||
|
||
if (!isGoodFile && m_skipBadFiles) | ||
continue; | ||
|
||
m_openFiles.insert(m_openFiles.begin(), file); | ||
|
||
// Check file format version, which is encoded in the Title of the TFile | ||
if (strcmp(file->GetTitle(), "1") != 0) { | ||
edm::Exception ex(edm::errors::FileReadError); | ||
ex << "Input file " << filename.c_str() << " does not appear to be a DQM Root file.\n"; | ||
ex << "Input file " << fNames[0].c_str() << " does not appear to be a DQM Root file.\n"; | ||
} | ||
|
||
// Read metadata from the file | ||
|
@@ -592,7 +562,8 @@ std::unique_ptr<edm::FileBlock> DQMRootSource::readFile_() { | |
m_fileMetadatas.push_back(temp); | ||
} | ||
} | ||
} | ||
|
||
} //end loop over files | ||
|
||
// Sort to make sure runs and lumis appear in sequential order | ||
std::stable_sort(m_fileMetadatas.begin(), m_fileMetadatas.end()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,9 +42,8 @@ namespace { | |
} // namespace | ||
|
||
namespace edm { | ||
|
||
FileLocator::FileLocator(std::string const& catUrl, bool fallback) : m_destination("any") { | ||
init(catUrl, fallback); | ||
FileLocator::FileLocator(std::string const& catUrl, unsigned iCatalog) : m_destination("any") { | ||
init(catUrl, iCatalog); | ||
|
||
// std::cout << m_protocols.size() << " protocols" << std::endl; | ||
// std::cout << m_directRules[m_protocols[0]].size() << " rules" << std::endl; | ||
|
@@ -90,19 +89,18 @@ namespace edm { | |
rules[protocol].emplace_back(std::move(rule)); | ||
} | ||
|
||
void FileLocator::init(std::string const& catUrl, bool fallback) { | ||
void FileLocator::init(std::string const& catUrl, unsigned iCatalog) { | ||
std::string m_url = catUrl; | ||
|
||
if (m_url.empty()) { | ||
Service<SiteLocalConfig> localconfservice; | ||
if (!localconfservice.isAvailable()) | ||
throw cms::Exception("TrivialFileCatalog", "edm::SiteLocalConfigService is not available"); | ||
|
||
m_url = (fallback ? localconfservice->fallbackDataCatalog() : localconfservice->dataCatalog()); | ||
if (iCatalog >= localconfservice->dataCatalogs().size()) | ||
throw cms::Exception("TrivialFileCatalog", "edm::FileLocator: Request nonexistence data catalog"); | ||
m_url = localconfservice->dataCatalogs()[iCatalog]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are all the callers guaranteed to give What happens if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ok, I see an exception is thrown from `SiteLocalConfigService'. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I add exception for iCatalog >= localconfservice->dataCatalogs().size(). Actually FileLocator is only called by FWCore/Catalog/src/InputFileCatalog.cc, where this exception never happens There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, see this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks ok. |
||
} | ||
|
||
// std::cout << "Connecting to the catalog " << m_url << std::endl; | ||
|
||
if (m_url.find("file:") == std::string::npos) { | ||
throw cms::Exception("TrivialFileCatalog", | ||
"TrivialFileCatalog::connect: Malformed url for file catalog configuration"); | ||
|
@@ -164,7 +162,6 @@ namespace edm { | |
throw cms::Exception("TrivialFileCatalog") | ||
<< "tinyxml file load failed with error : " << doc.ErrorStr() << std::endl; | ||
} | ||
|
||
/* trivialFileCatalog matches the following xml schema | ||
FIXME: write a proper DTD | ||
<storage-mapping> | ||
|
@@ -175,8 +172,7 @@ namespace edm { | |
path-match="lfn/guid match regular expression" | ||
result="$1"/> | ||
</storage-mapping> | ||
*/ | ||
|
||
*/ | ||
auto rootElement = doc.RootElement(); | ||
/*first of all do the lfn-to-pfn bit*/ | ||
for (auto el = rootElement->FirstChildElement("lfn-to-pfn"); el != nullptr; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe the propagation of information from the earlier file open errors
is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, please see above link