Skip to content

Improve DB access to get all the Tape Drive States

Currently taking all the drive states is very inefficient with hundreds of requests to the Database. It's done like this in TapeDrivesCatalogueState.cpp

std::list<cta::common::dataStructures::TapeDrive> TapeDrivesCatalogueState::getDriveStates(
  log::LogContext & lc) const {
  std::list<cta::common::dataStructures::TapeDrive> tapeDrivesList;
  const auto driveNames = m_catalogue.getTapeDriveNames();
  for (const auto& driveName : driveNames) {
    const auto tapeDrive = m_catalogue.getTapeDrive(driveName);
    if (!tapeDrive) continue;
    tapeDrivesList.push_back(tapeDrive.value());
  }
  return tapeDrivesList;
}

Better to use this RdbmsCatalogue method: RdbmsCatalogue::getTapeDrives