Commit caa2396d authored by Eric Cano's avatar Eric Cano
Browse files

Moved cta::DriveState and cta::DrveStatus classes into cta::common.

parent c8e948c5
......@@ -20,7 +20,7 @@
#include "scheduler/MountType.hpp"
namespace cta {
namespace cta { namespace common {
enum DriveStatus {
Down,
......@@ -59,4 +59,4 @@ namespace cta {
std::string currentTapePool;
};
}
\ No newline at end of file
}} //namespace cta::common
\ No newline at end of file
......@@ -148,7 +148,8 @@ void cta::objectstore::DriveRegister::addDrive(const std::string & driveName,
}
cta::objectstore::serializers::DriveStatus
cta::objectstore::DriveRegister::serializeDriveStatus(DriveStatus driveStatus) {
cta::objectstore::DriveRegister::serializeDriveStatus(common::DriveStatus driveStatus) {
using common::DriveStatus;
switch (driveStatus) {
case DriveStatus::Down:
return serializers::DriveStatus::Down;
......@@ -173,9 +174,10 @@ cta::objectstore::serializers::DriveStatus
}
}
cta::DriveStatus
cta::common::DriveStatus
cta::objectstore::DriveRegister::deserializeDriveStatus(
serializers::DriveStatus driveStatus) {
using common::DriveStatus;
switch (driveStatus) {
case serializers::DriveStatus::Down:
return DriveStatus::Down;
......@@ -237,10 +239,11 @@ namespace {
}
void cta::objectstore::DriveRegister::reportDriveStatus(const std::string& driveName,
const std::string& logicalLibary, DriveStatus status, time_t reportTime,
const std::string& logicalLibary, common::DriveStatus status, time_t reportTime,
cta::MountType::Enum mountType, uint64_t mountSessionId, uint64_t byteTransfered,
uint64_t filesTransfered, double latestBandwidth, const std::string & vid,
const std::string & tapepool) {
using common::DriveStatus;
// Wrap all the parameters together for easier manipulation by sub-functions
ReportDriveStatusInputs inputs (driveName, logicalLibary);
inputs.mountType = mountType;
......@@ -583,6 +586,7 @@ void cta::objectstore::DriveRegister::setDriveCleaningUp(ReportDriveStatusInputs
void cta::objectstore::DriveRegister::checkReportDriveStatusInputs(
ReportDriveStatusInputs& inputs) {
using common::DriveStatus;
// Depending on the status, we might or might not expect statistics.
std::set<int> statusesRequiringStats = {
(int)DriveStatus::Transfering,
......@@ -610,12 +614,12 @@ void cta::objectstore::DriveRegister::checkReportDriveStatusInputs(
}
auto cta::objectstore::DriveRegister::dumpDrives() -> std::list<DriveState> {
auto cta::objectstore::DriveRegister::dumpDrives() -> std::list<common::DriveState> {
checkPayloadReadable();
auto & dl = m_payload.drives();
std::list<DriveState> ret;
std::list<common::DriveState> ret;
for (auto d=dl.begin(); d!=dl.end(); d++) {
ret.push_back(DriveState());
ret.push_back(common::DriveState());
auto & di = ret.back();
di.name = d->drivename();
di.logicalLibrary = d->logicallibrary();
......
......@@ -47,8 +47,8 @@ public:
private:
cta::MountType::Enum deserializeMountType(serializers::MountType);
serializers::MountType serializeMountType(cta::MountType::Enum);
DriveStatus deserializeDriveStatus(serializers::DriveStatus);
serializers::DriveStatus serializeDriveStatus(DriveStatus);
common::DriveStatus deserializeDriveStatus(serializers::DriveStatus);
serializers::DriveStatus serializeDriveStatus(common::DriveStatus);
public:
CTA_GENERATE_EXCEPTION_CLASS(MissingStatistics);
CTA_GENERATE_EXCEPTION_CLASS(MissingTapeInfo);
......@@ -60,7 +60,7 @@ public:
* Report the status of the drive to the DB.
*/
void reportDriveStatus (const std::string & drive, const std::string & logicalLibary,
DriveStatus status, time_t reportTime,
common::DriveStatus status, time_t reportTime,
cta::MountType::Enum mountType = cta::MountType::NONE,
uint64_t mountSessionId = std::numeric_limits<uint64_t>::max(),
uint64_t byteTransfered = std::numeric_limits<uint64_t>::max(),
......@@ -73,7 +73,7 @@ private:
struct ReportDriveStatusInputs {
const std::string & drive;
const std::string & logicalLibary;
DriveStatus status;
common::DriveStatus status;
cta::MountType::Enum mountType;
time_t reportTime;
uint64_t mountSessionId;
......@@ -96,7 +96,7 @@ private:
void setDriveDrainingToDisk(ReportDriveStatusInputs & inputs, serializers::DriveState * drive);
void setDriveCleaningUp(ReportDriveStatusInputs & inputs, serializers::DriveState * drive);
public:
std::list<DriveState> dumpDrives();
std::list<common::DriveState> dumpDrives();
std::string dump();
};
......
......@@ -121,6 +121,6 @@ cta::ArchiveMount::~ArchiveMount() throw() {
//------------------------------------------------------------------------------
// setDriveStatus()
//------------------------------------------------------------------------------
void cta::ArchiveMount::setDriveStatus(cta::DriveStatus status) {
void cta::ArchiveMount::setDriveStatus(cta::common::DriveStatus status) {
m_dbMount->setDriveStatus(status, time(NULL));
}
......@@ -88,7 +88,7 @@ namespace cta {
/**
* Report a drive status change
*/
virtual void setDriveStatus(cta::DriveStatus status);
virtual void setDriveStatus(cta::common::DriveStatus status);
CTA_GENERATE_EXCEPTION_CLASS(SessionNotRunning);
/**
......
......@@ -150,13 +150,14 @@ std::unique_ptr<SchedulerDatabase::TapeMountDecisionInfo>
objectstore::ScopedSharedLock drl(dr);
dr.fetch();
auto dl = dr.dumpDrives();
using common::DriveStatus;
std::set<int> activeDriveStatuses = {
(int)cta::DriveStatus::Starting,
(int)cta::DriveStatus::Mounting,
(int)cta::DriveStatus::Transfering,
(int)cta::DriveStatus::Unloading,
(int)cta::DriveStatus::Unmounting,
(int)cta::DriveStatus::DrainingToDisk };
(int)DriveStatus::Starting,
(int)DriveStatus::Mounting,
(int)DriveStatus::Transfering,
(int)DriveStatus::Unloading,
(int)DriveStatus::Unmounting,
(int)DriveStatus::DrainingToDisk };
for (auto d=dl.begin(); d!= dl.end(); d++) {
if (activeDriveStatuses.count((int)d->status)) {
tmdi.existingMounts.push_back(ExistingMount());
......@@ -1104,7 +1105,7 @@ void OStoreDB::deleteRetrieveRequest(const SecurityIdentity& requester,
throw exception::Exception("Not Implemented");
}
std::list<cta::DriveState> OStoreDB::getDriveStates() const {
std::list<cta::common::DriveState> OStoreDB::getDriveStates() const {
RootEntry re(m_objectStore);
ScopedSharedLock rel(re);
re.fetch();
......@@ -1210,7 +1211,7 @@ std::unique_ptr<SchedulerDatabase::ArchiveMount>
// goes to mount state. If the work to be done gets depleted in the mean time,
// we will switch back to up.
dr.reportDriveStatus(driveName, logicalLibrary,
cta::DriveStatus::Starting, startTime,
cta::common::DriveStatus::Starting, startTime,
cta::MountType::ARCHIVE, privateRet->mountInfo.mountId,
0, 0, 0, vid, tapePool);
dr.commit();
......@@ -1314,7 +1315,7 @@ std::unique_ptr<SchedulerDatabase::RetrieveMount>
// goes to mount state. If the work to be done gets depleted in the mean time,
// we will switch back to up.
dr.reportDriveStatus(driveName, logicalLibrary,
cta::DriveStatus::Starting, startTime,
cta::common::DriveStatus::Starting, startTime,
cta::MountType::RETRIEVE, privateRet->mountInfo.mountId,
0, 0, 0, vid, tapePool);
dr.commit();
......@@ -1425,7 +1426,7 @@ void OStoreDB::ArchiveMount::complete(time_t completionTime) {
dr.fetch();
// Reset the drive state.
dr.reportDriveStatus(mountInfo.drive, mountInfo.logicalLibrary,
cta::DriveStatus::Up, completionTime,
cta::common::DriveStatus::Up, completionTime,
cta::MountType::NONE, 0,
0, 0, 0, "", "");
dr.commit();
......@@ -1550,7 +1551,7 @@ void OStoreDB::RetrieveMount::complete(time_t completionTime) {
dr.fetch();
// Reset the drive state.
dr.reportDriveStatus(mountInfo.drive, mountInfo.logicalLibrary,
cta::DriveStatus::Up, completionTime,
cta::common::DriveStatus::Up, completionTime,
cta::MountType::NONE, 0,
0, 0, 0, "", "");
dr.commit();
......@@ -1571,7 +1572,7 @@ void OStoreDB::RetrieveMount::complete(time_t completionTime) {
m_agent.commit();
}
void OStoreDB::RetrieveMount::setDriveStatus(cta::DriveStatus status, time_t completionTime) {
void OStoreDB::RetrieveMount::setDriveStatus(cta::common::DriveStatus status, time_t completionTime) {
// We just report the drive status as instructed by the tape thread.
// Get the drive register
objectstore::RootEntry re(m_objectStore);
......@@ -1588,7 +1589,7 @@ void OStoreDB::RetrieveMount::setDriveStatus(cta::DriveStatus status, time_t com
dr.commit();
}
void OStoreDB::ArchiveMount::setDriveStatus(cta::DriveStatus status, time_t completionTime) {
void OStoreDB::ArchiveMount::setDriveStatus(cta::common::DriveStatus status, time_t completionTime) {
// We just report the drive status as instructed by the tape thread.
// Get the drive register
objectstore::RootEntry re(m_objectStore);
......
......@@ -85,7 +85,7 @@ public:
virtual const MountInfo & getMountInfo();
virtual std::unique_ptr<ArchiveJob> getNextJob();
virtual void complete(time_t completionTime);
virtual void setDriveStatus(cta::DriveStatus status, time_t completionTime);
virtual void setDriveStatus(cta::common::DriveStatus status, time_t completionTime);
virtual void setTapeMaxFileCount(uint64_t maxFileId);
};
......@@ -123,7 +123,7 @@ public:
virtual const MountInfo & getMountInfo();
virtual std::unique_ptr<RetrieveJob> getNextJob();
virtual void complete(time_t completionTime);
virtual void setDriveStatus(cta::DriveStatus status, time_t completionTime);
virtual void setDriveStatus(cta::common::DriveStatus status, time_t completionTime);
};
/* === Retrieve Job handling ============================================== */
......@@ -297,7 +297,7 @@ public:
const std::string& remoteFile);
/* === Drive state handling ============================================== */
virtual std::list<cta::DriveState> getDriveStates() const;
virtual std::list<cta::common::DriveState> getDriveStates() const;
private:
objectstore::Backend & m_objectStore;
objectstore::Agent * m_agent;
......
......@@ -199,7 +199,7 @@ public:
m_OStoreDB.queue(rqst);
}
virtual std::list<cta::DriveState> getDriveStates() const {
virtual std::list<cta::common::DriveState> getDriveStates() const {
return m_OStoreDB.getDriveStates();
}
private:
......
......@@ -96,7 +96,7 @@ void cta::RetrieveMount::tapeComplete() {
} else {
// This is a special case: we have to report the tape server is draining
// its memory to disk
setDriveStatus(cta::DriveStatus::DrainingToDisk);
setDriveStatus(cta::common::DriveStatus::DrainingToDisk);
}
}
......@@ -126,7 +126,7 @@ void cta::RetrieveMount::abort() {
//------------------------------------------------------------------------------
// setDriveStatus()
//------------------------------------------------------------------------------
void cta::RetrieveMount::setDriveStatus(cta::DriveStatus status) {
void cta::RetrieveMount::setDriveStatus(cta::common::DriveStatus status) {
m_dbMount->setDriveStatus(status, time(NULL));
}
......
......@@ -84,7 +84,7 @@ namespace cta {
/**
* Report a drive status change
*/
virtual void setDriveStatus(cta::DriveStatus status);
virtual void setDriveStatus(cta::common::DriveStatus status);
/**
* Indicates that the disk thread of the mount was completed. This
......
......@@ -856,7 +856,7 @@ std::unique_ptr<cta::TapeMount> cta::Scheduler::getNextMount(
Utils::getShortHostname(),
time(NULL)).release());
internalRet->m_sessionRunning = true;
internalRet->setDriveStatus(cta::DriveStatus::Starting);
internalRet->setDriveStatus(cta::common::DriveStatus::Starting);
return std::unique_ptr<TapeMount> (internalRet.release());
} catch (cta::exception::Exception & ex) {
continue;
......@@ -881,7 +881,7 @@ std::unique_ptr<cta::TapeMount> cta::Scheduler::getNextMount(
internalRet->m_sessionRunning = true;
internalRet->m_diskRunning = true;
internalRet->m_tapeRunning = true;
internalRet->setDriveStatus(cta::DriveStatus::Starting);
internalRet->setDriveStatus(cta::common::DriveStatus::Starting);
return std::unique_ptr<TapeMount> (internalRet.release());
} catch (cta::exception::Exception & ex) {
std::string debug=ex.getMessageValue();
......@@ -899,6 +899,6 @@ std::unique_ptr<cta::TapeMount> cta::Scheduler::getNextMount(
//------------------------------------------------------------------------------
// getDriveStates
//------------------------------------------------------------------------------
std::list<cta::DriveState> cta::Scheduler::getDriveStates(const SecurityIdentity &requester) const {
std::list<cta::common::DriveState> cta::Scheduler::getDriveStates(const SecurityIdentity &requester) const {
return m_db.getDriveStates();
}
......@@ -634,7 +634,7 @@ public:
*
* @return The current list of registered drives.
*/
virtual std::list<cta::DriveState> getDriveStates(const SecurityIdentity &requester) const;
virtual std::list<cta::common::DriveState> getDriveStates(const SecurityIdentity &requester) const;
private:
......
......@@ -146,7 +146,7 @@ public:
virtual const MountInfo & getMountInfo() = 0;
virtual std::unique_ptr<ArchiveJob> getNextJob() = 0;
virtual void complete(time_t completionTime) = 0;
virtual void setDriveStatus(DriveStatus status, time_t completionTime) = 0;
virtual void setDriveStatus(common::DriveStatus status, time_t completionTime) = 0;
virtual ~ArchiveMount() {}
uint32_t nbFilesCurrentlyOnTape;
};
......@@ -220,7 +220,7 @@ public:
virtual const MountInfo & getMountInfo() = 0;
virtual std::unique_ptr<RetrieveJob> getNextJob() = 0;
virtual void complete(time_t completionTime) = 0;
virtual void setDriveStatus(DriveStatus status, time_t completionTime) = 0;
virtual void setDriveStatus(common::DriveStatus status, time_t completionTime) = 0;
virtual ~RetrieveMount() {}
uint32_t nbFilesCurrentlyOnTape;
};
......@@ -603,7 +603,7 @@ public:
*
* @return The current list of registered drives.
*/
virtual std::list<cta::DriveState> getDriveStates() const = 0;
virtual std::list<cta::common::DriveState> getDriveStates() const = 0;
}; // class SchedulerDatabase
......
......@@ -45,7 +45,7 @@ namespace unitTests{
virtual const MountInfo & getMountInfo() { throw std::runtime_error("Not implemented"); }
virtual std::unique_ptr<cta::SchedulerDatabase::RetrieveJob> getNextJob() { throw std::runtime_error("Not implemented");}
virtual void complete(time_t completionTime) { throw std::runtime_error("Not implemented"); }
virtual void setDriveStatus(cta::DriveStatus status, time_t completionTime) { throw std::runtime_error("Not implemented"); }
virtual void setDriveStatus(cta::common::DriveStatus status, time_t completionTime) { throw std::runtime_error("Not implemented"); }
};
class TestingRetrieveMount: public cta::RetrieveMount {
......
......@@ -38,7 +38,7 @@ namespace unitTests{
virtual const MountInfo & getMountInfo() { throw std::runtime_error("Not implemented"); }
virtual std::unique_ptr<cta::SchedulerDatabase::RetrieveJob> getNextJob() { throw std::runtime_error("Not implemented");}
virtual void complete(time_t completionTime) { throw std::runtime_error("Not implemented"); }
virtual void setDriveStatus(cta::DriveStatus status, time_t completionTime) { throw std::runtime_error("Not implemented"); }
virtual void setDriveStatus(cta::common::DriveStatus status, time_t completionTime) { throw std::runtime_error("Not implemented"); }
};
class TestingRetrieveMount: public cta::RetrieveMount {
......
......@@ -125,7 +125,7 @@ void MigrationReportPacker::ReportSuccessful::execute(MigrationReportPacker& rep
//------------------------------------------------------------------------------
//reportDriveStatus
//------------------------------------------------------------------------------
void MigrationReportPacker::reportDriveStatus(cta::DriveStatus status) {
void MigrationReportPacker::reportDriveStatus(cta::common::DriveStatus status) {
castor::server::MutexLocker ml(&m_producterProtection);
m_fifo.push(new ReportDriveStatus(status));
}
......@@ -135,7 +135,7 @@ void MigrationReportPacker::reportDriveStatus(cta::DriveStatus status) {
//------------------------------------------------------------------------------
void MigrationReportPacker::ReportDriveStatus::execute(MigrationReportPacker& parent){
parent.m_archiveMount->setDriveStatus(m_status);
if(m_status==cta::DriveStatus::Unmounting) {
if(m_status==cta::common::DriveStatus::Unmounting) {
parent.m_continue=false;
parent.m_archiveMount->complete();
}
......
......@@ -77,7 +77,7 @@ public:
* function is to be used by the tape thread when running.
* @param state the new drive state.
*/
virtual void reportDriveStatus(cta::DriveStatus status);
virtual void reportDriveStatus(cta::common::DriveStatus status);
/**
* Create into the MigrationReportPacker a report for the nominal end of session
......@@ -129,9 +129,9 @@ private:
};
class ReportDriveStatus : public Report {
cta::DriveStatus m_status;
cta::common::DriveStatus m_status;
public:
ReportDriveStatus(cta::DriveStatus status): m_status(status) {}
ReportDriveStatus(cta::common::DriveStatus status): m_status(status) {}
virtual void execute(MigrationReportPacker& reportPacker);
};
......
......@@ -86,7 +86,7 @@ void RecallReportPacker::reportEndOfSession(){
//------------------------------------------------------------------------------
//reportDriveStatus
//------------------------------------------------------------------------------
void RecallReportPacker::reportDriveStatus(cta::DriveStatus status) {
void RecallReportPacker::reportDriveStatus(cta::common::DriveStatus status) {
castor::server::MutexLocker ml(&m_producterProtection);
m_fifo.push(new ReportDriveStatus(status));
}
......@@ -155,7 +155,7 @@ bool RecallReportPacker::ReportEndofSession::goingToEnd(RecallReportPacker& pack
//------------------------------------------------------------------------------
void RecallReportPacker::ReportDriveStatus::execute(RecallReportPacker& parent){
parent.m_retrieveMount->setDriveStatus(m_status);
if(m_status==cta::DriveStatus::Unmounting) {
if(m_status==cta::common::DriveStatus::Unmounting) {
parent.m_retrieveMount->diskComplete();
parent.m_retrieveMount->tapeComplete();
}
......@@ -165,7 +165,7 @@ void RecallReportPacker::ReportDriveStatus::execute(RecallReportPacker& parent){
//ReportDriveStatus::goingToEnd
//------------------------------------------------------------------------------
bool RecallReportPacker::ReportDriveStatus::goingToEnd(RecallReportPacker& packer) {
if(m_status==cta::DriveStatus::Unmounting) return true;
if(m_status==cta::common::DriveStatus::Unmounting) return true;
return false;
}
......
......@@ -86,7 +86,7 @@ public:
* function is to be used by the tape thread when running.
* @param state the new drive state.
*/
virtual void reportDriveStatus(cta::DriveStatus status);
virtual void reportDriveStatus(cta::common::DriveStatus status);
/**
* Flag disk thread as done.
......@@ -159,9 +159,9 @@ private:
};
class ReportDriveStatus : public Report {
cta::DriveStatus m_status;
cta::common::DriveStatus m_status;
public:
ReportDriveStatus(cta::DriveStatus status): m_status(status) {}
ReportDriveStatus(cta::common::DriveStatus status): m_status(status) {}
virtual void execute(RecallReportPacker& reportPacker);
virtual bool goingToEnd(RecallReportPacker& packer);
};
......
......@@ -134,7 +134,7 @@ namespace unitTests
virtual const MountInfo & getMountInfo() { throw std::runtime_error("Not implemented"); }
virtual std::unique_ptr<cta::SchedulerDatabase::RetrieveJob> getNextJob() { throw std::runtime_error("Not implemented");}
virtual void complete(time_t completionTime) { throw std::runtime_error("Not implemented"); }
virtual void setDriveStatus(cta::DriveStatus status, time_t completionTime) { throw std::runtime_error("Not implemented"); }
virtual void setDriveStatus(cta::common::DriveStatus status, time_t completionTime) { throw std::runtime_error("Not implemented"); }
};
TEST_F(castor_tape_tapeserver_daemonTest, RecallTaskInjectorNominal) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment