/* * @project The CERN Tape Archive (CTA) * @copyright Copyright © 2021-2022 CERN * @license This program is free software, distributed under the terms of the GNU General Public * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". You can * redistribute it and/or modify it under the terms of the GPL Version 3, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * In applying this licence, CERN does not waive the privileges and immunities * granted to it by virtue of its status as an Intergovernmental Organization or * submit itself to any jurisdiction. */ #pragma once #include #include "catalogue/Catalogue.hpp" #include "common/log/LogContext.hpp" namespace cta::catalogue { /** * Wrapper around a CTA catalogue object that retries a method if a * LostConnectionException is thrown. */ class CatalogueRetryWrapper: public Catalogue { public: /** * Constructor. * * @param log Object representing the API to the CTA logging system. * @param catalogue The catalogue to be wrapped. * @param maxTriesToConnect The maximum number of times a single method should * try to connect to the database in the event of LostDatabaseConnection * exceptions being thrown. */ CatalogueRetryWrapper(log::Logger &log, std::unique_ptr catalogue, const uint32_t maxTriesToConnect = 3); CatalogueRetryWrapper(CatalogueRetryWrapper &) = delete; ~CatalogueRetryWrapper() override = default; CatalogueRetryWrapper &operator=(const CatalogueRetryWrapper &) = delete; const std::unique_ptr& Schema() override; const std::unique_ptr& AdminUser() override; const std::unique_ptr& DiskSystem() override; const std::unique_ptr& DiskInstance() override; const std::unique_ptr& DiskInstanceSpace() override; const std::unique_ptr& VO() override; const std::unique_ptr& ArchiveRoute() override; const std::unique_ptr& MediaType() override; const std::unique_ptr& StorageClass() override; const std::unique_ptr& TapePool() override; const std::unique_ptr& Tape() override; const std::unique_ptr& MountPolicy() override; const std::unique_ptr& RequesterActivityMountRule() override; const std::unique_ptr& RequesterMountRule() override; const std::unique_ptr& RequesterGroupMountRule() override; const std::unique_ptr& LogicalLibrary() override; const std::unique_ptr& PhysicalLibrary() override; const std::unique_ptr& DriveConfig() override; const std::unique_ptr& DriveState() override; const std::unique_ptr& TapeFile() override; const std::unique_ptr& FileRecycleLog() override; const std::unique_ptr& ArchiveFile() override; protected: /** * Object representing the API to the CTA logging system. */ log::Logger &m_log; /** * The wrapped catalogue. */ std::unique_ptr m_catalogue; /** * The maximum number of times a single method should try to connect to the * database in the event of LostDatabaseConnection exceptions being thrown. */ uint32_t m_maxTriesToConnect; private: std::unique_ptr m_schema; std::unique_ptr m_adminUser; std::unique_ptr m_diskSystem; std::unique_ptr m_diskInstance; std::unique_ptr m_diskInstanceSpace; std::unique_ptr m_vo; std::unique_ptr m_archiveRoute; std::unique_ptr m_mediaType; std::unique_ptr m_storageClass; std::unique_ptr m_tapePool; std::unique_ptr m_tape; std::unique_ptr m_mountPolicy; std::unique_ptr m_requesterActivityMountRule; std::unique_ptr m_requesterMountRule; std::unique_ptr m_requesterGroupMountRule; std::unique_ptr m_logicalLibrary; std::unique_ptr m_physicalLibrary; std::unique_ptr m_tapeFile; std::unique_ptr m_fileRecycleLog; std::unique_ptr m_driveConfig; std::unique_ptr m_driveState; std::unique_ptr m_archiveFile; }; // class CatalogueRetryWrapper } // namespace cta::catalogue