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

Tick is propagated from TapeDaemon::handleEvents to catalogue sessions

parent a4d4510a
......@@ -56,13 +56,24 @@ castor::tape::tapeserver::daemon::Catalogue::~Catalogue() throw() {
// Close any label-command connections that are still owned by the
// tape-drive catalogue
for(DriveMap::const_iterator itor = m_drives.begin(); itor != m_drives.end();
itor++) {
const CatalogueDrive *drive = itor->second;
itor++) {
const CatalogueDrive *const drive = itor->second;
delete drive;
}
}
//-----------------------------------------------------------------------------
// tick
//-----------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::Catalogue::tick() {
for(DriveMap::const_iterator itor = m_drives.begin(); itor != m_drives.end();
itor++) {
CatalogueDrive *const drive = itor->second;
drive->tick();
}
}
//-----------------------------------------------------------------------------
// populate
//-----------------------------------------------------------------------------
......
......@@ -83,6 +83,16 @@ public:
*/
~Catalogue() throw();
/**
* Notifies the catalogue that it should perform any time related actions
* such as implementing alarms.
*
* This method does not have to be called at any time precise interval,
* though it should be called at least twice as fast as the quickest reaction
* time imposed on the catalogue.
*/
void tick();
/**
* Poplates the catalogue using the specified tape-drive configurations.
*
......
......@@ -65,6 +65,12 @@ castor::tape::tapeserver::daemon::CatalogueCleanerSession::
m_assignmentTime(assignmentTime) {
}
//------------------------------------------------------------------------------
// tick
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::CatalogueCleanerSession::tick() {
}
//------------------------------------------------------------------------------
// sessionSucceeded
//------------------------------------------------------------------------------
......
......@@ -65,6 +65,16 @@ public:
const std::string &vid,
const unsigned short rmcPort,
const time_t assignmentTime);
/**
* Notifies the catalogue session that it should perform any time related
* actions such as implementing alarms.
*
* This method does not have to be called at any time precise interval,
* though it should be called at least twice as fast as the quickest reaction
* time imposed on the catalogue session.
*/
void tick();
/**
* To be called when the session has ended with success.
......
......@@ -67,6 +67,19 @@ castor::tape::tapeserver::daemon::CatalogueDrive::~CatalogueDrive()
deleteSession();
}
//------------------------------------------------------------------------------
// tick
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::CatalogueDrive::tick() {
try {
checkForSession();
} catch(...) {
return;
}
m_session->tick();
}
//------------------------------------------------------------------------------
// deleteSession
//------------------------------------------------------------------------------
......
......@@ -194,6 +194,16 @@ public:
*/
~CatalogueDrive() throw();
/**
* Notifies the catalogue drive that it should perform any time related
* actions such as implementing alarms.
*
* This method does not have to be called at any time precise interval,
* though it should be called at least twice as fast as the quickest reaction
* time imposed on the catalogue drive.
*/
void tick();
/**
* If there is a catalogue session associated with the tape drive then this
* method deletes it and sets the member variable pointing to it to NULL in
......
......@@ -115,6 +115,12 @@ castor::tape::tapeserver::daemon::CatalogueLabelSession::
}
}
//------------------------------------------------------------------------------
// tick
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::CatalogueLabelSession::tick() {
}
//------------------------------------------------------------------------------
// sessionSucceeded
//------------------------------------------------------------------------------
......
......@@ -80,6 +80,16 @@ public:
*/
~CatalogueLabelSession() throw();
/**
* Notifies the catalogue session that it should perform any time related
* actions such as implementing alarms.
*
* This method does not have to be called at any time precise interval,
* though it should be called at least twice as fast as the quickest reaction
* time imposed on the catalogue session.
*/
void tick();
/**
* To be called when the session has ended with success.
*/
......
......@@ -47,6 +47,16 @@ public:
*/
virtual ~CatalogueSession() = 0;
/**
* Notifies the catalogue session that it should perform any time related
* actions such as implementing alarms.
*
* This method does not have to be called at any time precise interval,
* though it should be called at least twice as fast as the quickest reaction
* time imposed on the catalogue session.
*/
virtual void tick() = 0;
/**
* To be called when the session has ended with success.
*/
......
......@@ -87,6 +87,12 @@ castor::tape::tapeserver::daemon::CatalogueTransferSession::
m_hostName(hostName) {
}
//------------------------------------------------------------------------------
// tick
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::CatalogueTransferSession::tick() {
}
//------------------------------------------------------------------------------
// sessionSucceeded
//------------------------------------------------------------------------------
......
......@@ -41,6 +41,7 @@ namespace daemon {
*/
class CatalogueTransferSession : public CatalogueSession {
public:
/**
* Creates a CatalogueTransferSession object.
*
......@@ -73,6 +74,16 @@ public:
const unsigned short rmcPort,
ProcessForkerProxy &processForker);
/**
* Notifies the catalogue session that it should perform any time related
* actions such as implementing alarms.
*
* This method does not have to be called at any time precise interval,
* though it should be called at least twice as fast as the quickest reaction
* time imposed on the catalogue session.
*/
void tick();
/**
* To be called when the session has ended with success.
*/
......
......@@ -90,7 +90,7 @@ castor::tape::tapeserver::daemon::TapeDaemon::TapeDaemon(
m_hostName(getHostName()),
m_processForker(NULL),
m_processForkerPid(0),
m_driveCatalogue(NULL),
m_catalogue(NULL),
m_zmqContext(NULL) {
}
......@@ -120,7 +120,7 @@ castor::tape::tapeserver::daemon::TapeDaemon::~TapeDaemon() throw() {
m_processForker->stopProcessForker("TapeDaemon destructor called");
delete m_processForker;
}
delete m_driveCatalogue;
delete m_catalogue;
destroyZmqContext();
google::protobuf::ShutdownProtobufLibrary();
}
......@@ -192,10 +192,10 @@ void castor::tape::tapeserver::daemon::TapeDaemon::exceptionThrowingMain(
const DataTransferSession::CastorConf dataTransferConfig =
getDataTransferConf();
m_processForker = new ProcessForkerProxySocket(m_log, cmdPair.tapeDaemon);
m_driveCatalogue = new Catalogue(m_netTimeout, m_log, dataTransferConfig,
m_catalogue = new Catalogue(m_netTimeout, m_log, dataTransferConfig,
*m_processForker, m_cupv, m_vdqm, m_vmgr, m_hostName);
m_driveCatalogue->populate(m_driveConfigs);
m_catalogue->populate(m_driveConfigs);
// There is no longer any need for the process to be able to change user,
// however the process should still be permitted to perform raw IO in the
......@@ -561,7 +561,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::blockSignals() const {
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::TapeDaemon::registerTapeDrivesWithVdqm()
{
const std::list<std::string> unitNames = m_driveCatalogue->getUnitNames();
const std::list<std::string> unitNames = m_catalogue->getUnitNames();
for(std::list<std::string>::const_iterator itor = unitNames.begin();
itor != unitNames.end(); itor++) {
......@@ -574,7 +574,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::registerTapeDrivesWithVdqm()
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::TapeDaemon::registerTapeDriveWithVdqm(
const std::string &unitName) {
const CatalogueDrive &drive = m_driveCatalogue->findDrive(unitName);
const CatalogueDrive &drive = m_catalogue->findDrive(unitName);
const utils::DriveConfig &driveConfig = drive.getConfig();
std::list<log::Param> params;
......@@ -641,7 +641,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
std::auto_ptr<ProcessForkerConnectionHandler> handler;
try {
handler.reset(new ProcessForkerConnectionHandler(reaperSocket, m_reactor,
m_log, *m_driveCatalogue));
m_log, *m_catalogue));
} catch(std::bad_alloc &ba) {
castor::exception::BadAlloc ex;
ex.getMessage() <<
......@@ -684,7 +684,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
std::auto_ptr<VdqmAcceptHandler> handler;
try {
handler.reset(new VdqmAcceptHandler(listenSock.get(), m_reactor, m_log,
*m_driveCatalogue));
*m_catalogue));
listenSock.release();
} catch(std::bad_alloc &ba) {
castor::exception::BadAlloc ex;
......@@ -730,7 +730,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
std::auto_ptr<AdminAcceptHandler> handler;
try {
handler.reset(new AdminAcceptHandler(listenSock.get(), m_reactor, m_log,
m_vdqm, *m_driveCatalogue, m_hostName));
m_vdqm, *m_catalogue, m_hostName));
listenSock.release();
} catch(std::bad_alloc &ba) {
castor::exception::BadAlloc ex;
......@@ -777,7 +777,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
std::auto_ptr<LabelCmdAcceptHandler> handler;
try {
handler.reset(new LabelCmdAcceptHandler(listenSock.get(), m_reactor, m_log,
*m_driveCatalogue, m_hostName, m_vdqm, m_vmgr));
*m_catalogue, m_hostName, m_vdqm, m_vmgr));
listenSock.release();
} catch(std::bad_alloc &ba) {
castor::exception::BadAlloc ex;
......@@ -805,7 +805,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
try {
std::auto_ptr<TapeMessageHandler> handler;
try {
handler.reset(new TapeMessageHandler(m_reactor, m_log, *m_driveCatalogue,
handler.reset(new TapeMessageHandler(m_reactor, m_log, *m_catalogue,
m_hostName, m_vdqm, m_vmgr, m_zmqContext));
} catch(std::bad_alloc &ba) {
castor::exception::BadAlloc ex;
......@@ -866,6 +866,8 @@ bool castor::tape::tapeserver::daemon::TapeDaemon::handleEvents()
"Unexpected and unknown exception thrown when handling an I/O event");
}
m_catalogue->tick();
return handlePendingSignals();
}
......
......@@ -544,7 +544,7 @@ protected:
* Catalogue used to keep track of both the initial and current state of
* each tape drive being controlled by the tapeserverd daemon.
*/
Catalogue *m_driveCatalogue;
Catalogue *m_catalogue;
/**
* The ZMQ context.
......
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