Commit 23c48137 authored by Eric Cano's avatar Eric Cano
Browse files

Added new function Scheduler::getQueuesAndMountSummaries() in order to implement showqueues.

Fixed a typo in a variable name.
parent 2d1ae0f0
......@@ -48,6 +48,7 @@ set (COMMON_LIB_SRC_FILES
dataStructures/LogicalLibrary.cpp
dataStructures/MountType.cpp
dataStructures/MountPolicy.cpp
dataStructures/QueueAndMountSummary.cpp
dataStructures/ReadTestResult.cpp
dataStructures/RepackInfo.cpp
dataStructures/RepackType.cpp
......
......@@ -29,8 +29,8 @@ namespace dataStructures {
//------------------------------------------------------------------------------
DriveState::DriveState():
sessionId(0),
bytesTransferedInSession(0),
filesTransferedInSession(0),
bytesTransferredInSession(0),
filesTransferredInSession(0),
latestBandwidth(0),
sessionStartTime(0),
mountStartTime(0),
......@@ -55,8 +55,8 @@ bool DriveState::operator==(const DriveState &rhs) const {
&& host==rhs.host
&& logicalLibrary==rhs.logicalLibrary
&& sessionId==rhs.sessionId
&& bytesTransferedInSession==rhs.bytesTransferedInSession
&& filesTransferedInSession==rhs.filesTransferedInSession
&& bytesTransferredInSession==rhs.bytesTransferredInSession
&& filesTransferredInSession==rhs.filesTransferredInSession
&& latestBandwidth==rhs.latestBandwidth
&& sessionStartTime==rhs.sessionStartTime
&& mountStartTime==rhs.mountStartTime
......@@ -94,8 +94,8 @@ std::ostream &operator<<(std::ostream &os, const DriveState &obj) {
<< " host=" << obj.host
<< " logicalLibrary=" << obj.logicalLibrary
<< " sessionId=" << obj.sessionId
<< " bytesTransferedInSession=" << obj.bytesTransferedInSession
<< " filesTransferedInSession=" << obj.filesTransferedInSession
<< " bytesTransferedInSession=" << obj.bytesTransferredInSession
<< " filesTransferedInSession=" << obj.filesTransferredInSession
<< " latestBandwidth=" << obj.latestBandwidth
<< " sessionStartTime=" << obj.sessionStartTime
<< " mountStartTime=" << obj.mountStartTime
......
......@@ -45,8 +45,8 @@ struct DriveState {
std::string host;
std::string logicalLibrary;
uint64_t sessionId;
uint64_t bytesTransferedInSession;
uint64_t filesTransferedInSession;
uint64_t bytesTransferredInSession;
uint64_t filesTransferredInSession;
double latestBandwidth; /** < Byte per seconds */
time_t sessionStartTime;
time_t mountStartTime;
......
/*
* 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/>.
*/
#include "QueueAndMountSummary.hpp"
#include "common/exception/Exception.hpp"
#include <set>
namespace cta {
namespace common {
namespace dataStructures {
QueueAndMountSummary& QueueAndMountSummary::getOrCreateEntry(std::list<QueueAndMountSummary> summaryList, MountType mountType, const std::string& tapePool, const std::string vid) {
for (auto & summary: summaryList) {
if ((mountType==MountType::Archive && summary.tapePool==tapePool) ||
(mountType==MountType::Retrieve && summary.vid==vid))
return summary;
}
if (std::set<MountType>({MountType::Archive, MountType::Retrieve}).count(mountType)) {
summaryList.push_back(QueueAndMountSummary());
summaryList.back().mountType=mountType;
summaryList.back().tapePool=tapePool;
if (MountType::Archive==mountType) {
summaryList.back().vid="-";
} else {
summaryList.back().vid=vid;
}
return summaryList.back();
}
throw cta::exception::Exception ("In QueueAndMountSummary::getOrCreateEntry(): Unexpected mount type.");
}
}}} //namespace cta::common::dataStructures
\ No newline at end of file
/*
* 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
#include "MountType.hpp"
#include "MountPolicy.hpp"
#include <string>
#include <list>
namespace cta {
namespace common {
namespace dataStructures {
/** This structure holds all the information regarding a VID (retrieves) */
struct QueueAndMountSummary {
MountType mountType=MountType::NoMount;
std::string tapePool;
std::string vid;
uint64_t filesQueued=0;
uint64_t bytesQueued=0;
MountPolicy mountPolicy;
uint64_t currentMounts=0;
uint64_t currentFiles=0;
uint64_t currentBytes=0;
double latestBandwidth=0;
uint64_t nextMounts=0;
uint64_t tapesCapacity=0;
uint64_t dataOnTapes=0;
uint64_t fullTapes=0;
uint64_t emptyTapes=0;
uint64_t disabledTapes=0;
uint64_t writableTapes=0;
static QueueAndMountSummary & getOrCreateEntry(std::list<QueueAndMountSummary> summaryList, MountType mountType, const std::string & tapePool, const std::string vid);
};
}}} //namespace cta::common::dataStructures
\ No newline at end of file
......@@ -113,8 +113,8 @@ std::list<cta::common::dataStructures::DriveState> DriveRegister::getAllDrivesSt
ret.back().host = d.host();
ret.back().logicalLibrary = d.logicallibrary();
ret.back().sessionId = d.sessionid();
ret.back().bytesTransferedInSession = d.bytestransferedinsession();
ret.back().filesTransferedInSession = d.filestransferedinsession();
ret.back().bytesTransferredInSession = d.bytestransferedinsession();
ret.back().filesTransferredInSession = d.filestransferedinsession();
ret.back().latestBandwidth = d.latestbandwidth();
ret.back().sessionStartTime = d.sessionstarttime();
ret.back().mountStartTime = d.mountstarttime();
......@@ -153,8 +153,8 @@ cta::common::dataStructures::DriveState DriveRegister::getDriveState(const std::
ret.host = d.host();
ret.logicalLibrary = d.logicallibrary();
ret.sessionId = d.sessionid();
ret.bytesTransferedInSession = d.bytestransferedinsession();
ret.filesTransferedInSession = d.filestransferedinsession();
ret.bytesTransferredInSession = d.bytestransferedinsession();
ret.filesTransferredInSession = d.filestransferedinsession();
ret.latestBandwidth = d.latestbandwidth();
ret.sessionStartTime = d.sessionstarttime();
ret.mountStartTime = d.mountstarttime();
......@@ -199,8 +199,8 @@ update:
ds->set_host(driveState.host);
ds->set_logicallibrary(driveState.logicalLibrary);
ds->set_sessionid(driveState.sessionId);
ds->set_bytestransferedinsession(driveState.bytesTransferedInSession);
ds->set_filestransferedinsession(driveState.filesTransferedInSession);
ds->set_bytestransferedinsession(driveState.bytesTransferredInSession);
ds->set_filestransferedinsession(driveState.filesTransferredInSession);
ds->set_latestbandwidth(driveState.latestBandwidth);
ds->set_sessionstarttime(driveState.sessionStartTime);
ds->set_mountstarttime(driveState.mountStartTime);
......
......@@ -81,25 +81,9 @@ void OStoreDB::ping() {
}
//------------------------------------------------------------------------------
// OStoreDB::getMountInfo()
// OStoreDB::fetchMountInfo()
//------------------------------------------------------------------------------
std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo>
OStoreDB::getMountInfo() {
//Allocate the getMountInfostructure to return.
assertAgentAddressSet();
std::unique_ptr<OStoreDB::TapeMountDecisionInfo> privateRet (new OStoreDB::TapeMountDecisionInfo(
m_objectStore, *m_agentReference));
TapeMountDecisionInfo & tmdi=*privateRet;
// Get all the tape pools and tapes with queues (potential mounts)
objectstore::RootEntry re(m_objectStore);
objectstore::ScopedSharedLock rel(re);
re.fetch();
// Take an exclusive lock on the scheduling and fetch it.
tmdi.m_schedulerGlobalLock.reset(
new SchedulerGlobalLock(re.getSchedulerGlobalLock(), m_objectStore));
tmdi.m_lockOnSchedulerGlobalLock.lock(*tmdi.m_schedulerGlobalLock);
tmdi.m_lockTaken = true;
tmdi.m_schedulerGlobalLock->fetch();
void OStoreDB::fetchMountInfo(SchedulerDatabase::TapeMountDecisionInfo& tmdi, RootEntry& re) {
// Walk the archive queues for statistics
for (auto & aqp: re.dumpArchiveQueues()) {
objectstore::ArchiveQueue aqueue(aqp.address, m_objectStore);
......@@ -147,7 +131,7 @@ std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo>
}
}
// Collect information about the existing and next mounts
// If a next mount exists it "counts double", but the corresponding drive
// If a next mount exists the drive "counts double", but the corresponding drive
// is either about to mount, or about to replace its current mount.
objectstore::DriveRegister dr(re.getDriveRegisterAddress(), m_objectStore);
objectstore::ScopedSharedLock drl(dr);
......@@ -172,6 +156,10 @@ std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo>
tmdi.existingOrNextMounts.back().tapePool = d->currentTapePool;
tmdi.existingOrNextMounts.back().driveName = d->driveName;
tmdi.existingOrNextMounts.back().vid = d->currentVid;
tmdi.existingOrNextMounts.back().currentMount = true;
tmdi.existingOrNextMounts.back().bytesTransferred = d->bytesTransferredInSession;
tmdi.existingOrNextMounts.back().filesTransferred = d->filesTransferredInSession;
tmdi.existingOrNextMounts.back().latestBandwidth = d->latestBandwidth;
}
if (activeMountTypes.count((int)d->nextMountType)) {
tmdi.existingOrNextMounts.push_back(ExistingMount());
......@@ -179,11 +167,76 @@ std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo>
tmdi.existingOrNextMounts.back().tapePool = d->nextTapepool;
tmdi.existingOrNextMounts.back().driveName = d->driveName;
tmdi.existingOrNextMounts.back().vid = d->nextVid;
tmdi.existingOrNextMounts.back().currentMount = false;
tmdi.existingOrNextMounts.back().bytesTransferred = 0;
tmdi.existingOrNextMounts.back().filesTransferred = 0;
tmdi.existingOrNextMounts.back().latestBandwidth = 0;
}
}
}
//------------------------------------------------------------------------------
// OStoreDB::getMountInfo()
//------------------------------------------------------------------------------
std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo>
OStoreDB::getMountInfo() {
//Allocate the getMountInfostructure to return.
assertAgentAddressSet();
std::unique_ptr<OStoreDB::TapeMountDecisionInfo> privateRet (new OStoreDB::TapeMountDecisionInfo(
m_objectStore, *m_agentReference));
TapeMountDecisionInfo & tmdi=*privateRet;
// Get all the tape pools and tapes with queues (potential mounts)
objectstore::RootEntry re(m_objectStore);
objectstore::ScopedSharedLock rel(re);
re.fetch();
// Take an exclusive lock on the scheduling and fetch it.
tmdi.m_schedulerGlobalLock.reset(
new SchedulerGlobalLock(re.getSchedulerGlobalLock(), m_objectStore));
tmdi.m_lockOnSchedulerGlobalLock.lock(*tmdi.m_schedulerGlobalLock);
tmdi.m_lockTaken = true;
tmdi.m_schedulerGlobalLock->fetch();
fetchMountInfo(tmdi, re);
std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> ret(std::move(privateRet));
return ret;
}
//------------------------------------------------------------------------------
// OStoreDB::getMountInfoNoLock()
//------------------------------------------------------------------------------
std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> OStoreDB::getMountInfoNoLock() {
//Allocate the getMountInfostructure to return.
assertAgentAddressSet();
std::unique_ptr<OStoreDB::TapeMountDecisionInfoNoLock> privateRet (new OStoreDB::TapeMountDecisionInfoNoLock);
// Get all the tape pools and tapes with queues (potential mounts)
objectstore::RootEntry re(m_objectStore);
objectstore::ScopedSharedLock rel(re);
re.fetch();
TapeMountDecisionInfoNoLock & tmdi=*privateRet;
fetchMountInfo(tmdi, re);
std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> ret(std::move(privateRet));
return ret;
}
//------------------------------------------------------------------------------
// OStoreDB::TapeMountDecisionInfoNoLock::createArchiveMount()
//------------------------------------------------------------------------------
std::unique_ptr<SchedulerDatabase::ArchiveMount> OStoreDB::TapeMountDecisionInfoNoLock::createArchiveMount(const catalogue::TapeForWriting& tape, const std::string driveName, const std::string& logicalLibrary, const std::string& hostName, time_t startTime) {
throw cta::exception::Exception("In OStoreDB::TapeMountDecisionInfoNoLock::createArchiveMount(): This function should not be called");
}
//------------------------------------------------------------------------------
// OStoreDB::TapeMountDecisionInfoNoLock::createRetrieveMount()
//------------------------------------------------------------------------------
std::unique_ptr<SchedulerDatabase::RetrieveMount> OStoreDB::TapeMountDecisionInfoNoLock::createRetrieveMount(const std::string& vid, const std::string& tapePool, const std::string driveName, const std::string& logicalLibrary, const std::string& hostName, time_t startTime) {
throw cta::exception::Exception("In OStoreDB::TapeMountDecisionInfoNoLock::createRetrieveMount(): This function should not be called");
}
//------------------------------------------------------------------------------
// OStoreDB::TapeMountDecisionInfoNoLock::~TapeMountDecisionInfoNoLock()
//------------------------------------------------------------------------------
OStoreDB::TapeMountDecisionInfoNoLock::~TapeMountDecisionInfoNoLock() {}
/* Old getMountInfo
//------------------------------------------------------------------------------
// OStoreDB::getMountInfo()
......@@ -960,8 +1013,8 @@ void OStoreDB::updateDriveStatusInRegitry(objectstore::DriveRegister& dr,
driveState.mountType = common::dataStructures::MountType::NoMount;
driveState.driveStatus = common::dataStructures::DriveStatus::Unknown;
driveState.sessionId = 0;
driveState.bytesTransferedInSession = 0;
driveState.filesTransferedInSession = 0;
driveState.bytesTransferredInSession = 0;
driveState.filesTransferredInSession = 0;
driveState.latestBandwidth = 0;
driveState.sessionStartTime = 0;
driveState.mountStartTime = 0;
......@@ -1030,8 +1083,8 @@ void OStoreDB::setDriveDown(common::dataStructures::DriveState & driveState,
}
// If we are changing state, then all should be reset.
driveState.sessionId=0;
driveState.bytesTransferedInSession=0;
driveState.filesTransferedInSession=0;
driveState.bytesTransferredInSession=0;
driveState.filesTransferredInSession=0;
driveState.latestBandwidth=0;
driveState.sessionStartTime=0;
driveState.mountStartTime=0;
......@@ -1068,8 +1121,8 @@ void OStoreDB::setDriveUpOrMaybeDown(common::dataStructures::DriveState & driveS
}
// If we are changing state, then all should be reset.
driveState.sessionId=0;
driveState.bytesTransferedInSession=0;
driveState.filesTransferedInSession=0;
driveState.bytesTransferredInSession=0;
driveState.filesTransferredInSession=0;
driveState.latestBandwidth=0;
driveState.sessionStartTime=0;
driveState.mountStartTime=0;
......@@ -1099,8 +1152,8 @@ void OStoreDB::setDriveStarting(common::dataStructures::DriveState & driveState,
// If we are changing state, then all should be reset. We are not supposed to
// know the direction yet.
driveState.sessionId=inputs.mountSessionId;
driveState.bytesTransferedInSession=0;
driveState.filesTransferedInSession=0;
driveState.bytesTransferredInSession=0;
driveState.filesTransferredInSession=0;
driveState.latestBandwidth=0;
driveState.sessionStartTime=inputs.reportTime;
driveState.mountStartTime=0;
......@@ -1130,8 +1183,8 @@ void OStoreDB::setDriveMounting(common::dataStructures::DriveState & driveState,
// If we are changing state, then all should be reset. We are not supposed to
// know the direction yet.
driveState.sessionId=inputs.mountSessionId;
driveState.bytesTransferedInSession=0;
driveState.filesTransferedInSession=0;
driveState.bytesTransferredInSession=0;
driveState.filesTransferredInSession=0;
driveState.latestBandwidth=0;
//driveState.sessionstarttime=inputs.reportTime;
driveState.mountStartTime=inputs.reportTime;
......@@ -1156,14 +1209,14 @@ void OStoreDB::setDriveTransfering(common::dataStructures::DriveState & driveSta
// If we were already transferring, we update the full statistics
if (driveState.driveStatus == common::dataStructures::DriveStatus::Transfering) {
driveState.lastUpdateTime=inputs.reportTime;
driveState.bytesTransferedInSession=inputs.byteTransfered;
driveState.filesTransferedInSession=inputs.filesTransfered;
driveState.bytesTransferredInSession=inputs.byteTransfered;
driveState.filesTransferredInSession=inputs.filesTransfered;
driveState.latestBandwidth=inputs.latestBandwidth;
return;
}
driveState.sessionId=inputs.mountSessionId;
driveState.bytesTransferedInSession=inputs.byteTransfered;
driveState.filesTransferedInSession=inputs.filesTransfered;
driveState.bytesTransferredInSession=inputs.byteTransfered;
driveState.filesTransferredInSession=inputs.filesTransfered;
driveState.latestBandwidth=inputs.latestBandwidth;
//driveState.sessionstarttime=inputs.reportTime;
//driveState.mountstarttime=inputs.reportTime;
......@@ -1192,8 +1245,8 @@ void OStoreDB::setDriveUnloading(common::dataStructures::DriveState & driveState
// If we are changing state, then all should be reset. We are not supposed to
// know the direction yet.
driveState.sessionId=inputs.mountSessionId;
driveState.bytesTransferedInSession=0;
driveState.filesTransferedInSession=0;
driveState.bytesTransferredInSession=0;
driveState.filesTransferredInSession=0;
driveState.latestBandwidth=0;
driveState.sessionStartTime=0;
driveState.mountStartTime=0;
......@@ -1222,8 +1275,8 @@ void OStoreDB::setDriveUnmounting(common::dataStructures::DriveState & driveStat
// If we are changing state, then all should be reset. We are not supposed to
// know the direction yet.
driveState.sessionId=inputs.mountSessionId;
driveState.bytesTransferedInSession=0;
driveState.filesTransferedInSession=0;
driveState.bytesTransferredInSession=0;
driveState.filesTransferredInSession=0;
driveState.latestBandwidth=0;
driveState.sessionStartTime=0;
driveState.mountStartTime=0;
......@@ -1252,8 +1305,8 @@ void OStoreDB::setDriveDrainingToDisk(common::dataStructures::DriveState & drive
// If we are changing state, then all should be reset. We are not supposed to
// know the direction yet.
driveState.sessionId=inputs.mountSessionId;
driveState.bytesTransferedInSession=0;
driveState.filesTransferedInSession=0;
driveState.bytesTransferredInSession=0;
driveState.filesTransferredInSession=0;
driveState.latestBandwidth=0;
driveState.sessionStartTime=0;
driveState.mountStartTime=0;
......@@ -1282,8 +1335,8 @@ void OStoreDB::setDriveCleaningUp(common::dataStructures::DriveState & driveStat
// If we are changing state, then all should be reset. We are not supposed to
// know the direction yet.
driveState.sessionId=inputs.mountSessionId;
driveState.bytesTransferedInSession=0;
driveState.filesTransferedInSession=0;
driveState.bytesTransferredInSession=0;
driveState.filesTransferredInSession=0;
driveState.latestBandwidth=0;
driveState.sessionStartTime=0;
driveState.mountStartTime=0;
......
......@@ -33,6 +33,7 @@ namespace cta {
namespace objectstore {
class Backend;
class Agent;
class RootEntry;
}
namespace ostoredb {
......@@ -81,9 +82,32 @@ public:
objectstore::Backend & m_objectStore;
objectstore::AgentReference & m_agentReference;
};
class TapeMountDecisionInfoNoLock: public SchedulerDatabase::TapeMountDecisionInfo {
public:
std::unique_ptr<SchedulerDatabase::ArchiveMount> createArchiveMount(
const catalogue::TapeForWriting & tape,
const std::string driveName, const std::string& logicalLibrary,
const std::string & hostName, time_t startTime) override;
std::unique_ptr<SchedulerDatabase::RetrieveMount> createRetrieveMount(
const std::string & vid, const std::string & tapePool,
const std::string driveName,
const std::string& logicalLibrary, const std::string& hostName,
time_t startTime) override;
virtual ~TapeMountDecisionInfoNoLock();
};
private:
/**
* An internal helper function with commonalities of both following functions
* @param tmdi The TapeMountDecisionInfo where to store the data.
* @param re A RootEntry object that should be locked and fetched.
*/
void fetchMountInfo(SchedulerDatabase::TapeMountDecisionInfo &tmdi, objectstore::RootEntry &re);
public:
std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> getMountInfo() override;
std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo> getMountInfoNoLock() override;
/* === Archive Mount handling ============================================= */
class ArchiveMount: public SchedulerDatabase::ArchiveMount {
friend class TapeMountDecisionInfo;
......
......@@ -127,7 +127,11 @@ public:
std::unique_ptr<TapeMountDecisionInfo> getMountInfo() override {
return m_OStoreDB.getMountInfo();
}
std::unique_ptr<TapeMountDecisionInfo> getMountInfoNoLock() override {
return m_OStoreDB.getMountInfoNoLock();
}
std::list<RetrieveQueueStatistics> getRetrieveQueueStatistics(const cta::common::dataStructures::RetrieveFileQueueCriteria& criteria,
const std::set<std::string> & vidsToConsider) override {
return m_OStoreDB.getRetrieveQueueStatistics(criteria, vidsToConsider);
......
......@@ -658,4 +658,69 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
return std::unique_ptr<TapeMount>();
}
std::list<common::dataStructures::QueueAndMountSummary> Scheduler::getQueuesAndMountSummaries(log::LogContext& lc) {
std::list<common::dataStructures::QueueAndMountSummary> ret;
// Extract relevant information from the object store.
auto mountDecisionInfo=m_db.getMountInfoNoLock();
for (auto & pm: mountDecisionInfo->potentialMounts) {
// Find or create the relevant entry.
auto & summary = common::dataStructures::QueueAndMountSummary::getOrCreateEntry(ret, pm.type, pm.tapePool, pm.vid);
switch (pm.type) {
case common::dataStructures::MountType::Archive:
summary.mountPolicy.archivePriority = pm.priority;
summary.mountPolicy.archiveMinRequestAge = pm.minArchiveRequestAge;
summary.mountPolicy.maxDrivesAllowed = pm.maxDrivesAllowed;
summary.bytesQueued = pm.bytesQueued;
summary.filesQueued = pm.filesQueued;
break;
case common::dataStructures::MountType::Retrieve:
// TODO: we should remove the retrieveMinRequestAge if it's redundant, or rename pm.minArchiveRequestAge.
summary.mountPolicy.retrieveMinRequestAge = pm.minArchiveRequestAge;
summary.mountPolicy.retrievePriority = pm.priority;
summary.mountPolicy.maxDrivesAllowed = pm.maxDrivesAllowed;
summary.bytesQueued = pm.bytesQueued;
summary.filesQueued = pm.filesQueued;
break;
default:
break;
}
}
for (auto & em: mountDecisionInfo->existingOrNextMounts) {
auto & summary = common::dataStructures::QueueAndMountSummary::getOrCreateEntry(ret, em.type, em.tapePool, em.vid);
switch (em.type) {
case common::dataStructures::MountType::Archive:
case common::dataStructures::MountType::Retrieve:
if (em.currentMount)
summary.currentMounts++;
else
summary.nextMounts++;
summary.currentBytes += em.bytesTransferred;
summary.currentFiles += em.filesTransferred;
summary.latestBandwidth += em.latestBandwidth;
break;
default:
break;
}
}
mountDecisionInfo.reset();
// Add the tape information where useful (archive queues).
for (auto & tp: ret) {
if (common::dataStructures::MountType::Archive==tp.mountType) {
// Get all the tape for this pool
cta::catalogue::TapeSearchCriteria tsc;
tsc.tapePool = tp.tapePool;
auto tapes=m_catalogue.getTapes(tsc);
for (auto & t:tapes) {
tp.tapesCapacity += t.capacityInBytes;
tp.dataOnTapes += t.dataOnTapeInBytes;
if (t.disabled) tp.disabledTapes++;
if (t.full) tp.fullTapes++;
if (!t.full && t.disabled) tp.writableTapes++;
}
}
}
return ret;
}
} // namespace cta
......@@ -40,6 +40,7 @@
#include "common/dataStructures/UpdateFileStorageClassRequest.hpp"
#include "common/dataStructures/VerifyInfo.hpp"
#include "common/dataStructures/WriteTestResult.hpp"
#include "common/dataStructures/QueueAndMountSummary.hpp"
#include "common/exception/Exception.hpp"
#include "common/log/LogContext.hpp"
......@@ -237,8 +238,21 @@ public:
std::list<cta::common::dataStructures::DriveState> getDriveStates(
const cta::common::dataStructures::SecurityIdentity &cliIdentity) const;
/*============== Actual mount scheduling ===================================*/
/*============== Actual mount scheduling and queue status reporting ========*/
/**
* Actually decide which mount to do next for a given drive.
* @param logicalLibraryName library for the drive we are scheduling
* @param driveName name of the drive we are scheduling
* @param lc log context
* @return unique pointer to the tape mount structure. Next step for the user will be find which type of mount this is.
*/
std::unique_ptr<TapeMount> getNextMount(const std::string &logicalLibraryName, const std::string &driveName, log::LogContext & lc);
/**
* A function returning
* @param lc
* @return
*/
std::list<common::dataStructures::QueueAndMountSummary> getQueuesAndMountSummaries(log::LogContext & lc);
/*============== Administrator management ==================================*/
void authorizeAdmin(const cta::common::dataStructures::SecurityIdentity &cliIdentity);
......
......@@ -401,6 +401,10 @@ public:
cta::common::dataStructures::MountType type;
std::string tapePool;
std::string vid;
bool currentMount; ///< True if the mount is current (othermise, it's a next mount).
uint64_t bytesTransferred;
uint64_t filesTransferred;
double latestBandwidth;
};
/**
...