diff --git a/catalogue/Catalogue.hpp b/catalogue/Catalogue.hpp index d5fe31bc26ee3e31fbc6dcaab0c9cad1ff482312..91356f3c888405fde35ff47c766cd2a5cbd1e2c0 100644 --- a/catalogue/Catalogue.hpp +++ b/catalogue/Catalogue.hpp @@ -543,12 +543,9 @@ public: virtual void unlockSchema() = 0; /** - * Checks that the most trivial query goes through. Returns true on success, - * false on failure. - * - * @return True if the query went through. + * Checks that the most trivial query goes through. Throws an exception if not. */ - virtual bool ping() = 0; + virtual void ping() = 0; }; // class Catalogue diff --git a/catalogue/CatalogueTest.cpp b/catalogue/CatalogueTest.cpp index 79811873d71bd5cf8451b6b5db080a1cc38bace9..bcd6684b20ab208f81b05b0eef619549a3bcc6cc 100644 --- a/catalogue/CatalogueTest.cpp +++ b/catalogue/CatalogueTest.cpp @@ -7139,7 +7139,7 @@ TEST_P(cta_catalogue_CatalogueTest, lockSchema_unlockSchema_lockSchema) { TEST_P(cta_catalogue_CatalogueTest, ping) { using namespace cta; - ASSERT_TRUE(m_catalogue->ping()); + m_catalogue->ping(); } } // namespace unitTests diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index f3d6612f41e8a67743e644e9d73439daac923c28..dfc86e5c8a2837d8a008e12b5c7907d0cab0d223 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -4521,16 +4521,11 @@ void RdbmsCatalogue::unlockSchema() { //------------------------------------------------------------------------------ // ping //------------------------------------------------------------------------------ -bool RdbmsCatalogue::ping() { - try { - const char *const sql = "SELECT COUNT(*) FROM CTA_CATALOGUE"; - auto conn = m_connPool.getConn(); - auto stmt = conn->createStmt(sql, rdbms::Stmt::AutocommitMode::OFF); - auto rset = stmt->executeQuery(); - return true; - } catch(...) { - return false; - } +void RdbmsCatalogue::ping() { + const char *const sql = "SELECT COUNT(*) FROM CTA_CATALOGUE"; + auto conn = m_connPool.getConn(); + auto stmt = conn->createStmt(sql, rdbms::Stmt::AutocommitMode::OFF); + auto rset = stmt->executeQuery(); } } // namespace catalogue diff --git a/catalogue/RdbmsCatalogue.hpp b/catalogue/RdbmsCatalogue.hpp index a95b8ce03570c9738e4d4cd653ecccea19e3cd5d..7b14d3294a7db76b080ac51c04a0e2cb7483d2af 100644 --- a/catalogue/RdbmsCatalogue.hpp +++ b/catalogue/RdbmsCatalogue.hpp @@ -517,7 +517,7 @@ public: * * @return True if the query went through. */ - bool ping() override; + void ping() override; protected: diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index 0dcbce72a164b26b748e7e616dc0efa0dfe6e2f3..30a68324a36dd73e0b3fb05d533b3511e9ab0306 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -74,16 +74,11 @@ void OStoreDB::assertAgentAddressSet() { //------------------------------------------------------------------------------ // OStoreDB::ping() //------------------------------------------------------------------------------ -bool OStoreDB::ping() { +void OStoreDB::ping() { // Validate we can lock and fetch the root entry. - try { - objectstore::RootEntry re(m_objectStore); - objectstore::ScopedSharedLock rel(re); - re.fetch(); - return true; - } catch (cta::exception::Exception & ex) { - return false; - } + objectstore::RootEntry re(m_objectStore); + objectstore::ScopedSharedLock rel(re); + re.fetch(); } //------------------------------------------------------------------------------ diff --git a/scheduler/OStoreDB/OStoreDB.hpp b/scheduler/OStoreDB/OStoreDB.hpp index 24c1fc7593ec355ba9bb6ab0beb61c03b2e168b5..daff5451b6df9e8e20bd84d27492d9aca3a81243 100644 --- a/scheduler/OStoreDB/OStoreDB.hpp +++ b/scheduler/OStoreDB/OStoreDB.hpp @@ -48,7 +48,7 @@ public: CTA_GENERATE_EXCEPTION_CLASS(NotImplemented); /*============ Basic IO check: validate object store access ===============*/ - bool ping() override; + void ping() override; /* === Session handling =================================================== */ class TapeMountDecisionInfo: public SchedulerDatabase::TapeMountDecisionInfo { diff --git a/scheduler/OStoreDB/OStoreDBFactory.hpp b/scheduler/OStoreDB/OStoreDBFactory.hpp index 8753087fc71bf31828ab0a9b551327381808ec8c..0dd203015aa9b95a89f9a09b7705a0b677afd477 100644 --- a/scheduler/OStoreDB/OStoreDBFactory.hpp +++ b/scheduler/OStoreDB/OStoreDBFactory.hpp @@ -52,8 +52,8 @@ public: ~OStoreDBWrapper() throw () {} - bool ping() override { - return m_OStoreDB.ping(); + void ping() override { + m_OStoreDB.ping(); } void queueArchive(const std::string &instanceName, const cta::common::dataStructures::ArchiveRequest& request, const cta::common::dataStructures::ArchiveFileQueueCriteria& criteria) override { diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index 8d891d3ebb9af1441bddf16a94174f9a5ae71f6e..2f0c122db627b57eb845a38517e563563ac1080b 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -52,8 +52,9 @@ cta::Scheduler::~Scheduler() throw() { } //------------------------------------------------------------------------------ // ping //------------------------------------------------------------------------------ -bool cta::Scheduler::ping() { - return m_db.ping() && m_catalogue.ping(); +void cta::Scheduler::ping() { + m_db.ping(); + m_catalogue.ping(); } //------------------------------------------------------------------------------ diff --git a/scheduler/Scheduler.hpp b/scheduler/Scheduler.hpp index 0ca6145e8a4889e460ffb4d0944e2d473f518acd..d7c549217031f99921aafdde1a8190eb40349de3 100644 --- a/scheduler/Scheduler.hpp +++ b/scheduler/Scheduler.hpp @@ -80,9 +80,9 @@ public: /** * Validates that the underlying storages are accessible - * @return true for success, false for failure + * Lets the exception through in case of failure. */ - bool ping(); + void ping(); /** * Queue an archive request and return the CTA file ID. diff --git a/scheduler/SchedulerDatabase.hpp b/scheduler/SchedulerDatabase.hpp index 5e6441c9e4f88c255c219cf7ef6a130837483762..aeaebaa4c52544956786d1b1f6435145437afe06 100644 --- a/scheduler/SchedulerDatabase.hpp +++ b/scheduler/SchedulerDatabase.hpp @@ -89,10 +89,9 @@ public: /*============ Basic IO check: validate object store access ===============*/ /** * Validates that the scheduler database is accessible. A trivial operation - * will be executed to check. - * @return true on success and false on failure. + * will be executed to check. The exception is let through in case of problem. */ - virtual bool ping() = 0; + virtual void ping() = 0; /*============ Archive management: user side ==============================*/ /** diff --git a/tapeserver/daemon/DriveHandler.cpp b/tapeserver/daemon/DriveHandler.cpp index d68e0de3c6b8c3d66e168997bec3eda554c96511..1463aeca40d6f1244cda3df6158c564a5555b0de 100644 --- a/tapeserver/daemon/DriveHandler.cpp +++ b/tapeserver/daemon/DriveHandler.cpp @@ -876,7 +876,11 @@ int DriveHandler::runChild() { cta::Scheduler scheduler(*catalogue, *osdb, 5, 2*1000*1000); //TODO: we have hardcoded the mount policy parameters here temporarily we will remove them once we know where to put them // Before launching the transfer session, we validate that the scheduler is reachable. - if (!scheduler.ping()) { + try { + scheduler.ping(); + } catch (cta::exception::Exception &ex) { + log::ScopedParamContainer param (m_processManager.logContext()); + param.add("errorMessage", ex.getMessageValue()); m_processManager.logContext().log(log::CRIT, "In DriveHandler::runChild(): failed to ping central storage before session. Reporting fatal error."); driveHandlerProxy.reportState(tape::session::SessionState::Fatal, tape::session::SessionType::Undetermined, ""); return castor::tape::tapeserver::daemon::Session::MARK_DRIVE_AS_DOWN;