Commit 106515d4 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Few changes for demo

parent b8b82fb5
......@@ -50,7 +50,7 @@ int main(void) {
try {
umask(0);
char path[100];
strncpy(path, "/tmp/CTAMockNSXXXXXX", 100);
strncpy(path, "/cephfs/ctaNS/CTAMockNSXXXXXX", 100);
cta::exception::Errnum::throwOnNull(mkdtemp(path), "MockNameServer() - Failed to create temporary directory");
std::string pathString(path);
std::stringstream uidss;
......
......@@ -42,38 +42,6 @@ public:
* Destructor.
*/
virtual ~TapeserverProxy() = 0;
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
* a recall job from the tapegatewayd daemon.
*
* @param vid The tape to be mounted for recall.
* @param unitName The unit name of the tape drive.
*/
virtual void gotRecallJobFromTapeGateway(const std::string &vid,
const std::string &unitName) = 0;
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
* a recall job from the readtp command-line tool.
*
* @param vid The tape to be mounted for recall.
* @param unitName The unit name of the tape drive.
*/
virtual void gotRecallJobFromReadTp(const std::string &vid,
const std::string &unitName) = 0;
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
* a migration job from the tapegatewayd daemon.
*
* @param vid The tape to be mounted for recall.
* @param unitName The unit name of the tape drive.
* @return The number of files currently stored on the tape as given by the
* vmgrd daemon.
*/
virtual uint32_t gotMigrationJobFromTapeGateway(const std::string &vid,
const std::string &unitName) = 0;
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
......@@ -96,18 +64,6 @@ public:
virtual void gotRetrieveJobFromCTA(const std::string &vid,
const std::string &unitName) = 0;
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
* a migration job from the writetp command-line tool.
*
* @param vid The tape to be mounted for recall.
* @param unitName The unit name of the tape drive.
* @return The number of files currently stored on the tape as given by the
* vmgrd daemon.
*/
virtual uint32_t gotMigrationJobFromWriteTp(const std::string &vid,
const std::string &unitName) = 0;
/**
* Notifies the tapeserverd daemon that the specified tape has been mounted.
*
......
......@@ -106,63 +106,6 @@ void castor::messages::TapeserverProxyZmq::gotRetrieveJobFromCTA(
}
}
//------------------------------------------------------------------------------
// gotRecallJobFromTapeGateway
//------------------------------------------------------------------------------
void castor::messages::TapeserverProxyZmq::gotRecallJobFromTapeGateway(
const std::string &vid, const std::string &unitName) {
MutexLocker lock(&m_mutex);
try {
const Frame rqst = createRecallJobFromTapeGatewayFrame(vid, unitName);
sendFrame(m_serverSocket, rqst);
ReturnValue reply;
recvTapeReplyOrEx(m_serverSocket, reply);
if(0 != reply.value()) {
// Should never get here
castor::exception::Exception ex;
ex.getMessage() << "Received an unexpected return value"
": expected=0 actual=" << reply.value();
throw ex;
}
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to notify tapeserver of recall job from tapegateway: " <<
"vid=" << vid << " unitName=" << unitName << ": " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// createRecallJobFromTapeGatewayFrame
//------------------------------------------------------------------------------
castor::messages::Frame castor::messages::TapeserverProxyZmq::
createRecallJobFromTapeGatewayFrame(const std::string &vid,
const std::string &unitName) {
try {
Frame frame;
frame.header = messages::protoTapePreFillHeader();
frame.header.set_msgtype(messages::MSG_TYPE_RECALLJOBFROMTAPEGATEWAY);
frame.header.set_bodysignature("PIPO");
RecallJobFromTapeGateway body;
body.set_vid(vid);
body.set_unitname(unitName);
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to create RecallJobFromTapeGateway frame: " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// createRetrieveJobFromCTAFrame
//------------------------------------------------------------------------------
......@@ -190,114 +133,6 @@ castor::messages::Frame castor::messages::TapeserverProxyZmq::
}
}
//------------------------------------------------------------------------------
// gotRecallJobFromReadTp
//------------------------------------------------------------------------------
void castor::messages::TapeserverProxyZmq::gotRecallJobFromReadTp(
const std::string &vid, const std::string &unitName) {
MutexLocker lock(&m_mutex);
try {
const Frame rqst = createRecallJobFromReadTpFrame(vid, unitName);
sendFrame(m_serverSocket, rqst);
ReturnValue reply;
recvTapeReplyOrEx(m_serverSocket, reply);
if(0 != reply.value()) {
// Should never get here
castor::exception::Exception ex;
ex.getMessage() << "Received an unexpected return value"
": expected=0 actual=" << reply.value();
throw ex;
}
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to notify tapeserver of recall job from readtp: " <<
"vid=" << vid << " unitName=" << unitName << ": " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// createRecallJobFromReadTpFrame
//------------------------------------------------------------------------------
castor::messages::Frame castor::messages::TapeserverProxyZmq::
createRecallJobFromReadTpFrame(const std::string &vid,
const std::string &unitName) {
try {
Frame frame;
frame.header = messages::protoTapePreFillHeader();
frame.header.set_msgtype(messages::MSG_TYPE_RECALLJOBFROMREADTP);
frame.header.set_bodysignature("PIPO");
RecallJobFromReadTp body;
body.set_vid(vid);
body.set_unitname(unitName);
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to create RecallJobFromReadTp frame: " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// gotMigrationJobFromTapeGateway
//------------------------------------------------------------------------------
uint32_t castor::messages::TapeserverProxyZmq::gotMigrationJobFromTapeGateway(
const std::string &vid, const std::string &unitName) {
MutexLocker lock(&m_mutex);
try {
const Frame rqst = createMigrationJobFromTapeGatewayFrame(vid, unitName);
sendFrame(m_serverSocket, rqst);
NbFilesOnTape reply;
recvTapeReplyOrEx(m_serverSocket, reply);
return reply.nbfiles();
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to notify tapeserver of migration job from tapegateway: " <<
"vid=" << vid << " unitName=" << unitName << ": " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// createMigrationJobFromTapeGatewayFrame
//------------------------------------------------------------------------------
castor::messages::Frame castor::messages::TapeserverProxyZmq::
createMigrationJobFromTapeGatewayFrame(const std::string &vid,
const std::string &unitName) {
try {
Frame frame;
frame.header = messages::protoTapePreFillHeader();
frame.header.set_msgtype(messages::MSG_TYPE_MIGRATIONJOBFROMTAPEGATEWAY);
frame.header.set_bodysignature("PIPO");
MigrationJobFromTapeGateway body;
body.set_vid(vid);
body.set_unitname(unitName);
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to create MigrationJobFromTapeGateway frame: " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// createArchiveJobFromCTAFrame
//------------------------------------------------------------------------------
......@@ -326,57 +161,6 @@ castor::messages::Frame castor::messages::TapeserverProxyZmq::
}
}
//------------------------------------------------------------------------------
// gotMigrationJobFromWriteTp
//------------------------------------------------------------------------------
uint32_t castor::messages::TapeserverProxyZmq::gotMigrationJobFromWriteTp(
const std::string &vid, const std::string &unitName) {
MutexLocker lock(&m_mutex);
try {
const Frame rqst = createMigrationJobFromWriteTpFrame(vid, unitName);
sendFrame(m_serverSocket, rqst);
NbFilesOnTape reply;
recvTapeReplyOrEx(m_serverSocket, reply);
return reply.nbfiles();
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to notify tapeserver of migration job from writetp: " <<
"vid=" << vid << " unitName=" << unitName << ": " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// createMigrationJobFromWriteTpFrame
//------------------------------------------------------------------------------
castor::messages::Frame castor::messages::TapeserverProxyZmq::
createMigrationJobFromWriteTpFrame(const std::string &vid,
const std::string &unitName) {
try {
Frame frame;
frame.header = messages::protoTapePreFillHeader();
frame.header.set_msgtype(messages::MSG_TYPE_MIGRATIONJOBFROMWRITETP);
frame.header.set_bodysignature("PIPO");
MigrationJobFromWriteTp body;
body.set_vid(vid);
body.set_unitname(unitName);
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to create MigrationJobFromWriteTp frame: " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// tapeMountedForRecall
//------------------------------------------------------------------------------
......
......@@ -69,50 +69,6 @@ public:
virtual void gotRetrieveJobFromCTA(const std::string &vid,
const std::string &unitName);
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
* a recall job from the tapegatewayd daemon.
*
* @param vid The tape to be mounted for recall.
* @param unitName The unit name of the tape drive.
*/
void gotRecallJobFromTapeGateway(const std::string &vid,
const std::string &unitName);
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
* a recall job from the readtp command-line tool.
*
* @param vid The tape to be mounted for recall.
* @param unitName The unit name of the tape drive.
*/
void gotRecallJobFromReadTp(const std::string &vid,
const std::string &unitName);
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
* a migration job from the tapegatewayd daemon.
*
* @param vid The tape to be mounted for recall.
* @param unitName The unit name of the tape drive.
* @return The number of files currently stored on the tape as given by the
* vmgrd daemon.
*/
uint32_t gotMigrationJobFromTapeGateway(const std::string &vid,
const std::string &unitName);
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
* a migration job from the writetp command-line tool.
*
* @param vid The tape to be mounted for recall.
* @param unitName The unit name of the tape drive.
* @return The number of files currently stored on the tape as given by the
* vmgrd daemon.
*/
uint32_t gotMigrationJobFromWriteTp(const std::string &vid,
const std::string &unitName);
/**
* Notifies the tapeserverd daemon that the specified tape has been mounted.
*
......@@ -231,46 +187,6 @@ private:
Frame createRetrieveJobFromCTAFrame(const std::string &vid,
const std::string &unitName);
/**
* Creates a frame containing a RecallJobFromTapeGateway message.
*
* @param vid The volume identifier of the tape.
* @param unitName The unit name of the tape drive.
* @return The frame.
*/
Frame createRecallJobFromTapeGatewayFrame(const std::string &vid,
const std::string &unitName);
/**
* Creates a frame containing a RecallJobFromReadTp message.
*
* @param vid The volume identifier of the tape.
* @param unitName The unit name of the tape drive.
* @return The frame.
*/
Frame createRecallJobFromReadTpFrame(const std::string &vid,
const std::string &unitName);
/**
* Creates a frame containing a MigrationJobFromTapeGateway message.
*
* @param vid The volume identifier of the tape.
* @param unitName The unit name of the tape drive.
* @return The frame.
*/
Frame createMigrationJobFromTapeGatewayFrame(const std::string &vid,
const std::string &unitName);
/**
* Creates a frame containing a MigrationJobFromWriteTp message.
*
* @param vid The volume identifier of the tape.
* @param unitName The unit name of the tape drive.
* @return The frame.
*/
Frame createMigrationJobFromWriteTpFrame(const std::string &vid,
const std::string &unitName);
/**
* Creates a frame containing a TapeMountedForRecall message.
*
......
......@@ -198,21 +198,9 @@ castor::messages::Frame castor::tape::tapeserver::daemon::TapeMessageHandler::
case messages::MSG_TYPE_RETRIEVEJOBFROMCTA:
return handleRetrieveJobFromCTA(rqst);
case messages::MSG_TYPE_MIGRATIONJOBFROMTAPEGATEWAY:
return handleMigrationJobFromTapeGateway(rqst);
case messages::MSG_TYPE_MIGRATIONJOBFROMWRITETP:
return handleMigrationJobFromWriteTp(rqst);
case messages::MSG_TYPE_LABELERROR:
return handleLabelError(rqst);
case messages::MSG_TYPE_RECALLJOBFROMREADTP:
return handleRecallJobFromReadTp(rqst);
case messages::MSG_TYPE_RECALLJOBFROMTAPEGATEWAY:
return handleRecallJobFromTapeGateway(rqst);
case messages::MSG_TYPE_TAPEMOUNTEDFORMIGRATION:
return handleTapeMountedForMigration(rqst);
......@@ -293,39 +281,6 @@ castor::messages::Frame castor::tape::tapeserver::daemon::TapeMessageHandler::
}
}
//------------------------------------------------------------------------------
// handleMigrationJobFromTapeGateway
//------------------------------------------------------------------------------
castor::messages::Frame castor::tape::tapeserver::daemon::TapeMessageHandler::
handleMigrationJobFromTapeGateway(const messages::Frame &rqst) {
m_log(LOG_INFO, "Handling MigrationJobFromTapeGateway message");
try {
castor::messages::MigrationJobFromWriteTp rqstBody;
rqst.parseBodyIntoProtocolBuffer(rqstBody);
CatalogueDrive &drive =
m_driveCatalogue.findDrive(rqstBody.unitname());
drive.getTransferSession().receivedMigrationJob(rqstBody.vid());
{
std::ostringstream msg;
msg << __FUNCTION__ << ": Not fully implemented because the number of"
" files on tape is not known because there is no vmgr in the CTA"
" project";
throw castor::exception::Exception(msg.str());
}
//messages::Frame reply = createNbFilesOnTapeFrame(tapeInfo.nbFiles);
//return reply;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to handle MigrationJobFromTapeGateway message: " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// handleArchiveJobFromCTA
//------------------------------------------------------------------------------
......@@ -368,91 +323,6 @@ castor::messages::Frame castor::tape::tapeserver::daemon::TapeMessageHandler::
return frame;
}
//------------------------------------------------------------------------------
// handleMigrationJobFromWriteTp
//------------------------------------------------------------------------------
castor::messages::Frame castor::tape::tapeserver::daemon::TapeMessageHandler::
handleMigrationJobFromWriteTp(const messages::Frame &rqst) {
m_log(LOG_INFO, "Handling MigrationJobFromWriteTp message");
try {
messages::MigrationJobFromWriteTp rqstBody;
rqst.parseBodyIntoProtocolBuffer(rqstBody);
CatalogueDrive &drive =
m_driveCatalogue.findDrive(rqstBody.unitname());
drive.getTransferSession().receivedMigrationJob(rqstBody.vid());
{
std::ostringstream msg;
msg << __FUNCTION__ << ": Not fully implemented because the number of"
" files on tape is not known because there is no vmgr in the CTA"
" project";
throw castor::exception::Exception(msg.str());
}
//messages::Frame reply = createNbFilesOnTapeFrame(tapeInfo.nbFiles);
//return reply;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to handle MigrationJobFromWriteTp message: " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// handleRecallJobFromReadTp
//------------------------------------------------------------------------------
castor::messages::Frame castor::tape::tapeserver::daemon::TapeMessageHandler::
handleRecallJobFromReadTp(const messages::Frame &rqst) {
try {
messages::RecallJobFromReadTp rqstBody;
rqst.parseBodyIntoProtocolBuffer(rqstBody);
CatalogueDrive &drive =
m_driveCatalogue.findDrive(rqstBody.unitname());
drive.getTransferSession().receivedRecallJob(rqstBody.vid());
const messages::Frame reply = createReturnValueFrame(0);
return reply;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to handle RecallJobFromTapeGateway message: " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// handleRecallJobFromTapeGateway
//------------------------------------------------------------------------------
castor::messages::Frame castor::tape::tapeserver::daemon::TapeMessageHandler::
handleRecallJobFromTapeGateway(const messages::Frame &rqst) {
m_log(LOG_INFO, "Handling RecallJobFromTapeGateway message");
try {
messages::RecallJobFromTapeGateway rqstBody;
rqst.parseBodyIntoProtocolBuffer(rqstBody);
CatalogueDrive &drive =
m_driveCatalogue.findDrive(rqstBody.unitname());
drive.getTransferSession().receivedRecallJob(rqstBody.vid());
const messages::Frame reply = createReturnValueFrame(0);
return reply;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to handle RecallJobFromTapeGateway message: " <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// handleRetrieveJobFromCTA
//------------------------------------------------------------------------------
......
......@@ -168,15 +168,6 @@ private:
* @return The reply.
*/
messages::Frame handleLabelError(const messages::Frame &rqst);
/**
* Handles the specified request.
*
* @param rqst The request.
* @return The reply.
*/
messages::Frame handleMigrationJobFromTapeGateway(
const messages::Frame &rqst);
/**
* Handles the specified request.
......@@ -194,22 +185,6 @@ private:
* @return The message frame.
*/
messages::Frame createNbFilesOnTapeFrame(const uint32_t nbFiles);
/**
* Handles the specified request.
*
* @param rqst The request.
* @return The reply.
*/
messages::Frame handleMigrationJobFromWriteTp(const messages::Frame &rqst);
/**
* Handles the specified request.
*
* @param rqst The request.
* @return The reply.
*/
messages::Frame handleRecallJobFromTapeGateway(const messages::Frame &rqst);
/**
* Handles the specified request.
......@@ -219,14 +194,6 @@ private:
*/
messages::Frame handleRetrieveJobFromCTA(const messages::