Commit 05de51f7 authored by Steven Murray's avatar Steven Murray
Browse files

cta/CTA#777 Minimize mounts for dual copy tape pool recalls

Simplified the code of the temporary fix.
parent 6282d0a6
...@@ -194,7 +194,7 @@ std::string Scheduler::queueRetrieve( ...@@ -194,7 +194,7 @@ std::string Scheduler::queueRetrieve(
queueCriteria = m_catalogue.prepareToRetrieveFile(instanceName, request.archiveFileID, request.requester, request.activity, lc); queueCriteria = m_catalogue.prepareToRetrieveFile(instanceName, request.archiveFileID, request.requester, request.activity, lc);
queueCriteria.archiveFile.diskFileInfo = request.diskFileInfo; queueCriteria.archiveFile.diskFileInfo = request.diskFileInfo;
// The following if statement is a temporary fix for the following CTA issue: // The following block of code is a temporary fix for the following CTA issue:
// //
// cta/CTA#777 Minimize mounts for dual copy tape pool recalls // cta/CTA#777 Minimize mounts for dual copy tape pool recalls
// //
...@@ -203,29 +203,16 @@ std::string Scheduler::queueRetrieve( ...@@ -203,29 +203,16 @@ std::string Scheduler::queueRetrieve(
// containing files with lower tape copy numbers but on the other hand it // containing files with lower tape copy numbers but on the other hand it
// reduces the number of overall number tape mounts in situations where files // reduces the number of overall number tape mounts in situations where files
// with multiple tape copies are being recalled. // with multiple tape copies are being recalled.
if (1 < queueCriteria.archiveFile.tapeFiles.size()) { {
uint8_t lowestCopyNb = std::numeric_limits<uint8_t>::max(); const auto lowestCopyNbTapeFileIter = std::min_element(
std::map<uint8_t, common::dataStructures::TapeFile> copyNbToTapeFile; queueCriteria.archiveFile.tapeFiles.begin(), queueCriteria.archiveFile.tapeFiles.end(),
for (auto tapeFile: queueCriteria.archiveFile.tapeFiles) { [](const common::dataStructures::TapeFile &a, const common::dataStructures::TapeFile &b) -> bool
if (copyNbToTapeFile.end() == copyNbToTapeFile.find(tapeFile.copyNb)) { {return a.copyNb < b.copyNb;});
if (tapeFile.copyNb < lowestCopyNb) {
lowestCopyNb = tapeFile.copyNb; if (queueCriteria.archiveFile.tapeFiles.end() != lowestCopyNbTapeFileIter) {
} const common::dataStructures::TapeFile lowestCopyNbTapeFile = *lowestCopyNbTapeFileIter;
copyNbToTapeFile[tapeFile.copyNb] = tapeFile; queueCriteria.archiveFile.tapeFiles.clear();
} else { queueCriteria.archiveFile.tapeFiles.push_back(lowestCopyNbTapeFile);
std::ostringstream msg;
msg << __FUNCTION__ << ": Found archive file with duplicate tape copy number: vid=" << tapeFile.vid <<
" copyNb=" << (uint32_t)tapeFile.copyNb;
lc.log(log::WARNING, msg.str());
}
}
if (!copyNbToTapeFile.empty()) {
const auto lowestCopyNbTapeFile = copyNbToTapeFile.find(lowestCopyNb);
if (copyNbToTapeFile.end() != lowestCopyNbTapeFile) {
queueCriteria.archiveFile.tapeFiles.clear();
queueCriteria.archiveFile.tapeFiles.push_back(lowestCopyNbTapeFile->second);
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment