Skip to content
Snippets Groups Projects
Commit cb081de9 authored by Steven Murray's avatar Steven Murray
Browse files

tapeserverd now fills the server field of VdqmDrvRqstMsgBody

parent 9d64795a
Branches
Tags
No related merge requests found
......@@ -20,7 +20,7 @@
*
*
*
* @author Nicola.Bessone@cern.ch Steven.Murray@cern.ch
* @author Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_TAPE_LEGACYMSG_VDQMMARSHAL_HPP
......
......@@ -48,14 +48,14 @@ castor::tape::legacymsg::RtcpJobRqstMsgBody
// setTapeDriveStatusDown
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::DummyVdqm::setTapeDriveStatusDown(
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception) {
const std::string &server, const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception) {
}
//------------------------------------------------------------------------------
// setTapeDriveStatusUp
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::DummyVdqm::setTapeDriveStatusUp(
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception) {
const std::string &server, const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception) {
}
......@@ -68,20 +68,26 @@ public:
/**
* Sets the status of the specified tape drive to down.
*
* @param server The host name of the server to which the tape drive is
* attached.
* @param unitName The unit name of the tape drive.
* @param dgn The device group name of the tape drive.
*/
void setTapeDriveStatusDown(const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception);
void setTapeDriveStatusDown(const std::string &server,
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception);
/**
* Sets the status of the specified tape drive to up.
*
* @param server The host name of the server to which the tape drive is
* attached.
* @param unitName The unit name of the tape drive.
* @param dgn The device group name of the tape drive.
*/
void setTapeDriveStatusUp(const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception);
void setTapeDriveStatusUp(const std::string &server,
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception);
private:
......
......@@ -48,7 +48,25 @@ castor::tape::tapeserver::daemon::TapeDaemon::TapeDaemon::TapeDaemon(
std::ostream &stdOut, std::ostream &stdErr, log::Logger &log, Vdqm &vdqm,
io::PollReactor &reactor) throw(castor::exception::Exception):
castor::server::Daemon(stdOut, stdErr, log), m_vdqm(vdqm), m_reactor(reactor),
m_programName("tapeserverd") {
m_programName("tapeserverd"), m_hostName(getHostName()) {
}
//------------------------------------------------------------------------------
// getHostName
//------------------------------------------------------------------------------
std::string
castor::tape::tapeserver::daemon::TapeDaemon::TapeDaemon::getHostName()
const throw(castor::exception::Exception) {
char nameBuf[81];
if(gethostname(nameBuf, sizeof(nameBuf))) {
char errBuf[100];
sstrerror_r(errno, errBuf, sizeof(errBuf));
castor::exception::Internal ex;
ex.getMessage() << "Failed to get host name: " << errBuf;
throw ex;
}
return nameBuf;
}
//------------------------------------------------------------------------------
......@@ -210,6 +228,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::registerTapeDriveWithVdqm(
const std::string dgn = m_driveCatalogue.getDgn(unitName);
std::list<log::Param> params;
params.push_back(log::Param("server", m_hostName));
params.push_back(log::Param("unitName", unitName));
params.push_back(log::Param("dgn", dgn));
......@@ -217,12 +236,12 @@ void castor::tape::tapeserver::daemon::TapeDaemon::registerTapeDriveWithVdqm(
case DriveCatalogue::DRIVE_STATE_DOWN:
params.push_back(log::Param("state", "down"));
m_log(LOG_INFO, "Registering tape drive with vdqm", params);
m_vdqm.setTapeDriveStatusDown(unitName, dgn);
m_vdqm.setTapeDriveStatusDown(m_hostName, unitName, dgn);
break;
case DriveCatalogue::DRIVE_STATE_UP:
params.push_back(log::Param("state", "up"));
m_log(LOG_INFO, "Registering tape drive with vdqm", params);
m_vdqm.setTapeDriveStatusUp(unitName, dgn);
m_vdqm.setTapeDriveStatusUp(m_hostName, unitName, dgn);
default:
{
castor::exception::Internal ex;
......
......@@ -82,6 +82,11 @@ public:
protected:
/**
* Returns the name of the host on which the tape daemon is running.
*/
std::string getHostName() const throw(castor::exception::Exception);
/**
* Exception throwing main() function.
*/
......@@ -193,6 +198,12 @@ protected:
*/
const std::string m_programName;
/**
* The name of the host on which tape daemon is running. This name is
* needed to fill in messages to be sent to the vdqmd daemon.
*/
const std::string m_hostName;
}; // class TapeDaemon
} // namespace daemon
......
......@@ -56,20 +56,26 @@ public:
/**
* Sets the status of the specified tape drive to down.
*
* @param server The host name of the server to which the tape drive is
* attached.
* @param unitName The unit name of the tape drive.
* @param dgn The device group name of the tape drive.
*/
virtual void setTapeDriveStatusDown(const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception) = 0;
virtual void setTapeDriveStatusDown(const std::string &server,
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception) = 0;
/**
* Sets the status of the specified tape drive to up.
*
* @param server The host name of the server to which the tape drive is
* attached.
* @param unitName The unit name of the tape drive.
* @param dgn The device group name of the tape drive.
*/
virtual void setTapeDriveStatusUp(const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception) = 0;
virtual void setTapeDriveStatusUp(const std::string &server,
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception) = 0;
}; // class Vdqm
......
......@@ -24,6 +24,7 @@
#include "castor/io/io.hpp"
#include "castor/tape/legacymsg/CommonMarshal.hpp"
#include "castor/tape/legacymsg/RtcpMarshal.hpp"
#include "castor/tape/legacymsg/VdqmMarshal.hpp"
#include "castor/tape/tapeserver/daemon/VdqmImpl.hpp"
#include "castor/utils/SmartFd.hpp"
#include "castor/utils/utils.hpp"
......@@ -158,10 +159,10 @@ void castor::tape::tapeserver::daemon::VdqmImpl::checkJobMsgLen(
// setTapeDriveStatusDown
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::VdqmImpl::setTapeDriveStatusDown(
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception) {
const std::string &server, const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception) {
try {
setTapeDriveStatus(unitName, dgn, VDQM_UNIT_DOWN);
setTapeDriveStatus(server, unitName, dgn, VDQM_UNIT_DOWN);
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to set drive status to down: " <<
......@@ -174,10 +175,10 @@ void castor::tape::tapeserver::daemon::VdqmImpl::setTapeDriveStatusDown(
// setTapeDriveStatusUp
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::VdqmImpl::setTapeDriveStatusUp(
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception) {
const std::string &server, const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception) {
try {
setTapeDriveStatus(unitName, dgn, VDQM_UNIT_UP);
setTapeDriveStatus(server, unitName, dgn, VDQM_UNIT_UP);
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to set drive status to up: " <<
......@@ -190,10 +191,34 @@ void castor::tape::tapeserver::daemon::VdqmImpl::setTapeDriveStatusUp(
// setTapeDriveStatus
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::VdqmImpl::setTapeDriveStatus(
const std::string &unitName, const std::string &dgn, const int status)
const std::string &server, const std::string &unitName,
const std::string &dgn, const int status)
throw(castor::exception::Exception) {
legacymsg::VdqmDrvRqstMsgBody drvRqstMsgBody;
drvRqstMsgBody.status = status;
castor::utils::copyString(drvRqstMsgBody.server, server.c_str());
castor::utils::copyString(drvRqstMsgBody.drive, unitName.c_str());
castor::utils::copyString(drvRqstMsgBody.dgn, dgn.c_str());
char drvRqstBuf[VDQM_MSGBUFSIZ];
const size_t drvRqstMsgLen = legacymsg::marshal(drvRqstBuf, drvRqstMsgBody);
castor::utils::SmartFd connection(connectToVdqm());
io::writeBytes(connection.get(), m_netTimeout, drvRqstMsgLen, drvRqstBuf);
char ackBuf[12]; // Magic + type + status
legacymsg::MessageHeader ackMsg;
io::readBytes(connection.get(), m_netTimeout, sizeof(ackBuf), ackBuf);
const char *ackBufPtr = ackBuf;
size_t ackBufLen = sizeof(ackBuf);
legacymsg::unmarshal(ackBufPtr, ackBufLen, ackMsg);
{
log::Param params[] = {
log::Param("magic", ackMsg.magic),
log::Param("reqType", ackMsg.reqType),
log::Param("status", ackMsg.lenOrStatus)};
m_log(LOG_INFO, "setTapeDriveStatus() received ack from vdqm", params);
}
}
//-----------------------------------------------------------------------------
......
......@@ -73,20 +73,26 @@ public:
/**
* Sets the status of the specified tape drive to down.
*
* @param server The host name of the server to which the tape drive is
* attached.
* @param unitName The unit name of the tape drive.
* @param dgn The device group name of the tape drive.
*/
void setTapeDriveStatusDown(const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception);
void setTapeDriveStatusDown(const std::string &server,
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception);
/**
* Sets the status of the specified tape drive to up.
*
* @param server The host name of the server to which the tape drive is
* attached.
* @param unitName The unit name of the tape drive.
* @param dgn The device group name of the tape drive.
*/
void setTapeDriveStatusUp(const std::string &unitName,
const std::string &dgn) throw(castor::exception::Exception);
void setTapeDriveStatusUp(const std::string &server,
const std::string &unitName, const std::string &dgn)
throw(castor::exception::Exception);
private:
......@@ -140,10 +146,13 @@ private:
/**
* Sets the status of the specified drive to the specified value.
*
* @param server The host name of the server to which the tape drive is
* attached.
* @param unitName The unit name of the tape drive.
* @param dgn The device group name of the tape drive.
*/
void setTapeDriveStatus(const std::string &unitName, const std::string &dgn,
void setTapeDriveStatus(const std::string &server,
const std::string &unitName, const std::string &dgn,
const int status) throw(castor::exception::Exception);
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment