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

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

parent c8e948c5
......@@ -45,7 +45,7 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeReadSingleThread(
//TapeCleaning::~TapeCleaning()
//------------------------------------------------------------------------------
castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeCleaning() {
m_this.m_rrp.reportDriveStatus(cta::DriveStatus::CleaningUp);
m_this.m_rrp.reportDriveStatus(cta::common::DriveStatus::CleaningUp);
// Tell everyone to wrap up the session
// We now acknowledge to the task injector that read reached the end. There
// will hence be no more requests for more.
......@@ -75,7 +75,7 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean
}
// in the special case of a "manual" mode tape, we should skip the unload too.
if (mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType()) {
m_this.m_rrp.reportDriveStatus(cta::DriveStatus::Unloading);
m_this.m_rrp.reportDriveStatus(cta::common::DriveStatus::Unloading);
m_this.m_drive.unloadTape();
m_this.m_logContext.log(LOG_INFO, "TapeReadSingleThread: Tape unloaded");
} else {
......@@ -86,9 +86,9 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean
// In case of manual mode, this will be filtered by the rmc daemon
// (which will do nothing)
currentErrorToCount = "Error_tapeDismount";
m_this.m_rrp.reportDriveStatus(cta::DriveStatus::Unmounting);
m_this.m_rrp.reportDriveStatus(cta::common::DriveStatus::Unmounting);
m_this.m_mc.dismountTape(m_this.m_volInfo.vid, m_this.m_drive.config.getLibrarySlot());
m_this.m_rrp.reportDriveStatus(cta::DriveStatus::Up);
m_this.m_rrp.reportDriveStatus(cta::common::DriveStatus::Up);
m_this.m_stats.unmountTime += m_timer.secs(castor::utils::Timer::resetCounter);
m_this.m_logContext.log(LOG_INFO, mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType() ?
"TapeReadSingleThread : tape unmounted":"TapeReadSingleThread : tape NOT unmounted (manual mode)");
......@@ -97,7 +97,7 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean
} catch(const castor::exception::Exception& ex){
// Something failed during the cleaning
m_this.m_hardwareStatus = Session::MARK_DRIVE_AS_DOWN;
m_this.m_rrp.reportDriveStatus(cta::DriveStatus::Down);
m_this.m_rrp.reportDriveStatus(cta::common::DriveStatus::Down);
castor::log::ScopedParamContainer scoped(m_this.m_logContext);
scoped.add("exception_message", ex.getMessageValue())
.add("exception_code",ex.code());
......@@ -110,7 +110,7 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean
} catch (...) {
// Notify something failed during the cleaning
m_this.m_hardwareStatus = Session::MARK_DRIVE_AS_DOWN;
m_this.m_rrp.reportDriveStatus(cta::DriveStatus::Down);
m_this.m_rrp.reportDriveStatus(cta::common::DriveStatus::Down);
m_this.m_logContext.log(LOG_ERR, "Non-Castor exception in TapeReadSingleThread-TapeCleaning when unmounting the tape");
try {
if (currentErrorToCount.size()) {
......@@ -204,7 +204,7 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() {
TapeCleaning tapeCleaner(*this, timer);
// Before anything, the tape should be mounted
currentErrorToCount = "Error_tapeMountForRead";
m_rrp.reportDriveStatus(cta::DriveStatus::Mounting);
m_rrp.reportDriveStatus(cta::common::DriveStatus::Mounting);
mountTapeReadOnly();
currentErrorToCount = "Error_tapeLoad";
waitForDrive();
......@@ -233,7 +233,7 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() {
// Then we will loop on the tasks as they get from
// the task injector
std::unique_ptr<TapeReadTask> task;
m_rrp.reportDriveStatus(cta::DriveStatus::Transfering);
m_rrp.reportDriveStatus(cta::common::DriveStatus::Transfering);
while(true) {
//get a task
task.reset(popAndRequestMoreJobs());
......
......@@ -170,7 +170,7 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() {
//
TapeCleaning cleaner(*this, timer);
currentErrorToCount = "Error_tapeMountForWrite";
m_reportPacker.reportDriveStatus(cta::DriveStatus::Mounting);
m_reportPacker.reportDriveStatus(cta::common::DriveStatus::Mounting);
// Before anything, the tape should be mounted
// This call does the logging of the mount
mountTapeReadWrite();
......@@ -206,7 +206,7 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() {
// Tasks handle their error logging themselves.
currentErrorToCount = "";
std::unique_ptr<TapeWriteTask> task;
m_reportPacker.reportDriveStatus(cta::DriveStatus::Transfering);
m_reportPacker.reportDriveStatus(cta::common::DriveStatus::Transfering);
while(1) {
//get a task
task.reset(m_tasks.pop());
......
......@@ -104,7 +104,7 @@ private:
TapeCleaning(TapeWriteSingleThread& parent, castor::utils::Timer & timer):
m_this(parent), m_timer(timer) {}
~TapeCleaning(){
m_this.m_reportPacker.reportDriveStatus(cta::DriveStatus::CleaningUp);
m_this.m_reportPacker.reportDriveStatus(cta::common::DriveStatus::CleaningUp);
// This out-of-try-catch variables allows us to record the stage of the
// process we're in, and to count the error if it occurs.
// We will not record errors for an empty string. This will allow us to
......@@ -127,7 +127,7 @@ private:
}
// in the special case of a "manual" mode tape, we should skip the unload too.
if (mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType()) {
m_this.m_reportPacker.reportDriveStatus(cta::DriveStatus::Unloading);
m_this.m_reportPacker.reportDriveStatus(cta::common::DriveStatus::Unloading);
m_this.m_drive.unloadTape();
m_this.m_logContext.log(LOG_INFO, "TapeWriteSingleThread: Tape unloaded");
} else {
......@@ -138,9 +138,9 @@ private:
// In case of manual mode, this will be filtered by the rmc daemon
// (which will do nothing)
currentErrorToCount = "Error_tapeDismount";
m_this.m_reportPacker.reportDriveStatus(cta::DriveStatus::Unmounting);
m_this.m_reportPacker.reportDriveStatus(cta::common::DriveStatus::Unmounting);
m_this.m_mc.dismountTape(m_this.m_volInfo.vid, m_this.m_drive.config.getLibrarySlot());
m_this.m_reportPacker.reportDriveStatus(cta::DriveStatus::Up);
m_this.m_reportPacker.reportDriveStatus(cta::common::DriveStatus::Up);
m_this.m_stats.unmountTime += m_timer.secs(castor::utils::Timer::resetCounter);
m_this.m_logContext.log(LOG_INFO, mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType() ?
"TapeWriteSingleThread : tape unmounted":"TapeWriteSingleThread : tape NOT unmounted (manual mode)");
......@@ -150,7 +150,7 @@ private:
catch(const castor::exception::Exception& ex){
// Notify something failed during the cleaning
m_this.m_hardwareStatus = Session::MARK_DRIVE_AS_DOWN;
m_this.m_reportPacker.reportDriveStatus(cta::DriveStatus::Down);
m_this.m_reportPacker.reportDriveStatus(cta::common::DriveStatus::Down);
castor::log::ScopedParamContainer scoped(m_this.m_logContext);
scoped.add("exception_message", ex.getMessageValue())
.add("exception_code",ex.code());
......@@ -165,7 +165,7 @@ private:
} catch (...) {
// Notify something failed during the cleaning
m_this.m_hardwareStatus = Session::MARK_DRIVE_AS_DOWN;
m_this.m_reportPacker.reportDriveStatus(cta::DriveStatus::Down);
m_this.m_reportPacker.reportDriveStatus(cta::common::DriveStatus::Down);
m_this.m_logContext.log(LOG_ERR, "Non-Castor exception in TapeWriteSingleThread-TapeCleaning when unmounting the tape");
try {
if (currentErrorToCount.size()) {
......
......@@ -1214,51 +1214,53 @@ void XrdProFile::xCom_listpendingretrieves(const std::vector<std::string> &token
m_data = responseSS.str();
}
std::string fromDriveStatusToString(cta::DriveStatus status) {
std::string fromDriveStatusToString(cta::common::DriveStatus status) {
using cta::common::DriveStatus;
switch(status) {
case cta::DriveStatus::CleaningUp:
case DriveStatus::CleaningUp:
return "CleaningUp";
case cta::DriveStatus::Down:
case DriveStatus::Down:
return "Down";
case cta::DriveStatus::DrainingToDisk:
case DriveStatus::DrainingToDisk:
return "DrainingToDisk";
case cta::DriveStatus::Mounting:
case DriveStatus::Mounting:
return "Mounting";
case cta::DriveStatus::Starting:
case DriveStatus::Starting:
return "Starting";
case cta::DriveStatus::Transfering:
case DriveStatus::Transfering:
return "Transferring";
case cta::DriveStatus::Unloading:
case DriveStatus::Unloading:
return "Unloading";
case cta::DriveStatus::Unmounting:
case DriveStatus::Unmounting:
return "Unmounting";
case cta::DriveStatus::Up:
case DriveStatus::Up:
return "Up";
default:
return "UnknownState";
}
}
time_t getDurationSinceStatusBegin(const cta::DriveState &state) {
time_t getDurationSinceStatusBegin(const cta::common::DriveState &state) {
time_t now = time(0);
switch(state.status) {
case cta::DriveStatus::CleaningUp:
using cta::common::DriveStatus;
case DriveStatus::CleaningUp:
return now-state.cleanupStartTime;
case cta::DriveStatus::Down:
case DriveStatus::Down:
return now-state.downOrUpStartTime;
case cta::DriveStatus::DrainingToDisk:
case DriveStatus::DrainingToDisk:
return now-state.drainingStartTime;
case cta::DriveStatus::Mounting:
case DriveStatus::Mounting:
return now-state.mountStartTime;
case cta::DriveStatus::Starting:
case DriveStatus::Starting:
return now-state.startStartTime;
case cta::DriveStatus::Transfering:
case DriveStatus::Transfering:
return now-state.transferStartTime;
case cta::DriveStatus::Unloading:
case DriveStatus::Unloading:
return now-state.unloadStartTime;
case cta::DriveStatus::Unmounting:
case DriveStatus::Unmounting:
return now-state.unmountStartTime;
case cta::DriveStatus::Up:
case DriveStatus::Up:
return now-state.downOrUpStartTime;
default:
return 0;
......
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