diff --git a/common/MountControl.hpp b/common/MountControl.hpp new file mode 100644 index 0000000000000000000000000000000000000000..74b98a749289d6698a768c005608edce7bda25fc --- /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 efd0b846ac23e0b974ec728cbeecb327c0d89551..dc8c9fc9ef881066ff72d4d3a0c762e902a1d0f3 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 9bec65941a4f23cc077c0079b100012d692483cd..1d07f433c74683a2a43d6728b3285695fb70372f 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 355e988be60fb24dba1096b5219a1bf3bdf66a89..fa4474dab1b0017ce9dc5d758d3cfff6a1f9a84d 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 3d5d621859d18dab676b34dca45519eaa2129e6a..a5c52bf5af1d101c26b87f8686af5b1508ef8af9 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 5f3b70bca84b0269e43b658f2bf0a99ca7ab824d..ddf6be1868b39e107e4b7f49ea92143d81cabbb9 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 2a2a800729e9449cf42334075b2b532290029af3..1dd6a9b6567f1c014041476c7b684a6cb51cef87 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 0d3d43b79896a93d02630cd2eb1d4b2cfbecb1bc..19dc28fe4526bea5d05a114bef0356d87a8ffef7 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 9de7155e15e8d191cefef776ea443cc075d06cc5..49a58d52da035820e3ae6af8fb16fcdcba7c6a9f 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 e9062d3a0b2535bd02fb1525343987f21318f57f..9e384863a787c5a0735c822427ef122b66ff71ca 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 ece3e93776f11927a2d13f5a471d5d95c203ae09..00f197cc10042523b92a2f34cdee782eb6d4f5cf 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 6b353d4d2ce82e599c97432a7f703d3265adcf5c..084814997131a2a0017ae14d2d8ebb0d72a1ff30 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 ffdf3b5a5acb7a6d090a076d44cebcee0ca83f46..4747e8b3861be1f7beffae254fbe25012d3b533a 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 a1fad3f24afacd20ab6fe7648448a2059acddfb4..7ac3e67a97f0414a641639d948703bb3b3eae624 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 7aad0c5be3e5b7ac63e2cbd2fd8618f60de61d22..1b2a729e57bef0ac06858f8398b318d682a325d6 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 3d2b7191959294cd81244a901f366ddd021c4df0..6c737c4ebbf9479e84968f4e8ac514f333a40926 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 c78a48a1082a1d1690347df552a4130b35596da2..6b3b6d064def4c316dfc3af1c4f0ba1bb81c0f03 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 77a86e7f2f7ba809af58bb6f9659ebcf1c4c5d4e..790f3129f9271ad15c9438a3784100223ff37616 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 bb6d14eac554d778cff1a872a70c3ef79206bee6..29c07614a43b695457a73faa9b6da8a04746919e 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 0f434c8611db0ce26fc171e4a9d7c23d66ce58fc..7078a7dffeea3376800b83b36183c9838e3740e2 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 c0b43b80d0d913d80f5967a0d89469c358bb76a7..59879f9694953b52dff9ca42ec24672d8a64386e 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 d973ba228d5da112a5546c7d84bde81e6006cb4b..404acfe63b0916628e2992adba55c86c4446b4a3 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 9c3e745ec3c0510a9e5c3218932a4815e20e28f1..5eea729e5d324e642190422a0272590a898bc877 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 82f407bdbe90591cc52c8992d1d5352a34c400ee..243e7e45a100d0f6b44da82a4519b7c888ac6de9 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 966e4bef8afd0eeee0e11081572985784c260b61..8c792e82e0957cb5dae6d953c472f6b67b82a90a 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 b39e2d247e21e5da7bd9edf856b9ce41e63e0b2f..96dd4dd2a1b4346c9de07a7e393f8514ce46818b 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"