diff --git a/scheduler/SchedulerDatabase.hpp b/scheduler/SchedulerDatabase.hpp index 0122d890619e2edf6ff40e52491761cae44706a5..097990f5202879bc56a67a505ea06abc54d935d8 100644 --- a/scheduler/SchedulerDatabase.hpp +++ b/scheduler/SchedulerDatabase.hpp @@ -543,6 +543,16 @@ public: 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)*/ + uint32_t mountCount; /**< The number of mounts for this tape pool (which is the current "chargeable" entity for quotas. */ + struct ActivityNameAndWeightedMountCount { + std::string activity; + double weight; + double weightedMountCount; + }; /**< Struct describing the activity if we have one for this mount. */ + + optional<ActivityNameAndWeightedMountCount> activityNameAndWeightedMountCount; + /**< Description if the activity for this potential mount. */ + bool operator < (const PotentialMount &other) const { if (priority < other.priority) @@ -553,8 +563,21 @@ public: return false; if (other.type == cta::common::dataStructures::MountType::ArchiveForUser && type != cta::common::dataStructures::MountType::ArchiveForUser) return true; - if (ratioOfMountQuotaUsed < other.ratioOfMountQuotaUsed) + // If we have achieved a HIGHER ratio of our mount allowance, then the other mount will be privileged + if (ratioOfMountQuotaUsed > other.ratioOfMountQuotaUsed) return true; + if (ratioOfMountQuotaUsed < other.ratioOfMountQuotaUsed) + return false; + // If we have activities (and the mounts are for the same tape pool) we can compare them. + // If not, it does not matter too much: one mount will go, increasing its ratio, and next time it will + // the tapepool. So for different tape pools, we do not order. Likewise, both mounts should have an activity to + // be comparable + if (activityNameAndWeightedMountCount && other.activityNameAndWeightedMountCount && tapePool == other.tapePool) { + if (activityNameAndWeightedMountCount.value().weightedMountCount > other.activityNameAndWeightedMountCount.value().weight) + return true; + if (activityNameAndWeightedMountCount.value().weightedMountCount < other.activityNameAndWeightedMountCount.value().weight) + return false; + } if(minRequestAge < other.minRequestAge) return true; if(minRequestAge > other.minRequestAge) @@ -585,6 +608,8 @@ public: uint64_t bytesTransferred; uint64_t filesTransferred; double latestBandwidth; + uint64_t priority; + optional<std::string> activity; }; /** diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp index a4176e7247f21a3c857b3780c98ef7ec57a3b3be..5b73e2aa9db9f4705773079eec6a79f7908d23b9 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp @@ -861,7 +861,7 @@ void RequestMessage::processDrive_Ls(cta::xrd::Response &response) std::vector<std::vector<std::string>> responseTable; std::vector<std::string> headers = { "library","drive","host","desired","request","status","since","vid","tapepool","files", - "MBytes","MB/s","session","age" + "MBytes","MB/s","session","priority","activity","age" }; responseTable.push_back(headers); @@ -928,6 +928,8 @@ void RequestMessage::processDrive_Ls(cta::xrd::Response &response) default: currentRow.push_back(std::to_string(static_cast<unsigned long long>(ds.sessionId))); } + currentRow.push_back(std::to_string(ds.currentPriority)); + currentRow.push_back(ds.currentActivityAndWeight?ds.currentActivityAndWeight.value().activity: "-"); currentRow.push_back(std::to_string(timeSinceLastUpdate_s) + (timeSinceLastUpdate_s > DRIVE_TIMEOUT ? " [STALE]" : "")); responseTable.push_back(currentRow);