diff --git a/cmdline/CtaAdminCmd.cpp b/cmdline/CtaAdminCmd.cpp index 3825d20e1c1e0c95d6c9d522898f760e96069c15..fca4cdf39657625a2ce8d944fa399c00c42e8ecd 100644 --- a/cmdline/CtaAdminCmd.cpp +++ b/cmdline/CtaAdminCmd.cpp @@ -144,7 +144,6 @@ void IStreamBuffer<cta::xrd::Data>::DataCallback(cta::xrd::Data record) const case Data::kVersionItem: formattedText.print(record.version_item()); break; case Data::kMtlsItem: formattedText.print(record.mtls_item()); break; case Data::kRtflsItem: formattedText.print(record.rtfls_item()); break; - case Data::kSilsItem: formattedText.print(record.sils_item()); break; default: throw std::runtime_error("Received invalid stream data from CTA Frontend."); } @@ -307,7 +306,6 @@ void CtaAdminCmd::send() const case HeaderType::VIRTUALORGANIZATION_LS: formattedText.printVirtualOrganizationLsHeader(); break; case HeaderType::VERSION_CMD: formattedText.printVersionHeader(); break; case HeaderType::MEDIATYPE_LS: formattedText.printMediaTypeLsHeader(); break; - case HeaderType::SCHEDULINGINFOS_LS: formattedText.printSchedulingInfoLsHeader(); break; case HeaderType::RECYLETAPEFILE_LS: formattedText.printRecycleTapeFileLsHeader(); break; case HeaderType::NONE: default: break; diff --git a/cmdline/CtaAdminCmdParse.hpp b/cmdline/CtaAdminCmdParse.hpp index 4d1c79959365df40bae435980af33220258263c4..ed15d5f9feda33f6903611fe500ab5e0d653643b 100644 --- a/cmdline/CtaAdminCmdParse.hpp +++ b/cmdline/CtaAdminCmdParse.hpp @@ -228,8 +228,6 @@ const cmdLookup_t cmdLookup = { { "vo", AdminCmd::CMD_VIRTUALORGANIZATION }, { "version", AdminCmd::CMD_VERSION}, { "v", AdminCmd::CMD_VERSION}, - { "schedulinginfo", AdminCmd::CMD_SCHEDULINGINFOS}, - { "si", AdminCmd::CMD_SCHEDULINGINFOS}, { "recycletf", AdminCmd::CMD_RECYCLETAPEFILE}, { "rtf", AdminCmd::CMD_RECYCLETAPEFILE}, { "activitymountrule", AdminCmd::CMD_ACTIVITYMOUNTRULE }, @@ -466,7 +464,6 @@ const std::map<AdminCmd::Cmd, CmdHelp> cmdHelp = { " * Specify the maximum file size (--maxfilesize) for this virtual organization (optional, 0 means no limit)\n\n" }}, { AdminCmd::CMD_VERSION, { "version", "v", { } }}, - { AdminCmd::CMD_SCHEDULINGINFOS, { "schedulinginfo", "si", { "ls" } }}, { AdminCmd::CMD_RECYCLETAPEFILE, { "recycletf", "rtf", { "ls" }, "\n Tape files in the recycle log can be listed by VID, EOS disk file ID, EOS disk instance,\n" " ArchiveFileId or copy number. Disk file IDs should be provided in hexadecimal format (fxid).\n\n" @@ -695,7 +692,6 @@ const std::map<cmd_key_t, cmd_val_t> cmdOptions = { {{ AdminCmd::CMD_VIRTUALORGANIZATION, AdminCmd::SUBCMD_LS }, { }}, {{ AdminCmd::CMD_VERSION, AdminCmd::SUBCMD_NONE }, { }}, - {{ AdminCmd::CMD_SCHEDULINGINFOS, AdminCmd::SUBCMD_LS }, { }}, {{ AdminCmd::CMD_RECYCLETAPEFILE, AdminCmd::SUBCMD_LS }, { opt_vid.optional(), opt_fid.optional(), opt_fidfile.optional(), opt_copynb.optional(), opt_archivefileid.optional(), opt_instance.optional() }}, {{ AdminCmd::CMD_RECYCLETAPEFILE, AdminCmd::SUBCMD_RESTORE }, diff --git a/cmdline/CtaAdminTextFormatter.cpp b/cmdline/CtaAdminTextFormatter.cpp index 41f1aec17588ff7553f874252fb23364968f1640..e30aa67ab58b7e676c17f254213010fea7b5cf78 100644 --- a/cmdline/CtaAdminTextFormatter.cpp +++ b/cmdline/CtaAdminTextFormatter.cpp @@ -1157,51 +1157,6 @@ void TextFormatter::print(const VersionItem & version_item){ ); } -void TextFormatter::printSchedulingInfoLsHeader(){ - push_back("HEADER"); - push_back( - "logical library", - "vid", - "tapepool", - "vo", - "media type", - "vendor", - "mount type", - "tape capacity", - "priority", - "min request age", - "files queued", - "bytes queued", - "oldest job start time", - "sleeping mount", - "sleep time", - "disk system slept for", - "mount count" - ); -} - -void TextFormatter::print(const SchedulingInfoLsItem& sils_item) { - push_back( - sils_item.logical_library(), - sils_item.vid(), - sils_item.tapepool(), - sils_item.vo(), - sils_item.media_type(), - sils_item.vendor(), - sils_item.mount_type(), - sils_item.tape_capacity_in_bytes(), - sils_item.mount_policy_priority(), - sils_item.mount_policy_min_request_age(), - sils_item.files_queued(), - sils_item.bytes_queued(), - sils_item.oldest_job_start_time(), - sils_item.sleeping_mount(), - sils_item.sleep_time(), - sils_item.disk_system_slept_for(), - sils_item.mount_count() - ); -} - void TextFormatter::printRecycleTapeFileLsHeader() { push_back("HEADER"); push_back( diff --git a/cmdline/CtaAdminTextFormatter.hpp b/cmdline/CtaAdminTextFormatter.hpp index 8298e44ae34da8e05c34a8244ffb6d00a11ff469..7dd571fdb743a6e5492578f6c9f1ad9acafc58a9 100644 --- a/cmdline/CtaAdminTextFormatter.hpp +++ b/cmdline/CtaAdminTextFormatter.hpp @@ -69,7 +69,6 @@ public: void printVirtualOrganizationLsHeader(); void printVersionHeader(); void printMediaTypeLsHeader(); - void printSchedulingInfoLsHeader(); void printRecycleTapeFileLsHeader(); // Output records @@ -100,7 +99,6 @@ public: void print(const VersionItem & version_item); void print(const MediaTypeLsItem &mtls_item); void print(const RecycleTapeFileLsItem & rtfls_item); - void print(const SchedulingInfoLsItem& sils_item); private: //! Add a line to the buffer diff --git a/cmdline/cta-admin.1cta b/cmdline/cta-admin.1cta index 9b3d5c57b44ffb64dd4201f7e4ed0e8e61fe1fc8..9edb0c2ba8f01ae3d1aef5d10a7636420fe9ffad 100644 --- a/cmdline/cta-admin.1cta +++ b/cmdline/cta-admin.1cta @@ -103,9 +103,6 @@ progress and display any errors. requestermountrule (rmr) Add, change, remove or list the requester mount rules. .TP -schedulinginfo (si) -List information about scheduling of archive and retrieve jobs. -.TP showqueues (sq) Show the status of all active queues. .TP diff --git a/scheduler/CMakeLists.txt b/scheduler/CMakeLists.txt index d128e88ae732d8b2afc073fb7c796b2d61e84fc2..87df04ba227724d1c815002504b91bfee5f8f8ba 100644 --- a/scheduler/CMakeLists.txt +++ b/scheduler/CMakeLists.txt @@ -34,7 +34,6 @@ set (CTA_SCHEDULER_SRC_FILES Scheduler.cpp SchedulerDatabase.cpp SchedulerDatabaseFactory.cpp - SchedulingInfos.cpp TapeMount.cpp) if(NOT CTA_USE_PGSCHED) diff --git a/scheduler/GenericSchedulerTest.cpp b/scheduler/GenericSchedulerTest.cpp index 153941620041ba934ff9cf8a6684e20e88b1a76e..acdaef77cea7197c9b0c7e600d557004203407d8 100644 --- a/scheduler/GenericSchedulerTest.cpp +++ b/scheduler/GenericSchedulerTest.cpp @@ -2417,255 +2417,6 @@ TEST_P(SchedulerTest, repackRetrieveRequestsFailToFetchDiskSystem){ ASSERT_EQ(0,1); } -TEST_P(SchedulerTest, getSchedulingInformations) { - //Queue 2 archive requests in two different logical libraries - using namespace cta; - - Scheduler &scheduler = getScheduler(); - auto &catalogue = getCatalogue(); - - setupDefaultCatalogue(); - catalogue.deleteTapeDrive("drive0"); // It's not needed -#ifdef STDOUT_LOGGING - log::StdoutLogger dl("dummy", "unitTest"); -#else - log::DummyLogger dl("", ""); -#endif - log::LogContext lc(dl); - - // Create the environment for the migration to happen (library + tape) - const std::string libraryComment = "Library comment"; - const bool libraryIsDisabled = false; - catalogue.createLogicalLibrary(s_adminOnAdminHost, s_libraryName, - libraryIsDisabled, libraryComment); - { - auto libraries = catalogue.getLogicalLibraries(); - ASSERT_EQ(1, libraries.size()); - ASSERT_EQ(s_libraryName, libraries.front().name); - ASSERT_EQ(libraryComment, libraries.front().comment); - } - - { - auto tape = getDefaultTape(); - catalogue.createTape(s_adminOnAdminHost, tape); - } - - const std::string driveName = "tape_drive"; - - catalogue.tapeLabelled(s_vid, driveName); - - { - // This first initialization is normally done by the dataSession function. - cta::common::dataStructures::DriveInfo driveInfo = { driveName, "myHost", s_libraryName }; - scheduler.reportDriveStatus(driveInfo, cta::common::dataStructures::MountType::NoMount, cta::common::dataStructures::DriveStatus::Down, lc); - scheduler.reportDriveStatus(driveInfo, cta::common::dataStructures::MountType::NoMount, cta::common::dataStructures::DriveStatus::Up, lc); - } - - uint64_t archiveFileId; - - // Queue an archive request. - cta::common::dataStructures::EntryLog creationLog; - creationLog.host="host2"; - creationLog.time=0; - creationLog.username="admin1"; - cta::common::dataStructures::DiskFileInfo diskFileInfo; - diskFileInfo.gid=GROUP_2; - diskFileInfo.owner_uid=CMS_USER; - diskFileInfo.path="path/to/file"; - cta::common::dataStructures::ArchiveRequest request; - request.checksumBlob.insert(cta::checksum::ADLER32, 0x1234abcd); - request.creationLog=creationLog; - request.diskFileInfo=diskFileInfo; - request.diskFileID="diskFileID"; - request.fileSize=100*1000*1000; - cta::common::dataStructures::RequesterIdentity requester; - requester.name = s_userName; - requester.group = "userGroup"; - request.requester = requester; - request.srcURL="srcURL"; - request.storageClass=s_storageClassName; - archiveFileId = scheduler.checkAndGetNextArchiveFileId(s_diskInstance, request.storageClass, request.requester, lc); - scheduler.queueArchiveWithGivenId(archiveFileId, s_diskInstance, request, lc); - - scheduler.waitSchedulerDbSubthreadsComplete(); - - { - auto schedulerInformations = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulerInformations.empty()); - - auto & schedulerInfo = schedulerInformations.front(); - ASSERT_EQ(s_libraryName,schedulerInfo.getLogicalLibraryName()); - const auto & potentialMounts = schedulerInfo.getPotentialMounts(); - - ASSERT_FALSE(potentialMounts.empty()); - const auto & potentialMount = potentialMounts.front(); - - ASSERT_EQ(request.fileSize,potentialMount.bytesQueued); - ASSERT_EQ(0,potentialMount.capacityInBytes); - ASSERT_EQ("",potentialMount.diskSystemSleptFor); - ASSERT_EQ(1,potentialMount.filesQueued); - ASSERT_EQ(0,potentialMount.mountCount); - ASSERT_EQ(s_minArchiveRequestAge,potentialMount.minRequestAge); - ASSERT_EQ(s_archivePriority,potentialMount.priority); - ASSERT_EQ(0,potentialMount.ratioOfMountQuotaUsed); - ASSERT_EQ(0,potentialMount.sleepTime); - ASSERT_FALSE(potentialMount.sleepingMount); - ASSERT_EQ(s_tapePoolName,potentialMount.tapePool); - ASSERT_EQ(cta::common::dataStructures::MountType::ArchiveForUser,potentialMount.type); - } - - { - std::unique_ptr<cta::TapeMount> mount; - mount.reset(scheduler.getNextMount(s_libraryName, driveName, lc).release()); - ASSERT_NE(nullptr, mount.get()); - std::unique_ptr<cta::ArchiveMount> archiveMount; - archiveMount.reset(dynamic_cast<cta::ArchiveMount*>(mount.release())); - ASSERT_NE(nullptr, archiveMount.get()); - std::list<std::unique_ptr<cta::ArchiveJob>> archiveJobBatch = archiveMount->getNextJobBatch(1,1,lc); - ASSERT_NE(nullptr, archiveJobBatch.front().get()); - std::unique_ptr<ArchiveJob> archiveJob = std::move(archiveJobBatch.front()); - archiveJob->tapeFile.blockId = 1; - archiveJob->tapeFile.fSeq = 1; - archiveJob->tapeFile.checksumBlob.insert(cta::checksum::ADLER32, 0x1234abcd); - archiveJob->tapeFile.fileSize = archiveJob->archiveFile.fileSize; - archiveJob->tapeFile.copyNb = 1; - archiveJob->validate(); - std::queue<std::unique_ptr <cta::ArchiveJob >> sDBarchiveJobBatch; - std::queue<cta::catalogue::TapeItemWritten> sTapeItems; - std::queue<std::unique_ptr <cta::SchedulerDatabase::ArchiveJob >> failedToReportArchiveJobs; - sDBarchiveJobBatch.emplace(std::move(archiveJob)); - archiveMount->reportJobsBatchTransferred(sDBarchiveJobBatch, sTapeItems,failedToReportArchiveJobs, lc); - archiveJobBatch = archiveMount->getNextJobBatch(1,1,lc); - ASSERT_EQ(0, archiveJobBatch.size()); - archiveMount->complete(); - } - - ASSERT_TRUE(scheduler.getSchedulingInformations(lc).empty()); - - //Queue a retrieve request for the archived file - { - cta::common::dataStructures::EntryLog creationLog; - creationLog.host="host2"; - creationLog.time=0; - creationLog.username="admin1"; - cta::common::dataStructures::DiskFileInfo diskFileInfo; - diskFileInfo.gid=GROUP_2; - diskFileInfo.owner_uid=CMS_USER; - diskFileInfo.path="path/to/file"; - cta::common::dataStructures::RetrieveRequest request; - request.archiveFileID = archiveFileId; - request.creationLog = creationLog; - request.diskFileInfo = diskFileInfo; - request.dstURL = "dstURL"; - request.requester.name = s_userName; - request.requester.group = "userGroup"; - scheduler.queueRetrieve(s_diskInstance, request, lc); - scheduler.waitSchedulerDbSubthreadsComplete(); - } - - { - auto schedulerInformations = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulerInformations.empty()); - - auto & schedulerInfo = schedulerInformations.front(); - ASSERT_EQ(s_libraryName,schedulerInfo.getLogicalLibraryName()); - const auto & potentialMounts = schedulerInfo.getPotentialMounts(); - - ASSERT_FALSE(potentialMounts.empty()); - const auto & potentialMount = potentialMounts.front(); - - ASSERT_EQ(request.fileSize,potentialMount.bytesQueued); - ASSERT_EQ(s_mediaTypeCapacityInBytes,potentialMount.capacityInBytes); - ASSERT_EQ("",potentialMount.diskSystemSleptFor); - ASSERT_EQ(1,potentialMount.filesQueued); - ASSERT_EQ(0,potentialMount.mountCount); - ASSERT_EQ(s_minRetrieveRequestAge,potentialMount.minRequestAge); - ASSERT_EQ(s_retrievePriority,potentialMount.priority); - ASSERT_EQ(0,potentialMount.ratioOfMountQuotaUsed); - ASSERT_EQ(0,potentialMount.sleepTime); - ASSERT_FALSE(potentialMount.sleepingMount); - ASSERT_EQ(s_tapePoolName,potentialMount.tapePool); - ASSERT_EQ(cta::common::dataStructures::MountType::Retrieve,potentialMount.type); - ASSERT_EQ(s_libraryName,potentialMount.logicalLibrary); - ASSERT_EQ(s_vid,potentialMount.vid); - ASSERT_EQ(s_vo,potentialMount.vo); - } - //Now let's queue an Archive request with a high priority - //Modify the mount policy to have an equality between all values - catalogue.modifyMountPolicyArchiveMinRequestAge(s_adminOnAdminHost,s_mountPolicyName,1); - catalogue.modifyMountPolicyArchivePriority(s_adminOnAdminHost,s_mountPolicyName,1); - catalogue.modifyMountPolicyRetrieveMinRequestAge(s_adminOnAdminHost,s_mountPolicyName,1); - catalogue.modifyMountPolicyRetrievePriority(s_adminOnAdminHost,s_mountPolicyName,1); - - { - auto schedulerInformations = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulerInformations.empty()); - - // Queue an archive request. - cta::common::dataStructures::EntryLog creationLog; - creationLog.host="host2"; - creationLog.time=0; - creationLog.username="admin1"; - cta::common::dataStructures::DiskFileInfo diskFileInfo; - diskFileInfo.gid=GROUP_2; - diskFileInfo.owner_uid=CMS_USER; - diskFileInfo.path="path/to/file2"; - cta::common::dataStructures::ArchiveRequest request; - request.checksumBlob.insert(cta::checksum::ADLER32, 0xabcd1234); - request.creationLog=creationLog; - request.diskFileInfo=diskFileInfo; - request.diskFileID="diskFileID"; - request.fileSize=200*1000*1000; - cta::common::dataStructures::RequesterIdentity requester; - requester.name = s_userName; - requester.group = "userGroup"; - request.requester = requester; - request.srcURL="srcURL2"; - request.storageClass=s_storageClassName; - uint64_t archiveFileId = scheduler.checkAndGetNextArchiveFileId(s_diskInstance, request.storageClass, request.requester, lc); - scheduler.queueArchiveWithGivenId(archiveFileId, s_diskInstance, request, lc); - - scheduler.waitSchedulerDbSubthreadsComplete(); - } - - { - auto schedulingInfos = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulingInfos.empty()); - //We have only one logical library - EXPECT_EQ(1,schedulingInfos.size()); - const auto & schedulingInfo = schedulingInfos.front(); - //We have two potential mounts - auto potentialMounts = schedulingInfo.getPotentialMounts(); - ASSERT_EQ(2,potentialMounts.size()); - //The first mount should be an Archive and the second one a Retrieve as Archive is more prior than the Retrieve - auto & firstMount = potentialMounts.front(); - ASSERT_EQ(cta::common::dataStructures::MountType::ArchiveForUser,firstMount.type); - potentialMounts.pop_front(); - auto & secondMount = potentialMounts.front(); - ASSERT_EQ(cta::common::dataStructures::MountType::Retrieve,secondMount.type); - } - - //Change the mount policies to have a Retrieve priority higher than the Archive priority - catalogue.modifyMountPolicyRetrievePriority(s_adminOnAdminHost,s_mountPolicyName,10); - - { - auto schedulingInfos = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulingInfos.empty()); - //We have only one logical library - EXPECT_EQ(1,schedulingInfos.size()); - const auto & schedulingInfo = schedulingInfos.front(); - //We have two potential mounts - auto potentialMounts = schedulingInfo.getPotentialMounts(); - ASSERT_EQ(2,potentialMounts.size()); - //The first mount should be an Archive and the second one a Retrieve as Archive is more prior than the Retrieve - auto & firstMount = potentialMounts.front(); - ASSERT_EQ(cta::common::dataStructures::MountType::Retrieve,firstMount.type); - potentialMounts.pop_front(); - auto & secondMount = potentialMounts.front(); - ASSERT_EQ(cta::common::dataStructures::MountType::ArchiveForUser,secondMount.type); - } -} - TEST_P(SchedulerTest, expandRepackRequestShouldThrowIfUseBufferNotRecallButNoDirectoryCreated){ using namespace cta; unitTests::TempDirectory tempDirectory; diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index 48d9bb2445d9a0b99b2effd15b9b33b215460fc8..0b0917d904d1ba96f8ed53cbfb00157184119dad 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -1629,55 +1629,6 @@ auto logicalLibrary = getLogicalLibrary(logicalLibraryName,getLogicalLibrariesTi return std::unique_ptr<TapeMount>(); } -//------------------------------------------------------------------------------ -// getSchedulingInformations -//------------------------------------------------------------------------------ -std::list<SchedulingInfos> Scheduler::getSchedulingInformations(log::LogContext& lc) { - - std::list<SchedulingInfos> ret; - - utils::Timer timer; - double getTapeInfoTime = 0; - double candidateSortingTime = 0; - double getTapeForWriteTime = 0; - - ExistingMountSummaryPerTapepool existingMountsDistinctTypeSummaryPerTapepool; - ExistingMountSummaryPerVo existingMountBasicTypeSummaryPerVo; - std::set<std::string> tapesInUse; - std::list<catalogue::TapeForWriting> tapeList; - - //get all drive informations and sort them by logical library name - cta::common::dataStructures::SecurityIdentity admin; - auto drives = getDriveStates(admin,lc); - - std::map<std::string,std::list<std::string>> logicalLibraryDriveNamesMap; - for(auto & drive : drives){ - logicalLibraryDriveNamesMap[drive.logicalLibrary].push_back(drive.driveName); - } - - for(auto & kv: logicalLibraryDriveNamesMap){ - //get mount informations - std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> mountInfo; - mountInfo = m_db.getMountInfoNoLock(cta::SchedulerDatabase::PurposeGetMountInfo::GET_NEXT_MOUNT,lc); - std::string logicalLibrary = kv.first; - cta::SchedulingInfos schedulingInfos(logicalLibrary); - for(auto & driveName: kv.second){ - sortAndGetTapesForMountInfo(mountInfo, logicalLibrary, driveName, timer, - existingMountsDistinctTypeSummaryPerTapepool, existingMountBasicTypeSummaryPerVo, tapesInUse, tapeList, - getTapeInfoTime, candidateSortingTime, getTapeForWriteTime, lc); - //schedulingInfos.addDrivePotentialMount - std::vector<cta::SchedulerDatabase::PotentialMount> potentialMounts = mountInfo->potentialMounts; - for(auto & potentialMount: potentialMounts){ - schedulingInfos.addPotentialMount(potentialMount); - } - } - if(!schedulingInfos.getPotentialMounts().empty()){ - ret.push_back(schedulingInfos); - } - } - return ret; -} - //------------------------------------------------------------------------------ // getQueuesAndMountSummaries //------------------------------------------------------------------------------ diff --git a/scheduler/Scheduler.hpp b/scheduler/Scheduler.hpp index 80ca96dccc279422f52dbd91f7e34b14d07b926a..94cbc3ebb1b135d1085fd16d12ce763aac8f6b95 100644 --- a/scheduler/Scheduler.hpp +++ b/scheduler/Scheduler.hpp @@ -52,7 +52,6 @@ #include "disk/DiskFile.hpp" #include "disk/DiskReporter.hpp" #include "disk/DiskReporterFactory.hpp" -#include "SchedulingInfos.hpp" #include <list> #include <map> @@ -328,13 +327,6 @@ public: */ std::unique_ptr<TapeMount> getNextMount(const std::string &logicalLibraryName, const std::string &driveName, log::LogContext & lc); - /** - * Returns scheduling informations for the cta-admin schedulinginfos ls command - * @param lc the log context - * @return the list of the scheduling informations for the cta-admin schedulinginfos ls command - */ - std::list<SchedulingInfos> getSchedulingInformations(log::LogContext & lc); - /** * A function returning * @param lc diff --git a/scheduler/SchedulerTest.cpp b/scheduler/SchedulerTest.cpp index 5337a767d00da3e556bb0c40c2882e7c3958e24c..647737d9a75fbec3c03d103d47b9b0ca32788773 100644 --- a/scheduler/SchedulerTest.cpp +++ b/scheduler/SchedulerTest.cpp @@ -5307,255 +5307,6 @@ TEST_P(SchedulerTest, repackRetrieveRequestsFailToFetchDiskSystem){ */ } -TEST_P(SchedulerTest, getSchedulingInformations) { - //Queue 2 archive requests in two different logical libraries - using namespace cta; - - Scheduler &scheduler = getScheduler(); - auto &catalogue = getCatalogue(); - - setupDefaultCatalogue(); - catalogue.deleteTapeDrive("drive0"); // It's not needed -#ifdef STDOUT_LOGGING - log::StdoutLogger dl("dummy", "unitTest"); -#else - log::DummyLogger dl("", ""); -#endif - log::LogContext lc(dl); - - // Create the environment for the migration to happen (library + tape) - const std::string libraryComment = "Library comment"; - const bool libraryIsDisabled = false; - catalogue.createLogicalLibrary(s_adminOnAdminHost, s_libraryName, - libraryIsDisabled, libraryComment); - { - auto libraries = catalogue.getLogicalLibraries(); - ASSERT_EQ(1, libraries.size()); - ASSERT_EQ(s_libraryName, libraries.front().name); - ASSERT_EQ(libraryComment, libraries.front().comment); - } - - { - auto tape = getDefaultTape(); - catalogue.createTape(s_adminOnAdminHost, tape); - } - - const std::string driveName = "tape_drive"; - - catalogue.tapeLabelled(s_vid, driveName); - - { - // This first initialization is normally done by the dataSession function. - cta::common::dataStructures::DriveInfo driveInfo = { driveName, "myHost", s_libraryName }; - scheduler.reportDriveStatus(driveInfo, cta::common::dataStructures::MountType::NoMount, cta::common::dataStructures::DriveStatus::Down, lc); - scheduler.reportDriveStatus(driveInfo, cta::common::dataStructures::MountType::NoMount, cta::common::dataStructures::DriveStatus::Up, lc); - } - - uint64_t archiveFileId; - - // Queue an archive request. - cta::common::dataStructures::EntryLog creationLog; - creationLog.host="host2"; - creationLog.time=0; - creationLog.username="admin1"; - cta::common::dataStructures::DiskFileInfo diskFileInfo; - diskFileInfo.gid=GROUP_2; - diskFileInfo.owner_uid=CMS_USER; - diskFileInfo.path="path/to/file"; - cta::common::dataStructures::ArchiveRequest request; - request.checksumBlob.insert(cta::checksum::ADLER32, 0x1234abcd); - request.creationLog=creationLog; - request.diskFileInfo=diskFileInfo; - request.diskFileID="diskFileID"; - request.fileSize=100*1000*1000; - cta::common::dataStructures::RequesterIdentity requester; - requester.name = s_userName; - requester.group = "userGroup"; - request.requester = requester; - request.srcURL="srcURL"; - request.storageClass=s_storageClassName; - archiveFileId = scheduler.checkAndGetNextArchiveFileId(s_diskInstance, request.storageClass, request.requester, lc); - scheduler.queueArchiveWithGivenId(archiveFileId, s_diskInstance, request, lc); - - scheduler.waitSchedulerDbSubthreadsComplete(); - - { - auto schedulerInformations = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulerInformations.empty()); - - auto & schedulerInfo = schedulerInformations.front(); - ASSERT_EQ(s_libraryName,schedulerInfo.getLogicalLibraryName()); - const auto & potentialMounts = schedulerInfo.getPotentialMounts(); - - ASSERT_FALSE(potentialMounts.empty()); - const auto & potentialMount = potentialMounts.front(); - - ASSERT_EQ(request.fileSize,potentialMount.bytesQueued); - ASSERT_EQ(0,potentialMount.capacityInBytes); - ASSERT_EQ("",potentialMount.diskSystemSleptFor); - ASSERT_EQ(1,potentialMount.filesQueued); - ASSERT_EQ(0,potentialMount.mountCount); - ASSERT_EQ(s_minArchiveRequestAge,potentialMount.minRequestAge); - ASSERT_EQ(s_archivePriority,potentialMount.priority); - ASSERT_EQ(0,potentialMount.ratioOfMountQuotaUsed); - ASSERT_EQ(0,potentialMount.sleepTime); - ASSERT_FALSE(potentialMount.sleepingMount); - ASSERT_EQ(s_tapePoolName,potentialMount.tapePool); - ASSERT_EQ(cta::common::dataStructures::MountType::ArchiveForUser,potentialMount.type); - } - - { - std::unique_ptr<cta::TapeMount> mount; - mount.reset(scheduler.getNextMount(s_libraryName, driveName, lc).release()); - ASSERT_NE(nullptr, mount.get()); - std::unique_ptr<cta::ArchiveMount> archiveMount; - archiveMount.reset(dynamic_cast<cta::ArchiveMount*>(mount.release())); - ASSERT_NE(nullptr, archiveMount.get()); - std::list<std::unique_ptr<cta::ArchiveJob>> archiveJobBatch = archiveMount->getNextJobBatch(1,1,lc); - ASSERT_NE(nullptr, archiveJobBatch.front().get()); - std::unique_ptr<ArchiveJob> archiveJob = std::move(archiveJobBatch.front()); - archiveJob->tapeFile.blockId = 1; - archiveJob->tapeFile.fSeq = 1; - archiveJob->tapeFile.checksumBlob.insert(cta::checksum::ADLER32, 0x1234abcd); - archiveJob->tapeFile.fileSize = archiveJob->archiveFile.fileSize; - archiveJob->tapeFile.copyNb = 1; - archiveJob->validate(); - std::queue<std::unique_ptr <cta::ArchiveJob >> sDBarchiveJobBatch; - std::queue<cta::catalogue::TapeItemWritten> sTapeItems; - std::queue<std::unique_ptr <cta::SchedulerDatabase::ArchiveJob >> failedToReportArchiveJobs; - sDBarchiveJobBatch.emplace(std::move(archiveJob)); - archiveMount->reportJobsBatchTransferred(sDBarchiveJobBatch, sTapeItems,failedToReportArchiveJobs, lc); - archiveJobBatch = archiveMount->getNextJobBatch(1,1,lc); - ASSERT_EQ(0, archiveJobBatch.size()); - archiveMount->complete(); - } - - ASSERT_TRUE(scheduler.getSchedulingInformations(lc).empty()); - - //Queue a retrieve request for the archived file - { - cta::common::dataStructures::EntryLog creationLog; - creationLog.host="host2"; - creationLog.time=0; - creationLog.username="admin1"; - cta::common::dataStructures::DiskFileInfo diskFileInfo; - diskFileInfo.gid=GROUP_2; - diskFileInfo.owner_uid=CMS_USER; - diskFileInfo.path="path/to/file"; - cta::common::dataStructures::RetrieveRequest request; - request.archiveFileID = archiveFileId; - request.creationLog = creationLog; - request.diskFileInfo = diskFileInfo; - request.dstURL = "dstURL"; - request.requester.name = s_userName; - request.requester.group = "userGroup"; - scheduler.queueRetrieve(s_diskInstance, request, lc); - scheduler.waitSchedulerDbSubthreadsComplete(); - } - - { - auto schedulerInformations = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulerInformations.empty()); - - auto & schedulerInfo = schedulerInformations.front(); - ASSERT_EQ(s_libraryName,schedulerInfo.getLogicalLibraryName()); - const auto & potentialMounts = schedulerInfo.getPotentialMounts(); - - ASSERT_FALSE(potentialMounts.empty()); - const auto & potentialMount = potentialMounts.front(); - - ASSERT_EQ(request.fileSize,potentialMount.bytesQueued); - ASSERT_EQ(s_mediaTypeCapacityInBytes,potentialMount.capacityInBytes); - ASSERT_EQ("",potentialMount.diskSystemSleptFor); - ASSERT_EQ(1,potentialMount.filesQueued); - ASSERT_EQ(0,potentialMount.mountCount); - ASSERT_EQ(s_minRetrieveRequestAge,potentialMount.minRequestAge); - ASSERT_EQ(s_retrievePriority,potentialMount.priority); - ASSERT_EQ(0,potentialMount.ratioOfMountQuotaUsed); - ASSERT_EQ(0,potentialMount.sleepTime); - ASSERT_FALSE(potentialMount.sleepingMount); - ASSERT_EQ(s_tapePoolName,potentialMount.tapePool); - ASSERT_EQ(cta::common::dataStructures::MountType::Retrieve,potentialMount.type); - ASSERT_EQ(s_libraryName,potentialMount.logicalLibrary); - ASSERT_EQ(s_vid,potentialMount.vid); - ASSERT_EQ(s_vo,potentialMount.vo); - } - //Now let's queue an Archive request with a high priority - //Modify the mount policy to have an equality between all values - catalogue.modifyMountPolicyArchiveMinRequestAge(s_adminOnAdminHost,s_mountPolicyName,1); - catalogue.modifyMountPolicyArchivePriority(s_adminOnAdminHost,s_mountPolicyName,1); - catalogue.modifyMountPolicyRetrieveMinRequestAge(s_adminOnAdminHost,s_mountPolicyName,1); - catalogue.modifyMountPolicyRetrievePriority(s_adminOnAdminHost,s_mountPolicyName,1); - - { - auto schedulerInformations = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulerInformations.empty()); - - // Queue an archive request. - cta::common::dataStructures::EntryLog creationLog; - creationLog.host="host2"; - creationLog.time=0; - creationLog.username="admin1"; - cta::common::dataStructures::DiskFileInfo diskFileInfo; - diskFileInfo.gid=GROUP_2; - diskFileInfo.owner_uid=CMS_USER; - diskFileInfo.path="path/to/file2"; - cta::common::dataStructures::ArchiveRequest request; - request.checksumBlob.insert(cta::checksum::ADLER32, 0xabcd1234); - request.creationLog=creationLog; - request.diskFileInfo=diskFileInfo; - request.diskFileID="diskFileID"; - request.fileSize=200*1000*1000; - cta::common::dataStructures::RequesterIdentity requester; - requester.name = s_userName; - requester.group = "userGroup"; - request.requester = requester; - request.srcURL="srcURL2"; - request.storageClass=s_storageClassName; - uint64_t archiveFileId = scheduler.checkAndGetNextArchiveFileId(s_diskInstance, request.storageClass, request.requester, lc); - scheduler.queueArchiveWithGivenId(archiveFileId, s_diskInstance, request, lc); - - scheduler.waitSchedulerDbSubthreadsComplete(); - } - - { - auto schedulingInfos = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulingInfos.empty()); - //We have only one logical library - EXPECT_EQ(1,schedulingInfos.size()); - const auto & schedulingInfo = schedulingInfos.front(); - //We have two potential mounts - auto potentialMounts = schedulingInfo.getPotentialMounts(); - ASSERT_EQ(2,potentialMounts.size()); - //The first mount should be an Archive and the second one a Retrieve as Archive is more prior than the Retrieve - auto & firstMount = potentialMounts.front(); - ASSERT_EQ(cta::common::dataStructures::MountType::ArchiveForUser,firstMount.type); - potentialMounts.pop_front(); - auto & secondMount = potentialMounts.front(); - ASSERT_EQ(cta::common::dataStructures::MountType::Retrieve,secondMount.type); - } - - //Change the mount policies to have a Retrieve priority higher than the Archive priority - catalogue.modifyMountPolicyRetrievePriority(s_adminOnAdminHost,s_mountPolicyName,10); - - { - auto schedulingInfos = scheduler.getSchedulingInformations(lc); - ASSERT_FALSE(schedulingInfos.empty()); - //We have only one logical library - EXPECT_EQ(1,schedulingInfos.size()); - const auto & schedulingInfo = schedulingInfos.front(); - //We have two potential mounts - auto potentialMounts = schedulingInfo.getPotentialMounts(); - ASSERT_EQ(2,potentialMounts.size()); - //The first mount should be an Archive and the second one a Retrieve as Archive is more prior than the Retrieve - auto & firstMount = potentialMounts.front(); - ASSERT_EQ(cta::common::dataStructures::MountType::Retrieve,firstMount.type); - potentialMounts.pop_front(); - auto & secondMount = potentialMounts.front(); - ASSERT_EQ(cta::common::dataStructures::MountType::ArchiveForUser,secondMount.type); - } -} - TEST_P(SchedulerTest, expandRepackRequestShouldThrowIfUseBufferNotRecallButNoDirectoryCreated){ using namespace cta; unitTests::TempDirectory tempDirectory; diff --git a/scheduler/SchedulingInfos.cpp b/scheduler/SchedulingInfos.cpp deleted file mode 100644 index dfba4503023ca8bcd6b2354bdbe061f5992fe053..0000000000000000000000000000000000000000 --- a/scheduler/SchedulingInfos.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * @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. - */ - -#include "SchedulingInfos.hpp" - -namespace cta { - -SchedulingInfos::SchedulingInfos(const std::string & logicalLibraryName):m_logicalLibraryName(logicalLibraryName) { -} - -SchedulingInfos::SchedulingInfos(const SchedulingInfos& other): m_logicalLibraryName(other.m_logicalLibraryName), m_potentialMounts(other.m_potentialMounts) { -} - -SchedulingInfos & SchedulingInfos::operator =(const SchedulingInfos& other){ - m_logicalLibraryName = other.m_logicalLibraryName; - m_potentialMounts = other.m_potentialMounts; - return *this; -} - -void SchedulingInfos::addPotentialMount(const cta::SchedulerDatabase::PotentialMount& potentialMount) { - m_potentialMounts.push_back(potentialMount); -} - -std::string SchedulingInfos::getLogicalLibraryName() const { - return m_logicalLibraryName; -} - -std::list<cta::SchedulerDatabase::PotentialMount> SchedulingInfos::getPotentialMounts() const { - return m_potentialMounts; -} - -SchedulingInfos::~SchedulingInfos() { -} - -} \ No newline at end of file diff --git a/scheduler/SchedulingInfos.hpp b/scheduler/SchedulingInfos.hpp deleted file mode 100644 index 430621b764496335e57f824c15895260303aa572..0000000000000000000000000000000000000000 --- a/scheduler/SchedulingInfos.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * @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 <string> - -#include "SchedulerDatabase.hpp" - - -namespace cta { - -/** - * This class represents a scheduling information for a logical library, it is basically - * a list of potential mounts (cta::SchedulerDatabase::PotentialMount object) for a given logical library. - */ -class SchedulingInfos { -public: - /** - * Constructor - * @param logicalLibraryName the logical library - */ - SchedulingInfos(const std::string & logicalLibraryName); - /** - * Copy constructor - */ - SchedulingInfos(const SchedulingInfos& other); - /** - * Assignment operator - */ - SchedulingInfos & operator=(const SchedulingInfos & other); - /** - * Add a potential mount to this logical library scheduling informations - * @param potentialMount the potential mount to add - */ - void addPotentialMount(const cta::SchedulerDatabase::PotentialMount & potentialMount); - - /** - * Returns the list of potential mounts for this logical library - * @return a list of potential mounts for this logical library - */ - std::list<cta::SchedulerDatabase::PotentialMount> getPotentialMounts() const; - - /** - * Returns the logical library name of this SchedulingInfos instance - * @return the logical library name of this SchedulingInfos instance - */ - std::string getLogicalLibraryName() const; - - /** - * Destructor - */ - virtual ~SchedulingInfos(); -private: - std::string m_logicalLibraryName; - std::list<cta::SchedulerDatabase::PotentialMount> m_potentialMounts; -}; - -} \ No newline at end of file diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp index 8113c8e2b5a393698706f393208e78cd59ae4876..635ee667aa502202674731c7169fff4f67e2d79e 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp @@ -42,7 +42,6 @@ using XrdSsiPb::PbException; #include "XrdCtaDiskInstanceSpaceLs.hpp" #include "XrdCtaVirtualOrganizationLs.hpp" #include "XrdCtaVersion.hpp" -#include "XrdCtaSchedulingInfosLs.hpp" #include "XrdCtaRecycleTapeFileLs.hpp" #include <limits> @@ -314,9 +313,6 @@ void RequestMessage::process(const cta::xrd::Request &request, cta::xrd::Respons case cmd_pair(AdminCmd::CMD_VERSION, AdminCmd::SUBCMD_NONE): processVersion(response, stream); break; - case cmd_pair(AdminCmd::CMD_SCHEDULINGINFOS, AdminCmd::SUBCMD_LS): - processSchedulingInfos_Ls(response,stream); - break; case cmd_pair(AdminCmd::CMD_RECYCLETAPEFILE, AdminCmd::SUBCMD_LS): processRecycleTapeFile_Ls(response,stream); break; @@ -2495,15 +2491,6 @@ void RequestMessage::processVersion(cta::xrd::Response &response, XrdSsiStream * response.set_type(cta::xrd::Response::RSP_SUCCESS); } -void RequestMessage::processSchedulingInfos_Ls(cta::xrd::Response &response, XrdSsiStream * & stream) { - using namespace cta::admin; - - stream = new SchedulingInfosLsStream(*this,m_catalogue,m_scheduler,m_lc); - - response.set_show_header(HeaderType::SCHEDULINGINFOS_LS); - response.set_type(cta::xrd::Response::RSP_SUCCESS); -} - void RequestMessage::processRecycleTapeFile_Ls(cta::xrd::Response &response, XrdSsiStream * & stream) { using namespace cta::admin; diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.hpp b/xroot_plugins/XrdSsiCtaRequestMessage.hpp index 4e180e4c815302398c8f6a16c87c459c1b887713..3c8674d326e13d6e9b60e305fbd0dab532b9d5d7 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.hpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.hpp @@ -254,7 +254,6 @@ private: admincmdstream_t processDiskInstanceSpace_Ls; admincmdstream_t processVirtualOrganization_Ls; admincmdstream_t processVersion; - admincmdstream_t processSchedulingInfos_Ls; admincmdstream_t processRecycleTapeFile_Ls; /*!