Commit b06c87c3 authored by Steven Murray's avatar Steven Murray
Browse files

tapeserverd tpcleaner is not launched if tptransfer crashes

parent 7e6da1d1
......@@ -73,9 +73,7 @@ pid_t castor::tape::tapeserver::daemon::DriveCatalogueCleanerSession::
const std::string &vid,
const unsigned short rmcPort) {
// TO BE DONE
// processForker->forkCleaner(driveConfig, vid, rmcPort);
return 0;
return processForker.forkCleaner(driveConfig, vid, rmcPort);
}
//------------------------------------------------------------------------------
......
......@@ -534,14 +534,9 @@ void castor::tape::tapeserver::daemon::DriveCatalogueEntry::receivedLabelJob(
//-----------------------------------------------------------------------------
// createCleaner
//-----------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::DriveCatalogueEntry::createCleaner() {
void castor::tape::tapeserver::daemon::DriveCatalogueEntry::createCleaner(
const std::string &vid, const time_t assignmentTime) {
try {
const DriveCatalogueSession &session = getSession();
const std::string vid = session.getVid();
const time_t assignmentTime = session.getAssignmentTime();
deleteSession();
// Create a cleaner session in the catalogue
m_state = DRIVE_STATE_RUNNING;
m_sessionType = SESSION_TYPE_CLEANER;
......@@ -779,6 +774,30 @@ std::string castor::tape::tapeserver::daemon::DriveCatalogueEntry::
}
}
//------------------------------------------------------------------------------
// getVidForCleaner
//------------------------------------------------------------------------------
std::string castor::tape::tapeserver::daemon::DriveCatalogueEntry::
getVidForCleaner() const throw() {
try {
return getSession().getVid();
} catch(...) {
return "";
}
}
//------------------------------------------------------------------------------
// getAssignmentTimeForCleaner
//------------------------------------------------------------------------------
time_t castor::tape::tapeserver::daemon::DriveCatalogueEntry::
getAssignmentTimeForCleaner() const throw() {
try {
return getSession().getAssignmentTime();
} catch(...) {
return 0;
}
}
//------------------------------------------------------------------------------
// getVsnForTapeStatDriveEntry
//------------------------------------------------------------------------------
......
......@@ -285,8 +285,14 @@ public:
/**
* Creates a cleaner session to eject any tape left in the tape drive.
*
* @param vid The volume identifier of the tape currently in the tape drive
* or the empty string if not know.
* @param The assignment time associated with the tape drive or 0 if not
* known. The assignment time is given as the number of seconds elapsed
* since the Epoch.
*/
void createCleaner();
void createCleaner(const std::string &vid, const time_t assignmentTime);
/**
* Moves the state of the tape drive to DRIVE_STATE_UP if the
......@@ -375,6 +381,23 @@ public:
*/
const DriveCatalogueSession &getSession() const;
/**
* Tries to determine the volume identifier of the tape currently associated
* with the tape drive.
*
* @return The volume identifier of the tape or the empty string if it was
* not possible to determine.
*/
std::string getVidForCleaner() const throw();
/**
* Tries to determine the assigment time associated with the tap[e drive.
*
* @return The assigment time associated with the tape drive or 0 if not
* known. The assignment time is given in seconds elapsed since the Epoch.
*/
time_t getAssignmentTimeForCleaner() const throw();
private:
/**
......@@ -537,15 +560,6 @@ private:
*/
std::string getVidForTapeStatDriveEntry() const throw();
/**
* Tries to determine the volume identifier of the tape currently associated
* with the tape drive.
*
* @return The volume identifier of the tape or the empty string if it was
* not possible to determine.
*/
std::string getVidForCleaner() const throw();
/**
* Returns the value of the vsn field of a TapeStatDriveEntry to be used
* in a TapeStatReplyMsgBody.
......
......@@ -226,9 +226,11 @@ void castor::tape::tapeserver::daemon::ProcessForkerConnectionHandler::
params.push_back(log::Param("signal", msg.signal()));
try {
drive.sessionFailed();
m_log(LOG_WARNING, "Data-transfer session failed", params);
drive.createCleaner();
const std::string vid = drive.getVidForCleaner();
const time_t assignmentTime = drive.getAssignmentTimeForCleaner();
drive.sessionFailed();
drive.createCleaner(vid, assignmentTime);
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to handle crashed data-transfer session: " <<
......
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