From c99770cbed53c848155d8a09b320d2d2209c146a Mon Sep 17 00:00:00 2001 From: Eric Cano <Eric.Cano@cern.ch> Date: Fri, 11 Sep 2015 12:12:15 +0200 Subject: [PATCH] Added support for setting the mount criteria in the tape pools. Removed usage of the mock scheduler database that will not be updated for further modification in the scheduler database interface. --- common/MountControl.hpp | 47 +++++++++++++++++ common/TapePool.cpp | 11 ++-- common/TapePool.hpp | 7 +++ objectstore/RootEntry.hpp | 2 + objectstore/TapePool.cpp | 27 ++++------ objectstore/TapePool.hpp | 27 ++-------- objectstore/cta.proto | 14 ++--- scheduler/CMakeLists.txt | 16 +++--- scheduler/OStoreDB/OStoreDB.cpp | 51 +++++++++++-------- scheduler/OStoreDB/OStoreDB.hpp | 5 ++ scheduler/OStoreDB/OStoreDBFactory.hpp | 4 ++ scheduler/Scheduler.cpp | 12 ++++- scheduler/Scheduler.hpp | 6 ++- scheduler/SchedulerDatabase.hpp | 31 +++++------ scheduler/SchedulerDatabaseTest.cpp | 4 +- scheduler/SchedulerTest.cpp | 11 ++-- scheduler/mockDB/MockSchedulerDatabase.cpp | 2 + scheduler/mockDB/MockSchedulerDatabase.hpp | 4 ++ .../tapeserver/daemon/DataTransferSession.cpp | 5 +- .../daemon/DataTransferSessionTest.cpp | 20 ++++---- .../tapeserver/daemon/DiskWriteTaskTest.cpp | 2 +- .../daemon/DiskWriteThreadPoolTest.cpp | 2 +- .../daemon/MigrationReportPackerTest.cpp | 2 +- .../daemon/RecallReportPackerTest.cpp | 5 +- xroot_plugins/XrdProFile.cpp | 2 +- xroot_plugins/XrdProFilesystem.cpp | 2 +- 26 files changed, 194 insertions(+), 127 deletions(-) create mode 100644 common/MountControl.hpp diff --git a/common/MountControl.hpp b/common/MountControl.hpp new file mode 100644 index 0000000000..74b98a7492 --- /dev/null +++ b/common/MountControl.hpp @@ -0,0 +1,47 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2015 CERN + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +namespace cta { + /** + * Description of the criteria to mount a tape + */ + struct MountCriteria { + uint64_t maxFilesQueued; /**< The maximum number of files to be queued + * before trigerring a mount */ + uint64_t maxBytesQueued; /**< The maximum amount a data before trigerring + * a request */ + uint64_t maxAge; /**< The maximum age for a request before trigerring + * a request (in seconds) */ + uint16_t quota; /**< The maximum number of mounts for this tape pool */ + MountCriteria(uint64_t maxFiles, uint64_t maxBytes, uint64_t maxAge, + uint16_t quota): + maxFilesQueued(maxFiles), maxBytesQueued(maxBytesQueued), maxAge(maxAge), + quota(quota) {} + MountCriteria(): maxFilesQueued(0), maxBytesQueued(0), maxAge(0), quota(0) {} + }; + + struct MountCriteriaByDirection { + MountCriteria archive; + MountCriteria retrieve; + MountCriteriaByDirection(const MountCriteria& archive, const MountCriteria & retrieve): + archive(archive), retrieve(retrieve) {} + MountCriteriaByDirection(): archive(), retrieve() {} + }; +} \ No newline at end of file diff --git a/common/TapePool.cpp b/common/TapePool.cpp index efd0b846ac..dc8c9fc9ef 100644 --- a/common/TapePool.cpp +++ b/common/TapePool.cpp @@ -35,13 +35,14 @@ cta::TapePool::~TapePool() throw() { // constructor //------------------------------------------------------------------------------ cta::TapePool::TapePool( - const std::string &name, - const uint32_t nbPartialTapes, - const CreationLog &creationLog): + const std::string &name, + const uint32_t nbPartialTapes, + const MountCriteriaByDirection & mountCriteriaByDirection, + const CreationLog &creationLog): name(name), nbPartialTapes(nbPartialTapes), - creationLog(creationLog) { -} + mountCriteriaByDirection(mountCriteriaByDirection), + creationLog(creationLog) {} //------------------------------------------------------------------------------ // operator< diff --git a/common/TapePool.hpp b/common/TapePool.hpp index 9bec65941a..1d07f433c7 100644 --- a/common/TapePool.hpp +++ b/common/TapePool.hpp @@ -19,6 +19,7 @@ #pragma once #include "common/CreationLog.hpp" +#include "common/MountControl.hpp" #include <string> @@ -51,6 +52,7 @@ struct TapePool { TapePool( const std::string &name, const uint32_t nbPartialTapes, + const MountCriteriaByDirection & mountCriteriaByDirection, const CreationLog &creationLog); /** @@ -71,6 +73,11 @@ struct TapePool { */ uint32_t nbPartialTapes; + /** + * The collection of criteria for deciding (or not) to mount a tape. + */ + MountCriteriaByDirection mountCriteriaByDirection; + /** * The record of the entry's creation */ diff --git a/objectstore/RootEntry.hpp b/objectstore/RootEntry.hpp index 355e988be6..fa4474dab1 100644 --- a/objectstore/RootEntry.hpp +++ b/objectstore/RootEntry.hpp @@ -24,6 +24,7 @@ #include "ObjectOps.hpp" #include "CreationLog.hpp" #include "UserIdentity.hpp" +#include "common/MountControl.hpp" #include <list> namespace cta { namespace objectstore { @@ -147,6 +148,7 @@ public: std::string tapePool; std::string address; uint32_t nbPartialTapes; + MountCriteriaByDirection mountCriteriaByDirection; CreationLog log; }; std::list<TapePoolDump> dumpTapePools(); diff --git a/objectstore/TapePool.cpp b/objectstore/TapePool.cpp index 3d5d621859..a5c52bf5af 100644 --- a/objectstore/TapePool.cpp +++ b/objectstore/TapePool.cpp @@ -56,10 +56,8 @@ void cta::objectstore::TapePool::initialize(const std::string& name) { m_payload.mutable_retievemountcriteria()->set_maxfilesbeforemount(100000); m_payload.mutable_retievemountcriteria()->set_maxsecondsbeforemount(7*24*60*60); // Default quotas are zero. - m_payload.mutable_archivemountquota()->set_quota(0); - m_payload.mutable_archivemountquota()->set_allowedoverhead(0); - m_payload.mutable_retrievemountquota()->set_quota(0); - m_payload.mutable_retrievemountquota()->set_allowedoverhead(0); + m_payload.mutable_archivemountcriteria()->set_quota(0); + m_payload.mutable_retievemountcriteria()->set_quota(0); // default the retries to 0. m_payload.set_maxretriespermount(0); m_payload.set_maxtotalretries(0); @@ -356,28 +354,25 @@ bool cta::objectstore::TapePool::addOrphanedJobPendingNsDeletion( return true; } -cta::objectstore::TapePool::MountCriteria - cta::objectstore::TapePool::getMountCriteria() { - MountCriteria ret; +cta::MountCriteriaByDirection + cta::objectstore::TapePool::getMountCriteriaByDirection() { + MountCriteriaByDirection ret; checkPayloadReadable(); ret.archive.maxAge = m_payload.archivemountcriteria().maxsecondsbeforemount(); ret.archive.maxBytesQueued = m_payload.archivemountcriteria().maxbytesbeforemount(); ret.archive.maxFilesQueued = m_payload.archivemountcriteria().maxfilesbeforemount(); + ret.archive.quota = m_payload.archivemountcriteria().quota(); ret.retrieve.maxAge = m_payload.retievemountcriteria().maxsecondsbeforemount(); ret.retrieve.maxBytesQueued = m_payload.retievemountcriteria().maxbytesbeforemount(); ret.retrieve.maxFilesQueued = m_payload.retievemountcriteria().maxfilesbeforemount(); + ret.retrieve.quota = m_payload.retievemountcriteria().quota(); return ret; } -cta::objectstore::TapePool::MountQuota - cta::objectstore::TapePool::getMountQuota() { - checkPayloadReadable(); - MountQuota ret; - ret.archive.quota = m_payload.archivemountquota().quota(); - ret.archive.allowedOverhead = m_payload.archivemountquota().allowedoverhead(); - ret.retrieve.quota = m_payload.retrievemountquota().quota(); - ret.retrieve.allowedOverhead = m_payload.retrievemountquota().allowedoverhead(); - return ret; +void cta::objectstore::TapePool::setMountCriteriaByDirection( + const MountCriteriaByDirection& mountCriteria) { + checkPayloadWritable(); + } diff --git a/objectstore/TapePool.hpp b/objectstore/TapePool.hpp index 5f3b70bca8..ddf6be1868 100644 --- a/objectstore/TapePool.hpp +++ b/objectstore/TapePool.hpp @@ -23,6 +23,7 @@ #include <string> #include "objectstore/cta.pb.h" #include "common/CreationLog.hpp" +#include "common/MountControl.hpp" #include "ArchiveToFileRequest.hpp" #include "CreationLog.hpp" #include "Agent.hpp" @@ -104,29 +105,9 @@ public: std::list<JobDump> dumpJobs(); // Mount management ========================================================== - struct MountCriteriaPerDirection { - uint64_t maxFilesQueued; /**< The maximum number of files to be queued - * before trigerring a mount */ - uint64_t maxBytesQueued; /**< The maximum amount a data before trigerring - * a request */ - uint64_t maxAge; /**< The maximum age for a request before trigerring - * a request (in seconds) */ - }; - struct MountCriteria { - MountCriteriaPerDirection archive; - MountCriteriaPerDirection retrieve; - }; - MountCriteria getMountCriteria(); - - struct MountQuotaPerDirection { - uint16_t quota; - uint16_t allowedOverhead; - }; - struct MountQuota { - MountQuotaPerDirection archive; - MountQuotaPerDirection retrieve; - }; - MountQuota getMountQuota(); + MountCriteriaByDirection getMountCriteriaByDirection(); + void setMountCriteriaByDirection(const MountCriteriaByDirection & mountCriteria); + // Retry limits ============================================================== uint16_t getMaxRetriesWithinMount(); diff --git a/objectstore/cta.proto b/objectstore/cta.proto index 2a2a800729..1dd6a9b656 100644 --- a/objectstore/cta.proto +++ b/objectstore/cta.proto @@ -197,11 +197,7 @@ message MountCriteria { required uint64 maxFilesBeforeMount = 3200; required uint64 maxBytesBeforeMount = 3201; required uint64 maxSecondsBeforeMount = 3202; -} - -message MountQuota { - required uint32 quota = 3300; - required uint32 allowedoverhead = 3301; + required uint32 quota = 3203; } // ------------- Tape pools --------------------------------------------------- @@ -224,11 +220,9 @@ message TapePool { required uint64 oldestJobCreationTime = 4106; required MountCriteria archivemountcriteria = 4107; required MountCriteria retievemountcriteria = 4108; - required MountQuota archivemountquota = 4109; - required MountQuota retrievemountquota = 4110; - required uint64 priority = 4111; - required uint32 maxretriespermount = 4112; - required uint32 maxtotalretries = 4113; + required uint64 priority = 4109; + required uint32 maxretriespermount = 4110; + required uint32 maxtotalretries = 4111; } // ------------- Tape ---------------------------------------------------------- diff --git a/scheduler/CMakeLists.txt b/scheduler/CMakeLists.txt index 0d3d43b798..19dc28fe45 100644 --- a/scheduler/CMakeLists.txt +++ b/scheduler/CMakeLists.txt @@ -13,10 +13,10 @@ set (CTA_SCHEDULER_SRC_FILES ArchiveToTapeCopyRequest.cpp TapeMount.cpp LogicalLibrary.cpp - mockDB/MockSchedulerDatabase.cpp - mockDB/MockSchedulerDatabaseFactory.cpp - mockDB/SqliteColumnNameToIndex.cpp - mockDB/SQLiteStatementDeleter.cpp +# mockDB/MockSchedulerDatabase.cpp +# mockDB/MockSchedulerDatabaseFactory.cpp +# mockDB/SqliteColumnNameToIndex.cpp +# mockDB/SQLiteStatementDeleter.cpp MountType.cpp PositioningMethod.cpp RetrieveJob.cpp @@ -28,8 +28,8 @@ set (CTA_SCHEDULER_SRC_FILES Scheduler.cpp SchedulerDatabase.cpp SchedulerDatabaseFactory.cpp - mockDB/SqliteColumnNameToIndex.cpp - mockDB/SQLiteStatementDeleter.cpp +# mockDB/SqliteColumnNameToIndex.cpp +# mockDB/SQLiteStatementDeleter.cpp MountType.cpp UserRequest.cpp) @@ -49,8 +49,8 @@ add_library (ctaschedulerutils SHARED DummyScheduler.cpp) add_library (ctaschedulerunittests SHARED - mockDB/MockSchedulerDatabase.cpp - mockDB/MockSchedulerDatabaseFactory.cpp +# mockDB/MockSchedulerDatabase.cpp +# mockDB/MockSchedulerDatabaseFactory.cpp SchedulerDatabaseFactory.cpp SchedulerDatabaseTest.cpp SchedulerTest.cpp) diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index 9de7155e15..49a58d52da 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -103,17 +103,13 @@ std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> m.priority = tpool.getJobsSummary().priority; m.mountCriteria.maxFilesQueued = - tpool.getMountCriteria().archive.maxFilesQueued; + tpool.getMountCriteriaByDirection().archive.maxFilesQueued; m.mountCriteria.maxBytesQueued = - tpool.getMountCriteria().archive.maxBytesQueued; + tpool.getMountCriteriaByDirection().archive.maxBytesQueued; m.mountCriteria.maxAge = - tpool.getMountCriteria().archive.maxAge; - - m.mountQuota.quota = - tpool.getMountQuota().archive.quota; - m.mountQuota.allowedOverhead = - tpool.getMountQuota().archive.allowedOverhead; - + tpool.getMountCriteriaByDirection().archive.maxAge; + m.mountCriteria.quota = + tpool.getMountCriteriaByDirection().archive.quota; m.logicalLibrary = ""; } @@ -135,17 +131,13 @@ std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> m.logicalLibrary = t.getLogicalLibrary(); m.mountCriteria.maxFilesQueued = - tpool.getMountCriteria().retrieve.maxFilesQueued; + tpool.getMountCriteriaByDirection().retrieve.maxFilesQueued; m.mountCriteria.maxBytesQueued = - tpool.getMountCriteria().retrieve.maxBytesQueued; + tpool.getMountCriteriaByDirection().retrieve.maxBytesQueued; m.mountCriteria.maxAge = - tpool.getMountCriteria().retrieve.maxAge; - - m.mountQuota.quota = - tpool.getMountQuota().retrieve.quota; - m.mountQuota.allowedOverhead = - tpool.getMountQuota().retrieve.allowedOverhead; - + tpool.getMountCriteriaByDirection().retrieve.maxAge; + m.mountCriteria.quota = + tpool.getMountCriteriaByDirection().retrieve.quota; m.logicalLibrary = t.getLogicalLibrary(); } } @@ -481,8 +473,22 @@ void OStoreDB::createTapePool(const std::string& name, assertAgentSet(); re.addOrGetTapePoolAndCommit(name, nbPartialTapes, 5, 5, *m_agent, creationLog); re.commit(); + } + +void OStoreDB::setTapePoolMountCriteria(const std::string& tapePool, + const MountCriteriaByDirection& mountCriteriaByDirection) { + RootEntry re(m_objectStore); + ScopedSharedLock rel(re); + re.fetch(); + objectstore::TapePool tp(re.getTapePoolAddress(tapePool),m_objectStore); + rel.release(); + ScopedExclusiveLock tplock(tp); + tp.fetch(); + tp.setMountCriteriaByDirection(mountCriteriaByDirection); + tp.commit(); } + std::list<cta::TapePool> OStoreDB::getTapePools() const { RootEntry re(m_objectStore); ScopedSharedLock rel(re); @@ -491,7 +497,8 @@ std::list<cta::TapePool> OStoreDB::getTapePools() const { rel.release(); std::list<cta::TapePool> ret; for (auto tp=tpd.begin(); tp!=tpd.end(); tp++) { - ret.push_back(cta::TapePool(tp->tapePool, tp->nbPartialTapes, tp->log)); + ret.push_back(cta::TapePool(tp->tapePool, tp->nbPartialTapes, + tp->mountCriteriaByDirection, tp->log)); } return ret; } @@ -860,10 +867,11 @@ std::map<cta::TapePool, std::list<ArchiveToTapeCopyRequest> > auto tpl = re.dumpTapePools(); rel.release(); for (auto tpp=tpl.begin(); tpp!=tpl.end(); tpp++) { - cta::TapePool tp(tpp->tapePool, tpp->nbPartialTapes, tpp->log); objectstore::TapePool ostp(tpp->address, m_objectStore); ScopedSharedLock ostpl(ostp); ostp.fetch(); + cta::TapePool tp(tpp->tapePool, tpp->nbPartialTapes, + ostp.getMountCriteriaByDirection(), tpp->log); auto arl = ostp.dumpJobs(); ostpl.release(); for (auto ar=arl.begin(); ar!=arl.end(); ar++) { @@ -905,10 +913,11 @@ std::list<ArchiveToTapeCopyRequest> for (auto tpp=tpl.begin(); tpp!=tpl.end(); tpp++) { if (tpp->tapePool != tapePoolName) continue; std::list<ArchiveToTapeCopyRequest> ret; - cta::TapePool tp(tpp->tapePool, tpp->nbPartialTapes, tpp->log); objectstore::TapePool ostp(tpp->address, m_objectStore); ScopedSharedLock ostpl(ostp); ostp.fetch(); + cta::TapePool tp(tpp->tapePool, tpp->nbPartialTapes, + ostp.getMountCriteriaByDirection(), tpp->log); auto arl = ostp.dumpJobs(); ostpl.release(); for (auto ar=arl.begin(); ar!=arl.end(); ar++) { diff --git a/scheduler/OStoreDB/OStoreDB.hpp b/scheduler/OStoreDB/OStoreDB.hpp index e9062d3a0b..9e384863a7 100644 --- a/scheduler/OStoreDB/OStoreDB.hpp +++ b/scheduler/OStoreDB/OStoreDB.hpp @@ -155,6 +155,11 @@ public: /* === Tape pools handling =============================================== */ virtual void createTapePool(const std::string& name, const uint32_t nbPartialTapes, const cta::CreationLog &creationLog); + + + virtual void setTapePoolMountCriteria(const std::string& tapePool, + const MountCriteriaByDirection& mountCriteriaByDirection); + virtual std::list<TapePool> getTapePools() const; diff --git a/scheduler/OStoreDB/OStoreDBFactory.hpp b/scheduler/OStoreDB/OStoreDBFactory.hpp index ece3e93776..00f197cc10 100644 --- a/scheduler/OStoreDB/OStoreDBFactory.hpp +++ b/scheduler/OStoreDB/OStoreDBFactory.hpp @@ -106,6 +106,10 @@ public: virtual void createTapePool(const std::string& name, const uint32_t nbPartialTapes, const CreationLog& creationLog) { m_OStoreDB.createTapePool(name, nbPartialTapes, creationLog); } + + virtual void setTapePoolMountCriteria(const std::string& tapePool, const MountCriteriaByDirection& mountCriteriaByDirection) { + m_OStoreDB.setTapePoolMountCriteria(tapePool, mountCriteriaByDirection); + } virtual void deleteAdminHost(const SecurityIdentity& requester, const std::string& hostName) { m_OStoreDB.deleteAdminHost(requester, hostName); diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index 6b353d4d2c..0848149971 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -319,6 +319,14 @@ std::list<cta::TapePool> cta::Scheduler::getTapePools( return m_db.getTapePools(); } +//------------------------------------------------------------------------------ +// getTapePools +//------------------------------------------------------------------------------ +void cta::Scheduler::setTapePoolMountCriteria( + const std::string & tapePool, const MountCriteriaByDirection & mountCriteriaByDirection) { + return m_db.setTapePoolMountCriteria(tapePool, mountCriteriaByDirection); +} + //------------------------------------------------------------------------------ // createArchiveRoute //------------------------------------------------------------------------------ @@ -809,11 +817,11 @@ std::unique_ptr<cta::TapeMount> cta::Scheduler::getNextMount( mountPassesACriteria = true; if (!existingMounts && ((time(NULL) - m->oldestJobStartTime) > (int64_t)m->mountCriteria.maxAge)) mountPassesACriteria = true; - if (!mountPassesACriteria || existingMounts > m->mountQuota.quota) { + if (!mountPassesACriteria || existingMounts > m->mountCriteria.quota) { m = mountInfo->potentialMounts.erase(m); } else { // populate the mount with a weight - m->ratioOfMountQuotaUsed = 1.0L * existingMounts / m->mountQuota.quota; + m->ratioOfMountQuotaUsed = 1.0L * existingMounts / m->mountCriteria.quota; } } diff --git a/scheduler/Scheduler.hpp b/scheduler/Scheduler.hpp index ffdf3b5a5a..4747e8b386 100644 --- a/scheduler/Scheduler.hpp +++ b/scheduler/Scheduler.hpp @@ -332,7 +332,7 @@ public: const std::string &name, const uint32_t nbPartialTapes, const std::string &comment); - + /** * Delete the tape pool with the specifed name. * @@ -352,6 +352,10 @@ public: */ virtual std::list<TapePool> getTapePools( const SecurityIdentity &requester) const; + + /***/ + virtual void setTapePoolMountCriteria(const std::string & tapePoolName, + const MountCriteriaByDirection & mountCriteriaByDirection); /** * Creates the specified archive route. diff --git a/scheduler/SchedulerDatabase.hpp b/scheduler/SchedulerDatabase.hpp index a1fad3f24a..7ac3e67a97 100644 --- a/scheduler/SchedulerDatabase.hpp +++ b/scheduler/SchedulerDatabase.hpp @@ -26,8 +26,12 @@ #include <vector> #include <stdexcept> #include "common/archiveNS/ArchiveFile.hpp" +#include "common/admin/AdminUser.hpp" +#include "common/admin/AdminHost.hpp" +#include "common/archiveRoutes/ArchiveRoute.hpp" #include "common/remoteFS/RemotePathAndStatus.hpp" #include "scheduler/MountType.hpp" +#include "common/MountControl.hpp" namespace cta { @@ -237,25 +241,10 @@ public: }; /*============ Session management ==========================================*/ - /** * A structure describing a potential mount with all the information allowing * comparison between mounts. */ - struct MountCriteria { - uint64_t maxFilesQueued; /**< The maximum number of files to be queued - * before trigerring a mount */ - uint64_t maxBytesQueued; /**< The maximum amount a data before trigerring - * a request */ - uint64_t maxAge; /**< The maximum age for a request before trigerring - * a request (in seconds) */ - }; - - struct MountQuota { - uint16_t quota; - uint16_t allowedOverhead; - }; - struct PotentialMount { cta::MountType::Enum type; /**< Is this an archive or retireve? */ std::string vid; /**< The tape VID (for a retieve) */ @@ -264,8 +253,7 @@ public: uint64_t filesQueued; /**< The number of files queued for this queue */ uint64_t bytesQueued; /**< The amount of data currently queued */ time_t oldestJobStartTime; /**< Creation time of oldest request */ - MountCriteria mountCriteria; /**< The mount criteria collection */ - MountQuota mountQuota; /**< The mount quota collection */ + MountCriteria mountCriteria; /**< The mount criteria collection */ std::string logicalLibrary; /**< The logical library (for a retrieve) */ double ratioOfMountQuotaUsed; /**< The [ 0.0, 1.0 [ ratio of existing mounts/quota (for faire share of mounts)*/ @@ -456,7 +444,16 @@ public: const std::string &name, const uint32_t nbPartialTapes, const CreationLog& creationLog) = 0; + + /** + * Sets the mount criteria for a tape pool. + * @param tapePool tape pool name + * @param mountCriteriaByDirection the set of all the mount criteria. + */ + virtual void setTapePoolMountCriteria(const std::string & tapePool, + const MountCriteriaByDirection & mountCriteriaByDirection) = 0; + /** * Delete the tape pool with the specified name. * diff --git a/scheduler/SchedulerDatabaseTest.cpp b/scheduler/SchedulerDatabaseTest.cpp index 7aad0c5be3..1b2a729e57 100644 --- a/scheduler/SchedulerDatabaseTest.cpp +++ b/scheduler/SchedulerDatabaseTest.cpp @@ -22,8 +22,8 @@ #include "common/archiveRoutes/ArchiveRoute.hpp" #include "scheduler/ArchiveToFileRequest.hpp" #include "scheduler/RetrieveToFileRequest.hpp" -#include "scheduler/mockDB/MockSchedulerDatabase.hpp" -#include "scheduler/mockDB/MockSchedulerDatabaseFactory.hpp" +//#include "scheduler/mockDB/MockSchedulerDatabase.hpp" +//#include "scheduler/mockDB/MockSchedulerDatabaseFactory.hpp" #include "scheduler/SchedulerDatabase.hpp" #include "scheduler/SchedulerDatabaseFactory.hpp" #include "common/SecurityIdentity.hpp" diff --git a/scheduler/SchedulerTest.cpp b/scheduler/SchedulerTest.cpp index 3d2b719195..6c737c4ebb 100644 --- a/scheduler/SchedulerTest.cpp +++ b/scheduler/SchedulerTest.cpp @@ -25,7 +25,7 @@ #include "scheduler/ArchiveToFileRequest.hpp" #include "scheduler/ArchiveToTapeCopyRequest.hpp" #include "scheduler/LogicalLibrary.hpp" -#include "scheduler/mockDB/MockSchedulerDatabaseFactory.hpp" +//#include "scheduler/mockDB/MockSchedulerDatabaseFactory.hpp" #include "scheduler/MountRequest.hpp" #include "scheduler/Scheduler.hpp" #include "scheduler/SchedulerDatabase.hpp" @@ -2287,6 +2287,8 @@ TEST_P(SchedulerTest, archive_and_retrieve_new_file) { const std::string tapePoolComment = "Tape-pool comment"; ASSERT_NO_THROW(scheduler.createTapePool(s_adminOnAdminHost, tapePoolName, nbPartialTapes, tapePoolComment)); + MountCriteriaByDirection mcbd(MountCriteria(0,0,0,1), MountCriteria(0,0,0,1)); + ASSERT_NO_THROW(scheduler.setTapePoolMountCriteria("TapeTapePool", mcbd)); const std::string libraryName = "TestLogicalLibrary"; const std::string libraryComment = "Library comment"; @@ -2562,13 +2564,14 @@ TEST_P(SchedulerTest, setOwner_statFile_top_level) { ASSERT_EQ(s_user.gid, status->owner.gid); } } - - static cta::MockNameServerFactory mockNsFactory; -static cta::MockSchedulerDatabaseFactory mockDbFactory; +#undef TEST_MOCK_DB +#ifdef TEST_MOCK_DB +static cta::MockSchedulerDatabaseFactory mockDbFactory; INSTANTIATE_TEST_CASE_P(MockSchedulerTest, SchedulerTest, ::testing::Values(SchedulerTestParam(mockNsFactory, mockDbFactory))); +#endif static cta::OStoreDBFactory<cta::objectstore::BackendVFS> OStoreDBFactory; diff --git a/scheduler/mockDB/MockSchedulerDatabase.cpp b/scheduler/mockDB/MockSchedulerDatabase.cpp index c78a48a108..6b3b6d064d 100644 --- a/scheduler/mockDB/MockSchedulerDatabase.cpp +++ b/scheduler/mockDB/MockSchedulerDatabase.cpp @@ -427,6 +427,7 @@ cta::TapePool cta::MockSchedulerDatabase::getTapePool(const std::string &name) pool = TapePool( (char *)sqlite3_column_text(statement.get(),idx("NAME")), sqlite3_column_int(statement.get(),idx("NBPARTIALTAPES")), + MountCriteriaByDirection(MountCriteria(0,0,0,0),MountCriteria(0,0,0,0)), CreationLog( UserIdentity(sqlite3_column_int(statement.get(),idx("UID")), sqlite3_column_int(statement.get(),idx("GID"))), @@ -1183,6 +1184,7 @@ std::list<cta::TapePool> cta::MockSchedulerDatabase::getTapePools() const { pools.push_back(TapePool( (char *)sqlite3_column_text(statement.get(),idx("NAME")), sqlite3_column_int(statement.get(),idx("NBPARTIALTAPES")), + MountCriteriaByDirection(), CreationLog( UserIdentity(sqlite3_column_int(statement.get(),idx("UID")), sqlite3_column_int(statement.get(),idx("GID"))), diff --git a/scheduler/mockDB/MockSchedulerDatabase.hpp b/scheduler/mockDB/MockSchedulerDatabase.hpp index 77a86e7f2f..790f3129f9 100644 --- a/scheduler/mockDB/MockSchedulerDatabase.hpp +++ b/scheduler/mockDB/MockSchedulerDatabase.hpp @@ -326,6 +326,10 @@ public: const SecurityIdentity &requester, const std::string &name); + + virtual void setTapePoolMountCriteria(const std::string& tapePool, const MountCriteriaByDirection& mountCriteriaByDirection); + + /** * Gets the current list of tape pools in lexicographical order. * diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp index bb6d14eac5..29c07614a4 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp @@ -87,7 +87,10 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction // Create a sticky thread name, which will be overridden by the other threads lc.pushOrReplace(log::Param("thread", "MainThread")); // 2a) Get initial information from the client - std::unique_ptr<cta::TapeMount> tapeMount(m_scheduler.getNextMount(m_driveConfig.getLogicalLibrary(), m_driveConfig.getUnitName())); //getNextMount throws not implemented exception + std::unique_ptr<cta::TapeMount> tapeMount(m_scheduler.getNextMount(m_driveConfig.getLogicalLibrary(), m_driveConfig.getUnitName())); //getNextMount throws not implemented exception, but can return NULL + // No mount to be done found, that was fast... + if (!tapeMount.get()) + return MARK_DRIVE_AS_UP; m_volInfo.vid=tapeMount->getVid(); m_volInfo.mountType=tapeMount->getMountType(); m_volInfo.density=tapeMount->getDensity(); diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp index 0f434c8611..7078a7dffe 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp @@ -48,7 +48,7 @@ #include "nameserver/mockNS/MockNameServer.hpp" #include "remotens/MockRemoteNS.hpp" #include "scheduler/DummyScheduler.hpp" -#include "scheduler/mockDB/MockSchedulerDatabase.hpp" +#include "scheduler/OStoreDB/OStoreDBFactory.hpp" #include "scheduler/MountType.hpp" #include <dirent.h> @@ -182,7 +182,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio // 4) Create the scheduler cta::MockNameServer ns; cta::MockRemoteNS rns; - cta::MockSchedulerDatabase db; + cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest"); cta::Scheduler scheduler(ns, db, rns); // Always use the same requester @@ -327,7 +327,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio // 4) Create the scheduler cta::MockNameServer ns; cta::MockRemoteNS rns; - cta::MockSchedulerDatabase db; + cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest"); cta::Scheduler scheduler(ns, db, rns); // Always use the same requester @@ -470,7 +470,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio // 4) Create the scheduler cta::MockNameServer ns; cta::MockRemoteNS rns; - cta::MockSchedulerDatabase db; + cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest"); cta::Scheduler scheduler(ns, db, rns); // Always use the same requester @@ -516,7 +516,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio // 4) Create the scheduler cta::MockNameServer ns; cta::MockRemoteNS rns; - cta::MockSchedulerDatabase db; + cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest"); cta::Scheduler scheduler(ns, db, rns); // Always use the same requester @@ -650,7 +650,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio // 4) Create the scheduler cta::MockNameServer ns; cta::MockRemoteNS rns; - cta::MockSchedulerDatabase db; + cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest"); cta::Scheduler scheduler(ns, db, rns); // Always use the same requester @@ -803,7 +803,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio castor::server::ProcessCapDummy capUtils; cta::MockNameServer ns; cta::MockRemoteNS rns; - cta::MockSchedulerDatabase db; + cta::OStoreDB db; cta::Scheduler scheduler(ns, db, rns); DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler); @@ -882,7 +882,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio castor::server::ProcessCapDummy capUtils; cta::MockNameServer ns; cta::MockRemoteNS rns; - cta::MockSchedulerDatabase db; + cta::OStoreDB db; cta::Scheduler scheduler(ns, db, rns); DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler); @@ -973,7 +973,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio castor::server::ProcessCapDummy capUtils; cta::MockNameServer ns; cta::MockRemoteNS rns; - cta::MockSchedulerDatabase db; + cta::OStoreDB db; cta::Scheduler scheduler(ns, db, rns); DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler); @@ -1069,7 +1069,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio castor::server::ProcessCapDummy capUtils; cta::MockNameServer ns; cta::MockRemoteNS rns; - cta::MockSchedulerDatabase db; + cta::OStoreDB db; cta::Scheduler scheduler(ns, db, rns); DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler); diff --git a/tapeserver/castor/tape/tapeserver/daemon/DiskWriteTaskTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/DiskWriteTaskTest.cpp index c0b43b80d0..59879f9694 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DiskWriteTaskTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DiskWriteTaskTest.cpp @@ -29,7 +29,7 @@ #include "castor/log/StringLogger.hpp" #include "castor/tape/tapeserver/daemon/MigrationMemoryManager.hpp" #include "castor/tape/tapeserver/daemon/MemBlock.hpp" -#include "scheduler/mockDB/MockSchedulerDatabase.hpp" +//#include "scheduler/mockDB/MockSchedulerDatabase.hpp" #include "serrno.h" #include "scheduler/Scheduler.hpp" diff --git a/tapeserver/castor/tape/tapeserver/daemon/DiskWriteThreadPoolTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/DiskWriteThreadPoolTest.cpp index d973ba228d..404acfe63b 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DiskWriteThreadPoolTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DiskWriteThreadPoolTest.cpp @@ -28,7 +28,7 @@ #include "castor/log/StringLogger.hpp" #include "castor/tape/tapeserver/daemon/MigrationMemoryManager.hpp" #include "castor/tape/tapeserver/daemon/MemBlock.hpp" -#include "scheduler/mockDB/MockSchedulerDatabase.hpp" +//#include "scheduler/mockDB/MockSchedulerDatabase.hpp" #include <gtest/gtest.h> namespace unitTests{ diff --git a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPackerTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPackerTest.cpp index 9c3e745ec3..5eea729e5d 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPackerTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPackerTest.cpp @@ -25,7 +25,7 @@ #include "castor/tape/tapeserver/daemon/MigrationReportPacker.hpp" #include "castor/tape/tapeserver/drive/DriveInterface.hpp" #include "serrno.h" -#include "scheduler/mockDB/MockSchedulerDatabase.hpp" +//#include "scheduler/mockDB/MockSchedulerDatabase.hpp" #include <gtest/gtest.h> diff --git a/tapeserver/castor/tape/tapeserver/daemon/RecallReportPackerTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/RecallReportPackerTest.cpp index 82f407bdbe..243e7e45a1 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/RecallReportPackerTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/RecallReportPackerTest.cpp @@ -25,7 +25,8 @@ #include "castor/log/StringLogger.hpp" #include "common/exception/Exception.hpp" #include "serrno.h" -#include "scheduler/mockDB/MockSchedulerDatabase.hpp" +#include "scheduler/OStoreDB/OStoreDBFactory.hpp" +#include "objectstore/BackendVFS.hpp" #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -154,7 +155,7 @@ TEST_F(castor_tape_tapeserver_daemonTest, RecallReportPackerBadBadEnd) { castor::log::StringLogger log("castor_tape_tapeserver_RecallReportPackerBadBadEnd"); castor::log::LogContext lc(log); - std::unique_ptr<cta::MockSchedulerDatabase> mdb(new cta::MockSchedulerDatabase); + std::unique_ptr<cta::SchedulerDatabase> mdb(new cta::OStoreDBWrapper<cta::objectstore::BackendVFS>("UnitTest")); castor::tape::tapeserver::daemon::RecallReportPacker rrp(&retrieveMount,lc); rrp.startThreads(); diff --git a/xroot_plugins/XrdProFile.cpp b/xroot_plugins/XrdProFile.cpp index 966e4bef8a..8c792e82e0 100644 --- a/xroot_plugins/XrdProFile.cpp +++ b/xroot_plugins/XrdProFile.cpp @@ -29,7 +29,7 @@ #include "common/UserIdentity.hpp" #include "scheduler/ArchiveToTapeCopyRequest.hpp" #include "scheduler/LogicalLibrary.hpp" -#include "scheduler/mockDB/MockSchedulerDatabase.hpp" +//#include "scheduler/mockDB/MockSchedulerDatabase.hpp" #include "scheduler/RetrieveFromTapeCopyRequest.hpp" #include "scheduler/SchedulerDatabase.hpp" #include "xroot_plugins/XrdProFile.hpp" diff --git a/xroot_plugins/XrdProFilesystem.cpp b/xroot_plugins/XrdProFilesystem.cpp index b39e2d247e..96dd4dd2a1 100644 --- a/xroot_plugins/XrdProFilesystem.cpp +++ b/xroot_plugins/XrdProFilesystem.cpp @@ -27,7 +27,7 @@ #include "scheduler/ArchiveToTapeCopyRequest.hpp" #include "scheduler/LogicalLibrary.hpp" #include "scheduler/OStoreDB/OStoreDB.hpp" -#include "scheduler/mockDB/MockSchedulerDatabase.hpp" +//#include "scheduler/mockDB/MockSchedulerDatabase.hpp" #include "scheduler/RetrieveFromTapeCopyRequest.hpp" #include "common/archiveNS/StorageClass.hpp" #include "scheduler/SchedulerDatabase.hpp" -- GitLab