diff --git a/catalogue/DummyCatalogue.hpp b/catalogue/DummyCatalogue.hpp index 83417a98289c4aa002ad5e35534ec827d861d8ca..daa1559a29a70d8a8ac35135f53350bdff540d17 100644 --- a/catalogue/DummyCatalogue.hpp +++ b/catalogue/DummyCatalogue.hpp @@ -18,6 +18,7 @@ #pragma once #include <iostream> +#include <list> #include "Catalogue.hpp" @@ -93,7 +94,6 @@ public: void deleteFileFromRecycleBin(const uint64_t archiveFileId, log::LogContext &lc) {throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");} void deleteFilesFromRecycleLog(const std::string & vid, log::LogContext & lc) {throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");} void createTapeDrive(const common::dataStructures::TapeDrive &tapeDrive) {throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");} - std::list<common::dataStructures::TapeDrive> getTapeDrives() const {throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");} void deleteTapeDrive(const std::string &tapeDriveName) {throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");} void createTapeDriveConfig(const std::string &tapeDriveName, const std::string &category, const std::string &keyName, const std::string &value, const std::string &source) {throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");} std::list<cta::catalogue::Catalogue::DriveConfig> getTapeDriveConfigs() const {throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");} @@ -266,7 +266,7 @@ public: return {m_tapeDriveStatus.driveName}; } - std::optional<common::dataStructures::TapeDrive> getTapeDrive(const std::string &tapeDriveName) const { + std::optional<common::dataStructures::TapeDrive> getTapeDrive(const std::string &tapeDriveName) const override { if (m_tapeDriveStatus.driveName != "") return m_tapeDriveStatus; common::dataStructures::TapeDrive tapeDriveStatus; const time_t reportTime = time(nullptr); @@ -290,6 +290,13 @@ public: return tapeDriveStatus; } + std::list<common::dataStructures::TapeDrive> getTapeDrives() const override { + std::list<common::dataStructures::TapeDrive> tapeDrives; + const auto tapeDrive = getTapeDrive(m_tapeDriveStatus.driveName); + if (tapeDrive.has_value()) tapeDrives.push_back(tapeDrive.value()); + return tapeDrives; + } + void setDesiredTapeDriveState(const std::string&, const common::dataStructures::DesiredDriveState &desiredState) override { m_tapeDriveStatus.desiredUp = desiredState.up; diff --git a/catalogue/TapeDrivesCatalogueState.cpp b/catalogue/TapeDrivesCatalogueState.cpp index e91aafce44c1b9e8f6ec3bb63f06b8fdfe72116c..972ac56ffa2c23e50a90d2e88430bf78c9e414e6 100644 --- a/catalogue/TapeDrivesCatalogueState.cpp +++ b/catalogue/TapeDrivesCatalogueState.cpp @@ -66,18 +66,6 @@ void TapeDrivesCatalogueState::checkDriveCanBeCreated(const cta::common::dataStr } } -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; -} - void TapeDrivesCatalogueState::removeDrive(const std::string& drive, log::LogContext &lc) { try { m_catalogue.deleteTapeDrive(drive); diff --git a/catalogue/TapeDrivesCatalogueState.hpp b/catalogue/TapeDrivesCatalogueState.hpp index 4d53954e2fd0f1960b1822898915ed0bd1fd1a34..e935d28d36b9c4fcb12ea5eef57662dffec156aa 100644 --- a/catalogue/TapeDrivesCatalogueState.hpp +++ b/catalogue/TapeDrivesCatalogueState.hpp @@ -71,7 +71,6 @@ public: const common::dataStructures::SecurityIdentity& identity, log::LogContext & lc); CTA_GENERATE_EXCEPTION_CLASS(DriveAlreadyExistsException); void checkDriveCanBeCreated(const cta::common::dataStructures::DriveInfo & driveInfo); - std::list<cta::common::dataStructures::TapeDrive> getDriveStates(log::LogContext & lc) const; void removeDrive(const std::string& drive, log::LogContext &lc); void setDesiredDriveState(const std::string& drive, const common::dataStructures::DesiredDriveState & desiredState, log::LogContext &lc); diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index a1cd9a08e49d1c307e483cc7a0431baffb1daeb1..88595b5017ab2f4be2d9caa3986c938c36b36703 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -483,7 +483,7 @@ void OStoreDB::fetchMountInfo(SchedulerDatabase::TapeMountDecisionInfo& tmdi, Ro // If a next mount exists the drive "counts double", but the corresponding drive // is either about to mount, or about to replace its current mount. double registerFetchTime = 0; - auto driveStates = m_tapeDrivesState->getDriveStates(logContext); + const auto driveStates = m_catalogue.getTapeDrives(); registerFetchTime = t.secs(utils::Timer::resetCounter); using common::dataStructures::DriveStatus; std::set<int> activeDriveStatuses = { diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index 0b0917d904d1ba96f8ed53cbfb00157184119dad..133c180117dbec60a666b61b9c6048dea2a687b6 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -757,10 +757,10 @@ void Scheduler::RepackReportBatch::report(log::LogContext& lc) { //------------------------------------------------------------------------------ common::dataStructures::DesiredDriveState Scheduler::getDesiredDriveState(const std::string& driveName, log::LogContext & lc) { utils::Timer t; - auto driveStates = m_tapeDrivesState->getDriveStates(lc); - for (auto & driveState : driveStates) { + const auto driveStates = m_catalogue.getTapeDrives(); + for (const auto & driveState : driveStates) { if (driveState.driveName == driveName) { - auto schedulerDbTime = t.secs(); + const auto schedulerDbTime = t.secs(); if (schedulerDbTime > 1) { log::ScopedParamContainer spc(lc); spc.add("drive", driveName) @@ -940,7 +940,7 @@ std::optional<cta::common::dataStructures::TapeDrive> Scheduler::getDriveState(c //------------------------------------------------------------------------------ std::list<common::dataStructures::TapeDrive> Scheduler::getDriveStates(const common::dataStructures::SecurityIdentity &cliIdentity, log::LogContext & lc) const { utils::Timer t; - auto ret = m_tapeDrivesState->getDriveStates(lc); + const auto ret = m_catalogue.getTapeDrives(); auto schedulerDbTime = t.secs(); log::ScopedParamContainer spc(lc); spc.add("schedulerDbTime", schedulerDbTime);