From 0f92c4aef2bd1c2b9415532d3868afe30d92e291 Mon Sep 17 00:00:00 2001 From: Eric Cano <Eric.Cano@cern.ch> Date: Tue, 4 Jun 2019 21:31:43 +0200 Subject: [PATCH] #471 Added support for activity in drive status. --- common/dataStructures/DriveState.cpp | 38 +++++++++++++++++++++++++--- common/dataStructures/DriveState.hpp | 10 +++++++- objectstore/DriveState.cpp | 36 ++++++++++++++++++++++++++ objectstore/cta.proto | 6 +++++ scheduler/OStoreDB/OStoreDB.cpp | 1 + 5 files changed, 87 insertions(+), 4 deletions(-) diff --git a/common/dataStructures/DriveState.cpp b/common/dataStructures/DriveState.cpp index 73d83e0099..a536affd4a 100644 --- a/common/dataStructures/DriveState.cpp +++ b/common/dataStructures/DriveState.cpp @@ -47,6 +47,7 @@ DriveState::DriveState(): mountType(dataStructures::MountType::NoMount), driveStatus(dataStructures::DriveStatus::Down), desiredDriveState({false, false}), + currentPriority(0), nextMountType(dataStructures::MountType::NoMount) {} //------------------------------------------------------------------------------ @@ -77,9 +78,24 @@ bool DriveState::operator==(const DriveState &rhs) const { && desiredDriveState==rhs.desiredDriveState && currentVid==rhs.currentVid && currentTapePool==rhs.currentTapePool + && currentPriority == rhs.currentPriority + && bool(currentActivityAndWeight) == bool(rhs.currentActivityAndWeight) + && (currentActivityAndWeight? ( + currentActivityAndWeight.value().activity + == rhs.currentActivityAndWeight.value().activity + && currentActivityAndWeight.value().weight + == rhs.currentActivityAndWeight.value().weight + ): true) && nextMountType == rhs.nextMountType && nextTapepool == rhs.nextTapepool - && nextVid == rhs.nextVid; + && nextVid == rhs.nextVid + && bool(nextActivityAndWeight) == bool(rhs.nextActivityAndWeight) + && (nextActivityAndWeight? ( + nextActivityAndWeight.value().activity + == rhs.nextActivityAndWeight.value().activity + && nextActivityAndWeight.value().weight + == rhs.nextActivityAndWeight.value().weight + ): true); } //------------------------------------------------------------------------------ @@ -118,9 +134,25 @@ std::ostream &operator<<(std::ostream &os, const DriveState &obj) { << " desiredState=" << obj.desiredDriveState << " currentVid=" << obj.currentVid << " currentTapePool=" << obj.currentTapePool - << " nextMountType=" << obj.nextMountType + << " currentPriority=" << obj.currentPriority + << " currentActivity="; + if (obj.currentActivityAndWeight) { + os << "(" << obj.currentActivityAndWeight.value().activity + << "," << obj.currentActivityAndWeight.value().weight << ")"; + } else { + os << "(none)"; + } + os << " nextMountType=" << obj.nextMountType << " nextVid=" << obj.nextVid - << " nextTapePool=" << obj.nextTapepool << ")"; + << " nextTapePool=" << obj.nextTapepool + << " currentNext="; + if (obj.nextActivityAndWeight) { + os << "(" << obj.nextActivityAndWeight.value().activity + << "," << obj.nextActivityAndWeight.value().weight << ")"; + } else { + os << "(none)"; + } + os << ")"; } } // namespace dataStructures diff --git a/common/dataStructures/DriveState.hpp b/common/dataStructures/DriveState.hpp index b4568c450f..075d071899 100644 --- a/common/dataStructures/DriveState.hpp +++ b/common/dataStructures/DriveState.hpp @@ -24,6 +24,7 @@ #include "DriveStatus.hpp" #include "MountType.hpp" #include "DesiredDriveState.hpp" +#include "common/optional.hpp" namespace cta { namespace common { @@ -65,10 +66,17 @@ struct DriveState { DesiredDriveState desiredDriveState; std::string currentVid; std::string currentTapePool; + uint64_t currentPriority; + struct ActivityAndWeight { + std::string activity; + double weight; + }; + optional<ActivityAndWeight> currentActivityAndWeight; MountType nextMountType; std::string nextVid; std::string nextTapepool; - + uint64_t nextPriority; + optional<ActivityAndWeight> nextActivityAndWeight; }; // struct DriveState std::ostream &operator<<(std::ostream &os, const DriveState &obj); diff --git a/objectstore/DriveState.cpp b/objectstore/DriveState.cpp index 4ee44117dc..9a70559451 100644 --- a/objectstore/DriveState.cpp +++ b/objectstore/DriveState.cpp @@ -108,6 +108,23 @@ cta::common::dataStructures::DriveState DriveState::getState() { ret.desiredDriveState.forceDown = m_payload.desiredforcedown(); ret.currentVid = m_payload.currentvid(); ret.currentTapePool = m_payload.currenttapepool(); + ret.currentPriority = m_payload.current_priority(); + if (m_payload.has_current_activity()) + ret.currentActivityAndWeight = + cta::common::dataStructures::DriveState::ActivityAndWeight{ + m_payload.current_activity(), m_payload.current_activity_weight()}; + if (m_payload.has_nextmounttype()) + ret.nextMountType = (common::dataStructures::MountType) m_payload.nextmounttype(); + if (m_payload.has_nexttapepool()) + ret.nextTapepool = m_payload.nexttapepool(); + if (m_payload.has_nextvid()) + ret.nextVid = m_payload.nextvid(); + if (m_payload.has_next_priority()) + ret.nextPriority = m_payload.next_priority(); + if (m_payload.has_next_activity()) + ret.nextActivityAndWeight = + cta::common::dataStructures::DriveState::ActivityAndWeight{ + m_payload.next_activity(), m_payload.next_activity_weight()}; return ret; } @@ -137,6 +154,25 @@ void DriveState::setState(cta::common::dataStructures::DriveState& state) { m_payload.set_desiredforcedown(state.desiredDriveState.forceDown); m_payload.set_currentvid(state.currentVid); m_payload.set_currenttapepool(state.currentTapePool); + m_payload.set_current_priority(state.currentPriority); + if (state.currentActivityAndWeight) { + m_payload.set_current_activity(state.currentActivityAndWeight.value().activity); + m_payload.set_current_activity_weight(state.currentActivityAndWeight.value().weight); + } else { + m_payload.clear_current_activity(); + m_payload.clear_current_activity_weight(); + } + m_payload.set_nextvid(state.nextVid); + m_payload.set_nexttapepool(state.nextTapepool); + m_payload.set_next_priority(state.nextPriority); + m_payload.set_nextmounttype((uint32_t)state.nextMountType); + if (state.nextActivityAndWeight) { + m_payload.set_next_activity(state.nextActivityAndWeight.value().activity); + m_payload.set_next_activity_weight(state.nextActivityAndWeight.value().weight); + } else { + m_payload.clear_next_activity(); + m_payload.clear_next_activity_weight(); + } } }} // namespace cta::objectstore diff --git a/objectstore/cta.proto b/objectstore/cta.proto index a80c6d002a..daab502935 100644 --- a/objectstore/cta.proto +++ b/objectstore/cta.proto @@ -231,10 +231,16 @@ message DriveState { required bool desiredUp = 5019; required bool desiredForceDown = 5020; optional string currentvid = 5021; + optional uint64 current_priority = 5028; + optional string current_activity = 5029; + optional double current_activity_weight = 5030; optional string currenttapepool = 5022; optional uint32 nextmounttype = 5023; optional string nextvid = 5024; optional string nexttapepool = 5025; + optional uint64 next_priority = 5031; + optional string next_activity = 5032; + optional double next_activity_weight = 5033; // TODO: implement or remove required EntryLog creationlog = 5023; } diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index a5d1f27de1..e73982e673 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -342,6 +342,7 @@ void OStoreDB::fetchMountInfo(SchedulerDatabase::TapeMountDecisionInfo& tmdi, Ro (int)cta::common::dataStructures::DriveStatus::CleaningUp }; std::set<int> activeMountTypes = { (int)cta::common::dataStructures::MountType::ArchiveForUser, + (int)cta::common::dataStructures::MountType::ArchiveForRepack, (int)cta::common::dataStructures::MountType::Retrieve, (int)cta::common::dataStructures::MountType::Label }; for (const auto &d : driveStates) { -- GitLab