Commit 379b5826 authored by Steven Murray's avatar Steven Murray
Browse files

LabelSession now has TapeserverProxyZmq object to communicate with parent process

parent bc1bd0c4
......@@ -43,13 +43,14 @@
// constructor
//------------------------------------------------------------------------------
castor::tape::tapeserver::daemon::LabelSession::LabelSession(
messages::TapeserverProxy &tapeserver,
legacymsg::RmcProxy &rmc,
const legacymsg::TapeLabelRqstMsgBody &clientRequest,
castor::log::Logger &log,
System::virtualWrapper &sysWrapper,
const utils::DriveConfig &driveConfig,
const bool force):
m_timeout(1), // 1 second of timeout for the network in the label session. This is not going to be a parameter of the constructor
m_tapeserver(tapeserver),
m_rmc(rmc),
m_request(clientRequest),
m_log(log),
......@@ -83,8 +84,11 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
labelTheTape(drive.get());
m_log(LOG_INFO, "The tape has been successfully labeled", params);
drive->unloadTape();
m_log(LOG_INFO, "The tape has been successfully unloaded after labeling",
params);
m_rmc.unmountTape(m_request.vid, m_driveConfig.librarySlot);
m_log(LOG_INFO, "The tape has been successfully unmounted after labeling", params);
m_log(LOG_INFO, "The tape has been successfully unmounted after labeling",
params);
return MARK_DRIVE_AS_UP;
}
......
......@@ -24,17 +24,17 @@
#pragma once
#include "castor/legacymsg/TapeLabelRqstMsgBody.hpp"
#include "castor/log/Logger.hpp"
#include "castor/legacymsg/RmcProxy.hpp"
#include "castor/log/LogContext.hpp"
#include "castor/tape/tapeserver/system/Wrapper.hpp"
#include "castor/tape/utils/DriveConfig.hpp"
#include "castor/tape/utils/utils.hpp"
#include "castor/log/Logger.hpp"
#include "castor/messages/TapeserverProxy.hpp"
#include "castor/tape/tapeserver/client/ClientProxy.hpp"
#include "castor/legacymsg/NsProxy.hpp"
#include "castor/tape/tapeserver/system/Wrapper.hpp"
#include "castor/tape/tapeserver/daemon/Session.hpp"
#include "castor/tape/tapeserver/drive/DriveInterface.hpp"
#include "castor/tape/tapeserver/SCSI/Device.hpp"
#include "castor/tape/utils/DriveConfig.hpp"
#include "castor/tape/utils/utils.hpp"
#include <memory>
......@@ -52,6 +52,7 @@ public:
/**
* Constructor
*
* @param tapeserver Proxy object representing the tapeserverd daemon.
* @param rmc Proxy object representing the rmcd daemon.
* @param clientRequest The request to label a tape received from the label
* tape command.
......@@ -63,6 +64,7 @@ public:
* tape.
*/
LabelSession(
messages::TapeserverProxy &tapeserver,
legacymsg::RmcProxy &rmc,
const legacymsg::TapeLabelRqstMsgBody &clientRequest,
castor::log::Logger &log,
......@@ -94,16 +96,6 @@ public:
private:
/**
* The network timeout in seconds
*/
const int m_timeout;
enum TapeNsStatus {
LABEL_SESSION_STEP_SUCCEEDED,
LABEL_SESSION_STEP_FAILED
};
/**
* Performs some meta-data checks that need to be done before deciding to
* mount the tape for labeling.
......@@ -153,6 +145,11 @@ private:
* @return
*/
void labelTheTape(drives::DriveInterface *const drive);
/**
* Proxy object representing the tapeserverd daemon.
*/
messages::TapeserverProxy &m_tapeserver;
/**
* The object representing the rmcd daemon.
......
......@@ -519,7 +519,6 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
const int sizeOfIOThreadPoolForZMQ = 1;
messages::SmartZmqContext
zmqContext(instantiateZmqContext(sizeOfIOThreadPoolForZMQ));
const int tapeserverNetTimeout = 10; // Timeout in seconds
messages::TapeserverProxyZmq tapeserver(m_log,
TAPE_SERVER_INTERNAL_LISTENING_PORT, tapeserverNetTimeout,
......@@ -838,6 +837,14 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
params.push_back(log::Param("rmcPort", rqst.rmcport()));
m_log(LOG_INFO, "Label-session child-process started", params);
const int sizeOfIOThreadPoolForZMQ = 1;
messages::SmartZmqContext
zmqContext(instantiateZmqContext(sizeOfIOThreadPoolForZMQ));
const int tapeserverNetTimeout = 10; // Timeout in seconds
messages::TapeserverProxyZmq tapeserver(m_log,
TAPE_SERVER_INTERNAL_LISTENING_PORT, tapeserverNetTimeout,
zmqContext.get());
// The network timeout of rmc communications should be several minutes due
// to the time it takes to mount and unmount tapes
const int rmcNetTimeout = 600; // Timeout in seconds
......@@ -845,6 +852,7 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
legacymsg::NsProxy_TapeAlwaysEmpty ns;
castor::tape::System::realWrapper sWrapper;
LabelSession labelsession(
tapeserver,
rmc,
labelJob,
m_log,
......
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