Commit 3073f0b4 authored by Steven Murray's avatar Steven Murray
Browse files

Removed the now redundant legacymsg::TapeUpdateDriveRqstMsgBody

parent 3fb87139
......@@ -58,7 +58,6 @@ set (CASTOR_LEGACYMSG_LIB_SRC_FILES
RtcpSegmentAttributes.cpp
RtcpTapeRqstMsgBody.cpp
ScsiLibrarySlot.cpp
TapeUpdateDriveRqstMsgBody.cpp
TapeBridgeMarshal.cpp
TapeConfigRequestMsgBody.cpp
TapeLabelRqstMsgBody.cpp
......
......@@ -375,86 +375,6 @@ size_t castor::legacymsg::marshal(char *const dst, const size_t dstLen,
return totalLen;
}
//-----------------------------------------------------------------------------
// marshal
//-----------------------------------------------------------------------------
size_t castor::legacymsg::marshal(char *const dst, const size_t dstLen, const TapeUpdateDriveRqstMsgBody &src) {
const char *task = "marshal TapeUpdateDriveRqstMsgBody";
if(dst == NULL) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to " << task <<
": Pointer to destination buffer is NULL";
throw ex;
}
// Calculate the length of the message body
const uint32_t bodyLen =
sizeof(uint32_t) + // event
sizeof(uint32_t) + // mode
sizeof(uint32_t) + // clientType
strlen(src.vid) + 1 + // vid
strlen(src.drive) + 1; // drive
// Calculate the total length of the message (header + body)
const uint32_t totalLen =
sizeof(uint32_t) + // magic
sizeof(uint32_t) + // reqType
sizeof(uint32_t) + // len
bodyLen;
// Check that the message buffer is big enough
if(totalLen > dstLen) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to " << task <<
": Buffer too small: required=" << totalLen << " actual=" << dstLen;
throw ex;
}
// Marshal message header
char *p = dst;
try {
const uint32_t magic = TPMAGIC;
const uint32_t reqType = UPDDRIVE;
io::marshalUint32(magic, p);
io::marshalUint32(reqType, p);
io::marshalUint32(totalLen, p);
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to " << task << ": Failed to marshal header: "
<< ne.getMessage().str();
throw ex;
}
// Marshal message body
try {
io::marshalUint32(src.event, p);
io::marshalUint32(src.mode, p);
io::marshalUint32(src.clientType, p);
io::marshalString(src.vid, p);
io::marshalString(src.drive, p);
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to " << task << ": Failed to marshal body: "
<< ne.getMessage().str();
throw ex;
}
// Calculate the number of bytes actually marshalled
const size_t nbBytesMarshalled = p - dst;
// Check that the number of bytes marshalled was what was expected
if(totalLen != nbBytesMarshalled) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to " << task <<
": Mismatch between expected total length and actual"
": expected=" << totalLen << " actual=" << nbBytesMarshalled;
throw ex;
}
return totalLen;
}
//-----------------------------------------------------------------------------
// unmarshal
//-----------------------------------------------------------------------------
......@@ -484,24 +404,6 @@ void castor::legacymsg::unmarshal(const char * &src, size_t &srcLen, TapeStatRep
}
}
//-----------------------------------------------------------------------------
// unmarshal
//-----------------------------------------------------------------------------
void castor::legacymsg::unmarshal(const char * &src, size_t &srcLen, TapeUpdateDriveRqstMsgBody &dst) {
try {
io::unmarshalUint32(src, srcLen, dst.event);
io::unmarshalUint32(src, srcLen, dst.mode);
io::unmarshalUint32(src, srcLen, dst.clientType);
io::unmarshalString(src, srcLen, dst.vid);
io::unmarshalString(src, srcLen, dst.drive);
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to unmarshal TapeUpdateDriveRqstMsgBody: " <<
ne.getMessage().str();
throw ex;
}
}
//-----------------------------------------------------------------------------
// unmarshal
//-----------------------------------------------------------------------------
......
......@@ -28,7 +28,6 @@
#include "castor/legacymsg/TapeConfigRequestMsgBody.hpp"
#include "castor/legacymsg/TapeStatReplyMsgBody.hpp"
#include "castor/legacymsg/TapeStatRequestMsgBody.hpp"
#include "castor/legacymsg/TapeUpdateDriveRqstMsgBody.hpp"
#include "castor/legacymsg/TapeLabelRqstMsgBody.hpp"
#include <errno.h>
......@@ -152,44 +151,6 @@ template<int n> size_t marshal(char (&dst)[n], const TapeStatReplyMsgBody &src)
*/
void unmarshal(const char * &src, size_t &srcLen, TapeStatReplyMsgBody &dst) ;
/**
* Marshals the specified source message body structure and its implicit
* header into the specified destination buffer.
*
* @param dst The destination message buffer.
* @param dstLen The length of the destination buffer.
* @param src The source structure.
* @return The total length of the message (header + body).
*/
size_t marshal(char *const dst, const size_t dstLen, const TapeUpdateDriveRqstMsgBody &src) ;
/**
* Marshals the specified source message body structure and its implicit
* header into the specified destination buffer.
*
* @param dst The destination message buffer.
* @param src The source structure.
* @return The total length of the message (header + body).
*/
template<int n> size_t marshal(char (&dst)[n], const TapeUpdateDriveRqstMsgBody &src) {
return marshal(dst, n, src);
}
/**
* Unmarshals a message body with the specified destination structure type
* from the specified source buffer.
*
* @param src In/out parameter, before invocation points to the source
* buffer where the message body should be unmarshalled from and on return
* points to the byte in the source buffer immediately after the
* unmarshalled message body.
* @param srcLen In/our parameter, before invocation is the length of the
* source buffer from where the message body should be unmarshalled and on
* return is the number of bytes remaining in the source buffer.
* @param dst The destination message body structure.
*/
void unmarshal(const char * &src, size_t &srcLen, TapeUpdateDriveRqstMsgBody &dst) ;
/**
* Marshals the specified source message body structure and its implicit
* header into the specified destination buffer.
......
......@@ -138,60 +138,6 @@ TEST_F(castor_legacymsg_TapeMarshalTest, marshalTapeStatRequestMsgBody) {
}
}
TEST_F(castor_legacymsg_TapeMarshalTest, marshalTapeUpdateDriveRqstMsgBody) {
using namespace castor::legacymsg;
char buf[37]; // Expect message (header + body) to occupy exactly 25 bytes
TapeUpdateDriveRqstMsgBody srcMsgBody;
// Marshal entire message (header + body)
{
srcMsgBody.event = 1;
srcMsgBody.mode = 2;
srcMsgBody.clientType = 3;
castor::utils::copyString(srcMsgBody.vid, "VIDVID");
castor::utils::copyString(srcMsgBody.drive, "DRIVE");
size_t bufLen = sizeof(buf);
size_t totalLen = 0; // Total length of message (header + body)
ASSERT_NO_THROW(totalLen = marshal(buf, bufLen, srcMsgBody));
ASSERT_EQ((uint32_t)37, totalLen);
}
// Unmarshall message header
{
MessageHeader dstHeader;
const char *bufPtr = buf;
size_t bufLen = 12; // Length of the message header
ASSERT_NO_THROW(unmarshal(bufPtr, bufLen, dstHeader));
ASSERT_EQ(buf + 12, bufPtr);
ASSERT_EQ((size_t)0, bufLen);
ASSERT_EQ((uint32_t)TPMAGIC, dstHeader.magic);
ASSERT_EQ((uint32_t)UPDDRIVE, dstHeader.reqType);
ASSERT_EQ((uint32_t)37, dstHeader.lenOrStatus);
}
// Unmarshall message body
{
TapeUpdateDriveRqstMsgBody dstMsgBody;
const char *bufPtr = buf + 12; // Point at beginning of message body
size_t bufLen = 25; // Length of the message body
ASSERT_NO_THROW(unmarshal(bufPtr, bufLen, dstMsgBody));
ASSERT_EQ(buf + 37, bufPtr);
ASSERT_EQ((size_t)0, bufLen);
ASSERT_EQ((uint32_t)1, dstMsgBody.event);
ASSERT_EQ((uint32_t)2, dstMsgBody.mode);
ASSERT_EQ((uint32_t)3, dstMsgBody.clientType);
ASSERT_EQ(std::string("VIDVID"), dstMsgBody.vid);
ASSERT_EQ(std::string("DRIVE"), dstMsgBody.drive);
}
}
TEST_F(castor_legacymsg_TapeMarshalTest, marshalTapeLabelRqstMsgBody) {
using namespace castor::legacymsg;
char buf[45]; // Expect message (header + body) to occupy exactly 27 bytes
......
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/legacymsg/TapeUpdateDriveRqstMsgBody.hpp"
#include <string.h>
castor::legacymsg::TapeUpdateDriveRqstMsgBody::TapeUpdateDriveRqstMsgBody() throw():
event(TAPE_STATUS_NONE),
mode(TAPE_MODE_NONE),
clientType(CLIENT_TYPE_NONE)
{
memset(vid, '\0', sizeof(vid));
memset(drive, '\0', sizeof(drive));
}
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include "castor/tape/tapegateway/ClientType.hpp"
#include "castor/tape/tapegateway/VolumeMode.hpp"
#include "h/Castor_limits.h"
#include <stdint.h>
namespace castor {
namespace legacymsg {
/**
* An update-VID message, used to update the drive catalogue with the contents of a drive.
*/
struct TapeUpdateDriveRqstMsgBody {
/**
* The status of the tape with respect to the drive mount and unmount operations
*/
enum TapeEvent {
TAPE_STATUS_NONE,
TAPE_STATUS_BEFORE_MOUNT_STARTED,
TAPE_STATUS_MOUNTED,
TAPE_STATUS_UNMOUNT_STARTED,
TAPE_STATUS_UNMOUNTED
};
uint32_t event;
/**
* Are we mounting for read, write (read/write), or dump
*/
enum TapeMode {
TAPE_MODE_NONE,
TAPE_MODE_READ,
TAPE_MODE_READWRITE,
TAPE_MODE_DUMP
};
uint32_t mode;
/**
* The client could be the gateway, readtp, writetp, or dumptp
*/
enum TapeClientType {
CLIENT_TYPE_NONE,
CLIENT_TYPE_GATEWAY,
CLIENT_TYPE_READTP,
CLIENT_TYPE_WRITETP,
CLIENT_TYPE_DUMPTP
};
uint32_t clientType;
/**
* The VID of the tape inside the drive ("" if empty)
*/
char vid[CA_MAXVIDLEN+1];
/**
* The drive name (a.k.a. unit name)
*/
char drive[CA_MAXUNMLEN+1];
/**
* Constructor: zeroes the two strings.
*/
TapeUpdateDriveRqstMsgBody() throw();
}; // struct TapeUpdateDriveRqstMsgBody
} // namespace legacymsg
} // namespace castor
......@@ -23,7 +23,6 @@
#include "castor/tape/tapeserver/daemon/DriveCatalogue.hpp"
#include "castor/utils/utils.hpp"
#include "castor/legacymsg/TapeUpdateDriveRqstMsgBody.hpp"
#include <string.h>
#include <time.h>
......
......@@ -29,7 +29,6 @@
#include "castor/tape/utils/DriveConfigMap.hpp"
#include "castor/tape/tapeserver/client/ClientProxy.hpp"
#include "castor/tape/tapeserver/daemon/DriveCatalogueEntry.hpp"
#include "castor/legacymsg/TapeUpdateDriveRqstMsgBody.hpp"
#include <map>
#include <string>
......
......@@ -128,23 +128,6 @@ std::string castor::tape::tapeserver::daemon::DriveCatalogueEntry::getVid()
return m_vid;
}
//------------------------------------------------------------------------------
// setAssignmentTime
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::DriveCatalogueEntry::setAssignmentTime(
const time_t assignmentTime) {
m_assignmentTime = assignmentTime;
}
//------------------------------------------------------------------------------
// getAssignmentTime
//------------------------------------------------------------------------------
time_t
castor::tape::tapeserver::daemon::DriveCatalogueEntry::getAssignmentTime()
const {
return m_assignmentTime;
}
//------------------------------------------------------------------------------
// getState
//------------------------------------------------------------------------------
......
......@@ -26,7 +26,6 @@
#include "castor/legacymsg/RtcpJobRqstMsgBody.hpp"
#include "castor/legacymsg/TapeLabelRqstMsgBody.hpp"
#include "castor/legacymsg/TapeStatDriveEntry.hpp"
#include "castor/legacymsg/TapeUpdateDriveRqstMsgBody.hpp"
#include "castor/tape/tapeserver/daemon/DriveCatalogueSession.hpp"
#include "castor/tape/utils/DriveConfig.hpp"
......@@ -221,18 +220,6 @@ public:
*/
std::string getVid() const;
/**
* Sets the point in time when the drive was assigned a tape.
*/
void setAssignmentTime(const time_t assignmentTime);
/**
* Gets the point in time when the drive was assigned a tape.
*
* @return Te point in time when the drive was assigned a tape.
*/
time_t getAssignmentTime() const;
/**
* Gets the current state of the tape drive.
*
......
......@@ -65,20 +65,6 @@ castor::tape::tapeserver::daemon::DriveCatalogueSession::SessionState castor::ta
return m_state;
}
//------------------------------------------------------------------------------
// setEvent
//------------------------------------------------------------------------------
void castor::tape::tapeserver::daemon::DriveCatalogueSession::setEvent(const castor::legacymsg::TapeUpdateDriveRqstMsgBody::TapeEvent event) {
m_event = event;
}
//------------------------------------------------------------------------------
// getEvent
//------------------------------------------------------------------------------
castor::legacymsg::TapeUpdateDriveRqstMsgBody::TapeEvent castor::tape::tapeserver::daemon::DriveCatalogueSession::getEvent() const {
return m_event;
}
//------------------------------------------------------------------------------
// setAssignmentTime
//------------------------------------------------------------------------------
......
......@@ -23,11 +23,9 @@
#pragma once
#include "castor/legacymsg/TapeUpdateDriveRqstMsgBody.hpp"
#include <unistd.h>
#include <sys/types.h>
#include <string>
#include <sys/types.h>
#include <unistd.h>
namespace castor {
namespace tape {
......@@ -63,22 +61,6 @@ namespace daemon {
*/
virtual pid_t getPid() const;
/**
* event setter method
*
* @param vid The status of the tape with respect to the drive mount and unmount
* operations.
*/
virtual void setEvent(const castor::legacymsg::TapeUpdateDriveRqstMsgBody::TapeEvent event);
/**
* event getter method
*
* @return The status of the tape with respect to the drive mount and unmount
* operations.
*/
virtual castor::legacymsg::TapeUpdateDriveRqstMsgBody::TapeEvent getEvent() const;
/**
* Sets the point in time when the drive was assigned a tape.
*/
......@@ -125,12 +107,6 @@ namespace daemon {
*/
time_t m_assignmentTime;
/**
* The status of the tape with respect to the drive mount and unmount
* operations.
*/
castor::legacymsg::TapeUpdateDriveRqstMsgBody::TapeEvent m_event;
/**
* The state of the drive catalogue session
*/
......
......@@ -24,7 +24,6 @@
#include "castor/log/Logger.hpp"
#include "castor/tape/tapeserver/daemon/DriveCatalogue.hpp"
#include "castor/legacymsg/MessageHeader.hpp"
#include "castor/legacymsg/TapeUpdateDriveRqstMsgBody.hpp"
#include "castor/legacymsg/VdqmProxy.hpp"
#include "castor/legacymsg/VmgrProxy.hpp"
#include "castor/tape/reactor/ZMQReactor.hpp"
......
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