diff --git a/tapeserver/castor/messages/AcsProxy.cpp b/common/Constants.hpp similarity index 80% rename from tapeserver/castor/messages/AcsProxy.cpp rename to common/Constants.hpp index 597a18dc0d53eba85c16970f7384119ace8ae807..0ce76c46a0ce638751a9045ab6e590991fb26b07 100644 --- a/tapeserver/castor/messages/AcsProxy.cpp +++ b/common/Constants.hpp @@ -18,13 +18,16 @@ * * * + * * @author Castor Dev team, castor-dev@cern.ch *****************************************************************************/ -#include "castor/messages/AcsProxy.hpp" +#pragma once + +namespace cta { + +const int CA_MAXVIDLEN = 6; // maximum length for a VID + +} // namespace cta + -//----------------------------------------------------------------------------- -// destructor -//----------------------------------------------------------------------------- -castor::messages::AcsProxy::~AcsProxy() { -} diff --git a/mediachanger/CMakeLists.txt b/mediachanger/CMakeLists.txt index ceaf7a1b0a5e3cfe171209193e97a8d255e4c2b2..ece695a92ccc262d3fb09e64aad72029d4d4b46a 100644 --- a/mediachanger/CMakeLists.txt +++ b/mediachanger/CMakeLists.txt @@ -60,16 +60,16 @@ set (MEDIACHANGER_LIB_SRC_FILES ZmqSocketMT.cpp ZmqSocketST.cpp) -add_library (ctamediachanger2 SHARED +add_library (ctamediachanger SHARED ${MEDIACHANGER_LIB_SRC_FILES}) -target_link_libraries (ctamediachanger2 +target_link_libraries (ctamediachanger ctacommon protobuf ssl zmq) -install (TARGETS ctamediachanger2 DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) +install (TARGETS ctamediachanger DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) set (MEDIACHANGER_UNIT_TESTS_LIB_SRC_FILES AcsLibrarySlotTest.cpp @@ -83,37 +83,37 @@ set (MEDIACHANGER_UNIT_TESTS_LIB_SRC_FILES MountCmdLineTest.cpp ScsiLibrarySlotTest.cpp) -add_library (ctamediachangerunittests2 SHARED +add_library (ctamediachangerunittests SHARED ${MEDIACHANGER_UNIT_TESTS_LIB_SRC_FILES}) -target_link_libraries (ctamediachangerunittests2 - ctamediachanger2) +target_link_libraries (ctamediachangerunittests + ctamediachanger) -install (TARGETS ctamediachangerunittests2 DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) +install (TARGETS ctamediachangerunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) set (MEDIA_CHANGER_MOUNT_SRC_FILES MountCmd.cpp MountCmdLine.cpp MountCmdMain.cpp) -add_executable (cta-mediachanger-mount2 ${MEDIA_CHANGER_MOUNT_SRC_FILES}) -set_target_properties (cta-mediachanger-mount2 PROPERTIES +add_executable (cta-mediachanger-mount ${MEDIA_CHANGER_MOUNT_SRC_FILES}) +set_target_properties (cta-mediachanger-mount PROPERTIES COMPILE_FLAGS -I/usr/include/CDK COMPILE_DEFINITIONS LINUX) -target_link_libraries (cta-mediachanger-mount2 +target_link_libraries (cta-mediachanger-mount ctacommon - ctamediachanger2) -install (TARGETS cta-mediachanger-mount2 DESTINATION /usr/bin) -install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-mediachanger-mount2.1cta DESTINATION /usr/share/man/man1) + ctamediachanger) +install (TARGETS cta-mediachanger-mount DESTINATION /usr/bin) +install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-mediachanger-mount.1cta DESTINATION /usr/share/man/man1) set (MEDIA_CHANGER_DISMOUNT_SRC_FILES DismountCmd.cpp DismountCmdLine.cpp DismountCmdMain.cpp) -add_executable (cta-mediachanger-dismount2 +add_executable (cta-mediachanger-dismount ${MEDIA_CHANGER_DISMOUNT_SRC_FILES}) -set_target_properties (cta-mediachanger-dismount2 PROPERTIES +set_target_properties (cta-mediachanger-dismount PROPERTIES COMPILE_FLAGS -I/usr/include/CDK COMPILE_DEFINITIONS LINUX) -target_link_libraries (cta-mediachanger-dismount2 +target_link_libraries (cta-mediachanger-dismount ctacommon - ctamediachanger2) + ctamediachanger) diff --git a/mediachanger/Constants.hpp b/mediachanger/Constants.hpp index 58e7090a76a38d2b3210b98277ba8ffc1e34c529..8e5b5fc08910b0b5c29cdffef2a31ccd76e5c4be 100644 --- a/mediachanger/Constants.hpp +++ b/mediachanger/Constants.hpp @@ -34,8 +34,6 @@ const size_t HOSTNAMEBUFLEN = 256; const int LISTENBACKLOG = 2; const size_t SERVICENAMEBUFLEN = 256; -const int CA_MAXVIDLEN = 6; // maximum length for a VID - enum ProtocolType { PROTOCOL_TYPE_NONE, PROTOCOL_TYPE_TAPE diff --git a/mediachanger/RmcMountMsgBody.hpp b/mediachanger/RmcMountMsgBody.hpp index 792dfc9cd2925f7792d039c94165e618328c899b..b2f586f7e5c965bda3eef09fc1044f1bdb9110a9 100644 --- a/mediachanger/RmcMountMsgBody.hpp +++ b/mediachanger/RmcMountMsgBody.hpp @@ -23,7 +23,7 @@ #pragma once -#include "mediachanger/Constants.hpp" +#include "common/Constants.hpp" #include <stdint.h> diff --git a/mediachanger/RmcUnmountMsgBody.hpp b/mediachanger/RmcUnmountMsgBody.hpp index 2719d73d8a97a6d3e58e615ff43ece34a3f89408..237d303e3873f9c524c9bf91b6e5106cd18c1561 100644 --- a/mediachanger/RmcUnmountMsgBody.hpp +++ b/mediachanger/RmcUnmountMsgBody.hpp @@ -23,7 +23,7 @@ #pragma once -#include "mediachanger/Constants.hpp" +#include "common/Constants.hpp" #include <stdint.h> diff --git a/tapeserver/castor/CMakeLists.txt b/tapeserver/castor/CMakeLists.txt index 0a1eb4de79f780534c72922400671350b92d19a9..f7da4be66857f9df0f9451240ba3e249d2c87b70 100644 --- a/tapeserver/castor/CMakeLists.txt +++ b/tapeserver/castor/CMakeLists.txt @@ -20,7 +20,6 @@ cmake_minimum_required (VERSION 2.6) add_subdirectory (io) add_subdirectory (legacymsg) -add_subdirectory (mediachanger) add_subdirectory (messages) add_subdirectory (tape) add_subdirectory (utils) diff --git a/tapeserver/castor/legacymsg/CMakeLists.txt b/tapeserver/castor/legacymsg/CMakeLists.txt index 95ed008cf93e35619445b29efe0c38bdffae5b05..8222c4bc59e63082baa59fd66fd2ec654a62a76d 100644 --- a/tapeserver/castor/legacymsg/CMakeLists.txt +++ b/tapeserver/castor/legacymsg/CMakeLists.txt @@ -5,8 +5,6 @@ include_directories(${PROJECT_SOURCE_DIR}/tapeserver/h) add_library (ctalegacymsg TapeLabelRqstMsgBody.cpp - RmcProxyTcpIp.cpp - RmcMarshal.cpp GenericMarshal.cpp MessageHeader.cpp legacymsg.cpp @@ -17,11 +15,7 @@ add_library (ctalegacymsg TapeStatRequestMsgBody.cpp GenericErrorReplyMsgBody.cpp GenericReplyMsgBody.cpp - TapeStatDriveEntry.cpp - RmcProxy.cpp - RmcMountMsgBody.cpp - RmcUnmountMsgBody.cpp - RmcProxyDummy.cpp) + TapeStatDriveEntry.cpp) add_library (ctalegacymsgunittests SHARED CommonMarshalTest.cpp diff --git a/tapeserver/castor/legacymsg/RmcMarshal.cpp b/tapeserver/castor/legacymsg/RmcMarshal.cpp deleted file mode 100644 index 9320933b8a2940e1936404c2cb83b7b754c91243..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcMarshal.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/****************************************************************************** - * - * 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/io/io.hpp" -#include "castor/legacymsg/RmcMarshal.hpp" -#include "rmc_constants.h" - -#include <string.h> - -//----------------------------------------------------------------------------- -// marshal -//----------------------------------------------------------------------------- -size_t castor::legacymsg::marshal(char *const dst, const size_t dstLen, const RmcMountMsgBody &src) { - const char *task = "marshal RmcMountMsgBody"; - - if(dst == NULL) { - cta::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(src.uid) + - sizeof(src.gid) + - strlen(src.unusedLoader) + 1 + - strlen(src.vid) + 1 + - sizeof(src.side) + - sizeof(src.drvOrd); - - // 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) { - cta::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 = RMC_MAGIC; - const uint32_t reqType = RMC_MOUNT; - io::marshalUint32(magic , p); - io::marshalUint32(reqType, p); - io::marshalUint32(totalLen, p); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to " << task << ": Failed to marshal header: " - << ne.getMessage().str(); - throw ex; - } - - // Marshal message body - try { - io::marshalUint32(src.uid, p); - io::marshalUint32(src.gid, p); - io::marshalString(src.unusedLoader, p); - io::marshalString(src.vid, p); - io::marshalUint16(src.side, p); - io::marshalUint16(src.drvOrd, p); - } catch(cta::exception::Exception &ne) { - cta::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) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to " << task << - ": Mismatch between expected total length and actual" - ": expected=" << totalLen << " actual=" << nbBytesMarshalled; - throw ex; - } - - return totalLen; -} - -//----------------------------------------------------------------------------- -// unmarshal -//----------------------------------------------------------------------------- -void castor::legacymsg::unmarshal(const char * &src, size_t &srcLen, RmcMountMsgBody &dst) { - try { - io::unmarshalUint32(src, srcLen, dst.uid); - io::unmarshalUint32(src, srcLen, dst.gid); - io::unmarshalString(src, srcLen, dst.unusedLoader); - io::unmarshalString(src, srcLen, dst.vid); - io::unmarshalUint16(src, srcLen, dst.side); - io::unmarshalUint16(src, srcLen, dst.drvOrd); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to unmarshal RmcMountMsgBody: " << - ne.getMessage().str(); - throw ex; - } -} - -//----------------------------------------------------------------------------- -// marshal -//----------------------------------------------------------------------------- -size_t castor::legacymsg::marshal(char *const dst, const size_t dstLen, const RmcUnmountMsgBody &src) { - const char *const task = "marshal RmcUnmountMsgBody"; - - if(dst == NULL) { - cta::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(src.uid) + - sizeof(src.gid) + - strlen(src.unusedLoader) + 1 + - strlen(src.vid) + 1 + - sizeof(src.drvOrd) + - sizeof(src.force); - - // 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) { - cta::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 = RMC_MAGIC; - const uint32_t reqType = RMC_UNMOUNT; - io::marshalUint32(magic , p); - io::marshalUint32(reqType, p); - io::marshalUint32(totalLen, p); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to " << task << ": Failed to marshal header: " - << ne.getMessage().str(); - throw ex; - } - - // Marshal message body - try { - io::marshalUint32(src.uid, p); - io::marshalUint32(src.gid, p); - io::marshalString(src.unusedLoader, p); - io::marshalString(src.vid, p); - io::marshalUint16(src.drvOrd, p); - io::marshalUint16(src.force, p); - } catch(cta::exception::Exception &ne) { - cta::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) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to " << task << - ": Mismatch between expected total length and actual" - ": expected=" << totalLen << " actual=" << nbBytesMarshalled; - throw ex; - } - - return totalLen; -} - -//----------------------------------------------------------------------------- -// unmarshal -//----------------------------------------------------------------------------- -void castor::legacymsg::unmarshal(const char * &src, size_t &srcLen, RmcUnmountMsgBody &dst) { - try { - io::unmarshalUint32(src, srcLen, dst.uid); - io::unmarshalUint32(src, srcLen, dst.gid); - io::unmarshalString(src, srcLen, dst.unusedLoader); - io::unmarshalString(src, srcLen, dst.vid); - io::unmarshalUint16(src, srcLen, dst.drvOrd); - io::unmarshalUint16(src, srcLen, dst.force); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to unmarshal RmcUnmountMsgBody: " << - ne.getMessage().str(); - throw ex; - } -} diff --git a/tapeserver/castor/legacymsg/RmcMarshal.hpp b/tapeserver/castor/legacymsg/RmcMarshal.hpp deleted file mode 100644 index bd65b63caa5ac9dc95a32274bdf3ecb9f4a16196..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcMarshal.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/****************************************************************************** - * - * 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/legacymsg/RmcMountMsgBody.hpp" -#include "castor/legacymsg/RmcUnmountMsgBody.hpp" -#include "common/exception/Exception.hpp" - -namespace castor { -namespace legacymsg { - -/** - * 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 RmcMountMsgBody &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 RmcMountMsgBody &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/out 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, RmcMountMsgBody &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 RmcUnmountMsgBody &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 RmcUnmountMsgBody &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/out 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, RmcUnmountMsgBody &dst) ; - -} // namespace legacymsg -} // namespace castor - diff --git a/tapeserver/castor/legacymsg/RmcMountMsgBody.cpp b/tapeserver/castor/legacymsg/RmcMountMsgBody.cpp deleted file mode 100644 index 44be575cb05d88b0a924c2253ec9508197e6f1b4..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcMountMsgBody.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * - * 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/RmcMountMsgBody.hpp" - -#include <string.h> - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::legacymsg::RmcMountMsgBody::RmcMountMsgBody() throw(): - uid(0), - gid(0), - side(0), - drvOrd(0) { - memset(unusedLoader, '\0', sizeof(unusedLoader)); - memset(vid, '\0', sizeof(vid)); -} diff --git a/tapeserver/castor/legacymsg/RmcMountMsgBody.hpp b/tapeserver/castor/legacymsg/RmcMountMsgBody.hpp deleted file mode 100644 index bcd8a976aa44b59cb5533ba32ce672eb2c9ccfe4..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcMountMsgBody.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** - * - * 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 "tapeserver/h/Castor_limits.h" -#include <stdint.h> - -namespace castor { -namespace legacymsg { - -/** - * The body of an RMC_SCSI_MOUNT message. - */ -struct RmcMountMsgBody { - uint32_t uid; - uint32_t gid; - char unusedLoader[1]; // Should always be set to the emtpy string - char vid[CA_MAXVIDLEN + 1]; - uint16_t side; - uint16_t drvOrd; - - /** - * Constructor. - * - * Sets all integer member-variables to 0 and all string member-variables to - * the empty string. - */ - RmcMountMsgBody() throw(); -}; // struct RmcMountMsgBody - -} // namespace legacymsg -} // namespace castor - diff --git a/tapeserver/castor/legacymsg/RmcProxy.cpp b/tapeserver/castor/legacymsg/RmcProxy.cpp deleted file mode 100644 index 6103e369a15b9d72462956a5b008b259587697f6..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcProxy.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * - * 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/RmcProxy.hpp" - -//----------------------------------------------------------------------------- -// destructor -//----------------------------------------------------------------------------- -castor::legacymsg::RmcProxy::~RmcProxy() throw() { -} diff --git a/tapeserver/castor/legacymsg/RmcProxy.hpp b/tapeserver/castor/legacymsg/RmcProxy.hpp deleted file mode 100644 index ec99ea5afd4811b116dca4fe3f0045e8d4eb08b9..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcProxy.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/****************************************************************************** - * - * 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 "tapeserver/castor/mediachanger/ScsiLibrarySlot.hpp" -#include "common/exception/Exception.hpp" - -#include <string> - -namespace castor { -namespace legacymsg { - -/** - * Abstract class defining the interface to a proxy object representing the - * SCSI media-changer daemon (rmcd). - */ -class RmcProxy { -public: - - /** - * Destructor. - */ - virtual ~RmcProxy() throw() = 0; - - /** - * Requests the media changer to mount the specified tape for read-only - * access into the drive in the specified library slot. - * - * Please note that this method provides a best-effort service because not all - * media changers support read-only mounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - virtual void mountTapeReadOnly(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) = 0; - - /** - * Requests the media changer to mount of the specified tape for read/write - * access into the drive in the specified library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - virtual void mountTapeReadWrite(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) = 0; - - /** - * Requests the media changer to dismount of the specified tape from the - * drive in the specifed library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - virtual void dismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) = 0; - - /** - * Requests the media changer to forcefully dismount the specified tape from - * the drive in the specifed library slot. Forcefully means rewinding and - * ejecting the tape where necessary. - * - * Please note that this method provides a best-effort service because not all - * media changers support forceful dismounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - virtual void forceDismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) = 0; - -}; // class RmcProxy - -} // namespace legacymsg -} // namespace castor - diff --git a/tapeserver/castor/legacymsg/RmcProxyDummy.cpp b/tapeserver/castor/legacymsg/RmcProxyDummy.cpp deleted file mode 100644 index 342dceb609cdadc0c82bb3c5c5dc534386a6edef..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcProxyDummy.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** - * - * 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/RmcProxyDummy.hpp" - -//------------------------------------------------------------------------------ -// mountTapeReadOnly -//------------------------------------------------------------------------------ -void castor::legacymsg::RmcProxyDummy::mountTapeReadOnly(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) { -} - -//------------------------------------------------------------------------------ -// mountTapeReadWrite -//------------------------------------------------------------------------------ -void castor::legacymsg::RmcProxyDummy::mountTapeReadWrite(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) { -} - -//------------------------------------------------------------------------------ -// dismountTape -//------------------------------------------------------------------------------ -void castor::legacymsg::RmcProxyDummy::dismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) { -} - -//------------------------------------------------------------------------------ -// forceDismountTape -//------------------------------------------------------------------------------ -void castor::legacymsg::RmcProxyDummy::forceDismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) { -} diff --git a/tapeserver/castor/legacymsg/RmcProxyDummy.hpp b/tapeserver/castor/legacymsg/RmcProxyDummy.hpp deleted file mode 100644 index f84d058d7ac3bc8c25d5c5b21767a743f5b14c07..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcProxyDummy.hpp +++ /dev/null @@ -1,87 +0,0 @@ -/****************************************************************************** - * - * 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/legacymsg/RmcProxy.hpp" - -#include <string> - -namespace castor { -namespace legacymsg { - -/** - * Concrete class implementing a dummy RmcProxyDummy. - */ -class RmcProxyDummy: public RmcProxy { -public: - - /** - * Requests the media changer to mount the specified tape for read-only - * access into the drive in the specified library slot. - * - * Please note that this method provides a best-effort service because not all - * media changers support read-only mounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadOnly(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot); - - /** - * Requests the media changer to mount of the specified tape for read/write - * access into the drive in the specified library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadWrite(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot); - - /** - * Requests the media changer to dismount of the specified tape from the - * drive in the specifed library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void dismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot); - - /** - * Requests the media changer to forcefully dismount the specified tape from - * the drive in the specifed library slot. Forcefully means rewinding and - * ejecting the tape where necessary. - * - * Please note that this method provides a best-effort service because not all - * media changers support forceful dismounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void forceDismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot); - -}; // class RmcProxyDummy - -} // namespace legacymsg -} // namespace castor diff --git a/tapeserver/castor/legacymsg/RmcProxyTcpIp.cpp b/tapeserver/castor/legacymsg/RmcProxyTcpIp.cpp deleted file mode 100644 index 26c68ee2ec305aa693160334f81ab615e8197c39..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcProxyTcpIp.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/****************************************************************************** - * - * 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/io/io.hpp" -#include "castor/legacymsg/CommonMarshal.hpp" -#include "castor/legacymsg/RmcMarshal.hpp" -#include "castor/legacymsg/RmcProxyTcpIp.hpp" -#include "castor/utils/utils.hpp" -#include "Castor_limits.h" -#include "common/SmartFd.hpp" -#include "rmc_constants.h" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::legacymsg::RmcProxyTcpIp::RmcProxyTcpIp( - const unsigned short rmcPort, - const int netTimeout, - const unsigned int maxRqstAttempts) throw(): - m_rmcPort(rmcPort), - m_netTimeout(netTimeout), - m_maxRqstAttempts(maxRqstAttempts) { -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::legacymsg::RmcProxyTcpIp::~RmcProxyTcpIp() throw() { -} - -//------------------------------------------------------------------------------ -// mountTapeReadOnly -//------------------------------------------------------------------------------ -void castor::legacymsg::RmcProxyTcpIp::mountTapeReadOnly( - const std::string &vid, const mediachanger::ScsiLibrarySlot &librarySlot) { - // SCSI libraries do not support read-only mounts - mountTapeReadWrite(vid, librarySlot); -} - -//------------------------------------------------------------------------------ -// mountTapeReadWrite -//------------------------------------------------------------------------------ -void castor::legacymsg::RmcProxyTcpIp::mountTapeReadWrite( - const std::string &vid, const mediachanger::ScsiLibrarySlot &librarySlot) { - try { - RmcMountMsgBody rqstBody; - rqstBody.uid = geteuid(); - rqstBody.gid = getegid(); - castor::utils::copyString(rqstBody.vid, vid); - rqstBody.drvOrd = librarySlot.getDrvOrd(); - - rmcSendRecvNbAttempts(m_maxRqstAttempts, rqstBody); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << - "Failed to mount tape in SCSI tape-library for read/write access" - ": vid=" << vid << " librarySlot=" << librarySlot.str() << ": " << - ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// dismountTape -//------------------------------------------------------------------------------ -void castor::legacymsg::RmcProxyTcpIp::dismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) { - try { - RmcUnmountMsgBody rqstBody; - rqstBody.uid = geteuid(); - rqstBody.gid = getegid(); - castor::utils::copyString(rqstBody.vid, vid); - rqstBody.drvOrd = librarySlot.getDrvOrd(); - rqstBody.force = 0; - - rmcSendRecvNbAttempts(m_maxRqstAttempts, rqstBody); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << - "Failed to dismount tape in SCSI tape-library" - ": vid=" << vid << " librarySlot=" << librarySlot.str() << ": " << - ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// forceDismountTape -//------------------------------------------------------------------------------ -void castor::legacymsg::RmcProxyTcpIp::forceDismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot) { - // SCSI libraries do not support forced dismounts - dismountTape(vid, librarySlot); -} - -//----------------------------------------------------------------------------- -// connectToRmc -//----------------------------------------------------------------------------- -int castor::legacymsg::RmcProxyTcpIp::connectToRmc() - const { - const std::string rmcHost = "localhost"; - cta::SmartFd smartConnectSock; - try { - smartConnectSock.reset(io::connectWithTimeout(rmcHost, m_rmcPort, - m_netTimeout)); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to connect to rmcd: rmcHost=" << rmcHost - << " rmcPort=" << RMC_PORT << ": " << ne.getMessage().str(); - throw ex; - } - - return smartConnectSock.release(); -} - -//----------------------------------------------------------------------------- -// writeRmcMountMsg -//----------------------------------------------------------------------------- -void castor::legacymsg::RmcProxyTcpIp::writeRmcMountMsg(const int fd, - const RmcMountMsgBody &body) { - char buf[RMC_MSGBUFSIZ]; - const size_t len = marshal(buf, body); - - try { - io::writeBytes(fd, m_netTimeout, len, buf); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to write RMC_SCSI_MOUNT message: " - << ne.getMessage().str(); - throw ex; - } -} - -//----------------------------------------------------------------------------- -// readRmcMsgHeader -//----------------------------------------------------------------------------- -castor::legacymsg::MessageHeader - castor::legacymsg::RmcProxyTcpIp::readRmcMsgHeader(const int fd) { - char buf[12]; // Magic + type + len - MessageHeader header; - - try { - io::readBytes(fd, m_netTimeout, sizeof(buf), buf); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to read message header: " - << ne.getMessage().str(); - throw ex; - } - - const char *bufPtr = buf; - size_t bufLen = sizeof(buf); - unmarshal(bufPtr, bufLen, header); - - if(RMC_MAGIC != header.magic) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to read message header: " - " Header contains an invalid magic number: expected=0x" << std::hex << - RMC_MAGIC << " actual=0x" << header.magic; - throw ex; - } - - return header; -} - -//----------------------------------------------------------------------------- -// writeRmcUnmountMsg -//----------------------------------------------------------------------------- -void castor::legacymsg::RmcProxyTcpIp::writeRmcUnmountMsg(const int fd, - const RmcUnmountMsgBody &body) { - char buf[RMC_MSGBUFSIZ]; - const size_t len = marshal(buf, body); - - try { - io::writeBytes(fd, m_netTimeout, len, buf); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to write RMC_SCSI_UNMOUNT message: " - << ne.getMessage().str(); - throw ex; - } -} - -//----------------------------------------------------------------------------- -// rmcReplyTypeToStr -//----------------------------------------------------------------------------- -std::string castor::legacymsg::RmcProxyTcpIp::rmcReplyTypeToStr( - const int replyType) { - std::ostringstream oss; - switch(replyType) { - case RMC_RC: - oss << "RMC_RC"; - break; - case MSG_ERR: - oss << "MSG_ERR"; - break; - default: - oss << "UNKNOWN(0x" << std::hex << replyType << ")"; - } - return oss.str(); -} - -//----------------------------------------------------------------------------- -// handleMSG_ERR -//----------------------------------------------------------------------------- -std::string castor::legacymsg::RmcProxyTcpIp::handleMSG_ERR( - const MessageHeader &header, - const int fd) { - char errorBuf[1024]; - const int nbBytesToRead = header.lenOrStatus > sizeof(errorBuf) ? - sizeof(errorBuf) : header.lenOrStatus; - io::readBytes(fd, m_netTimeout, nbBytesToRead, errorBuf); - errorBuf[sizeof(errorBuf) - 1] = '\0'; - return errorBuf; -} diff --git a/tapeserver/castor/legacymsg/RmcProxyTcpIp.hpp b/tapeserver/castor/legacymsg/RmcProxyTcpIp.hpp deleted file mode 100644 index 61f48349036ba9578fe520079c31b371aea9231e..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcProxyTcpIp.hpp +++ /dev/null @@ -1,310 +0,0 @@ -/****************************************************************************** - * - * 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 "tapeserver/castor/io/io.hpp" -#include "MessageHeader.hpp" -#include "RmcMountMsgBody.hpp" -#include "RmcProxy.hpp" -#include "RmcUnmountMsgBody.hpp" -#include "tapeserver/castor/utils/utils.hpp" -#include "common/SmartFd.hpp" -#include "tapeserver/h/rmc_constants.h" - -#include <unistd.h> -#include <sys/types.h> - -/* - *------------------------------------------------------------------------ - * RMC (Remote SCSI media changer server) errors - *------------------------------------------------------------------------ - */ -#define ERMBASEOFF 2200 /* RMC error base offset */ -#define ERMCNACT ERMBASEOFF+1 /* Remote SCSI media changer server not active or service being drained */ -#define ERMCRBTERR (ERMBASEOFF+2) /* Remote SCSI media changer error */ -#define ERMCUNREC ERMCRBTERR+1 /* Remote SCSI media changer unrec. error */ -#define ERMCSLOWR ERMCRBTERR+2 /* Remote SCSI media changer error (slow retry) */ -#define ERMCFASTR ERMCRBTERR+3 /* Remote SCSI media changer error (fast retry) */ -#define ERMCDFORCE ERMCRBTERR+4 /* Remote SCSI media changer error (demount force) */ -#define ERMCDDOWN ERMCRBTERR+5 /* Remote SCSI media changer error (drive down) */ -#define ERMCOMSGN ERMCRBTERR+6 /* Remote SCSI media changer error (ops message) */ -#define ERMCOMSGS ERMCRBTERR+7 /* Remote SCSI media changer error (ops message + retry) */ -#define ERMCOMSGR ERMCRBTERR+8 /* Remote SCSI media changer error (ops message + wait) */ -#define ERMCUNLOAD ERMCRBTERR+9 /* Remote SCSI media changer error (unload + demount) */ -#define ERMMAXERR ERMBASEOFF+11 - -namespace castor { -namespace legacymsg { - -/** - * A concrete implementation of the interface to the rmc daemon. - */ -class RmcProxyTcpIp: public RmcProxy { -public: - - /** - * Constructor. - * - * @param rmcPort The TCP/IP port on which the rmcd daemon is listening. - * @param netTimeout The timeout in seconds to be applied when performing - * network read and write operations. - * @parm maxRqstAttempts The maximum number of attempts a retriable RMC - * request should be issued. - */ - RmcProxyTcpIp( - const unsigned short rmcPort, - const int netTimeout, - const unsigned int maxRqstAttempts) throw(); - - /** - * Destructor. - */ - ~RmcProxyTcpIp() throw(); - - /** - * Requests the media changer to mount the specified tape for read-only - * access into the drive in the specified library slot. - * - * Please note that this method provides a best-effort service because not all - * media changers support read-only mounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadOnly(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot); - - /** - * Requests the media changer to mount of the specified tape for read/write - * access into the drive in the specified library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadWrite(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot); - - /** - * Requests the media changer to dismount of the specified tape from the - * drive in the specifed library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void dismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot); - - /** - * Requests the media changer to forcefully dismount the specified tape from - * the drive in the specifed library slot. Forcefully means rewinding and - * ejecting the tape where necessary. - * - * Please note that this method provides a best-effort service because not all - * media changers support forceful dismounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void forceDismountTape(const std::string &vid, - const mediachanger::ScsiLibrarySlot &librarySlot); - -protected: - - /** - * The size of buffer used to marshal or unmarshal RMC messages. - */ - static const int RMC_MSGBUFSIZ = 256; - - /** - * The TCP/IP port on which the rmcd daemon is listening. - */ - const unsigned short m_rmcPort; - - /** - * The timeout in seconds to be applied when performing network read and - * write operations. - */ - const int m_netTimeout; - - /** - * The maximum number of attempts a retriable RMC request should be issued. - */ - const unsigned int m_maxRqstAttempts; - - /** - * Connects to the rmcd daemon. - * - * Please note that the rmcd daemon only listens on loopback interface. - * - * @return The socket-descriptor of the connection with the rmcd daemon. - */ - int connectToRmc() const ; - - /** - * Writes an RMC_SCSI_MOUNT message with the specifed body to the specified - * connection. - * - * @param fd The file descriptor of the connection. - * @param body The body of the message. - */ - void writeRmcMountMsg(const int fd, const RmcMountMsgBody &body) ; - - /** - * Reads the header of an RMC_MAGIC message from the specified connection. - * - * @param fd The file descriptor of the connection. - * @return The message header. - */ - MessageHeader readRmcMsgHeader(const int fd) ; - - /** - * Writes an RMC_SCSI_UNMOUNT message with the specifed body to the specified - * connection. - * - * @param fd The file descriptor of the connection. - * @param body The body of the message. - */ - void writeRmcUnmountMsg(const int fd, const RmcUnmountMsgBody &body) ; - - /** - * Sends the specified request to the rmcd daemon and receives the reply - * until success or the specified number of retriable attempts has been - * reached. - * - * @param maxAttempts The maximum number of retriable attempts. - * @param rqstBody The request to be sent. - */ - template<typename T> void rmcSendRecvNbAttempts(const int maxAttempts, - const T &rqstBody) { - for(int attemptNb = 1; attemptNb <= maxAttempts; attemptNb++) { - std::ostringstream rmcErrorStream; - const int rmcRc = rmcSendRecv(rqstBody, rmcErrorStream); - switch(rmcRc) { - case 0: // Success - return; - case ERMCFASTR: // Fast retry - // If this was the last attempt - if(maxAttempts == attemptNb) { - cta::exception::Exception ex; - ex.getMessage() << - "Received error from rmcd after several fast retries" << - ": nbAttempts=" << attemptNb << " rmcErrorStream=" << - rmcErrorStream.str(); - throw ex; - } - - // Pause a moment between attempts - sleep(1); - - continue; - default: - { - cta::exception::Exception ex; - ex.getMessage() << "Received error from rmcd: rmcRc=" << rmcRc; - if(!rmcErrorStream.str().empty()) { - ex.getMessage() << " rmcErrorStream=" << rmcErrorStream.str(); - } - throw ex; - } - } - } - } - - /** - * Sends the specified request to the rmcd daemon and receives the reply. - * - * @param rqstBody The request to be sent. - * @param rmcErrorStream The error stream constructed from ERR_MSG received - * within the reply from the rmcd daemon. - * @param The RMC return code. - */ - template<typename T> int rmcSendRecv(const T &rqstBody, - std::ostringstream &rmcErrorStream) { - // Connect to rmcd and send request - cta::SmartFd fd(connectToRmc()); - { - char buf[RMC_MSGBUFSIZ]; - const size_t len = marshal(buf, rqstBody); - io::writeBytes(fd.get(), m_netTimeout, len, buf); - } - - // A single RMC reply is composed of 0 to 10 ERR_MSG replies - // followed by a terminating RMC_RC reply - const int maxERR_MSG = 10; - int nbERR_MSG = 0; - while(true) { - const MessageHeader header = readRmcMsgHeader(fd.get()); - switch(header.reqType) { - case RMC_RC: - return header.lenOrStatus; - case MSG_ERR: - nbERR_MSG++; - - if(maxERR_MSG < nbERR_MSG) { - cta::exception::Exception ex; - ex.getMessage() << - "Reply from rmcd contains too many ERR_MSG messages" - ": maxERR_MSG=" << maxERR_MSG << " rmcErrorStream=" << - rmcErrorStream.str(); - throw ex; - } - - if(nbERR_MSG > 1) { - rmcErrorStream << " "; - } - - rmcErrorStream << handleMSG_ERR(header, fd.get()); - break; - default: - { - cta::exception::Exception ex; - ex.getMessage() << - "First part of reply from rmcd has unexpected type" - ": expected=RMC_RC or MSG_ERR actual=" << - rmcReplyTypeToStr(header.reqType); - throw ex; - } - } // switch(header.reqType) - } // while(true) - } - - /** - * Returns a string representation of the specified RMC reply type. - * - * @param replyType The reply type. - * @return The string representation. - */ - std::string rmcReplyTypeToStr(const int replyType); - - /** - * Handles a MSG_ERR reply from rmcd. - * - * @param header The header of the reply. - * @param fd The file descriptor of the connection with rmcd daemon. - * @return The message contained within the MSG_ERR reply. - */ - std::string handleMSG_ERR(const MessageHeader &header, const int fd); - -}; // class RmcProxyTcpIp - -} // namespace legacymsg -} // namespace castor diff --git a/tapeserver/castor/legacymsg/RmcUnmountMsgBody.cpp b/tapeserver/castor/legacymsg/RmcUnmountMsgBody.cpp deleted file mode 100644 index 41d3538a64a2e9d878f95a11bee289d752f1beb0..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcUnmountMsgBody.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * - * 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/RmcUnmountMsgBody.hpp" - -#include <string.h> - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::legacymsg::RmcUnmountMsgBody::RmcUnmountMsgBody() throw(): - uid(0), - gid(0), - drvOrd(0), - force(0) { - memset(unusedLoader, '\0', sizeof(unusedLoader)); - memset(vid, '\0', sizeof(vid)); -} diff --git a/tapeserver/castor/legacymsg/RmcUnmountMsgBody.hpp b/tapeserver/castor/legacymsg/RmcUnmountMsgBody.hpp deleted file mode 100644 index 9e9e8472795cb7595ae429337eb51d71ed948d0c..0000000000000000000000000000000000000000 --- a/tapeserver/castor/legacymsg/RmcUnmountMsgBody.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** - * - * 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 "tapeserver/h/Castor_limits.h" -#include <stdint.h> - -namespace castor { -namespace legacymsg { - -/** - * The body of an RMC_SCSI_UNMOUNT message. - */ -struct RmcUnmountMsgBody { - uint32_t uid; - uint32_t gid; - char unusedLoader[1]; // Should always be set to the emtpy string - char vid[CA_MAXVIDLEN + 1]; - uint16_t drvOrd; - uint16_t force; - - /** - * Constructor. - * - * Sets all integer member-variables to 0 and all string member-variables to - * the empty string. - */ - RmcUnmountMsgBody() throw(); -}; // struct RmcUnmountMsgBody - -} // namespace legacymsg -} // namespace castor - diff --git a/tapeserver/castor/legacymsg/TapeLabelRqstMsgBody.hpp b/tapeserver/castor/legacymsg/TapeLabelRqstMsgBody.hpp index ab6453b5d8346fcd7ddbaae64339e097647971f9..142b64b6aeaaf2481cfefd7139ae57884cef7eeb 100644 --- a/tapeserver/castor/legacymsg/TapeLabelRqstMsgBody.hpp +++ b/tapeserver/castor/legacymsg/TapeLabelRqstMsgBody.hpp @@ -24,6 +24,7 @@ #pragma once #include "h/Castor_limits.h" +#include "common/Constants.hpp" #include <stdint.h> namespace castor { @@ -37,7 +38,7 @@ struct TapeLabelRqstMsgBody { uint16_t force; // set to 1 if force==true, 0 otherwise uint32_t uid; uint32_t gid; - char vid[CA_MAXVIDLEN + 1]; + char vid[cta::CA_MAXVIDLEN + 1]; char drive[CA_MAXUNMLEN + 1]; char logicalLibrary[CA_MAXDGNLEN + 1]; diff --git a/tapeserver/castor/legacymsg/TapeStatDriveEntry.hpp b/tapeserver/castor/legacymsg/TapeStatDriveEntry.hpp index f640320286646231b158f532704d77488b9ca09c..d29bce4c180894cd9e3c64be909329d853967024 100644 --- a/tapeserver/castor/legacymsg/TapeStatDriveEntry.hpp +++ b/tapeserver/castor/legacymsg/TapeStatDriveEntry.hpp @@ -23,6 +23,7 @@ #pragma once +#include "common/Constants.hpp" #include "h/Castor_limits.h" #include <stdint.h> @@ -43,7 +44,7 @@ struct TapeStatDriveEntry { uint16_t mode; // WRITE_DISABLE or WRITE_ENABLE char lblcode[CA_MAXLBLTYPLEN+1]; // label code: AUL or DMP uint16_t tobemounted; // 1 means tape to be mounted - char vid[CA_MAXVIDLEN+1]; + char vid[cta::CA_MAXVIDLEN+1]; char vsn[CA_MAXVSNLEN+1]; uint32_t cfseq; // current file sequence number diff --git a/tapeserver/castor/mediachanger/AcsLibrarySlot.cpp b/tapeserver/castor/mediachanger/AcsLibrarySlot.cpp deleted file mode 100644 index efd2aedd25420e65c46437158ef79dc8747ffea5..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/AcsLibrarySlot.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/AcsLibrarySlot.hpp" -#include "castor/utils/utils.hpp" - -#include <sstream> - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::AcsLibrarySlot::AcsLibrarySlot() throw(): - LibrarySlot(TAPE_LIBRARY_TYPE_ACS), - m_acs(0), - m_lsm(0), - m_panel(0), - m_drive(0) { - m_str = librarySlotToString(0, 0, 0, 0); -} - -//------------------------------------------------------------------------------ -// librarySlotToString -//------------------------------------------------------------------------------ -std::string castor::mediachanger::AcsLibrarySlot::librarySlotToString( - const uint32_t acs, const uint32_t lsm, const uint32_t panel, - const uint32_t drive) const { - std::ostringstream oss; - oss << "acs" << acs << "," << lsm << "," << panel << "," << drive; - return oss.str(); -} - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::AcsLibrarySlot::AcsLibrarySlot(const uint32_t acs, - const uint32_t lsm, const uint32_t panel, const uint32_t drive) throw(): - LibrarySlot(TAPE_LIBRARY_TYPE_ACS), - m_acs(acs), - m_lsm(lsm), - m_panel(panel), - m_drive(drive) { - m_str = librarySlotToString(acs, lsm, panel, drive); -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::mediachanger::AcsLibrarySlot::~AcsLibrarySlot() throw() { -} - -//------------------------------------------------------------------------------ -// clone -//------------------------------------------------------------------------------ -castor::mediachanger::LibrarySlot *castor::mediachanger::AcsLibrarySlot:: - clone() { - return new AcsLibrarySlot(*this); -} - -//------------------------------------------------------------------------------ -// getAcs -//------------------------------------------------------------------------------ -uint32_t castor::mediachanger::AcsLibrarySlot::getAcs() const throw () { - return m_acs; -} - -//------------------------------------------------------------------------------ -// getLsm -//------------------------------------------------------------------------------ -uint32_t castor::mediachanger::AcsLibrarySlot::getLsm() const throw () { - return m_lsm; -} - -//------------------------------------------------------------------------------ -// getPanel -//------------------------------------------------------------------------------ -uint32_t castor::mediachanger::AcsLibrarySlot::getPanel() const throw () { - return m_panel; -} - -//------------------------------------------------------------------------------ -// getDrive -//------------------------------------------------------------------------------ -uint32_t castor::mediachanger::AcsLibrarySlot::getDrive() const throw () { - return m_drive; -} diff --git a/tapeserver/castor/mediachanger/AcsLibrarySlot.hpp b/tapeserver/castor/mediachanger/AcsLibrarySlot.hpp deleted file mode 100644 index de3785061f5e164be947811550e568247c94845e..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/AcsLibrarySlot.hpp +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * - * 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 "common/exception/InvalidArgument.hpp" -#include "tapeserver/castor/mediachanger/LibrarySlot.hpp" - -#include <stdint.h> - -namespace castor { -namespace mediachanger { - -/** - * Class reprsenting a slot in an ACS tape-library. - */ -class AcsLibrarySlot: public LibrarySlot { -public: - - /** - * Default constructor that sets all integer members to 0. - */ - AcsLibrarySlot() throw(); - - /** - * Constructor. - * - * @param acs The acs component of the library slot. - * @param lsm The lsm component of the library slot. - * @param panel The panel component of the library slot. - * @param drive The drive component of the library slot. - */ - AcsLibrarySlot(const uint32_t acs, const uint32_t lsm, - const uint32_t panel, const uint32_t drive) throw(); - - /** - * Destructor. - */ - ~AcsLibrarySlot() throw(); - - /** - * Creates a clone of this object. - * - * @return The clone. - */ - LibrarySlot *clone(); - - /** - * Gets the acs component of the library slot. - * - * @return the acs component of the library slot. - */ - uint32_t getAcs() const throw(); - - /** - * Gets the lsm component of the library slot. - * - * @return the lsm component of the library slot. - */ - uint32_t getLsm() const throw(); - - /** - * Gets the panel component of the library slot. - * - * @return the panel component of the library slot. - */ - uint32_t getPanel() const throw(); - - /** - * Gets the drive component of the library slot. - * - * @return the drive component of the library slot. - */ - uint32_t getDrive() const throw(); - -private: - - /** - * The acs component of the library slot. - */ - uint32_t m_acs; - - /** - * The lsm component of the library slot. - */ - uint32_t m_lsm; - - /** - * The panel component of the library slot. - */ - uint32_t m_panel; - - /** - * The drive component of the library slot. - */ - uint32_t m_drive; - - /** - * Returns the string representation of the specified ACS library slot. - * - * @param acs The acs component of the library slot. - * @param lsm The lsm component of the library slot. - * @param panel The panel component of the library slot. - * @param drive The drive component of the library slot. - * @return The string representation. - */ - std::string librarySlotToString(const uint32_t acs, const uint32_t lsm, - const uint32_t panel, const uint32_t drive) const; - -}; // class AcsProxy - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/AcsLibrarySlotTest.cpp b/tapeserver/castor/mediachanger/AcsLibrarySlotTest.cpp deleted file mode 100644 index 487cf7c1edaf6cf0f113593ddd6dd9ca3fe94660..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/AcsLibrarySlotTest.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/AcsLibrarySlot.hpp" - -#include <gtest/gtest.h> -#include <memory> - -namespace unitTests { - -class castor_mediachanger_AcsLibrarySlotTest : public ::testing::Test { -protected: - - virtual void SetUp() { - } - - virtual void TearDown() { - } -}; - -TEST_F(castor_mediachanger_AcsLibrarySlotTest, goodDay) { - using namespace castor::mediachanger; - AcsLibrarySlot slot(11, 22, 33, 44); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, slot.getLibraryType()); - ASSERT_EQ(std::string("acs11,22,33,44"), slot.str()); - ASSERT_EQ((uint32_t)11, slot.getAcs()); - ASSERT_EQ((uint32_t)22, slot.getLsm()); - ASSERT_EQ((uint32_t)33, slot.getPanel()); - ASSERT_EQ((uint32_t)44, slot.getDrive()); -} - -TEST_F(castor_mediachanger_AcsLibrarySlotTest, clone) { - using namespace castor::mediachanger; - - std::unique_ptr<AcsLibrarySlot> slot1; - ASSERT_NO_THROW(slot1.reset(new AcsLibrarySlot(11, 22, 33, 44))); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, slot1->getLibraryType()); - ASSERT_EQ(std::string("acs11,22,33,44"), slot1->str()); - ASSERT_EQ((uint32_t)11, slot1->getAcs()); - ASSERT_EQ((uint32_t)22, slot1->getLsm()); - ASSERT_EQ((uint32_t)33, slot1->getPanel()); - ASSERT_EQ((uint32_t)44, slot1->getDrive()); - - std::unique_ptr<AcsLibrarySlot> slot2; - ASSERT_NO_THROW(slot2.reset((AcsLibrarySlot*)slot1->clone())); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, slot2->getLibraryType()); - ASSERT_EQ(std::string("acs11,22,33,44"), slot2->str()); - ASSERT_EQ((uint32_t)11, slot2->getAcs()); - ASSERT_EQ((uint32_t)22, slot2->getLsm()); - ASSERT_EQ((uint32_t)33, slot2->getPanel()); - ASSERT_EQ((uint32_t)44, slot2->getDrive()); -} - -} // namespace unitTests diff --git a/tapeserver/castor/mediachanger/CMakeLists.txt b/tapeserver/castor/mediachanger/CMakeLists.txt deleted file mode 100644 index b2bc597c0ed9688c08c9e8106b9ee15b13e5e6da..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ -# 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 -# -cmake_minimum_required (VERSION 2.6) - -include_directories(${CMAKE_SOURCE_DIR}/tapeserver) -include_directories(${PROJECT_BINARY_DIR}/tapeserver) - -set (MEDIA_CHANGER_LIB_SRC_FILES - AcsLibrarySlot.cpp - LibrarySlot.cpp - LibrarySlotParser.cpp - ManualLibrarySlot.cpp - MediaChangerFacade.cpp - MmcProxy.cpp - MmcProxyLog.cpp - MmcProxyNotSupported.cpp - ScsiLibrarySlot.cpp - TapeLibraryType.cpp) -add_library(ctamediachanger ${MEDIA_CHANGER_LIB_SRC_FILES}) - -add_library(ctamediachangerutils SHARED - MmcProxyDummy.cpp) -install(TARGETS ctamediachangerutils DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) - -set (MEDIA_CHANGER_MOUNT_SRC_FILES - CmdLine.cpp - CmdLineTool.cpp - DebugBuf.cpp - MountCmd.cpp - MountCmdLine.cpp - MountCmdMain.cpp) -add_executable (cta-mediachanger-mount ${MEDIA_CHANGER_MOUNT_SRC_FILES}) -set_target_properties (cta-mediachanger-mount PROPERTIES - COMPILE_FLAGS -I/usr/include/CDK - COMPILE_DEFINITIONS LINUX) -target_link_libraries (cta-mediachanger-mount - ctacommon - ctalegacymsg - ctamediachanger - ctamessages - ctautils - ctaio) -install (TARGETS cta-mediachanger-mount DESTINATION /usr/bin) -install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-mediachanger-mount.1cta DESTINATION /usr/share/man/man1) - -set (MEDIA_CHANGER_DISMOUNT_SRC_FILES - CmdLine.cpp - CmdLineTool.cpp - DebugBuf.cpp - DismountCmd.cpp - DismountCmdLine.cpp - DismountCmdMain.cpp) -add_executable (cta-mediachanger-dismount - ${MEDIA_CHANGER_DISMOUNT_SRC_FILES}) -set_target_properties (cta-mediachanger-dismount PROPERTIES - COMPILE_FLAGS -I/usr/include/CDK - COMPILE_DEFINITIONS LINUX) -target_link_libraries (cta-mediachanger-dismount - ctacommon - ctalegacymsg - ctamediachanger - ctamessages - ctautils - ctaio) - -add_library (ctamediachangerunittests SHARED - LibrarySlotParserTest.cpp - ManualLibrarySlotTest.cpp) - -install(TARGETS ctamediachangerunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) -install (TARGETS cta-mediachanger-dismount DESTINATION /usr/bin) -install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-mediachanger-dismount.1cta DESTINATION /usr/share/man/man1) diff --git a/tapeserver/castor/mediachanger/CmdLine.cpp b/tapeserver/castor/mediachanger/CmdLine.cpp deleted file mode 100644 index c87416e4fc52b9a226f9ca1232041a745c47efcf..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/CmdLine.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/CmdLine.hpp" -#include "common/exception/InvalidArgument.hpp" -#include "common/exception/MissingOperand.hpp" -#include <getopt.h> - -//------------------------------------------------------------------------------ -// handleMissingParameter -//------------------------------------------------------------------------------ -void castor::mediachanger::CmdLine::handleMissingParameter(const int opt) { - cta::exception::MissingOperand ex; - ex.getMessage() << "The -" << (char)opt << " option requires a parameter"; - throw ex; -} - -//------------------------------------------------------------------------------ -// handleUnknownOption -//------------------------------------------------------------------------------ -void castor::mediachanger::CmdLine::handleUnknownOption(const int opt) { - cta::exception::InvalidArgument ex; - if(0 == optopt) { - ex.getMessage() << "Unknown command-line option"; - } else { - ex.getMessage() << "Unknown command-line option: -" << (char)opt; - } - throw ex; -} diff --git a/tapeserver/castor/mediachanger/CmdLine.hpp b/tapeserver/castor/mediachanger/CmdLine.hpp deleted file mode 100644 index b2a6e717dad27abf692237c9b62fe4dcbe9467e9..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/CmdLine.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** - * - * 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 <string> - -namespace castor { -namespace mediachanger { - -/** - * Class containing the code common to the parsed command-line of the ACS - * command-line tools provided by CASTOR. - */ -class CmdLine { -protected: - - /** - * Handles the specified parameter that is missing a parameter. - * - * @param opt The option. - */ - void handleMissingParameter(const int opt); - - /** - * Handles the specified unknown option. - * - * @param opt The option. - */ - void handleUnknownOption(const int opt); - -}; // class CmdLine - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/CmdLineTool.cpp b/tapeserver/castor/mediachanger/CmdLineTool.cpp deleted file mode 100644 index 77ac5a5a173edf0772343c341a219bf6d574fbb6..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/CmdLineTool.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/CmdLineTool.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::CmdLineTool::CmdLineTool( - std::istream &inStream, - std::ostream &outStream, - std::ostream &errStream, - MediaChangerFacade &mc) throw(): - m_in(inStream), - m_out(outStream), - m_err(errStream), - m_mc(mc), - m_debugBuf(outStream), - m_dbg(&m_debugBuf) { -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::mediachanger::CmdLineTool::~CmdLineTool() throw() { -} - -//------------------------------------------------------------------------------ -// bool2Str -//------------------------------------------------------------------------------ -std::string castor::mediachanger::CmdLineTool::bool2Str(const bool value) - const throw() { - return value ? "TRUE" : "FALSE"; -} diff --git a/tapeserver/castor/mediachanger/CmdLineTool.hpp b/tapeserver/castor/mediachanger/CmdLineTool.hpp deleted file mode 100644 index 1128542389f04d492b35dc8311de89f2fbe2e378..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/CmdLineTool.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/MediaChangerFacade.hpp" -#include "castor/mediachanger/DebugBuf.hpp" - -#include <istream> -#include <ostream> -#include <string> - -namespace castor { -namespace mediachanger { - -/** - * Abstract class implementing common code and data structures for a - * command-line tool. - */ -class CmdLineTool { -public: - /** - * Constructor. - * - * @param inStream Standard input stream. - * @param outStream Standard output stream. - * @param errStream Standard error stream. - * @param mc Interface to the media changer. - */ - CmdLineTool(std::istream &inStream, std::ostream &outStream, - std::ostream &errStream, MediaChangerFacade &mc) - throw(); - - /** - * Pure-virtual destructor to guarantee this class is abstract. - */ - virtual ~CmdLineTool() throw() = 0; - -protected: - - /** - * Standard input stream. - */ - std::istream &m_in; - - /** - * Standard output stream. - */ - std::ostream &m_out; - - /** - * Standard error stream. - */ - std::ostream &m_err; - - /** - * Interface to the media changer. - */ - MediaChangerFacade &m_mc; - - /** - * Debug stream buffer that inserts a standard debug preamble before each - * message-line written to it. - */ - DebugBuf m_debugBuf; - - /** - * Stream used to write debug messages. - * - * This stream will insert a standard debug preamble before each message-line - * written to it. - */ - std::ostream m_dbg; - - /** - * Returns the string representation of the specfied boolean value. - * - * @param value The boolean value. - */ - std::string bool2Str(const bool value) const throw(); - -}; // class CmdLineTool - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/DebugBuf.cpp b/tapeserver/castor/mediachanger/DebugBuf.cpp deleted file mode 100644 index 504e383e831a930c749d190ded818ba707fe7258..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/DebugBuf.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/DebugBuf.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::DebugBuf::DebugBuf(std::ostream &os): - m_debug(false), m_os(os), m_writePreamble(true) { -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::mediachanger::DebugBuf::~DebugBuf() { -} - -//------------------------------------------------------------------------------ -// setDebug -//------------------------------------------------------------------------------ -void castor::mediachanger::DebugBuf::setDebug(const bool value) throw() { - m_debug = value; -} - -//------------------------------------------------------------------------------ -// overflow -//------------------------------------------------------------------------------ -std::streambuf::int_type castor::mediachanger::DebugBuf::overflow( - const int_type c) { - // Only write something if debug mode is on - if(m_debug) { - if(m_writePreamble) { - writePreamble(); - m_writePreamble = false; - } - m_os << (char)c; - } - - // If an end of line was encountered then the next write should be preceeded - // with a preamble - if('\n' == (char)c) { - m_writePreamble = true; - } - - return c; -} - -//------------------------------------------------------------------------------ -// writePreamble -//------------------------------------------------------------------------------ -void castor::mediachanger::DebugBuf::writePreamble() throw() { - m_os << "DEBUG: "; -} diff --git a/tapeserver/castor/mediachanger/DebugBuf.hpp b/tapeserver/castor/mediachanger/DebugBuf.hpp deleted file mode 100644 index c721cbd7c0582ae44ebb2a535a78681f04eccf3c..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/DebugBuf.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/****************************************************************************** - * - * 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 <ostream> -#include <streambuf> - -namespace castor { -namespace mediachanger { - -/** - * Stream buffer class used to prepend a standard preamble to debug - * message-lines. - * - * This stream buffer does not write any output if debug mode has not been - * turned on by calling setDebugMode(true). Any debug message written to this - * stream buffer will be discarded if debug mode is off. - */ -class DebugBuf : public std::streambuf { -public: - - /** - * Constructor. - * - * Initialises the the debug mode to be off. - * - * @param os The output stream to which each debug message-line togther with - * its standard preamble shall be written. - */ - DebugBuf(std::ostream &os); - - /** - * Destructor. - */ - ~DebugBuf(); - - /** - * Set the debug mode to be on (true) or off (false). - * - * The default set in the constructor is off (false). - */ - void setDebug(const bool value) throw(); - -protected: - - /** - * Sends the specified character to the output channnel. - */ - int_type overflow (const int_type c); - - /** - * Writes the standard preamble to the output stream. - */ - void writePreamble() throw(); - -private: - - /** - * True if debug mode is on. - */ - bool m_debug; - - /** - * The output stream to which each debug message-line togther with its - * standard preamble shall be written. - */ - std::ostream &m_os; - - /** - * True is a preamble should be written. - */ - bool m_writePreamble; - -}; // class DebugBuf - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/DismountCmd.cpp b/tapeserver/castor/mediachanger/DismountCmd.cpp deleted file mode 100644 index 80c1f60c26639a85e7d3c7d8e475b5bd00148000..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/DismountCmd.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/DismountCmd.hpp" - -#include <getopt.h> -#include <iostream> -#include <memory> - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::DismountCmd::DismountCmd( - std::istream &inStream, std::ostream &outStream, std::ostream &errStream, - MediaChangerFacade &mc) throw(): - CmdLineTool(inStream, outStream, errStream, mc) { -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::mediachanger::DismountCmd::~DismountCmd() throw() { - // Do nothing -} - -//------------------------------------------------------------------------------ -// exceptionThrowingMain -//------------------------------------------------------------------------------ -int castor::mediachanger::DismountCmd::exceptionThrowingMain(const int argc, - char *const *const argv) { - try { - m_cmdLine = DismountCmdLine(argc, argv); - } catch(cta::exception::Exception &ex) { - m_err << ex.getMessage().str() << std::endl; - m_err << std::endl; - m_err << m_cmdLine.getUsage() << std::endl; - return 1; - } - - // Display the usage message to standard out and exit with success if the - // user requested help - if(m_cmdLine.getHelp()) { - m_out << m_cmdLine.getUsage(); - return 0; - } - - // Setup debug mode to be on or off depending on the command-line arguments - m_debugBuf.setDebug(m_cmdLine.getDebug()); - - m_dbg << "VID = " << m_cmdLine.getVid() << std::endl; - m_dbg << "DRIVE_SLOT = " << m_cmdLine.getDriveLibrarySlot().str() << - std::endl; - - if(m_cmdLine.getForce()) { - m_mc.forceDismountTape(m_cmdLine.getVid(), - m_cmdLine.getDriveLibrarySlot()); - } else { - m_mc.dismountTape(m_cmdLine.getVid(), m_cmdLine.getDriveLibrarySlot()); - } - return 0; -} diff --git a/tapeserver/castor/mediachanger/DismountCmd.hpp b/tapeserver/castor/mediachanger/DismountCmd.hpp deleted file mode 100644 index e838b279ecb5d359488bbd86535333bc341ecd15..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/DismountCmd.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - * - * 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 "common/exception/InvalidArgument.hpp" -#include "common/exception/MissingOperand.hpp" -#include "castor/mediachanger/CmdLineTool.hpp" -#include "castor/mediachanger/DismountCmdLine.hpp" - -#include <stdint.h> - -namespace castor { -namespace mediachanger { - -/** - * The class implementing the command-line tool for dismounting tapes on both - * ACS and SCSI tape libraries. - */ -class DismountCmd: public CmdLineTool { -public: - - /** - * Constructor. - * - * @param inStream Standard input stream. - * @param outStream Standard output stream. - * @param errStream Standard error stream. - * @param mc Interface to the media changer. - */ - DismountCmd(std::istream &inStream, std::ostream &outStream, - std::ostream &errStream, MediaChangerFacade &mc) throw(); - - /** - * Destructor. - */ - virtual ~DismountCmd() throw(); - - /** - * The entry function of the command. - * - * @param argc The number of command-line arguments. - * @param argv The command-line arguments. - * @return The exit value of the program. - */ - int exceptionThrowingMain(const int argc, char *const *const argv); - -private: - - /** - * The parsed command-line. - * - * The value of this member variable is set within the main() method of this - * class. - */ - DismountCmdLine m_cmdLine; - -}; // class DismountCmd - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/DismountCmdLine.cpp b/tapeserver/castor/mediachanger/DismountCmdLine.cpp deleted file mode 100644 index 9915f98a99c8020a7fb071ddbc443eccf1b4144e..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/DismountCmdLine.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/****************************************************************************** - * - * 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 "common/exception/MissingOperand.hpp" -#include "castor/mediachanger/DismountCmdLine.hpp" -#include "castor/mediachanger/LibrarySlotParser.hpp" -#include "common/exception/Exception.hpp" - -#include <getopt.h> - -//----------------------------------------------------------------------------- -// constructor -//----------------------------------------------------------------------------- -castor::mediachanger::DismountCmdLine::DismountCmdLine() throw(): - m_debug(false), - m_help(false), - m_driveLibrarySlot(0), - m_force(false) { -} - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::DismountCmdLine::DismountCmdLine(const int argc, - char *const *const argv): - m_debug(false), - m_help(false), - m_driveLibrarySlot(0), - m_force(false) { - - static struct option longopts[] = { - {"debug", 0, NULL, 'd'}, - {"help" , 0, NULL, 'h'}, - {"force", 0, NULL, 'f'}, - {NULL , 0, NULL, 0} - }; - - // Prevent getopt() from printing an error message if it does not recognize - // an option character - opterr = 0; - - int opt = 0; - while((opt = getopt_long(argc, argv, ":dhf", longopts, NULL)) != -1) { - processOption(opt); - } - - // There is no need to continue parsing when the help option is set - if(m_help) { - return; - } - - // Calculate the number of non-option ARGV-elements - const int nbArgs = argc - optind; - - // Check that both VID and DRIVE_SLOT has been specified - if(nbArgs < 2) { - cta::exception::MissingOperand ex; - ex.getMessage() << "Both VID and DRIVE_SLOT must be specified"; - throw ex; - } - - // Parse the VID command-line argument - m_vid = argv[optind]; - - // Move on to the next command-line argument - optind++; - - // Parse the DRIVE_SLOT command-line argument - const std::string driveLibrarySlot = argv[optind]; - m_driveLibrarySlot = LibrarySlotParser::parse(driveLibrarySlot); -} - -//----------------------------------------------------------------------------- -// copy constructor -//----------------------------------------------------------------------------- -castor::mediachanger::DismountCmdLine::DismountCmdLine( - const DismountCmdLine &obj): - m_debug(obj.m_debug), - m_help(obj.m_help), - m_vid(obj.m_vid), - m_driveLibrarySlot(0 == obj.m_driveLibrarySlot ? 0 : - obj.m_driveLibrarySlot->clone()), - m_force(obj.m_force) { -} - -//----------------------------------------------------------------------------- -// destructor -//----------------------------------------------------------------------------- -castor::mediachanger::DismountCmdLine::~DismountCmdLine() throw() { - delete m_driveLibrarySlot; -} - -//------------------------------------------------------------------------------ -// assignment operator -//------------------------------------------------------------------------------ -castor::mediachanger::DismountCmdLine &castor::mediachanger::DismountCmdLine:: - operator=(const DismountCmdLine &rhs) { - // If this is not a self assigment - if(this != &rhs) { - // Avoid a memory leak - delete(m_driveLibrarySlot); - - m_debug = rhs.m_debug; - m_help = rhs.m_help; - m_vid = rhs.m_vid; - m_driveLibrarySlot = 0 == rhs.m_driveLibrarySlot ? 0 : - rhs.m_driveLibrarySlot->clone(); - m_force = rhs.m_force; - } - - return *this; -} - -//------------------------------------------------------------------------------ -// getForce -//------------------------------------------------------------------------------ -bool castor::mediachanger::DismountCmdLine::getForce() const throw() { - return m_force; -} - -//------------------------------------------------------------------------------ -// processOption -//------------------------------------------------------------------------------ -void castor::mediachanger::DismountCmdLine::processOption(const int opt) { - switch(opt) { - case 'd': - m_debug = true; - break; - case 'h': - m_help = true; - break; - case 'f': - m_force = true; - break; - case ':': - return handleMissingParameter(optopt); - case '?': - return handleUnknownOption(optopt); - default: - { - cta::exception::Exception ex; - ex.getMessage() << - "getopt_long returned the following unknown value: 0x" << - std::hex << (int)opt; - throw ex; - } - } // switch(opt) -} - -//------------------------------------------------------------------------------ -// getUsage -//------------------------------------------------------------------------------ -std::string castor::mediachanger::DismountCmdLine::getUsage() throw() { - return - "Usage:\n" - "\n" - " castor-tape-mediachanger-dismount [options] VID DRIVE_SLOT\n" - "\n" - "Where:\n" - "\n" - " VID The VID of the volume to be dismounted.\n" - " DRIVE_SLOT The slot in the tape library where the drive is located.\n" - " DRIVE_SLOT must be in one of the following two forms:\n" - "\n" - " acsACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER\n" - " smcDRIVE_ORDINAL\n" - "\n" - "Options:\n" - "\n" - " -d|--debug Turn on the printing of debug information.\n" - "\n" - " -h|--help Print this help message and exit.\n" - "\n" - " -f|--force Force the dismount (rewind and eject the tape where necessary)." - "\n" - "Comments to: Castor.Support@cern.ch\n"; -} - -//------------------------------------------------------------------------------ -// getDebug -//------------------------------------------------------------------------------ -bool castor::mediachanger::DismountCmdLine::getDebug() const throw() { - return m_debug; -} - -//------------------------------------------------------------------------------ -// getHelp -//------------------------------------------------------------------------------ -bool castor::mediachanger::DismountCmdLine::getHelp() const throw() { - return m_help; -} - -//------------------------------------------------------------------------------ -// getVid -//------------------------------------------------------------------------------ -const std::string &castor::mediachanger::DismountCmdLine::getVid() - const throw() { - return m_vid; -} - -//------------------------------------------------------------------------------ -// getDriveLibrarySlot -//------------------------------------------------------------------------------ -const castor::mediachanger::LibrarySlot &castor::mediachanger:: - DismountCmdLine::getDriveLibrarySlot() const { - if(0 == m_driveLibrarySlot) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to get drive library-slot: Value not set"; - throw ex; - } - - return *m_driveLibrarySlot; -} - diff --git a/tapeserver/castor/mediachanger/DismountCmdLine.hpp b/tapeserver/castor/mediachanger/DismountCmdLine.hpp deleted file mode 100644 index 13352fc7c9c2270a919cf99d6add03eb5fa8a8f1..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/DismountCmdLine.hpp +++ /dev/null @@ -1,155 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/CmdLine.hpp" -#include "castor/mediachanger/LibrarySlot.hpp" - -#include <string> - -namespace castor { -namespace mediachanger { - -/** - * Data type used to store the results of parsing the command-line. - */ -class DismountCmdLine: public CmdLine { -public: - - /** - * Constructor. - */ - DismountCmdLine() throw(); - - /** - * Constructor. - * - * Parses the specified command-line arguments. - * - * @param argc Argument count from the executable's entry function: main(). - * @param argv Argument vector from the executable's entry function: main(). - */ - DismountCmdLine(const int argc, char *const *const argv); - - /** - * Copy constructor. - * - * @param obj The object to be copied. - */ - DismountCmdLine(const DismountCmdLine &obj); - - /** - * Destructor. - */ - ~DismountCmdLine() throw(); - - /** - * Assignment oprator. - * - * @param rhs The right-hand side of the operator. - */ - DismountCmdLine &operator=(const DismountCmdLine &rhs); - - /** - * Gets the usage message that describes the command line. - * - * @return The usage message. - */ - static std::string getUsage() throw(); - - /** - * Gets the value of the debug option. - * - * @return True if the debug option has been set. - */ - bool getDebug() const throw(); - - /** - * Gets the value of the help option. - * - * @return True if the help option has been set. - */ - bool getHelp() const throw(); - - /** - * Gets the volume identifier of the tape to be mounted. - * - * @return The volume identifier of the tape to be mounted. - */ - const std::string &getVid() const throw(); - - /** - * Gets the slot in the tape library where the drive is located. - * - * @return The slot in the tape library where the drive is located. - */ - const LibrarySlot &getDriveLibrarySlot() const; - - /** - * Gets the value of the force option. - * - * @return True if the dismount should be forced. Forcing a dismount means - * rewinding and ejecting the tape where necessary. - */ - bool getForce() const throw(); - -private: - - /** - * True if the debug option has been set. - */ - bool m_debug; - - /** - * True if the help option has been set. - */ - bool m_help; - - /** - * The volume identifier of the tape to be mounted. - */ - std::string m_vid; - - /** - * The slot in the tape library where the drive is located. - */ - LibrarySlot *m_driveLibrarySlot; - - /** - * True if the dismount should be forced. Forcing a dismount means - * rewinding and ejecting the tape where necessary. - */ - bool m_force; - - /** - * Processes the specified option that was returned by getopt_long(). - * - * @param opt The option that was returned by getopt_long(). - */ - void processOption(const int opt); - -}; // class DismountCmdLine - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/DismountCmdLineTest.cpp b/tapeserver/castor/mediachanger/DismountCmdLineTest.cpp deleted file mode 100644 index 2b087891ba5e437b5cce0c5341dd1570dee7e274..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/DismountCmdLineTest.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/****************************************************************************** - * - * 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/exception/Exception.hpp" -#include "castor/mediachanger/DismountCmdLine.hpp" - -#include <gtest/gtest.h> -#include <list> -#include <memory> - -namespace unitTests { - -class castor_mediachanger_DismountCmdLineTest : public ::testing::Test { -protected: - - struct Argcv { - int argc; - char **argv; - Argcv(): argc(0), argv(NULL) { - } - }; - typedef std::list<Argcv*> ArgcvList; - ArgcvList m_argsList; - - /** - * Creates a duplicate string using the new operator. - */ - char *dupString(const char *str) { - const size_t len = strlen(str); - char *duplicate = new char[len+1]; - strncpy(duplicate, str, len); - duplicate[len] = '\0'; - return duplicate; - } - - virtual void SetUp() { - } - - virtual void TearDown() { - // Allow getopt_long to be called again - optind = 0; - - for(ArgcvList::const_iterator itor = m_argsList.begin(); - itor != m_argsList.end(); itor++) { - for(int i=0; i < (*itor)->argc; i++) { - delete[] (*itor)->argv[i]; - } - delete[] (*itor)->argv; - delete *itor; - } - } -}; - -TEST_F(castor_mediachanger_DismountCmdLineTest, acs) { - using namespace castor::mediachanger; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 3; - args->argv = new char *[4]; - args->argv[0] = dupString("castor-tape-mediachanger-dismount"); - args->argv[1] = dupString("vid"); - args->argv[2] = dupString("acs1,2,3,4"); - args->argv[3] = NULL; - - std::unique_ptr<DismountCmdLine> cmdLine; - ASSERT_NO_THROW(cmdLine.reset(new DismountCmdLine(args->argc, args->argv))); - - ASSERT_FALSE(cmdLine->getHelp()); - ASSERT_FALSE(cmdLine->getDebug()); - ASSERT_FALSE(cmdLine->getForce()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine->getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs1,2,3,4"), - cmdLine->getDriveLibrarySlot().str()); -} - -TEST_F(castor_mediachanger_DismountCmdLineTest, copy_constructor) { - using namespace castor::mediachanger; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 3; - args->argv = new char *[4]; - args->argv[0] = dupString("castor-tape-mediachanger-dismount"); - args->argv[1] = dupString("vid"); - args->argv[2] = dupString("acs1,2,3,4"); - args->argv[3] = NULL; - - DismountCmdLine cmdLine1(args->argc, args->argv); - ASSERT_FALSE(cmdLine1.getHelp()); - ASSERT_FALSE(cmdLine1.getDebug()); - ASSERT_FALSE(cmdLine1.getForce()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine1.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs1,2,3,4"), - cmdLine1.getDriveLibrarySlot().str()); - - DismountCmdLine cmdLine2(cmdLine1); - ASSERT_FALSE(cmdLine2.getHelp()); - ASSERT_FALSE(cmdLine2.getDebug()); - ASSERT_FALSE(cmdLine2.getForce()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine2.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs1,2,3,4"), - cmdLine2.getDriveLibrarySlot().str()); -} - -TEST_F(castor_mediachanger_DismountCmdLineTest, assignment) { - using namespace castor::mediachanger; - - Argcv *args1 = new Argcv(); - m_argsList.push_back(args1); - args1->argc = 3; - args1->argv = new char *[4]; - args1->argv[0] = dupString("castor-tape-mediachanger-dismount"); - args1->argv[1] = dupString("vid"); - args1->argv[2] = dupString("acs1,2,3,4"); - args1->argv[3] = NULL; - - DismountCmdLine cmdLine1(args1->argc, args1->argv); - ASSERT_FALSE(cmdLine1.getHelp()); - ASSERT_FALSE(cmdLine1.getDebug()); - ASSERT_FALSE(cmdLine1.getForce()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine1.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs1,2,3,4"), - cmdLine1.getDriveLibrarySlot().str()); - - Argcv *args2 = new Argcv(); - m_argsList.push_back(args2); - args2->argc = 3; - args2->argv = new char *[4]; - args2->argv[0] = dupString("castor-tape-mediachanger-dismount"); - args2->argv[1] = dupString("vid"); - args2->argv[2] = dupString("acs5,6,7,8"); - args2->argv[3] = NULL; - - DismountCmdLine cmdLine2(args2->argc, args2->argv); - ASSERT_FALSE(cmdLine2.getHelp()); - ASSERT_FALSE(cmdLine2.getDebug()); - ASSERT_FALSE(cmdLine2.getForce()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine2.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs5,6,7,8"), - cmdLine2.getDriveLibrarySlot().str()); - - cmdLine1 = cmdLine2; - - ASSERT_FALSE(cmdLine1.getHelp()); - ASSERT_FALSE(cmdLine1.getDebug()); - ASSERT_FALSE(cmdLine1.getForce()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine1.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs5,6,7,8"), - cmdLine1.getDriveLibrarySlot().str()); - - ASSERT_FALSE(cmdLine2.getHelp()); - ASSERT_FALSE(cmdLine2.getDebug()); - ASSERT_FALSE(cmdLine2.getForce()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine2.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs5,6,7,8"), - cmdLine2.getDriveLibrarySlot().str()); -} - -TEST_F(castor_mediachanger_DismountCmdLineTest, scsi) { - using namespace castor::mediachanger; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 3; - args->argv = new char *[4]; - args->argv[0] = dupString("castor-tape-mediachanger-dismount"); - args->argv[1] = dupString("vid"); - args->argv[2] = dupString("smc1"); - args->argv[3] = NULL; - - std::unique_ptr<DismountCmdLine> cmdLine; - ASSERT_NO_THROW(cmdLine.reset(new DismountCmdLine(args->argc, args->argv))); - - ASSERT_FALSE(cmdLine->getHelp()); - ASSERT_FALSE(cmdLine->getDebug()); - ASSERT_FALSE(cmdLine->getForce()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_SCSI, - cmdLine->getDriveLibrarySlot().getLibraryType()); -} - -} // namespace unitTests diff --git a/tapeserver/castor/mediachanger/DismountCmdMain.cpp b/tapeserver/castor/mediachanger/DismountCmdMain.cpp deleted file mode 100644 index 190e7571c4be26ce8ee089673f367657dc06bca4..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/DismountCmdMain.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/****************************************************************************** - * - * 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/acs/Constants.hpp" -#include "castor/common/CastorConfiguration.hpp" -#include "castor/legacymsg/RmcProxyTcpIp.hpp" -#include "castor/mediachanger/DismountCmd.hpp" -#include "castor/mediachanger/DismountCmdLine.hpp" -#include "castor/mediachanger/MmcProxyNotSupported.hpp" -#include "castor/messages/AcsProxyZmq.hpp" -#include "castor/messages/SmartZmqContext.hpp" -#include "castor/utils/utils.hpp" -#include "common/exception/Exception.hpp" -#include "h/rmc_constants.h" - -#include <exception> -#include <iostream> -#include <zmq.h> - -/** - * An exception throwing version of main(). - * - * @param argc The number of command-line arguments including the program name. - * @param argv The command-line arguments. - * @return The exit value of the program. - */ -static int exceptionThrowingMain(const int argc, char *const *const argv); - -/** - * Instantiates a ZMQ context. - * - * @param sizeOfIOThreadPoolForZMQ The size of the thread pool used to perform - * IO. This is usually 1 thread. - * @return A pointer to the newly created ZMQ context. - */ -static void *instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ); - -//------------------------------------------------------------------------------ -// main -//------------------------------------------------------------------------------ -int main(const int argc, char *const *const argv) { - using namespace castor; - - std::string errorMessage; - - try { - const int rc = exceptionThrowingMain(argc, argv); - google::protobuf::ShutdownProtobufLibrary(); - return rc; - } catch(cta::exception::Exception &ex) { - errorMessage = ex.getMessage().str(); - } catch(std::exception &se) { - errorMessage = se.what(); - } catch(...) { - errorMessage = "An unknown exception was thrown"; - } - - // Reaching this point means the command has failed, ane exception was throw - // and errorMessage has been set accordingly - - std::cerr << "Aborting: " << errorMessage << std::endl; - google::protobuf::ShutdownProtobufLibrary(); - return 1; -} - - -//------------------------------------------------------------------------------ -// exceptionThrowingMain -//------------------------------------------------------------------------------ -static int exceptionThrowingMain(const int argc, char *const *const argv) { - using namespace castor; - - const int sizeOfIOThreadPoolForZMQ = 1; - messages::SmartZmqContext zmqContext(instantiateZmqContext( - sizeOfIOThreadPoolForZMQ)); - messages::AcsProxyZmq acs(acs::ACS_PORT, zmqContext.get()); - - mediachanger::MmcProxyNotSupported mmc; - - common::CastorConfiguration &castorConf = - common::CastorConfiguration::getConfig(); - - const unsigned short rmcPort = castorConf.getConfEntInt("RMC", "PORT", - (unsigned short)RMC_PORT); - - const unsigned int rmcMaxRqstAttempts = castorConf.getConfEntInt("RMC", - "MAXRQSTATTEMPTS", (unsigned int)RMC_MAXRQSTATTEMPTS); - - // 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 - - legacymsg::RmcProxyTcpIp rmc(rmcPort, rmcNetTimeout, rmcMaxRqstAttempts); - - mediachanger::MediaChangerFacade mc(acs, mmc, rmc); - - mediachanger::DismountCmd cmd(std::cin, std::cout, std::cerr, mc); - - return cmd.exceptionThrowingMain(argc, argv); -} - -//------------------------------------------------------------------------------ -// instantiateZmqContext -//------------------------------------------------------------------------------ -static void *instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ) { - using namespace castor; - void *const zmqContext = zmq_init(sizeOfIOThreadPoolForZMQ); - if(NULL == zmqContext) { - const std::string message = cta::utils::errnoToString(errno); - cta::exception::Exception ex; - ex.getMessage() << "Failed to instantiate ZMQ context: " << message; - throw ex; - } - return zmqContext; -} diff --git a/tapeserver/castor/mediachanger/LibrarySlot.cpp b/tapeserver/castor/mediachanger/LibrarySlot.cpp deleted file mode 100644 index 04c44e416a1bb1779727450a55678537c504c5cd..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/LibrarySlot.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/LibrarySlot.hpp" -#include "common/exception/Exception.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::LibrarySlot::LibrarySlot( - const TapeLibraryType libraryType) throw(): - m_libraryType(libraryType) { -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::mediachanger::LibrarySlot::~LibrarySlot() throw() { -} - -//------------------------------------------------------------------------------ -// getLibrarySlotType -//------------------------------------------------------------------------------ -castor::mediachanger::TapeLibraryType castor::mediachanger::LibrarySlot:: - getLibraryTypeOfSlot(const std::string &slot) { - if(0 == slot.find("acs")) return TAPE_LIBRARY_TYPE_ACS; - if(0 == slot.find("manual")) return TAPE_LIBRARY_TYPE_MANUAL; - if(0 == slot.find("smc")) return TAPE_LIBRARY_TYPE_SCSI; - - cta::exception::Exception ex; - ex.getMessage() << "Cannot determine tape-library type of library slot" - ": slot=" << slot; - throw ex; -} - -//------------------------------------------------------------------------------ -// str -//------------------------------------------------------------------------------ -const std::string &castor::mediachanger::LibrarySlot::str() const - throw() { - return m_str; -} - -//------------------------------------------------------------------------------ -// getLibraryType -//------------------------------------------------------------------------------ -castor::mediachanger::TapeLibraryType - castor::mediachanger::LibrarySlot::getLibraryType() const throw() { - return m_libraryType; -} diff --git a/tapeserver/castor/mediachanger/LibrarySlot.hpp b/tapeserver/castor/mediachanger/LibrarySlot.hpp deleted file mode 100644 index 0bc09420975de58d708d59c9760d5dd681602769..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/LibrarySlot.hpp +++ /dev/null @@ -1,102 +0,0 @@ -/****************************************************************************** - * - * 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 "tapeserver/castor/mediachanger/TapeLibraryType.hpp" - -#include <string> - -namespace castor { -namespace mediachanger { - -/** - * Class representing a generic tape-library slot as found in the - * /etc/castor/TPCONFIG. - */ -class LibrarySlot { -protected: - - /** - * Constructor. - * - * @param libraryType The library type of the slot. - */ - LibrarySlot(const TapeLibraryType libraryType) throw(); - -public: - - /** - * Destructor. - */ - virtual ~LibrarySlot() throw() = 0; - - /** - * Creates a clone of this object. - * - * @return The clone. - */ - virtual LibrarySlot *clone() = 0; - - /** - * Gets the string representation of this tape library slot. - * - * @return The string representation of this tape library slot. - */ - const std::string &str() const throw(); - - /** - * Returns the type of the tape library to which this library slot refers. - */ - TapeLibraryType getLibraryType() const throw(); - -protected: - - /** - * The string representation of this tape library slot. - */ - std::string m_str; - -private: - - /** - * The library type of the slot. - */ - TapeLibraryType m_libraryType; - - /** - * Thread safe method that returns the type of the tape-library to which the - * specified library slot refers. - * - * This function throws a cta::exception::Exception if the type of the - * tape-library cannot be determined. - * - * @param slot The tape-library slot. - * @return The type of the tape library. - */ - static TapeLibraryType getLibraryTypeOfSlot(const std::string &slot); - -}; // class LibrarySlot - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/LibrarySlotParser.cpp b/tapeserver/castor/mediachanger/LibrarySlotParser.cpp deleted file mode 100644 index 0bdbb53c3599cff67319f7e5d8604e29ff9ad92a..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/LibrarySlotParser.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/AcsLibrarySlot.hpp" -#include "castor/mediachanger/LibrarySlotParser.hpp" -#include "castor/mediachanger/ManualLibrarySlot.hpp" -#include "castor/mediachanger/ScsiLibrarySlot.hpp" -#include "common/utils/utils.hpp" - -#include <sstream> -#include <vector> - -//------------------------------------------------------------------------------ -// parse -//------------------------------------------------------------------------------ -castor::mediachanger::LibrarySlot *castor::mediachanger::LibrarySlotParser:: - parse(const std::string &str) { - try { - // Parse the string representation in two steps, first parsing the beginning - // to get the library type and then the rst to get the details. This two - // step strategy gives the end user more detailed syntax errors wherei - // necessary - const TapeLibraryType libraryType = getLibrarySlotType(str); - return parse(libraryType, str); - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to parse library slot from string" - " representation: " << ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// getLibrarySlotType -//------------------------------------------------------------------------------ -castor::mediachanger::TapeLibraryType castor::mediachanger::LibrarySlotParser:: - getLibrarySlotType(const std::string &str) { - if(isAcs(str)) return TAPE_LIBRARY_TYPE_ACS; - if(isManual(str)) return TAPE_LIBRARY_TYPE_MANUAL; - if(isScsi(str)) return TAPE_LIBRARY_TYPE_SCSI; - - cta::exception::Exception ex; - ex.getMessage() << "Cannot determine library slot type: str=" << str; - throw ex; -} - -//------------------------------------------------------------------------------ -// isAcs -//------------------------------------------------------------------------------ -bool castor::mediachanger::LibrarySlotParser::isAcs(const std::string &str) - throw() { - return 0 == str.find("acs"); -} - -//------------------------------------------------------------------------------ -// isManual -//------------------------------------------------------------------------------ -bool castor::mediachanger::LibrarySlotParser::isManual(const std::string &str) - throw() { - return 0 == str.find("manual"); -} - -//------------------------------------------------------------------------------ -// isScsi -//------------------------------------------------------------------------------ -bool castor::mediachanger::LibrarySlotParser::isScsi(const std::string &str) - throw() { - return 0 == str.find("smc"); -} - -//------------------------------------------------------------------------------ -// parse -//------------------------------------------------------------------------------ -castor::mediachanger::LibrarySlot *castor::mediachanger::LibrarySlotParser:: - parse(const TapeLibraryType libraryType, const std::string &str) { - - switch(libraryType) { - case TAPE_LIBRARY_TYPE_ACS: return parseAcsLibrarySlot(str); - case TAPE_LIBRARY_TYPE_MANUAL: return parseManualLibrarySlot(str); - case TAPE_LIBRARY_TYPE_SCSI: return parseScsiLibrarySlot(str); - default: - { - // Should never get here - cta::exception::Exception ex; - ex.getMessage() << "Unknown tape library type: libraryType=" << - libraryType; - throw ex; - } - } -} - -//------------------------------------------------------------------------------ -// parseAcsLibrarySlot -//------------------------------------------------------------------------------ -castor::mediachanger::AcsLibrarySlot *castor::mediachanger::LibrarySlotParser:: - parseAcsLibrarySlot(const std::string &str) { - const std::string errMsg("Failed to construct AcsLibrarySlot"); - std::vector<std::string> components; - cta::utils::splitString(str, ',', components); - if(4 != components.size()) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": Invalid number of components" - ": expected=4, actual=" << components.size(); - throw ex; - } - - // check for acs in the beginning - const std::string &acsWithACS_NUMBERStr = components[0]; - if(0 != acsWithACS_NUMBERStr.find("acs")) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": Invalid tape library-slot format" - ": expected=acsACS_NUMBER, actual=" << acsWithACS_NUMBERStr; - throw ex; - } - - const std::string::size_type indexOfACS_NUMBER = 3; // skip acs - const std::string &acsStr = acsWithACS_NUMBERStr.substr(indexOfACS_NUMBER); - const std::string &lsmStr = components[1]; - const std::string &panStr = components[2]; - const std::string &drvStr = components[3]; - - // Each of the 4 components must be between 1 and than 3 characters long - if(1 > acsStr.length() || 3 < acsStr.length()) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": Invalid ACS_NUMBER string length" - ": expected=1..3, actual=" << acsStr.length(); - throw ex; - } - if(1 > lsmStr.length() || 3 < lsmStr.length()) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": Invalid LSM_NUMBER string length" - ": expected=1..3, actual=" << lsmStr.length(); - throw ex; - } - if(1 > panStr.length() || 3 < panStr.length()) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": Invalid PANEL_NUMBER string length" - ": expected=1..3, actual=" << panStr.length(); - throw ex; - } - if(1 > drvStr.length() || 3 < drvStr.length()) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": Invalid TRANSPORT_NUMBER string length" - ": expected=1..3, actual=" << drvStr.length(); - throw ex; - } - - if(!cta::utils::isValidUInt(acsStr)) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": ACS_NUMBER must be an unsigned integer:" - " value=" << acsStr; - throw ex; - } - if(!cta::utils::isValidUInt(lsmStr)) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": LSM_NUMBER must be an unsigned integer:" - " value=" << lsmStr; - throw ex; - } - if(!cta::utils::isValidUInt(panStr)) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": PANEL_NUMBER must be an unsigned integer:" - " value=" << panStr; - throw ex; - } - if(!cta::utils::isValidUInt(drvStr)) { - cta::exception::InvalidArgument ex; - ex.getMessage() << errMsg << ": TRANSPORT_NUMBER must be an unsigned" - " integer: value=" << drvStr; - throw ex; - } - - return new AcsLibrarySlot( - atoi(acsStr.c_str()), - atoi(lsmStr.c_str()), - atoi(panStr.c_str()), - atoi(drvStr.c_str())); -} - -//------------------------------------------------------------------------------ -// parseManualLibrarySlot -//------------------------------------------------------------------------------ -castor::mediachanger::ManualLibrarySlot *castor::mediachanger:: - LibrarySlotParser::parseManualLibrarySlot(const std::string &str) { - return new ManualLibrarySlot(str); -} - -//------------------------------------------------------------------------------ -// parseScsiLibrarySlot -//------------------------------------------------------------------------------ -castor::mediachanger::ScsiLibrarySlot *castor::mediachanger:: - LibrarySlotParser::parseScsiLibrarySlot(const std::string &str) { - if(str.find("smc")) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to construct ScsiLibrarySlot" - ": Library slot must start with smc: slot=" << str; - throw ex; - } - - const size_t drvOrdStrLen = str.length() - 3; // length of "smc" is 3 - const std::string drvOrdStr = str.substr(3, drvOrdStrLen); - if(drvOrdStr.empty()) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to construct ScsiLibrarySlot" - ": Missing drive ordinal: slot=" << str; - throw ex; - } - - if(!cta::utils::isValidUInt(drvOrdStr)) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to construct ScsiLibrarySlot: Drive ordinal " << - drvOrdStr << " is not a valid unsigned integer: slot=" << str; - throw ex; - } - - const uint16_t drvOrd = atoi(drvOrdStr.c_str()); - return new ScsiLibrarySlot(drvOrd); -} diff --git a/tapeserver/castor/mediachanger/LibrarySlotParser.hpp b/tapeserver/castor/mediachanger/LibrarySlotParser.hpp deleted file mode 100644 index fe0e0c564af284a79b79d145533a6297a9fc23d4..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/LibrarySlotParser.hpp +++ /dev/null @@ -1,137 +0,0 @@ -/****************************************************************************** - * - * 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 "LibrarySlot.hpp" -#include "AcsLibrarySlot.hpp" -#include "ManualLibrarySlot.hpp" -#include "ScsiLibrarySlot.hpp" - -namespace castor { -namespace mediachanger { - -/** - * Creates objects representing tape library slots by parsing their string - * representations. - */ -class LibrarySlotParser { -public: - - /** - * Parses the specified string representation of a tape library slot and - * creates the corresponding object. - * - * The string representation of a tape library-slot must be in one of the - * following three forms: - * - acsACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER - * - manual - * - smcDRIVE_ORDINAL - * - * @param str The string represetion of the library slot. - */ - static LibrarySlot *parse(const std::string &str); - -private: - - /** - * Gets the type of the specified string representation of a tape library - * slot. - * - * This method purposely only parses the beginning of the specified string. - * This permits a two step parsing strategy where the user can be given more - * detailed syntax errors where necessary. - * - * This method throws a cta::exception::Exception if the type of the - * library slot cannot be determined. - * - * @param str The string representation of the tape library slot. - * @return The type of the library slot. - */ - static castor::mediachanger::TapeLibraryType getLibrarySlotType( - const std::string &str); - - /** - * Returns true if the type of the specified tape library slot is ACS. - * - * @param str The string representation of the tape library slot. - * @return True if the type if the library slot is ACS. - */ - static bool isAcs(const std::string &str) throw(); - - /** - * Returns true if the type of the specified tape library slot is manual. - * - * @param str The string representation of the tape library slot. - * @return True if the type of the library slot is a manual. - */ - static bool isManual(const std::string &str) throw(); - - /** - * Returns true if the type of the specified tape library slot is SCSI. - * - * @param str The string representation of the tape library slot. - * @return True if the type of the library slot is a manual. - */ - static bool isScsi(const std::string &str) throw(); - - /** - * Parses the specified string representation of a library slot taking into - * account the specified library type. - * - * @param libraryType The library type of the slot. - * @param str The string representation of the tape library slot. - * @return The newly created library slot. - */ - static castor::mediachanger::LibrarySlot *parse( - const castor::mediachanger::TapeLibraryType libraryType, - const std::string &str); - - /** - * Parses the specified string representation of an ACS library slot. - * - * @param str The string representation of the tape library slot. - */ - static castor::mediachanger::AcsLibrarySlot *parseAcsLibrarySlot( - const std::string &str); - - /** - * Parses the specified string representation of a manual library slot. - * - * @param str The string representation of the tape library slot. - */ - static castor::mediachanger::ManualLibrarySlot *parseManualLibrarySlot( - const std::string &str); - - /** - * Parses the specified string representation of a SCSI library slot. - * - * @param str The string representation of the tape library slot. - */ - static castor::mediachanger::ScsiLibrarySlot *parseScsiLibrarySlot( - const std::string &str); - -}; // class LibrarySlot - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/LibrarySlotParserTest.cpp b/tapeserver/castor/mediachanger/LibrarySlotParserTest.cpp deleted file mode 100644 index 0595469007bfb02e524689c30ce73605b415e1cf..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/LibrarySlotParserTest.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************** - * - * 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 "common/exception/Exception.hpp" -#include "castor/mediachanger/LibrarySlotParser.hpp" - -#include <gtest/gtest.h> -#include <memory> - -namespace unitTests { - -class castor_mediachanger_LibrarySlotParserTest : public ::testing::Test { -protected: - - virtual void SetUp() { - } - - virtual void TearDown() { - } -}; - -TEST_F(castor_mediachanger_LibrarySlotParserTest, acs) { - using namespace castor::mediachanger; - - std::unique_ptr<LibrarySlot> slot; - ASSERT_NO_THROW(slot.reset(LibrarySlotParser::parse("acs1,2,3,4"))); - ASSERT_NE((LibrarySlot*)0, slot.get()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, slot->getLibraryType()); -} - -TEST_F(castor_mediachanger_LibrarySlotParserTest, manual) { - using namespace castor::mediachanger; - - std::unique_ptr<LibrarySlot> slot; - ASSERT_NO_THROW(slot.reset(LibrarySlotParser::parse("manual"))); - ASSERT_NE((LibrarySlot*)0, slot.get()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_MANUAL, slot->getLibraryType()); -} - -TEST_F(castor_mediachanger_LibrarySlotParserTest, scsi) { - using namespace castor::mediachanger; - - std::unique_ptr<LibrarySlot> slot; - ASSERT_NO_THROW(slot.reset(LibrarySlotParser::parse("smc1"))); - ASSERT_NE((LibrarySlot*)0, slot.get()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_SCSI, slot->getLibraryType()); -} - -TEST_F(castor_mediachanger_LibrarySlotParserTest, nonsense) { - using namespace castor::mediachanger; - - std::unique_ptr<LibrarySlot> slot; - ASSERT_THROW(slot.reset(LibrarySlotParser::parse("nonsense")), - cta::exception::Exception); -} - -} // namespace unitTests diff --git a/tapeserver/castor/mediachanger/ManualLibrarySlot.cpp b/tapeserver/castor/mediachanger/ManualLibrarySlot.cpp deleted file mode 100644 index fc5cf2ca906a93a53f098f71a82e7c9a31ba923c..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/ManualLibrarySlot.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/ManualLibrarySlot.hpp" -#include "castor/utils/utils.hpp" -#include "common/exception/Exception.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::ManualLibrarySlot::ManualLibrarySlot() - throw(): - LibrarySlot(TAPE_LIBRARY_TYPE_MANUAL) { - m_str = "manual"; -} - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::ManualLibrarySlot::ManualLibrarySlot( - const std::string &str): - LibrarySlot(TAPE_LIBRARY_TYPE_MANUAL) { - m_str = str; - - if(str.find("manual")) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to construct ManualLibrarySlot" - ": Library slot must start with manual: str=" << str; - throw ex; - } -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::mediachanger::ManualLibrarySlot::~ManualLibrarySlot() throw() { -} - -//------------------------------------------------------------------------------ -// clone -//------------------------------------------------------------------------------ -castor::mediachanger::LibrarySlot *castor::mediachanger::ManualLibrarySlot:: - clone() { - return new ManualLibrarySlot(*this); -} diff --git a/tapeserver/castor/mediachanger/ManualLibrarySlot.hpp b/tapeserver/castor/mediachanger/ManualLibrarySlot.hpp deleted file mode 100644 index 311a61a336b4fa36bae38911f51689283ce96b59..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/ManualLibrarySlot.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/****************************************************************************** - * - * 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 "LibrarySlot.hpp" - -namespace castor { -namespace mediachanger { - -/** - * Class representing a slot in a manually operated tape library. - */ -class ManualLibrarySlot: public LibrarySlot { -public: - - /** - * Constructor. - * - * Sets all string member-variables to the empty string. - */ - ManualLibrarySlot() throw(); - - /** - * Constructor. - * - * Initialises the member variables based on the result of parsing the - * specified string representation of the library slot. - * - * @param str The string representation of the library slot. - */ - ManualLibrarySlot(const std::string &str); - - /** - * Destructor. - */ - ~ManualLibrarySlot() throw(); - - /** - * Creates a clone of this object. - * - * @return The clone. - */ - LibrarySlot *clone(); - -}; // class ManualLibrarySlot - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/ManualLibrarySlotTest.cpp b/tapeserver/castor/mediachanger/ManualLibrarySlotTest.cpp deleted file mode 100644 index e20fec8bf889c64e07b02634319cde6e90a1c698..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/ManualLibrarySlotTest.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** - * - * 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 "common/exception/Exception.hpp" -#include "castor/mediachanger/ManualLibrarySlot.hpp" - -#include <gtest/gtest.h> -#include <memory> - -namespace unitTests { - -class castor_mediachanger_ManualLibrarySlotTest : public ::testing::Test { -protected: - - virtual void SetUp() { - } - - virtual void TearDown() { - } -}; - -TEST_F(castor_mediachanger_ManualLibrarySlotTest, manual1234) { - using namespace castor::mediachanger; - - std::unique_ptr<ManualLibrarySlot> slot; - ASSERT_NO_THROW(slot.reset(new ManualLibrarySlot("manual1234"))); - - ASSERT_EQ(TAPE_LIBRARY_TYPE_MANUAL, slot->getLibraryType()); - ASSERT_EQ("manual1234", slot->str()); -} - -TEST_F(castor_mediachanger_ManualLibrarySlotTest, notmanual) { - using namespace castor::mediachanger; - - std::unique_ptr<ManualLibrarySlot> slot; - ASSERT_THROW(slot.reset(new ManualLibrarySlot("notmanual")), - cta::exception::Exception); -} - -TEST_F(castor_mediachanger_ManualLibrarySlotTest, clone) { - using namespace castor::mediachanger; - - std::unique_ptr<ManualLibrarySlot> slot1; - ASSERT_NO_THROW(slot1.reset(new ManualLibrarySlot("manual1234"))); - - ASSERT_EQ(TAPE_LIBRARY_TYPE_MANUAL, slot1->getLibraryType()); - ASSERT_EQ("manual1234", slot1->str()); - - std::unique_ptr<ManualLibrarySlot> slot2; - ASSERT_NO_THROW(slot2.reset((ManualLibrarySlot*)slot1->clone())); - - ASSERT_EQ(TAPE_LIBRARY_TYPE_MANUAL, slot2->getLibraryType()); - ASSERT_EQ("manual1234", slot2->str()); -} - -} // namespace unitTests diff --git a/tapeserver/castor/mediachanger/MediaChangerFacade.cpp b/tapeserver/castor/mediachanger/MediaChangerFacade.cpp deleted file mode 100644 index f82af4d5d02cdb24ce0ea5370eea53d1d05689f9..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MediaChangerFacade.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/MediaChangerFacade.hpp" -#include "common/exception/Exception.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::MediaChangerFacade::MediaChangerFacade( - messages::AcsProxy &acs, - MmcProxy &mmc, - legacymsg::RmcProxy &rmc) throw(): - m_acs(acs), - m_mmc(mmc), - m_rmc(rmc) { -} - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::MediaChangerFacade::MediaChangerFacade( - messages::AcsProxy &acs, - legacymsg::RmcProxy &rmc) throw(): - m_acs(acs), - m_mmc(m_mmcNotSupported), - m_rmc(rmc) { -} - -//------------------------------------------------------------------------------ -// mountTapeReadOnly -//------------------------------------------------------------------------------ -void castor::mediachanger::MediaChangerFacade::mountTapeReadOnly( - const std::string &vid, const LibrarySlot &slot) { - try { - const TapeLibraryType libraryType = slot.getLibraryType(); - - // Dispatch the appropriate helper method depending on library slot type - switch(libraryType) { - case TAPE_LIBRARY_TYPE_ACS: - return m_acs.mountTapeReadOnly(vid, - dynamic_cast<const AcsLibrarySlot&>(slot)); - case TAPE_LIBRARY_TYPE_MANUAL: - return m_mmc.mountTapeReadOnly(vid, - dynamic_cast<const ManualLibrarySlot&>(slot)); - case TAPE_LIBRARY_TYPE_SCSI: - // SCSI media-changers to not support read-only mounts - return m_rmc.mountTapeReadWrite(vid, - dynamic_cast<const ScsiLibrarySlot&>(slot)); - default: - { - // Should never get here - cta::exception::Exception ex; - ex.getMessage() << "Library slot has an unexpected library type"; - throw ex; - } - } - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to mount tape for read-only access" - ": vid=" << vid << " slot=" << slot.str() << ": " << - ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// mountTapeReadWrite -//------------------------------------------------------------------------------ -void castor::mediachanger::MediaChangerFacade::mountTapeReadWrite( - const std::string &vid, const LibrarySlot &slot) { - try { - const TapeLibraryType libraryType = slot.getLibraryType(); - - // Dispatch the appropriate helper method depending on library slot type - switch(libraryType) { - case TAPE_LIBRARY_TYPE_ACS: - return m_acs.mountTapeReadWrite(vid, - dynamic_cast<const AcsLibrarySlot&>(slot)); - case TAPE_LIBRARY_TYPE_MANUAL: - return m_mmc.mountTapeReadWrite(vid, - dynamic_cast<const ManualLibrarySlot&>(slot)); - case TAPE_LIBRARY_TYPE_SCSI: - return m_rmc.mountTapeReadWrite(vid, - dynamic_cast<const ScsiLibrarySlot&>(slot)); - default: - { - // Should never get here - cta::exception::Exception ex; - ex.getMessage() << "Library slot has an unexpected library type"; - throw ex; - } - } - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to mount tape for read/write access" - ": vid=" << vid << " slot=" << slot.str() << ": " << - ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// dismountTape -//------------------------------------------------------------------------------ -void castor::mediachanger::MediaChangerFacade::dismountTape( - const std::string &vid, const LibrarySlot &slot) { - try { - const TapeLibraryType libraryType = slot.getLibraryType(); - - // Dispatch the appropriate helper method depending on library slot type - switch(libraryType) { - case TAPE_LIBRARY_TYPE_ACS: - return m_acs.dismountTape(vid, - dynamic_cast<const AcsLibrarySlot&>(slot)); - case TAPE_LIBRARY_TYPE_MANUAL: - return m_mmc.dismountTape(vid, - dynamic_cast<const ManualLibrarySlot&>(slot)); - case TAPE_LIBRARY_TYPE_SCSI: - return m_rmc.dismountTape(vid, - dynamic_cast<const ScsiLibrarySlot&>(slot)); - default: - { - // Should never get here - cta::exception::Exception ex; - ex.getMessage() << "Library slot has an unexpected library type"; - throw ex; - } - } - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to dismount tape" - ": vid=" << vid << " slot=" << slot.str() << ": " << - ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// forceDismountTape -//------------------------------------------------------------------------------ -void castor::mediachanger::MediaChangerFacade::forceDismountTape( - const std::string &vid, const LibrarySlot &slot) { - try { - const TapeLibraryType libraryType = slot.getLibraryType(); - - // Dispatch the appropriate helper method depending on library slot type - switch(libraryType) { - case TAPE_LIBRARY_TYPE_ACS: - return m_acs.forceDismountTape(vid, - dynamic_cast<const AcsLibrarySlot&>(slot)); - case TAPE_LIBRARY_TYPE_MANUAL: - return m_mmc.forceDismountTape(vid, - dynamic_cast<const ManualLibrarySlot&>(slot)); - case TAPE_LIBRARY_TYPE_SCSI: - return m_rmc.forceDismountTape(vid, - dynamic_cast<const ScsiLibrarySlot&>(slot)); - default: - { - // Should never get here - cta::exception::Exception ex; - ex.getMessage() << "Library slot has an unexpected library type"; - throw ex; - } - } - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to force dismount tape" - ": vid=" << vid << " slot=" << slot.str() << ": " << - ne.getMessage().str(); - throw ex; - } -} diff --git a/tapeserver/castor/mediachanger/MediaChangerFacade.hpp b/tapeserver/castor/mediachanger/MediaChangerFacade.hpp deleted file mode 100644 index abc87eb7876062616f88937ea5cd0a9abab4869a..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MediaChangerFacade.hpp +++ /dev/null @@ -1,135 +0,0 @@ -/****************************************************************************** - * - * 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 "tapeserver/castor/legacymsg/RmcProxy.hpp" -#include "LibrarySlot.hpp" -#include "MmcProxy.hpp" -#include "MmcProxyNotSupported.hpp" -#include "tapeserver/castor/messages/AcsProxy.hpp" - -#include <unistd.h> -#include <sys/types.h> - -namespace castor { -namespace mediachanger { - -/** - * Provides a facade to three communications proxies: acs, manual and rmc. - * - * This facade will forward requests to mount and dismount tapes to the - * appropriate communications proxy based on the type of library slot. - */ -class MediaChangerFacade { -public: - - /** - * Constructor. - * - * @param acs Proxy object representing the CASTOR ACS daemon. - * @param mmc Proxy object representing the manual media-changer. - * @param rmc Proxy object representing the rmcd daemon. - */ - MediaChangerFacade(messages::AcsProxy &acs, MmcProxy &mmc, - legacymsg::RmcProxy &rmc) throw(); - - /** - * Constructor. - * - * Use this constructor when manual media-changers are not to be supported. - * - * @param acs Proxy object representing the CASTOR ACS daemon. - * @param rmc Proxy object representing the rmcd daemon. - */ - MediaChangerFacade(messages::AcsProxy &acs, legacymsg::RmcProxy &rmc) - throw(); - - /** - * Requests the media changer to mount the specified tape for read-only - * access into the drive in the specified library slot. - * - * Please note that this method provides a best-effort service because not all - * media changers support read-only mounts. - * - * @param vid The volume identifier of the tape. - * @param slot The library slot containing the tape drive. - */ - void mountTapeReadOnly(const std::string &vid, const LibrarySlot &slot); - - /** - * Requests the media changer to mount the specified tape for read/write - * access into the drive in the specified library slot. - * - * @param vid The volume identifier of the tape. - * @param slot The library slot containing the tape drive. - */ - void mountTapeReadWrite(const std::string &vid, const LibrarySlot &slot); - - /** - * Requests the media changer to dismount the specified tape from the - * drive in the specifed library slot. - * - * @param vid The volume identifier of the tape. - * @param slot The library slot containing the tape drive. - */ - void dismountTape(const std::string &vid, const LibrarySlot &slot); - - /** - * Requests the media changer to forcefully dismount the specified tape from - * the drive in the specifed library slot. Forcefully means rewinding and - * ejecting the tape where necessary. - * - * Please note that this method provides a best-effort service because not all - * media changers support forceful dismounts. - * - * @param vid The volume identifier of the tape. - * @param slot The library slot containing the tape drive. - */ - void forceDismountTape(const std::string &vid, const LibrarySlot &slot); - -private: - - /** - * Proxy object representing the CASTOR ACS daemon. - */ - messages::AcsProxy &m_acs; - - /** - * Proxy object representing the manual media-changer. - */ - MmcProxy &m_mmc; - - /** - * Proxy object representing the rmcd daemon. - */ - legacymsg::RmcProxy &m_rmc; - - /** - * The manual media-changer proxy object that is used when manual - * media-changers are not to be supported. - */ - MmcProxyNotSupported m_mmcNotSupported; - -}; // class MediaChangerFacade - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/MediaChangerFacadeTest.cpp b/tapeserver/castor/mediachanger/MediaChangerFacadeTest.cpp deleted file mode 100644 index 47d73c0536d1feb9b6b90947b0ae19537be4f152..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MediaChangerFacadeTest.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/LibrarySlot.hpp" -#include "castor/mediachanger/LibrarySlotParser.hpp" -#include "castor/mediachanger/MediaChangerFacade.hpp" - -#include <gtest/gtest.h> -#include <iostream> -#include <memory> -#include <sstream> - -namespace unitTests { - -class castor_mediachanger_MediaChangerFacadeTest : public ::testing::Test { -protected: - - struct MockAcsProxy: public castor::messages::AcsProxy { - unsigned int nbTimesMountTapeReadOnlyCalled; - unsigned int nbTimesMountTapeReadWriteCalled; - unsigned int nbTimesDismountTapeCalled; - unsigned int nbTimesForceDismountTapeCalled; - - MockAcsProxy(): - nbTimesMountTapeReadOnlyCalled(0), - nbTimesMountTapeReadWriteCalled(0), - nbTimesDismountTapeCalled(0), - nbTimesForceDismountTapeCalled(0) { - } - - void mountTapeReadOnly(const std::string &vid, - const castor::mediachanger::AcsLibrarySlot &librarySlot) { - nbTimesMountTapeReadOnlyCalled++; - } - - void mountTapeReadWrite(const std::string &vid, - const castor::mediachanger::AcsLibrarySlot &librarySlot) { - nbTimesMountTapeReadWriteCalled++; - } - - void dismountTape(const std::string &vid, - const castor::mediachanger::AcsLibrarySlot &librarySlot) { - nbTimesDismountTapeCalled++; - } - - void forceDismountTape(const std::string &vid, - const castor::mediachanger::AcsLibrarySlot &librarySlot) { - nbTimesForceDismountTapeCalled++; - } - }; // struct MockAcsProxy - - struct MockMmcProxy: public castor::mediachanger::MmcProxy { - unsigned int nbTimesMountTapeReadOnlyCalled; - unsigned int nbTimesMountTapeReadWriteCalled; - unsigned int nbTimesDismountTapeCalled; - unsigned int nbTimesForceDismountTapeCalled; - - MockMmcProxy(): - nbTimesMountTapeReadOnlyCalled(0), - nbTimesMountTapeReadWriteCalled(0), - nbTimesDismountTapeCalled(0), - nbTimesForceDismountTapeCalled(0) { - } - - void mountTapeReadOnly(const std::string &vid, - const castor::mediachanger::ManualLibrarySlot &librarySlot) { - nbTimesMountTapeReadOnlyCalled++; - } - - void mountTapeReadWrite(const std::string &vid, - const castor::mediachanger::ManualLibrarySlot &librarySlot) { - nbTimesMountTapeReadWriteCalled++; - } - - void dismountTape(const std::string &vid, - const castor::mediachanger::ManualLibrarySlot &librarySlot) { - nbTimesDismountTapeCalled++; - } - - void forceDismountTape(const std::string &vid, - const castor::mediachanger::ManualLibrarySlot &librarySlot) { - nbTimesForceDismountTapeCalled++; - } - }; // struct MockMmcProxy - - struct MockRmcProxy: public castor::legacymsg::RmcProxy { - unsigned int nbTimesMountTapeReadOnlyCalled; - unsigned int nbTimesMountTapeReadWriteCalled; - unsigned int nbTimesDismountTapeCalled; - unsigned int nbTimesForceDismountTapeCalled; - - MockRmcProxy(): - nbTimesMountTapeReadOnlyCalled(0), - nbTimesMountTapeReadWriteCalled(0), - nbTimesDismountTapeCalled(0), - nbTimesForceDismountTapeCalled(0) { - } - - void mountTapeReadOnly(const std::string &vid, - const castor::mediachanger::ScsiLibrarySlot &librarySlot) { - nbTimesMountTapeReadOnlyCalled++; - } - - void mountTapeReadWrite(const std::string &vid, - const castor::mediachanger::ScsiLibrarySlot &librarySlot) { - nbTimesMountTapeReadWriteCalled++; - } - - void dismountTape(const std::string &vid, - const castor::mediachanger::ScsiLibrarySlot &librarySlot) { - nbTimesDismountTapeCalled++; - } - - void forceDismountTape(const std::string &vid, - const castor::mediachanger::ScsiLibrarySlot &librarySlot) { - nbTimesForceDismountTapeCalled++; - } - }; // struct MockRmcProxy - - MockAcsProxy m_acs; // ACS - MockMmcProxy m_mmc; // Manual - MockRmcProxy m_rmc; // SCSI - - const std::string m_vid; - - const castor::mediachanger::LibrarySlot *m_acsSlot; - const castor::mediachanger::LibrarySlot *m_mmcSlot; - const castor::mediachanger::LibrarySlot *m_rmcSlot; - - castor_mediachanger_MediaChangerFacadeTest(): - m_vid("123456"), - m_acsSlot(castor::mediachanger::LibrarySlotParser::parse("acs1,2,3,4")), - m_mmcSlot(castor::mediachanger::LibrarySlotParser::parse("manual")), - m_rmcSlot(castor::mediachanger::LibrarySlotParser::parse("smc1")) { - } - - ~castor_mediachanger_MediaChangerFacadeTest() { - delete(m_acsSlot); - delete(m_mmcSlot); - delete(m_rmcSlot); - } - - virtual void SetUp() { - m_acs.nbTimesMountTapeReadOnlyCalled = 0; - m_acs.nbTimesMountTapeReadWriteCalled = 0; - m_acs.nbTimesDismountTapeCalled = 0; - - m_mmc.nbTimesMountTapeReadOnlyCalled = 0; - m_mmc.nbTimesMountTapeReadWriteCalled = 0; - m_mmc.nbTimesDismountTapeCalled = 0; - - m_rmc.nbTimesMountTapeReadWriteCalled = 0; - m_rmc.nbTimesDismountTapeCalled = 0; - } - - virtual void TearDown() { - SetUp(); - } - -}; // class castor_mediachanger_MediaChangerFacadeTest - -TEST_F(castor_mediachanger_MediaChangerFacadeTest, mountTapeReadOnlyAcs) { - using namespace castor::mediachanger; - - MediaChangerFacade facade(m_acs, m_mmc, m_rmc); - facade.mountTapeReadOnly(m_vid, *m_acsSlot); - - ASSERT_EQ(1, m_acs.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_acs.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_mmc.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_rmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_rmc.nbTimesDismountTapeCalled); -} - -TEST_F(castor_mediachanger_MediaChangerFacadeTest, mountTapeReadOnlyMmc) { - using namespace castor::mediachanger; - - MediaChangerFacade facade(m_acs, m_mmc, m_rmc); - facade.mountTapeReadOnly(m_vid, *m_mmcSlot); - - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_acs.nbTimesDismountTapeCalled); - - ASSERT_EQ(1, m_mmc.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_mmc.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_rmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_rmc.nbTimesDismountTapeCalled); -} - -TEST_F(castor_mediachanger_MediaChangerFacadeTest, mountTapeReadOnlyRmc) { - using namespace castor::mediachanger; - - MediaChangerFacade facade(m_acs, m_mmc, m_rmc); - facade.mountTapeReadOnly(m_vid, *m_rmcSlot); - - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_acs.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_mmc.nbTimesDismountTapeCalled); - - // SCSI tape-libraries do not support mounting tapes for read-only access - ASSERT_EQ(1, m_rmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_rmc.nbTimesDismountTapeCalled); -} - -TEST_F(castor_mediachanger_MediaChangerFacadeTest, mountTapeReadWriteAcs) { - using namespace castor::mediachanger; - - MediaChangerFacade facade(m_acs, m_mmc, m_rmc); - facade.mountTapeReadWrite(m_vid, *m_acsSlot); - - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(1, m_acs.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_acs.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_mmc.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_rmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_rmc.nbTimesDismountTapeCalled); -} - -TEST_F(castor_mediachanger_MediaChangerFacadeTest, mountTapeReadWriteMmc) { - using namespace castor::mediachanger; - - MediaChangerFacade facade(m_acs, m_mmc, m_rmc); - facade.mountTapeReadWrite(m_vid, *m_mmcSlot); - - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_acs.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(1, m_mmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_mmc.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_rmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_rmc.nbTimesDismountTapeCalled); -} - -TEST_F(castor_mediachanger_MediaChangerFacadeTest, mountTapeReadWriteRmc) { - using namespace castor::mediachanger; - - MediaChangerFacade facade(m_acs, m_mmc, m_rmc); - facade.mountTapeReadWrite(m_vid, *m_rmcSlot); - - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_acs.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_mmc.nbTimesDismountTapeCalled); - - ASSERT_EQ(1, m_rmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_rmc.nbTimesDismountTapeCalled); -} - -TEST_F(castor_mediachanger_MediaChangerFacadeTest, dismountTapeAcs) { - using namespace castor::mediachanger; - - MediaChangerFacade facade(m_acs, m_mmc, m_rmc); - facade.dismountTape(m_vid, *m_acsSlot); - - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(1, m_acs.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_mmc.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_rmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_rmc.nbTimesDismountTapeCalled); -} - -TEST_F(castor_mediachanger_MediaChangerFacadeTest, dismountTapeMmc) { - using namespace castor::mediachanger; - - MediaChangerFacade facade(m_acs, m_mmc, m_rmc); - facade.dismountTape(m_vid, *m_mmcSlot); - - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_acs.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(1, m_mmc.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_rmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_rmc.nbTimesDismountTapeCalled); -} - -TEST_F(castor_mediachanger_MediaChangerFacadeTest, dismountTapeRmc) { - using namespace castor::mediachanger; - - MediaChangerFacade facade(m_acs, m_mmc, m_rmc); - facade.dismountTape(m_vid, *m_rmcSlot); - - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_acs.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_acs.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadOnlyCalled); - ASSERT_EQ(0, m_mmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(0, m_mmc.nbTimesDismountTapeCalled); - - ASSERT_EQ(0, m_rmc.nbTimesMountTapeReadWriteCalled); - ASSERT_EQ(1, m_rmc.nbTimesDismountTapeCalled); -} - -} // namespace unitTests diff --git a/tapeserver/castor/mediachanger/MmcProxy.cpp b/tapeserver/castor/mediachanger/MmcProxy.cpp deleted file mode 100644 index c4fe3c2b9c542538f3367b591560b424ea0ed4b9..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MmcProxy.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/MmcProxy.hpp" - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::mediachanger::MmcProxy::~MmcProxy() throw() { -} diff --git a/tapeserver/castor/mediachanger/MmcProxy.hpp b/tapeserver/castor/mediachanger/MmcProxy.hpp deleted file mode 100644 index bee0c0ecfb2a7255eb2fb32c9864a64383cbacd3..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MmcProxy.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** - * - * 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 "ManualLibrarySlot.hpp" - -#include <string> - -namespace castor { -namespace mediachanger { - -/** - * Asbtract class defining the interface to manually operated media-changer. - */ -class MmcProxy { -public: - - /** - * Destructor. - */ - virtual ~MmcProxy() throw() = 0; - - /** - * Requests the media changer to mount of the specified tape for read-only - * access into the drive in the specified library slot. - * - * Please note that this method provides a best-effort service because not all - * media changers support read-only mounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - virtual void mountTapeReadOnly(const std::string &vid, - const mediachanger::ManualLibrarySlot &librarySlot) = 0; - - /** - * Requests the media changer to mount of the specified tape for read/write - * access into the drive in the specified library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - virtual void mountTapeReadWrite(const std::string &vid, - const mediachanger::ManualLibrarySlot &librarySlot) = 0; - - /** - * Requests the media changer to dismount of the specified tape from the - * drive in the specifed library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - virtual void dismountTape(const std::string &vid, - const mediachanger::ManualLibrarySlot &librarySlot) = 0; - - /** - * Requests the media changer to forcefully dismount the specified tape from - * the drive in the specifed library slot. Forcefully means rewinding and - * ejecting the tape where necessary. - * - * Please note that this method provides a best-effort service because not all - * media changers support forceful dismounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - virtual void forceDismountTape(const std::string &vid, - const mediachanger::ManualLibrarySlot &librarySlot) = 0; - -}; // class MmcProxy - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/MmcProxyDummy.cpp b/tapeserver/castor/mediachanger/MmcProxyDummy.cpp deleted file mode 100644 index 0a953b3f617d764d705691425321f1d9dd8c6b77..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MmcProxyDummy.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/MmcProxyDummy.hpp" - -//------------------------------------------------------------------------------ -// mountTapeReadOnly -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyDummy::mountTapeReadOnly( - const std::string &vid, const ManualLibrarySlot &librarySlot) { -} - -//------------------------------------------------------------------------------ -// mountTapeReadWrite -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyDummy::mountTapeReadWrite( - const std::string &vid, const ManualLibrarySlot &librarySlot) { -} - -//------------------------------------------------------------------------------ -// dismountTape -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyDummy::dismountTape( - const std::string &vid, const ManualLibrarySlot &librarySlot) { -} - -//------------------------------------------------------------------------------ -// forceDismountTape -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyDummy::forceDismountTape( - const std::string &vid, const ManualLibrarySlot &librarySlot) { -} diff --git a/tapeserver/castor/mediachanger/MmcProxyDummy.hpp b/tapeserver/castor/mediachanger/MmcProxyDummy.hpp deleted file mode 100644 index e8ab1a1a29fd3b34d597bbfd7ac968c55b3a8672..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MmcProxyDummy.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/MmcProxy.hpp" - -namespace castor { -namespace mediachanger { - -/** - * Concrete class implementing a dummy MmcProxyDummy. - */ -class MmcProxyDummy: public MmcProxy { -public: - - /** - * Requests the media changer to mount the specified tape for read-only - * access into the drive in the specified library slot. - * - * Please note that this method provides a best-effort service because not all - * media changers support read-only mounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadOnly(const std::string &vid, - const ManualLibrarySlot &librarySlot); - - /** - * Requests the media changer to mount the specified tape for read/write - * access into the drive in the specified library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadWrite(const std::string &vid, - const ManualLibrarySlot &librarySlot); - - /** - * Requests the media changer to dismount the specified tape from the - * drive in the specifed library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void dismountTape(const std::string &vid, - const ManualLibrarySlot &librarySlot); - - /** - * Request the CASTOR ACS daemon to forcefully dismount the specifed tape - * from the tape drive in the specified library slot. Forcefully means - * rewinding and ejecting the tape if necessary. - * - * Please note that this method provides a best-effort service because not all - * media changers support forceful dismounts. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - void forceDismountTape(const std::string &vid, - const ManualLibrarySlot &librarySlot); - -}; // class MmcProxyDummy - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/MmcProxyLog.cpp b/tapeserver/castor/mediachanger/MmcProxyLog.cpp deleted file mode 100644 index 5c695aa58002db7518bcc5aa59d60a1fee446549..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MmcProxyLog.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/MmcProxyLog.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::MmcProxyLog::MmcProxyLog(cta::log::Logger &log) throw(): - m_log(log) { -} - -//------------------------------------------------------------------------------ -// mountTapeReadOnly -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyLog::mountTapeReadOnly( - const std::string &vid, const ManualLibrarySlot &librarySlot) { - std::list<cta::log::Param> params = { - cta::log::Param("TPVID", vid), - cta::log::Param("librarySlot", librarySlot.str())}; - m_log(cta::log::WARNING, "Tape should be manual mounted for read-only access", - params); -} - -//------------------------------------------------------------------------------ -// mountTapeReadWrite -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyLog::mountTapeReadWrite( - const std::string &vid, const ManualLibrarySlot &librarySlot) { - std::list<cta::log::Param> params = { - cta::log::Param("TPVID", vid), - cta::log::Param("librarySlot", librarySlot.str())}; - m_log(cta::log::WARNING, "Tape should be manual mounted for read/write access", - params); -} - -//------------------------------------------------------------------------------ -// dismountTape -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyLog::dismountTape( - const std::string &vid, const ManualLibrarySlot &librarySlot) { - std::list<cta::log::Param> params = { - cta::log::Param("TPVID", vid), - cta::log::Param("librarySlot", librarySlot.str())}; - m_log(cta::log::WARNING, "Tape should be manual dismounted", params); -} - -//------------------------------------------------------------------------------ -// forceDismountTape -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyLog::forceDismountTape( - const std::string &vid, const ManualLibrarySlot &librarySlot) { - std::list<cta::log::Param> params = { - cta::log::Param("TPVID", vid), - cta::log::Param("librarySlot", librarySlot.str())}; - m_log(cta::log::WARNING, "Tape should be manual dismounted", params); -} diff --git a/tapeserver/castor/mediachanger/MmcProxyLog.hpp b/tapeserver/castor/mediachanger/MmcProxyLog.hpp deleted file mode 100644 index d6ea73feb16ad475bb3674d27f08414927e86dc4..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MmcProxyLog.hpp +++ /dev/null @@ -1,101 +0,0 @@ -/****************************************************************************** - * - * 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 "common/log/Logger.hpp" -#include "MmcProxy.hpp" - -namespace castor { -namespace mediachanger { - -/** - * Concrete class implementing a MmcProxy that simply logs mount and dismount - * requests. - */ -class MmcProxyLog: public MmcProxy { -public: - - /** - * Constructor. - * - * @param log Object representing the API to the CASTOR logging system. - */ - MmcProxyLog(cta::log::Logger &log) throw(); - - /** - * Requests the media changer to mount the specified tape for read-only - * access into the drive in the specified library slot. - * - * Please note that this method provides a best-effort service because not all - * media changers support read-only mounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadOnly(const std::string &vid, - const ManualLibrarySlot &librarySlot); - - /** - * Requests the media changer to mount the specified tape for read/write - * access into the drive in the specified library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadWrite(const std::string &vid, - const ManualLibrarySlot &librarySlot); - - /** - * Requests the media changer to dismount the specified tape from the - * drive in the specifed library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void dismountTape(const std::string &vid, - const ManualLibrarySlot &librarySlot); - - /** - * Requests the media changer to forcefully dismount the specified tape from - * the drive in the specifed library slot. Forcefully means rewinding and - * ejecting the tape where necessary. - * - * Please note that this method provides a best-effort service because not all - * media changers support forceful dismounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void forceDismountTape(const std::string &vid, - const ManualLibrarySlot &librarySlot); - -private: - - /** - * Object representing the API to the CASTOR logging system. - */ - cta::log::Logger &m_log; - -}; // class MmcProxyLog - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/MmcProxyNotSupported.cpp b/tapeserver/castor/mediachanger/MmcProxyNotSupported.cpp deleted file mode 100644 index a81c83009b7f46cbeea1b42fa2543b513310b0f0..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MmcProxyNotSupported.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/MmcProxyNotSupported.hpp" -#include "common/exception/Exception.hpp" - -//------------------------------------------------------------------------------ -// mountTapeReadOnly -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyNotSupported::mountTapeReadOnly( - const std::string &vid, const ManualLibrarySlot &librarySlot) { - cta::exception::Exception ex; - ex.getMessage() << "Manual mounting is not supported"; - throw ex; -} - -//------------------------------------------------------------------------------ -// mountTapeReadWrite -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyNotSupported::mountTapeReadWrite( - const std::string &vid, const ManualLibrarySlot &librarySlot) { - cta::exception::Exception ex; - ex.getMessage() << "Manual mounting is not supported"; - throw ex; -} - -//------------------------------------------------------------------------------ -// dismountTape -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyNotSupported::dismountTape( - const std::string &vid, const ManualLibrarySlot &librarySlot) { - cta::exception::Exception ex; - ex.getMessage() << "Manual dismounting is not supported"; - throw ex; -} - -//------------------------------------------------------------------------------ -// forceDismountTape -//------------------------------------------------------------------------------ -void castor::mediachanger::MmcProxyNotSupported::forceDismountTape( - const std::string &vid, const ManualLibrarySlot &librarySlot) { - cta::exception::Exception ex; - ex.getMessage() << "Manual dismounting is not supported"; - throw ex; -} diff --git a/tapeserver/castor/mediachanger/MmcProxyNotSupported.hpp b/tapeserver/castor/mediachanger/MmcProxyNotSupported.hpp deleted file mode 100644 index c675f667a87248d73733aa58def836112d7466e5..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MmcProxyNotSupported.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/****************************************************************************** - * - * 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 "MmcProxy.hpp" - -namespace castor { -namespace mediachanger { - -/** - * Concrete class implementing a manual media-changer that throws - * "not supported" exceptions. - */ -class MmcProxyNotSupported: public MmcProxy { -public: - - /** - * Requests the media changer to mount the specified tape for read-only - * access into the drive in the specified library slot. - * - * Please note that this method provides a best-effort service because not all - * media changers support read-only mounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadOnly(const std::string &vid, - const ManualLibrarySlot &librarySlot); - - /** - * Requests the media changer to mount the specified tape for read/write - * access into the drive in the specified library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void mountTapeReadWrite(const std::string &vid, - const ManualLibrarySlot &librarySlot); - - /** - * Requests the media changer to dismount the specified tape from the - * drive in the specifed library slot. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void dismountTape(const std::string &vid, - const ManualLibrarySlot &librarySlot); - - /** - * Requests the media changer to forcefully dismount the specified tape from - * the drive in the specifed library slot. Forcefully means rewinding and - * ejecting the tape where necessary. - * - * Please note that this method provides a best-effort service because not all - * media changers support forceful dismounts. - * - * @param vid The volume identifier of the tape. - * @param librarySlot The library slot containing the tape drive. - */ - void forceDismountTape(const std::string &vid, - const ManualLibrarySlot &librarySlot); - -}; // class MmcProxyNotSupported - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/MountCmd.cpp b/tapeserver/castor/mediachanger/MountCmd.cpp deleted file mode 100644 index a0516c50bad1b28d5281ab94b1f69d4e389f2e44..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MountCmd.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/MountCmd.hpp" - -#include <getopt.h> -#include <iostream> -#include <memory> - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::MountCmd::MountCmd( - std::istream &inStream, std::ostream &outStream, std::ostream &errStream, - MediaChangerFacade &mc) throw(): - CmdLineTool(inStream, outStream, errStream, mc) { -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::mediachanger::MountCmd::~MountCmd() throw() { - // Do nothing -} - -//------------------------------------------------------------------------------ -// exceptionThrowingMain -//------------------------------------------------------------------------------ -int castor::mediachanger::MountCmd::exceptionThrowingMain(const int argc, - char *const *const argv) { - try { - m_cmdLine = MountCmdLine(argc, argv); - } catch(cta::exception::Exception &ex) { - m_err << ex.getMessage().str() << std::endl; - m_err << std::endl; - m_err << m_cmdLine.getUsage() << std::endl; - return 1; - } - - // Display the usage message to standard out and exit with success if the - // user requested help - if(m_cmdLine.getHelp()) { - m_out << MountCmdLine::getUsage(); - return 0; - } - - // Setup debug mode to be on or off depending on the command-line arguments - m_debugBuf.setDebug(m_cmdLine.getDebug()); - - m_dbg << "readonly = " << bool2Str(m_cmdLine.getReadOnly()) << std::endl; - m_dbg << "VID = " << m_cmdLine.getVid() << std::endl; - m_dbg << "DRIVE_SLOT = " << m_cmdLine.getDriveLibrarySlot().str() << - std::endl; - - mountTape(); - return 0; -} - -//------------------------------------------------------------------------------ -// mountTape -//------------------------------------------------------------------------------ -void castor::mediachanger::MountCmd::mountTape() { - if(m_cmdLine.getReadOnly()) { - m_mc.mountTapeReadOnly(m_cmdLine.getVid(), m_cmdLine.getDriveLibrarySlot()); - } else { - m_mc.mountTapeReadWrite(m_cmdLine.getVid(), - m_cmdLine.getDriveLibrarySlot()); - } -} diff --git a/tapeserver/castor/mediachanger/MountCmd.hpp b/tapeserver/castor/mediachanger/MountCmd.hpp deleted file mode 100644 index 5c107327c433fa7af4e4c480c34ff75b21e3818f..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MountCmd.hpp +++ /dev/null @@ -1,87 +0,0 @@ -/****************************************************************************** - * - * 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 "common/exception/InvalidArgument.hpp" -#include "common/exception/MissingOperand.hpp" -#include "castor/mediachanger/CmdLineTool.hpp" -#include "castor/mediachanger/MountCmdLine.hpp" - -#include <stdint.h> - -namespace castor { -namespace mediachanger { - -/** - * The class implementing the command-line tool for mounting tapes on both ACS - * and SCSI tape libraries. - */ -class MountCmd: public CmdLineTool { -public: - - /** - * Constructor. - * - * @param inStream Standard input stream. - * @param outStream Standard output stream. - * @param errStream Standard error stream. - * @param mc Interface to the media changer. - */ - MountCmd(std::istream &inStream, std::ostream &outStream, - std::ostream &errStream, MediaChangerFacade &mc) throw(); - - /** - * Destructor. - */ - virtual ~MountCmd() throw(); - - /** - * The entry function of the command. - * - * @param argc The number of command-line arguments. - * @param argv The command-line arguments. - * @return The exit value of the program. - */ - int exceptionThrowingMain(const int argc, char *const *const argv); - -private: - - /** - * The parsed command-line. - * - * The value of this member variable is set within the main() method of this - * class. - */ - MountCmdLine m_cmdLine; - - /** - * Requests the media changer to mount the tape and returns only when the - * operation has terminated. - */ - void mountTape(); - -}; // class MountCmd - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/MountCmdLine.cpp b/tapeserver/castor/mediachanger/MountCmdLine.cpp deleted file mode 100644 index 0a21549050eeaf21e725312288c3932f1bedbc85..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MountCmdLine.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/****************************************************************************** - * - * 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 "common/exception/MissingOperand.hpp" -#include "castor/mediachanger/MountCmdLine.hpp" -#include "common/exception/Exception.hpp" - -#include <getopt.h> - -//----------------------------------------------------------------------------- -// constructor -//----------------------------------------------------------------------------- -castor::mediachanger::MountCmdLine::MountCmdLine() throw(): - m_debug(false), - m_help(false), - m_readOnly(false), - m_driveLibrarySlot(0) { -} - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::MountCmdLine::MountCmdLine(const int argc, - char *const *const argv): - m_debug(false), - m_help(false), - m_readOnly(false), - m_driveLibrarySlot(0) { - - static struct option longopts[] = { - {"debug" , 0, NULL, 'd'}, - {"help" , 0, NULL, 'h'}, - {"readonly" , 0, NULL, 'r'}, - {NULL , 0, NULL, 0} - }; - - // Prevent getopt() from printing an error message if it does not recognize - // an option character - opterr = 0; - - int opt = 0; - while((opt = getopt_long(argc, argv, ":dhr", longopts, NULL)) != -1) { - processOption(opt); - } - - // There is no need to continue parsing when the help option is set - if(m_help) { - return; - } - - // Calculate the number of non-option ARGV-elements - const int nbArgs = argc - optind; - - // Check that both VID and DRIVE_SLOT has been specified - if(nbArgs < 2) { - cta::exception::MissingOperand ex; - ex.getMessage() << "Both VID and DRIVE_SLOT must be specified"; - throw ex; - } - - // Parse the VID command-line argument - m_vid = argv[optind]; - - // Move on to the next command-line argument - optind++; - - // Parse the DRIVE_SLOT command-line argument - const std::string driveLibrarySlot = argv[optind]; - m_driveLibrarySlot = LibrarySlotParser::parse(driveLibrarySlot); -} - -//----------------------------------------------------------------------------- -// copy constructor -//----------------------------------------------------------------------------- -castor::mediachanger::MountCmdLine::MountCmdLine(const MountCmdLine &obj): - m_debug(obj.m_debug), - m_help(obj.m_help), - m_readOnly(obj.m_readOnly), - m_vid(obj.m_vid), - m_driveLibrarySlot(0 == obj.m_driveLibrarySlot ? 0 : - obj.m_driveLibrarySlot->clone()) { -} - -//----------------------------------------------------------------------------- -// destructor -//----------------------------------------------------------------------------- -castor::mediachanger::MountCmdLine::~MountCmdLine() throw() { - delete m_driveLibrarySlot; -} - -//------------------------------------------------------------------------------ -// assignment operator -//------------------------------------------------------------------------------ -castor::mediachanger::MountCmdLine &castor::mediachanger::MountCmdLine:: - operator=(const MountCmdLine &rhs) { - // If this is not a self assigment - if(this != &rhs) { - // Avoid a memory leak - delete(m_driveLibrarySlot); - - m_debug = rhs.m_debug; - m_help = rhs.m_help; - m_readOnly = rhs.m_readOnly; - m_vid = rhs.m_vid; - m_driveLibrarySlot = 0 == rhs.m_driveLibrarySlot ? 0 : - rhs.m_driveLibrarySlot->clone(); - } - - return *this; -} - -//------------------------------------------------------------------------------ -// processOption -//------------------------------------------------------------------------------ -void castor::mediachanger::MountCmdLine::processOption(const int opt) { - switch(opt) { - case 'd': - m_debug = true; - break; - case 'h': - m_help = true; - break; - case 'r': - m_readOnly = true; - break; - case ':': - return handleMissingParameter(optopt); - case '?': - return handleUnknownOption(optopt); - default: - { - cta::exception::Exception ex; - ex.getMessage() << - "getopt_long returned the following unknown value: 0x" << - std::hex << (int)opt; - throw ex; - } - } // switch(opt) -} - -//------------------------------------------------------------------------------ -// getUsage -//------------------------------------------------------------------------------ -std::string castor::mediachanger::MountCmdLine::getUsage() throw() { - return - "Usage:\n" - "\n" - " castor-tape-mediachanger-mount [options] VID DRIVE_SLOT\n" - "\n" - "Where:\n" - "\n" - " VID The VID of the volume to be mounted.\n" - " DRIVE_SLOT The slot in the tape library where the drive is located.\n" - " DRIVE_SLOT must be in one of the following two forms:\n" - "\n" - " acsACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER\n" - " smcDRIVE_ORDINAL\n" - "\n" - "Options:\n" - "\n" - " -d|--debug Turn on the printing of debug information.\n" - "\n" - " -h|--help Print this help message and exit.\n" - "\n" - " -r|--readOnly Request the volume is mounted for read-only access\n" - "\n" - "Comments to: Castor.Support@cern.ch\n"; -} - -//------------------------------------------------------------------------------ -// getDebug -//------------------------------------------------------------------------------ -bool castor::mediachanger::MountCmdLine::getDebug() const throw() { - return m_debug; -} - -//------------------------------------------------------------------------------ -// getHelp -//------------------------------------------------------------------------------ -bool castor::mediachanger::MountCmdLine::getHelp() const throw() { - return m_help; -} - -//------------------------------------------------------------------------------ -// getReadOnly -//------------------------------------------------------------------------------ -bool castor::mediachanger::MountCmdLine::getReadOnly() const throw() { - return m_readOnly; -} - -//------------------------------------------------------------------------------ -// getVid -//------------------------------------------------------------------------------ -std::string castor::mediachanger::MountCmdLine::getVid() const throw() { - return m_vid; -} - -//------------------------------------------------------------------------------ -// getDriveLibrarySlot -//------------------------------------------------------------------------------ -const castor::mediachanger::LibrarySlot &castor::mediachanger::MountCmdLine:: - getDriveLibrarySlot() const { - if(0 == m_driveLibrarySlot) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to get drive library-slot: Value not set"; - throw ex; - } - return *m_driveLibrarySlot; -} diff --git a/tapeserver/castor/mediachanger/MountCmdLine.hpp b/tapeserver/castor/mediachanger/MountCmdLine.hpp deleted file mode 100644 index 0270ff508861af4ba3c28ec6b6b612e7081e7445..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MountCmdLine.hpp +++ /dev/null @@ -1,157 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/CmdLine.hpp" -#include "castor/mediachanger/LibrarySlot.hpp" -#include "castor/mediachanger/LibrarySlotParser.hpp" - -#include <string> - -namespace castor { -namespace mediachanger { - -/** - * Data type used to store the results of parsing the command-line. - */ -class MountCmdLine: public CmdLine { -public: - - /** - * Constructor. - * - * Initialises all BOOLEAN member-variables to FALSE, all integer - * member-variables to 0 and the volume identifier to an empty string. - */ - MountCmdLine() throw(); - - /** - * Constructor. - * - * Parses the specified command-line arguments. - * - * @param argc Argument count from the executable's entry function: main(). - * @param argv Argument vector from the executable's entry function: main(). - */ - MountCmdLine(const int argc, char *const *const argv); - - /** - * Copy constructor. - * - * @param obj The object to be copied. - */ - MountCmdLine(const MountCmdLine &obj); - - /** - * Destructor. - */ - ~MountCmdLine() throw(); - - /** - * Assignment oprator. - * - * @param rhs The right-hand side of the operator. - */ - MountCmdLine &operator=(const MountCmdLine &rhs); - - /** - * Gets the usage message that describes the command line. - * - * @return The usage message. - */ - static std::string getUsage() throw(); - - /** - * Gets the value of the debug option. - * - * @return True if the debug option has been set. - */ - bool getDebug() const throw(); - - /** - * Gets the value of th ehelp option. - * - * True if the help option has been set. - */ - bool getHelp() const throw(); - - /** - * Gets the value of the read-only option. - * - * @return True if the tape is to be mount for read-only access. - */ - bool getReadOnly() const throw(); - - /** - * Gets the volume identifier of the tape to be mounted. - * - * @return The volume identifier of the tape to be mounted. - */ - std::string getVid() const throw(); - - /** - * Gets the slot in the tape library where the drive is located. - * - * @return The slot in the tape library where the drive is located. - */ - const LibrarySlot &getDriveLibrarySlot() const; - -private: - - /** - * True if the debug option has been set. - */ - bool m_debug; - - /** - * True if the help option has been set. - */ - bool m_help; - - /** - * True if the tape is to be mount for read-only access. - */ - bool m_readOnly; - - /** - * The volume identifier of the tape to be mounted. - */ - std::string m_vid; - - /** - * The slot in the tape library where the drive is located. - */ - LibrarySlot *m_driveLibrarySlot; - - /** - * Processes the specified option that was returned by getopt_long(). - * - * @param opt The option that was returned by getopt_long(). - */ - void processOption(const int opt); - -}; // class MountCmdLine - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/MountCmdLineTest.cpp b/tapeserver/castor/mediachanger/MountCmdLineTest.cpp deleted file mode 100644 index 7dfac247a628114cda3bab6221f601d3fcc4f38e..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MountCmdLineTest.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/****************************************************************************** - * - * 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/exception/Exception.hpp" -#include "castor/mediachanger/MountCmdLine.hpp" - -#include <gtest/gtest.h> -#include <list> -#include <memory> - -namespace unitTests { - -class castor_mediachanger_MountCmdLineTest : public ::testing::Test { -protected: - - struct Argcv { - int argc; - char **argv; - Argcv(): argc(0), argv(NULL) { - } - }; - typedef std::list<Argcv*> ArgcvList; - ArgcvList m_argsList; - - /** - * Creates a duplicate string using the new operator. - */ - char *dupString(const char *str) { - const size_t len = strlen(str); - char *duplicate = new char[len+1]; - strncpy(duplicate, str, len); - duplicate[len] = '\0'; - return duplicate; - } - - virtual void SetUp() { - } - - virtual void TearDown() { - // Allow getopt_long to be called again - optind = 0; - - for(ArgcvList::const_iterator itor = m_argsList.begin(); - itor != m_argsList.end(); itor++) { - for(int i=0; i < (*itor)->argc; i++) { - delete[] (*itor)->argv[i]; - } - delete[] (*itor)->argv; - delete *itor; - } - } -}; - -TEST_F(castor_mediachanger_MountCmdLineTest, acs) { - using namespace castor::mediachanger; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 3; - args->argv = new char *[4]; - args->argv[0] = dupString("castor-tape-mediachanger-mount"); - args->argv[1] = dupString("vid"); - args->argv[2] = dupString("acs1,2,3,4"); - args->argv[3] = NULL; - - std::unique_ptr<MountCmdLine> cmdLine; - ASSERT_NO_THROW(cmdLine.reset(new MountCmdLine(args->argc, args->argv))); - - ASSERT_FALSE(cmdLine->getHelp()); - ASSERT_FALSE(cmdLine->getDebug()); - ASSERT_FALSE(cmdLine->getReadOnly()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine->getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs1,2,3,4"), - cmdLine->getDriveLibrarySlot().str()); -} - -TEST_F(castor_mediachanger_MountCmdLineTest, copy_constructor) { - using namespace castor::mediachanger; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 3; - args->argv = new char *[4]; - args->argv[0] = dupString("castor-tape-mediachanger-mount"); - args->argv[1] = dupString("vid"); - args->argv[2] = dupString("acs1,2,3,4"); - args->argv[3] = NULL; - - MountCmdLine cmdLine1(args->argc, args->argv); - ASSERT_FALSE(cmdLine1.getHelp()); - ASSERT_FALSE(cmdLine1.getDebug()); - ASSERT_FALSE(cmdLine1.getReadOnly()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine1.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs1,2,3,4"), - cmdLine1.getDriveLibrarySlot().str()); - - MountCmdLine cmdLine2(cmdLine1); - ASSERT_FALSE(cmdLine2.getHelp()); - ASSERT_FALSE(cmdLine2.getDebug()); - ASSERT_FALSE(cmdLine2.getReadOnly()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine2.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs1,2,3,4"), - cmdLine2.getDriveLibrarySlot().str()); -} - -TEST_F(castor_mediachanger_MountCmdLineTest, assignment) { - using namespace castor::mediachanger; - - Argcv *args1 = new Argcv(); - m_argsList.push_back(args1); - args1->argc = 3; - args1->argv = new char *[4]; - args1->argv[0] = dupString("castor-tape-mediachanger-mount"); - args1->argv[1] = dupString("vid"); - args1->argv[2] = dupString("acs1,2,3,4"); - args1->argv[3] = NULL; - - MountCmdLine cmdLine1(args1->argc, args1->argv); - ASSERT_FALSE(cmdLine1.getHelp()); - ASSERT_FALSE(cmdLine1.getDebug()); - ASSERT_FALSE(cmdLine1.getReadOnly()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine1.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs1,2,3,4"), - cmdLine1.getDriveLibrarySlot().str()); - - Argcv *args2 = new Argcv(); - m_argsList.push_back(args2); - args2->argc = 3; - args2->argv = new char *[4]; - args2->argv[0] = dupString("castor-tape-mediachanger-mount"); - args2->argv[1] = dupString("vid"); - args2->argv[2] = dupString("acs5,6,7,8"); - args2->argv[3] = NULL; - - MountCmdLine cmdLine2(args2->argc, args2->argv); - ASSERT_FALSE(cmdLine2.getHelp()); - ASSERT_FALSE(cmdLine2.getDebug()); - ASSERT_FALSE(cmdLine2.getReadOnly()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine2.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs5,6,7,8"), - cmdLine2.getDriveLibrarySlot().str()); - - cmdLine1 = cmdLine2; - - ASSERT_FALSE(cmdLine1.getHelp()); - ASSERT_FALSE(cmdLine1.getDebug()); - ASSERT_FALSE(cmdLine1.getReadOnly()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine1.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs5,6,7,8"), - cmdLine1.getDriveLibrarySlot().str()); - - ASSERT_FALSE(cmdLine2.getHelp()); - ASSERT_FALSE(cmdLine2.getDebug()); - ASSERT_FALSE(cmdLine2.getReadOnly()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_ACS, - cmdLine2.getDriveLibrarySlot().getLibraryType()); - ASSERT_EQ(std::string("acs5,6,7,8"), - cmdLine2.getDriveLibrarySlot().str()); -} - -TEST_F(castor_mediachanger_MountCmdLineTest, scsi) { - using namespace castor::mediachanger; - - Argcv *args = new Argcv(); - m_argsList.push_back(args); - args->argc = 3; - args->argv = new char *[4]; - args->argv[0] = dupString("castor-tape-mediachanger-mount"); - args->argv[1] = dupString("vid"); - args->argv[2] = dupString("smc1"); - args->argv[3] = NULL; - - std::unique_ptr<MountCmdLine> cmdLine; - ASSERT_NO_THROW(cmdLine.reset(new MountCmdLine(args->argc, args->argv))); - - ASSERT_FALSE(cmdLine->getHelp()); - ASSERT_FALSE(cmdLine->getDebug()); - ASSERT_FALSE(cmdLine->getReadOnly()); - ASSERT_EQ(TAPE_LIBRARY_TYPE_SCSI, - cmdLine->getDriveLibrarySlot().getLibraryType()); -} - -} // namespace unitTests diff --git a/tapeserver/castor/mediachanger/MountCmdMain.cpp b/tapeserver/castor/mediachanger/MountCmdMain.cpp deleted file mode 100644 index 2a7614da826324b93bea62634b61b136d7506c0b..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/MountCmdMain.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/****************************************************************************** - * - * 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/acs/Constants.hpp" -#include "castor/common/CastorConfiguration.hpp" -#include "castor/legacymsg/RmcProxyTcpIp.hpp" -#include "castor/mediachanger/MmcProxyNotSupported.hpp" -#include "castor/mediachanger/MountCmd.hpp" -#include "castor/mediachanger/MountCmdLine.hpp" -#include "castor/messages/AcsProxyZmq.hpp" -#include "castor/messages/SmartZmqContext.hpp" -#include "castor/utils/utils.hpp" -#include "common/exception/Exception.hpp" -#include "h/rmc_constants.h" - -#include <exception> -#include <iostream> -#include <zmq.h> - -/** - * An exception throwing version of main(). - * - * @param argc The number of command-line arguments including the program name. - * @param argv The command-line arguments. - * @return The exit value of the program. - */ -static int exceptionThrowingMain(const int argc, char *const *const argv); - -/** - * Instantiates a ZMQ context. - * - * @param sizeOfIOThreadPoolForZMQ The size of the thread pool used to perform - * IO. This is usually 1 thread. - * @return A pointer to the newly created ZMQ context. - */ -static void *instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ); - -//------------------------------------------------------------------------------ -// main -//------------------------------------------------------------------------------ -int main(const int argc, char *const *const argv) { - using namespace castor; - std::string errorMessage; - - try { - const int rc = exceptionThrowingMain(argc, argv); - google::protobuf::ShutdownProtobufLibrary(); - return rc; - } catch(cta::exception::Exception &ex) { - errorMessage = ex.getMessage().str(); - } catch(std::exception &se) { - errorMessage = se.what(); - } catch(...) { - errorMessage = "An unknown exception was thrown"; - } - - // Reaching this point means the command has failed, ane exception was throw - // and errorMessage has been set accordingly - - std::cerr << "Aborting: " << errorMessage << std::endl; - google::protobuf::ShutdownProtobufLibrary(); - return 1; -} - -//------------------------------------------------------------------------------ -// exceptionThrowingMain -//------------------------------------------------------------------------------ -static int exceptionThrowingMain(const int argc, char *const *const argv) { - using namespace castor; - - const int sizeOfIOThreadPoolForZMQ = 1; - messages::SmartZmqContext zmqContext(instantiateZmqContext( - sizeOfIOThreadPoolForZMQ)); - messages::AcsProxyZmq acs(acs::ACS_PORT, zmqContext.get()); - - mediachanger::MmcProxyNotSupported mmc; - - common::CastorConfiguration &castorConf = - common::CastorConfiguration::getConfig(); - - const unsigned short rmcPort = castorConf.getConfEntInt("RMC", "PORT", - (unsigned short)RMC_PORT); - - const unsigned int rmcMaxRqstAttempts = castorConf.getConfEntInt("RMC", - "MAXRQSTATTEMPTS", (unsigned int)RMC_MAXRQSTATTEMPTS); - - // 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 - - legacymsg::RmcProxyTcpIp rmc(rmcPort, rmcNetTimeout, rmcMaxRqstAttempts); - - mediachanger::MediaChangerFacade mc(acs, mmc, rmc); - - mediachanger::MountCmd cmd(std::cin, std::cout, std::cerr, mc); - - return cmd.exceptionThrowingMain(argc, argv); -} - -//------------------------------------------------------------------------------ -// instantiateZmqContext -//------------------------------------------------------------------------------ -static void *instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ) { - using namespace castor; - void *const zmqContext = zmq_init(sizeOfIOThreadPoolForZMQ); - if(NULL == zmqContext) { - const std::string message = cta::utils::errnoToString(errno); - cta::exception::Exception ex; - ex.getMessage() << "Failed to instantiate ZMQ context: " << message; - throw ex; - } - return zmqContext; -} diff --git a/tapeserver/castor/mediachanger/ScsiLibrarySlot.cpp b/tapeserver/castor/mediachanger/ScsiLibrarySlot.cpp deleted file mode 100644 index 6656463a03f99b8cc3895011b0f6fd018eff20f9..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/ScsiLibrarySlot.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/ScsiLibrarySlot.hpp" -#include "castor/utils/utils.hpp" -#include "common/exception/Exception.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::ScsiLibrarySlot::ScsiLibrarySlot() - throw(): - LibrarySlot(TAPE_LIBRARY_TYPE_SCSI), - m_drvOrd(0) { - m_str = librarySlotToString(0); -} - -//------------------------------------------------------------------------------ -// librarySlotToString -//------------------------------------------------------------------------------ -std::string castor::mediachanger::ScsiLibrarySlot::librarySlotToString( - const uint16_t drvOrd) { - std::ostringstream oss; - oss << "smc" << drvOrd; - return oss.str(); -} - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::mediachanger::ScsiLibrarySlot::ScsiLibrarySlot(const uint16_t drvOrd): - LibrarySlot(TAPE_LIBRARY_TYPE_SCSI), - m_drvOrd(drvOrd) { - m_str = librarySlotToString(drvOrd); -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -castor::mediachanger::ScsiLibrarySlot::~ScsiLibrarySlot() throw() { -} - -//------------------------------------------------------------------------------ -// clone -//------------------------------------------------------------------------------ -castor::mediachanger::LibrarySlot *castor::mediachanger::ScsiLibrarySlot:: - clone() { - return new ScsiLibrarySlot(*this); -} - -//------------------------------------------------------------------------------ -// getDrvOrd -//------------------------------------------------------------------------------ -uint16_t castor::mediachanger::ScsiLibrarySlot::getDrvOrd() const throw() { - return m_drvOrd; -} diff --git a/tapeserver/castor/mediachanger/ScsiLibrarySlot.hpp b/tapeserver/castor/mediachanger/ScsiLibrarySlot.hpp deleted file mode 100644 index 7f8539e0a48202821ce43d6c5346e20254d659dd..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/ScsiLibrarySlot.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/****************************************************************************** - * - * 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 "LibrarySlot.hpp" - -#include <stdint.h> - -namespace castor { -namespace mediachanger { - -/** - * Class representing a slot in a SCSI tape-library. - */ -class ScsiLibrarySlot: public LibrarySlot { -public: - - /** - * Constructor. - * - * Sets all integer member-variables to 0 and all strings to the empty string. - */ - ScsiLibrarySlot() throw(); - - /** - * Constructor. - * - * @param drvOrd The drive ordinal. - */ - ScsiLibrarySlot(const uint16_t drvOrd); - - /** - * Destructor. - */ - ~ScsiLibrarySlot() throw(); - - /** - * Creates a clone of this object. - * - * @return The clone. - */ - LibrarySlot *clone(); - - /** - * Gets the drive ordinal. - * - * @return The drive ordinal. - */ - uint16_t getDrvOrd() const throw(); - -private: - - /** - * The drive ordinal. - */ - uint16_t m_drvOrd; - - /** - * Returns the string representation of the specified SCSI library slot. - * - * @param drvOrd The drive ordinal. - * @return The string representation. - */ - std::string librarySlotToString(const uint16_t drvOrd); - -}; // class ScsiLibrarySlot - -} // namespace mediachanger -} // namespace castor - diff --git a/tapeserver/castor/mediachanger/ScsiLibrarySlotTest.cpp b/tapeserver/castor/mediachanger/ScsiLibrarySlotTest.cpp deleted file mode 100644 index c2d036b8f7a2264c152957431385adf2e8ed1395..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/ScsiLibrarySlotTest.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/****************************************************************************** - * - * 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/exception/Exception.hpp" -#include "castor/mediachanger/ScsiLibrarySlot.hpp" - -#include <gtest/gtest.h> -#include <memory> - -namespace unitTests { - -class castor_mediachanger_ScsiLibrarySlotTest : public ::testing::Test { -protected: - - virtual void SetUp() { - } - - virtual void TearDown() { - } -}; - -TEST_F(castor_mediachanger_ScsiLibrarySlotTest, goodDay) { - using namespace castor::mediachanger; - - ScsiLibrarySlot slot(2); - ASSERT_EQ(TAPE_LIBRARY_TYPE_SCSI, slot.getLibraryType()); - ASSERT_EQ(std::string("smc2"), slot.str()); - ASSERT_EQ((uint16_t)2, slot.getDrvOrd()); -} - -TEST_F(castor_mediachanger_ScsiLibrarySlotTest, clone) { - using namespace castor::mediachanger; - - std::unique_ptr<ScsiLibrarySlot> slot1; - ASSERT_NO_THROW(slot1.reset(new ScsiLibrarySlot(2))); - ASSERT_EQ(TAPE_LIBRARY_TYPE_SCSI, slot1->getLibraryType()); - ASSERT_EQ(std::string("smc2"), slot1->str()); - - std::unique_ptr<ScsiLibrarySlot> slot2; - ASSERT_NO_THROW(slot2.reset((ScsiLibrarySlot*)slot1->clone())); - ASSERT_EQ(TAPE_LIBRARY_TYPE_SCSI, slot2->getLibraryType()); - ASSERT_EQ(std::string("smc2"), slot2->str()); -} - -} // namespace unitTests diff --git a/tapeserver/castor/mediachanger/TapeLibraryType.cpp b/tapeserver/castor/mediachanger/TapeLibraryType.cpp deleted file mode 100644 index a612399d220b22cf498b53ee9a90679a986841ac..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/TapeLibraryType.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * - * 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/mediachanger/TapeLibraryType.hpp" - -//------------------------------------------------------------------------------ -// tapeLibraryTypeToString -//------------------------------------------------------------------------------ -const char *castor::mediachanger::tapeLibraryTypeToString( - const TapeLibraryType libraryType) throw() { - switch(libraryType) { - case TAPE_LIBRARY_TYPE_NONE : return "NONE"; - case TAPE_LIBRARY_TYPE_ACS : return "ACS"; - case TAPE_LIBRARY_TYPE_MANUAL: return "MANUAL"; - case TAPE_LIBRARY_TYPE_SCSI : return "SCSI"; - default : return "UNKNOWN"; - } -} diff --git a/tapeserver/castor/mediachanger/TapeLibraryType.hpp b/tapeserver/castor/mediachanger/TapeLibraryType.hpp deleted file mode 100644 index c97eaccbe1785c56e216d33f843d5899e5fac707..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/TapeLibraryType.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************** - * - * 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 - -namespace castor { -namespace mediachanger { - -/** - * Enumeration of the different types of tape library. - */ -enum TapeLibraryType { - TAPE_LIBRARY_TYPE_NONE, - TAPE_LIBRARY_TYPE_ACS, - TAPE_LIBRARY_TYPE_MANUAL, - TAPE_LIBRARY_TYPE_SCSI}; - -/** - * Thread safe method that returns the string representation of the - * specified tape library. - * - * Please note that this function does not throw an exception. If the - * tape-library type is not known then an appropriate string is returned. - */ -const char *tapeLibraryTypeToString(const TapeLibraryType libraryType) throw(); - -} // namespace mediachanger -} // namespace castor diff --git a/tapeserver/castor/mediachanger/cta-mediachanger-dismount.1cta b/tapeserver/castor/mediachanger/cta-mediachanger-dismount.1cta deleted file mode 100644 index 6d254e70b9abc1503f48be171ab7406679675cc0..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/cta-mediachanger-dismount.1cta +++ /dev/null @@ -1,56 +0,0 @@ -.\" The CERN Tape Archive (CTA) project -.\" Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>. -.TH CTA-MEDIACHANGER-DISMOUNT 1CTA "August 2016" CTA CTA -.SH NAME -cta-mediachanger-dismount \- dismount a volume -.SH SYNOPSIS -.BI "cta-mediachanger-dismount [options] VID DRIVE_SLOT" - -.SH DESCRIPTION -\fBWarning\fP, \fBcta-mediachanger-dismount\fP is a developer tool and -is therefore subject to change in and even removal from a future release of -CASTOR. -End users should not rely on this tool to operate their CASTOR installation. - -\fBcta-mediachanger-dismount\fP dismounts the volume with the specified -\fBVID\fP from the drive located in the specified \fBDRIVE_SLOT\fP within the -tape library. \fBDRIVE_SLOT\fP must be in one of the following two forms: -.IP -.B acsACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER -.IP -.B smcDRIVE_ORDINAL - -.SH OPTIONS -.TP -\fB\-d, \-\-debug -Turns on the printing of debug information. -.TP -\fB\-h, \-\-help -Prints the usage message. -.TP -\fB\-f, \-\-force -Force the dismount (rewind and eject the tape where necessary). - -.SH "RETURN CODES" -.TP -\fB 0 -Ok. -.TP -\fB 1 -Command failed. - -.SH AUTHOR -\fBCTA\fP Team diff --git a/tapeserver/castor/mediachanger/cta-mediachanger-mount.1cta b/tapeserver/castor/mediachanger/cta-mediachanger-mount.1cta deleted file mode 100644 index 4e58c135ca5dec9f3034bfd1b6dfb0f508dd4d54..0000000000000000000000000000000000000000 --- a/tapeserver/castor/mediachanger/cta-mediachanger-mount.1cta +++ /dev/null @@ -1,55 +0,0 @@ -.\" The CERN Tape Archive (CTA) project -.\" Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>. -.TH CTA-MEDIACHANGER-MOUNT 1CTA "August 2016" CTA CTA -.SH NAME -cta-mediachanger-mount \- mount a volume -.SH SYNOPSIS -.BI "cta-mediachanger-mount [options] VID DRIVE_SLOT" - -.SH DESCRIPTION -\fBWarning\fP, \fBcastor-tape-mediachanger-mount\fP is a developer tool and is -therefore subject to change in and even removal from a future release of CASTOR. -End users should not rely on this tool to operate their CASTOR installation. - -\fBcastor-tape-mediachanger-mount\fP mounts the volume with the specified -\fBVID\fP into the drive located in the specified \fBDRIVE_SLOT\fP within the -tape library. \fBDRIVE_SLOT\fP must be in one of the following two forms: -.IP -.B acsACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER -.IP -.B smcDRIVE_ORDINAL - -.SH OPTIONS -.TP -\fB\-d, \-\-debug -Turns on the printing of debug information. -.TP -\fB\-h, \-\-help -Prints the usage message. -.TP -\fB\-r, \-\-readonly -Request the volume is mounted for read-only access. - -.SH "RETURN CODES" -.TP -\fB 0 -Ok. -.TP -\fB 1 -Command failed. - -.SH AUTHOR -\fBCTA\fP Team diff --git a/tapeserver/castor/messages/AcsDismountTape.proto b/tapeserver/castor/messages/AcsDismountTape.proto deleted file mode 100644 index 8b5061512c8381673a0c12b906c7fefdc13ff0b8..0000000000000000000000000000000000000000 --- a/tapeserver/castor/messages/AcsDismountTape.proto +++ /dev/null @@ -1,26 +0,0 @@ -// 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 -package castor.messages; - -message AcsDismountTape { - required string vid = 1; - required uint32 acs = 2; - required uint32 lsm = 3; - required uint32 panel = 4; - required uint32 drive = 5; -} diff --git a/tapeserver/castor/messages/AcsForceDismountTape.proto b/tapeserver/castor/messages/AcsForceDismountTape.proto deleted file mode 100644 index 7671c6f195ccd740530f80788182e17e08c66b4b..0000000000000000000000000000000000000000 --- a/tapeserver/castor/messages/AcsForceDismountTape.proto +++ /dev/null @@ -1,26 +0,0 @@ -// 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 -package castor.messages; - -message AcsForceDismountTape { - required string vid = 1; - required uint32 acs = 2; - required uint32 lsm = 3; - required uint32 panel = 4; - required uint32 drive = 5; -} diff --git a/tapeserver/castor/messages/AcsMountTapeReadOnly.proto b/tapeserver/castor/messages/AcsMountTapeReadOnly.proto deleted file mode 100644 index 15065c4f8ae13f60bf1a5fe54794d3cab006ce32..0000000000000000000000000000000000000000 --- a/tapeserver/castor/messages/AcsMountTapeReadOnly.proto +++ /dev/null @@ -1,26 +0,0 @@ -// 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 -package castor.messages; - -message AcsMountTapeReadOnly { - required string vid = 1; - required uint32 acs = 2; - required uint32 lsm = 3; - required uint32 panel = 4; - required uint32 drive = 5; -} diff --git a/tapeserver/castor/messages/AcsMountTapeReadWrite.proto b/tapeserver/castor/messages/AcsMountTapeReadWrite.proto deleted file mode 100644 index 4788a973d0a0c339fbc495e9256b3d8445082717..0000000000000000000000000000000000000000 --- a/tapeserver/castor/messages/AcsMountTapeReadWrite.proto +++ /dev/null @@ -1,26 +0,0 @@ -// 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 -package castor.messages; - -message AcsMountTapeReadWrite { - required string vid = 1; - required uint32 acs = 2; - required uint32 lsm = 3; - required uint32 panel = 4; - required uint32 drive = 5; -} diff --git a/tapeserver/castor/messages/AcsProxy.hpp b/tapeserver/castor/messages/AcsProxy.hpp deleted file mode 100644 index 18f669d1124003049e7722d73973b1042fbb6686..0000000000000000000000000000000000000000 --- a/tapeserver/castor/messages/AcsProxy.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/****************************************************************************** - * - * 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 "tapeserver/castor/mediachanger/AcsLibrarySlot.hpp" - -#include <stdint.h> -#include <string> - -namespace castor { -namespace messages { - -/** - * Abstract class defining the interface to a proxy object representing the - * CASTOR ACS daemon. - */ -class AcsProxy { -public: - - /** - * Destructor. - */ - virtual ~AcsProxy() = 0; - - /** - * Request the CASTOR ACS daemon to mount the specified tape for read-only - * access into the tape drive in the specified library slot. - * - * Please note that this method provides a best-effort service because not all - * media changers support read-only mounts. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - virtual void mountTapeReadOnly(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) = 0; - - /** - * Request the CASTOR ACS daemon to mount the specifed tape for read/write - * access into the tape drive in the specified library slot. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - virtual void mountTapeReadWrite(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) = 0; - - /** - * Request the CASTOR ACS daemon to dismount the specifed tape from the tape - * drive in the specified library slot. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - virtual void dismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) = 0; - - /** - * Request the CASTOR ACS daemon to forcefully dismount the specifed tape - * from the tape drive in the specified library slot. Forcefully means - * rewinding and ejecting the tape if necessary. - * - * Please note that this method provides a best-effort service because not all - * media changers support forceful dismounts. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - virtual void forceDismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) = 0; - -}; // class AcsProxy - -} // namespace messages -} // namespace castor - diff --git a/tapeserver/castor/messages/AcsProxyDummy.cpp b/tapeserver/castor/messages/AcsProxyDummy.cpp deleted file mode 100644 index 6be51336cd906266df5cf128a949abf3b279d02e..0000000000000000000000000000000000000000 --- a/tapeserver/castor/messages/AcsProxyDummy.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** - * - * 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 "AcsProxyDummy.hpp" - -//------------------------------------------------------------------------------ -// mountTapeReadOnly -//------------------------------------------------------------------------------ -void castor::messages::AcsProxyDummy::mountTapeReadOnly(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { -} - -//------------------------------------------------------------------------------ -// mountTapeForMigration -//------------------------------------------------------------------------------ -void castor::messages::AcsProxyDummy::mountTapeReadWrite(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { -} - -//------------------------------------------------------------------------------ -// dismountTape -//------------------------------------------------------------------------------ -void castor::messages::AcsProxyDummy::dismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { -} - -//------------------------------------------------------------------------------ -// dismountTape -//------------------------------------------------------------------------------ -void castor::messages::AcsProxyDummy::forceDismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { -} diff --git a/tapeserver/castor/messages/AcsProxyDummy.hpp b/tapeserver/castor/messages/AcsProxyDummy.hpp deleted file mode 100644 index a57509a4e5245704a1948e6e9ae6154a86b8b68b..0000000000000000000000000000000000000000 --- a/tapeserver/castor/messages/AcsProxyDummy.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/****************************************************************************** - * - * 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/messages/AcsProxy.hpp" - -namespace castor { -namespace messages { - -/** - * Concrete class implementimg a dummy AcsProxy. - */ -class AcsProxyDummy: public AcsProxy { -public: - - /** - * Request the CASTOR ACS daemon to mount the specified tape for read-only - * access into the tape drive in the specified library slot. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - void mountTapeReadOnly(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - - /** - * Request the CASTOR ACS daemon to mount the specifed tape for read/write - * access into the tape drive in the specified library slot. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - void mountTapeReadWrite(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - - /** - * Request the CASTOR ACS daemon to dismount the specifed tape from the tape - * drive in the specified library slot. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - void dismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - - /** - * Request the CASTOR ACS daemon to forcefully dismount the specifed tape - * from the tape drive in the specified library slot. Forcefully means - * rewinding and ejecting the tape if necessary. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - void forceDismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - -}; // class AcsProxyDummy - -} // namespace messages -} // namespace castor - diff --git a/tapeserver/castor/messages/AcsProxyZmq.cpp b/tapeserver/castor/messages/AcsProxyZmq.cpp deleted file mode 100644 index 5c2f96e0d57670f9ad930cfb440324fe51cc40cd..0000000000000000000000000000000000000000 --- a/tapeserver/castor/messages/AcsProxyZmq.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/****************************************************************************** - * - * 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/messages/AcsMountTapeReadOnly.pb.h" -#include "castor/messages/AcsMountTapeReadWrite.pb.h" -#include "castor/messages/AcsDismountTape.pb.h" -#include "castor/messages/AcsForceDismountTape.pb.h" -#include "castor/messages/ReturnValue.pb.h" -#include "castor/messages/AcsProxyZmq.hpp" -#include "castor/messages/Constants.hpp" -#include "castor/messages/messages.hpp" -#include "common/threading/MutexLocker.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -castor::messages::AcsProxyZmq::AcsProxyZmq(const unsigned short serverPort, - void *const zmqContext) throw(): - m_serverPort(serverPort), - m_serverSocket(zmqContext, ZMQ_REQ) { - connectZmqSocketToLocalhost(m_serverSocket, serverPort); -} - -//------------------------------------------------------------------------------ -// mountTapeReadOnly -//------------------------------------------------------------------------------ -void castor::messages::AcsProxyZmq::mountTapeReadOnly(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { - cta::threading::MutexLocker lock(m_mutex); - - try { - const Frame rqst = createAcsMountTapeReadOnlyFrame(vid, librarySlot); - sendFrame(m_serverSocket, rqst); - - ReturnValue reply; - recvTapeReplyOrEx(m_serverSocket, reply); - if(0 != reply.value()) { - // Should never get here - cta::exception::Exception ex; - ex.getMessage() << "Received an unexpected return value" - ": expected=0 actual=" << reply.value(); - throw ex; - } - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << - "Failed to request CASTOR ACS daemon to mount tape for read only access: " - << librarySlot.str() << ": " << ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// createAcsMountTapeReadnOnlyFrame -//------------------------------------------------------------------------------ -castor::messages::Frame castor::messages::AcsProxyZmq:: - createAcsMountTapeReadOnlyFrame(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { - try { - Frame frame; - - frame.header = messages::protoTapePreFillHeader(); - frame.header.set_msgtype(messages::MSG_TYPE_ACSMOUNTTAPEREADONLY); - frame.header.set_bodysignature("PIPO"); - - AcsMountTapeReadOnly body; - body.set_vid(vid); - body.set_acs(librarySlot.getAcs()); - body.set_lsm(librarySlot.getLsm()); - body.set_panel(librarySlot.getPanel()); - body.set_drive(librarySlot.getDrive()); - frame.serializeProtocolBufferIntoBody(body); - - return frame; - - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to create AcsMountTapeReadOnly frame: " << - ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// mountTapeReadWrite -//------------------------------------------------------------------------------ -void castor::messages::AcsProxyZmq::mountTapeReadWrite(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { - cta::threading::MutexLocker lock(m_mutex); - - try { - const Frame rqst = createAcsMountTapeReadWriteFrame(vid, librarySlot); - sendFrame(m_serverSocket, rqst); - - ReturnValue reply; - recvTapeReplyOrEx(m_serverSocket, reply); - if(0 != reply.value()) { - // Should never get here - cta::exception::Exception ex; - ex.getMessage() << "Received an unexpected return value" - ": expected=0 actual=" << reply.value(); - throw ex; - } - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << - "Failed to request CASTOR ACS daemon to mount tape for read/write " - "access: " << librarySlot.str() << ": " << ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// createAcsMountTapeReadWriteFrame -//------------------------------------------------------------------------------ -castor::messages::Frame castor::messages::AcsProxyZmq:: - createAcsMountTapeReadWriteFrame(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { - try { - Frame frame; - - frame.header = messages::protoTapePreFillHeader(); - frame.header.set_msgtype(messages::MSG_TYPE_ACSMOUNTTAPEREADWRITE); - frame.header.set_bodysignature("PIPO"); - - AcsMountTapeReadWrite body; - body.set_vid(vid); - body.set_acs(librarySlot.getAcs()); - body.set_lsm(librarySlot.getLsm()); - body.set_panel(librarySlot.getPanel()); - body.set_drive(librarySlot.getDrive()); - frame.serializeProtocolBufferIntoBody(body); - - return frame; - - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to create AcsMountTapeReadWrite frame: " << - ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// dismountTape -//------------------------------------------------------------------------------ -void castor::messages::AcsProxyZmq::dismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { - cta::threading::MutexLocker lock(m_mutex); - - try { - const Frame rqst = createAcsDismountTapeFrame(vid, librarySlot); - sendFrame(m_serverSocket, rqst); - - ReturnValue reply; - recvTapeReplyOrEx(m_serverSocket, reply); - if(0 != reply.value()) { - // Should never get here - cta::exception::Exception ex; - ex.getMessage() << "Received an unexpected return value" - ": expected=0 actual=" << reply.value(); - throw ex; - } - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << - "Failed to request CASTOR ACS daemon to dismount tape: " << - librarySlot.str() << ": " << ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// createAcsDismountTapeFrame -//------------------------------------------------------------------------------ -castor::messages::Frame castor::messages::AcsProxyZmq:: - createAcsDismountTapeFrame(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { - try { - Frame frame; - - frame.header = messages::protoTapePreFillHeader(); - frame.header.set_msgtype(messages::MSG_TYPE_ACSDISMOUNTTAPE); - frame.header.set_bodysignature("PIPO"); - - AcsDismountTape body; - body.set_vid(vid); - body.set_acs(librarySlot.getAcs()); - body.set_lsm(librarySlot.getLsm()); - body.set_panel(librarySlot.getPanel()); - body.set_drive(librarySlot.getDrive()); - frame.serializeProtocolBufferIntoBody(body); - - return frame; - - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to create AcsDismountTape frame: " << - ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// forceDismountTape -//------------------------------------------------------------------------------ -void castor::messages::AcsProxyZmq::forceDismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { - cta::threading::MutexLocker lock(m_mutex); - - try { - const Frame rqst = createAcsForceDismountTapeFrame(vid, librarySlot); - sendFrame(m_serverSocket, rqst); - - ReturnValue reply; - recvTapeReplyOrEx(m_serverSocket, reply); - if(0 != reply.value()) { - // Should never get here - cta::exception::Exception ex; - ex.getMessage() << "Received an unexpected return value" - ": expected=0 actual=" << reply.value(); - throw ex; - } - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << - "Failed to request CASTOR ACS daemon to force dismount tape: " << - librarySlot.str() << ": " << ne.getMessage().str(); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// createAcsForceDismountTapeFrame -//------------------------------------------------------------------------------ -castor::messages::Frame castor::messages::AcsProxyZmq:: - createAcsForceDismountTapeFrame(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot) { - try { - Frame frame; - - frame.header = messages::protoTapePreFillHeader(); - frame.header.set_msgtype(messages::MSG_TYPE_ACSFORCEDISMOUNTTAPE); - frame.header.set_bodysignature("PIPO"); - - AcsForceDismountTape body; - body.set_vid(vid); - body.set_acs(librarySlot.getAcs()); - body.set_lsm(librarySlot.getLsm()); - body.set_panel(librarySlot.getPanel()); - body.set_drive(librarySlot.getDrive()); - frame.serializeProtocolBufferIntoBody(body); - - return frame; - - } catch(cta::exception::Exception &ne) { - cta::exception::Exception ex; - ex.getMessage() << "Failed to create AcsForceDismountTape frame: " << - ne.getMessage().str(); - throw ex; - } -} diff --git a/tapeserver/castor/messages/AcsProxyZmq.hpp b/tapeserver/castor/messages/AcsProxyZmq.hpp deleted file mode 100644 index 6548bf8acab9d21ebf50a94240f6a1718410d39d..0000000000000000000000000000000000000000 --- a/tapeserver/castor/messages/AcsProxyZmq.hpp +++ /dev/null @@ -1,150 +0,0 @@ -/****************************************************************************** - * - * 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 "AcsProxy.hpp" -#include "Frame.hpp" -#include "common/threading/Mutex.hpp" -#include "ZmqSocketMT.hpp" - -namespace castor { -namespace messages { - -/** - * Concrete class providing a ZMQ implementation of an AcsProxy. - */ -class AcsProxyZmq: public AcsProxy { -public: - - /** - * Constructor. - * - * @param serverPort The TCP/IP port on which the CASTOR ACS daemon is - * listening for ZMQ messages. - * @param zmqContext The ZMQ context. - */ - AcsProxyZmq(const unsigned short serverPort, void *const zmqContext) throw(); - - /** - * Request the CASTOR ACS daemon to mount the specified tape for read-only - * access into the tape drive in the specified library slot. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - void mountTapeReadOnly(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - - /** - * Request the CASTOR ACS daemon to mount the specifed tape for read/write - * access into the tape drive in the specified library slot. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - void mountTapeReadWrite(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - - /** - * Request the CASTOR ACS daemon to dismount the specifed tape from the tape - * drive in the specified library slot. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - void dismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - - /** - * Request the CASTOR ACS daemon to forcefully dismount the specifed tape - * from the tape drive in the specified library slot. Forcefully means - * rewinding and ejecting the tape if necessary. - * - * @param vid The volume identifier of the tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - */ - void forceDismountTape(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - -private: - - /** - * Mutex used to implement a critical section around the enclosed - * ZMQ socket. - */ - cta::threading::Mutex m_mutex; - - /** - * The TCP/IP port on which the CASTOR ACS daemon is listening for ZMQ - * messages. - */ - const unsigned short m_serverPort; - - /** - * Socket connecting this proxy the daemon it represents. - */ - ZmqSocketMT m_serverSocket; - - /** - * Creates a frame containing a AcsMountTapeForRecall message. - * - * @param vid The tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - * @return The frame. - */ - Frame createAcsMountTapeReadOnlyFrame(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - - /** - * Creates a frame containing a AcsMountTapeForMigration message. - * - * @param vid The tape to be mounted. - * @param librarySlot The slot in the library that contains the tape drive. - * @return The frame. - */ - Frame createAcsMountTapeReadWriteFrame(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - - /** - * Creates a frame containing a AcsDismountTape message. - * - * @param vid The tape to be dismounted. - * @param librarySlot The slot in the library that contains the tape drive. - * @return The frame. - */ - Frame createAcsDismountTapeFrame(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - - /** - * Creates a frame containing a AcsDismountTape message. - * - * @param vid The tape to be dismounted. - * @param librarySlot The slot in the library that contains the tape drive. - * @return The frame. - */ - Frame createAcsForceDismountTapeFrame(const std::string &vid, - const mediachanger::AcsLibrarySlot &librarySlot); - -}; // class AcsProxyZmq - -} // namespace messages -} // namespace castor diff --git a/tapeserver/castor/messages/CMakeLists.txt b/tapeserver/castor/messages/CMakeLists.txt index 08ef9c710d4defb5b05ff8bb941d68951fe2e31b..1857591ac70d2ccdef7b9a9edddc3caafe3b6325 100644 --- a/tapeserver/castor/messages/CMakeLists.txt +++ b/tapeserver/castor/messages/CMakeLists.txt @@ -31,13 +31,10 @@ add_library(ctamessagesprotobuf ${ProtoSources}) add_library(ctamessagesutils SHARED - AcsProxyDummy.cpp TapeserverProxyDummy.cpp) install(TARGETS ctamessagesutils DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) set(CtaMessageSrcs - AcsProxy.cpp - AcsProxyZmq.cpp Constants.cpp Frame.cpp messages.cpp diff --git a/tapeserver/castor/tape/tapeserver/daemon/CatalogueTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/CatalogueTest.cpp index 716a33b358f5ef5a9fdc91fae516d88e24357f9e..7ff9404a87ced01cf17ca4a0859dbc1d35fdbab6 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/CatalogueTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/CatalogueTest.cpp @@ -87,7 +87,7 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, goodDayPopulate) { // Daniele changed this to DRIVE_STATE_UP while doing the full system test ,because the tpconfig command is // not working properly. ASSERT_NO_THROW(unit1Config.getLibrarySlot()); - ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, + ASSERT_EQ(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, unit1Config.getLibrarySlot().getLibraryType()); ASSERT_EQ(std::string("manual@SLOT1"), unit1Config.getLibrarySlot().str()); @@ -106,7 +106,7 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, goodDayPopulate) { // Daniele changed this to DRIVE_STATE_UP while doing the full system test ,because the tpconfig command is // not working properly. ASSERT_NO_THROW(unit2Config.getLibrarySlot()); - ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, + ASSERT_EQ(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, unit2Config.getLibrarySlot().getLibraryType()); ASSERT_EQ(std::string("manual@SLOT2"), unit2Config.getLibrarySlot().str()); } diff --git a/tapeserver/castor/tape/tapeserver/daemon/CleanerSession.cpp b/tapeserver/castor/tape/tapeserver/daemon/CleanerSession.cpp index 41d0d4748fc209c44f1857651b6be667771b2fc0..9def2b3e24857f4c8e47e7c2e54be853bc2625e1 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/CleanerSession.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/CleanerSession.cpp @@ -28,7 +28,7 @@ //------------------------------------------------------------------------------ castor::tape::tapeserver::daemon::CleanerSession::CleanerSession( cta::server::ProcessCap &capUtils, - mediachanger::MediaChangerFacade &mc, + cta::mediachanger::MediaChangerFacade &mc, cta::log::Logger &log, const DriveConfig &driveConfig, System::virtualWrapper &sysWrapper, @@ -294,7 +294,7 @@ std::string castor::tape::tapeserver::daemon::CleanerSession::checkVolumeLabel( //------------------------------------------------------------------------------ void castor::tape::tapeserver::daemon::CleanerSession::unloadTape( const std::string &vid, drive::DriveInterface &drive) { - const mediachanger::LibrarySlot &librarySlot = m_driveConfig.getLibrarySlot(); + const cta::mediachanger::LibrarySlot &librarySlot = m_driveConfig.getLibrarySlot(); std::list<cta::log::Param> params; params.push_back(cta::log::Param("TPVID", vid)); params.push_back(cta::log::Param("unitName", m_driveConfig.getUnitName())); @@ -302,7 +302,7 @@ void castor::tape::tapeserver::daemon::CleanerSession::unloadTape( // We implement the same policy as with the tape sessions: // if the librarySlot parameter is "manual", do nothing. - if(mediachanger::TAPE_LIBRARY_TYPE_MANUAL == librarySlot.getLibraryType()) { + if(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL == librarySlot.getLibraryType()) { m_log(cta::log::INFO, "Cleaner not unloading tape because media changer is" " manual", params); return; @@ -325,7 +325,7 @@ void castor::tape::tapeserver::daemon::CleanerSession::unloadTape( //------------------------------------------------------------------------------ void castor::tape::tapeserver::daemon::CleanerSession::dismountTape( const std::string &vid) { - const mediachanger::LibrarySlot &librarySlot = m_driveConfig.getLibrarySlot(); + const cta::mediachanger::LibrarySlot &librarySlot = m_driveConfig.getLibrarySlot(); std::list<cta::log::Param> params; params.push_back(cta::log::Param("TPVID", vid)); params.push_back(cta::log::Param("unitName", m_driveConfig.getUnitName())); @@ -333,7 +333,7 @@ void castor::tape::tapeserver::daemon::CleanerSession::dismountTape( try { m_mc.dismountTape(vid, librarySlot); - const bool dismountWasManual = mediachanger::TAPE_LIBRARY_TYPE_MANUAL == + const bool dismountWasManual = cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL == librarySlot.getLibraryType(); if(dismountWasManual) { m_log(cta::log::INFO, "Cleaner did not dismount tape because media changer is" diff --git a/tapeserver/castor/tape/tapeserver/daemon/CleanerSession.hpp b/tapeserver/castor/tape/tapeserver/daemon/CleanerSession.hpp index 42743d7c880ee1fb9e1f6837ef4baaa7ae082199..7f42ba747dadcfe1ca228daf1141174da2b152a8 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/CleanerSession.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/CleanerSession.hpp @@ -25,9 +25,9 @@ #include "common/log/LogContext.hpp" #include "common/log/Logger.hpp" -#include "tapeserver/castor/mediachanger/MediaChangerFacade.hpp" #include "common/processCap/ProcessCap.hpp" #include "DriveConfig.hpp" +#include "mediachanger/MediaChangerFacade.hpp" #include "Session.hpp" #include "tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp" #include "tapeserver/castor/tape/tapeserver/file/Structures.hpp" @@ -65,7 +65,7 @@ namespace daemon { */ CleanerSession( cta::server::ProcessCap &capUtils, - mediachanger::MediaChangerFacade &mc, + cta::mediachanger::MediaChangerFacade &mc, cta::log::Logger &log, const DriveConfig &driveConfig, System::virtualWrapper &sysWrapper, @@ -93,7 +93,7 @@ namespace daemon { /** * The object representing the media changer. */ - mediachanger::MediaChangerFacade &m_mc; + cta::mediachanger::MediaChangerFacade &m_mc; /** * The logging object diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp index 00495a4889fed41a5075ce9d95412345ce618ac9..566c091627af5b8539b8882c72e1f61429ddf9d0 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp @@ -51,7 +51,7 @@ castor::tape::tapeserver::daemon::DataTransferSession::DataTransferSession( cta::log::Logger & log, System::virtualWrapper & sysWrapper, const DriveConfig & driveConfig, - castor::mediachanger::MediaChangerFacade & mc, + cta::mediachanger::MediaChangerFacade & mc, cta::tape::daemon::TapedProxy & initialProcess, cta::server::ProcessCap & capUtils, const DataTransferConfig & castorConf, diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.hpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.hpp index a4e7b4fad8bc83177dc0005b654a53e9d62da2c5..a75200b3167fe41ce143b1710ce2cf38abdfe2ef 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.hpp @@ -25,9 +25,9 @@ #include "common/log/LogContext.hpp" #include "common/log/Logger.hpp" -#include "tapeserver/castor/mediachanger/MediaChangerFacade.hpp" -#include "tapeserver/daemon/TapedProxy.hpp" #include "common/processCap/ProcessCap.hpp" +#include "mediachanger/MediaChangerFacade.hpp" +#include "tapeserver/daemon/TapedProxy.hpp" #include "DataTransferConfig.hpp" #include "DriveConfig.hpp" #include "Session.hpp" @@ -60,7 +60,7 @@ namespace daemon { cta::log::Logger & log, System::virtualWrapper & sysWrapper, const DriveConfig & driveConfig, - castor::mediachanger::MediaChangerFacade & mc, + cta::mediachanger::MediaChangerFacade & mc, cta::tape::daemon::TapedProxy & initialProcess, cta::server::ProcessCap &capUtils, const DataTransferConfig & castorConf, @@ -128,7 +128,7 @@ namespace daemon { EndOfSessionAction executeLabel(cta::log::LogContext & lc, cta::LabelMount *labelMount); /** Reference to the MediaChangerFacade, allowing the mounting of the tape * by the library. It will be used exclusively by the tape thread. */ - castor::mediachanger::MediaChangerFacade & m_mc; + cta::mediachanger::MediaChangerFacade & m_mc; /** Reference to the tape server's parent process to report detailed status */ cta::tape::daemon::TapedProxy & m_intialProcess; /** Object providing utilities for working UNIX capabilities. */ diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp index f8a07abe505cffa304badcc8b13fa1dfab44da58..b894d5a9785032c6a781ca72e85ded332563eeb5 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp @@ -27,31 +27,31 @@ #include <inttypes.h> #include <gtest/gtest.h> -#include "castor/legacymsg/RmcProxyDummy.hpp" -#include "common/log/StringLogger.hpp" -#include "castor/mediachanger/MediaChangerFacade.hpp" -#include "castor/mediachanger/MmcProxyDummy.hpp" -#include "castor/messages/AcsProxyDummy.hpp" #include "castor/messages/TapeserverProxyDummy.hpp" -#include "common/processCap/ProcessCapDummy.hpp" -#include "common/threading/Threading.hpp" #include "castor/tape/tapeserver/daemon/DataTransferSession.hpp" #include "castor/tape/tapeserver/daemon/VolumeInfo.hpp" #include "castor/tape/tapeserver/system/Wrapper.hpp" #include "castor/tape/tapeserver/file/File.hpp" #include "castor/tape/tapeserver/drive/FakeDrive.hpp" +#include "catalogue/InMemoryCatalogue.hpp" #include "common/exception/Exception.hpp" +#include "common/log/StringLogger.hpp" #include "common/make_unique.hpp" +#include "common/processCap/ProcessCapDummy.hpp" +#include "common/threading/Threading.hpp" #include "common/utils/utils.hpp" -#include "scheduler/Scheduler.hpp" +#include "mediachanger/AcsProxyDummy.hpp" +#include "mediachanger/MediaChangerFacade.hpp" +#include "mediachanger/MmcProxyDummy.hpp" +#include "mediachanger/RmcProxyDummy.hpp" //#include "smc_struct.h" -#include "catalogue/InMemoryCatalogue.hpp" #include "remotens/MockRemoteNS.hpp" #include "remotens/MockRemoteFullFS.hpp" //#include "scheduler/DummyScheduler.hpp" #include "scheduler/OStoreDB/OStoreDBFactory.hpp" #include "scheduler/MountType.hpp" //#include "nameserver/NameServer.hpp" +#include "scheduler/Scheduler.hpp" #include "scheduler/testingMocks/MockRetrieveMount.hpp" #include "scheduler/testingMocks/MockArchiveJob.hpp" #include "scheduler/testingMocks/MockArchiveMount.hpp" @@ -438,10 +438,10 @@ TEST_P(DataTransferSessionTest, DataTransferSessionGooddayRecall) { castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000; castorConf.bulkRequestRecallMaxFiles = 1000; castorConf.nbDiskThreads = 1; - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); cta::server::ProcessCap capUtils; castor::messages::TapeserverProxyDummy initialProcess; castor::tape::tapeserver::daemon::DataTransferSession sess("tapeHost", logger, mockSys, @@ -631,10 +631,10 @@ TEST_P(DataTransferSessionTest, DataTransferSessionWrongRecall) { castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000; castorConf.bulkRequestRecallMaxFiles = 1000; castorConf.nbDiskThreads = 1; - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); cta::server::ProcessCap capUtils; castor::messages::TapeserverProxyDummy initialProcess; DataTransferSession sess("tapeHost", logger, mockSys, @@ -793,10 +793,10 @@ TEST_P(DataTransferSessionTest, DataTransferSessionNoSuchDrive) { DataTransferConfig castorConf; castorConf.bufsz = 1024; castorConf.nbBufs = 10; - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); castor::messages::TapeserverProxyDummy initialProcess; cta::server::ProcessCapDummy capUtils; DataTransferSession sess("tapeHost", logger, mockSys, @@ -940,10 +940,10 @@ TEST_P(DataTransferSessionTest, DataTransferSessionFailtoMount) { castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000; castorConf.bulkRequestRecallMaxFiles = 1000; castorConf.nbDiskThreads = 3; - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); cta::server::ProcessCap capUtils; castor::messages::TapeserverProxyDummy initialProcess; DataTransferSession sess("tapeHost", logger, mockSys, @@ -1008,10 +1008,10 @@ TEST_P(DataTransferSessionTest, DataTransferSessionEmptyOnVolReq) { castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000; castorConf.bulkRequestRecallMaxFiles = 1000; castorConf.nbDiskThreads = 3; - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); cta::server::ProcessCap capUtils; castor::messages::TapeserverProxyDummy initialProcess; DataTransferSession sess("tapeHost", logger, mockSys, @@ -1126,10 +1126,10 @@ TEST_P(DataTransferSessionTest, DataTransferSessionGooddayMigration) { castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000; castorConf.bulkRequestRecallMaxFiles = 1000; castorConf.nbDiskThreads = 1; - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); cta::server::ProcessCap capUtils; castor::messages::TapeserverProxyDummy initialProcess; DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler); @@ -1266,10 +1266,10 @@ TEST_P(DataTransferSessionTest, DataTransferSessionMissingFilesMigration) { castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000; castorConf.bulkRequestRecallMaxFiles = 1000; castorConf.nbDiskThreads = 1; - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); cta::server::ProcessCap capUtils; castor::messages::TapeserverProxyDummy initialProcess; DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler); @@ -1400,10 +1400,10 @@ TEST_P(DataTransferSessionTest, DataTransferSessionTapeFullMigration) { castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000; castorConf.bulkRequestRecallMaxFiles = 1000; castorConf.nbDiskThreads = 1; - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); cta::server::ProcessCap capUtils; castor::messages::TapeserverProxyDummy initialProcess; DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler); @@ -1548,10 +1548,10 @@ TEST_P(DataTransferSessionTest, DataTransferSessionTapeFullOnFlushMigration) { castorConf.bulkRequestRecallMaxBytes = UINT64_C(100)*1000*1000*1000; castorConf.bulkRequestRecallMaxFiles = 1000; castorConf.nbDiskThreads = 1; - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); cta::server::ProcessCap capUtils; castor::messages::TapeserverProxyDummy initialProcess; DataTransferSession sess("tapeHost", logger, mockSys, driveConfig, mc, initialProcess, capUtils, castorConf, scheduler); diff --git a/tapeserver/castor/tape/tapeserver/daemon/DriveConfig.cpp b/tapeserver/castor/tape/tapeserver/daemon/DriveConfig.cpp index 4120b30d5f5627618d1921075706fcc923f043c7..ebf3dc87da78a735674c9b552efd60469401522e 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DriveConfig.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DriveConfig.cpp @@ -21,9 +21,9 @@ * @author Castor Dev team, castor-dev@cern.ch *****************************************************************************/ -#include "castor/mediachanger/LibrarySlotParser.hpp" #include "castor/tape/tapeserver/daemon/DriveConfig.hpp" #include "common/exception/Exception.cpp" +#include "mediachanger/LibrarySlotParser.hpp" //------------------------------------------------------------------------------ // constructor @@ -43,7 +43,7 @@ castor::tape::tapeserver::daemon::DriveConfig::DriveConfig( m_unitName(unitName), m_logicalLibrary(logicalLibrary), m_devFilename(devFilename), - m_librarySlot(mediachanger::LibrarySlotParser::parse(librarySlot)) { + m_librarySlot(cta::mediachanger::LibrarySlotParser::parse(librarySlot)) { } //------------------------------------------------------------------------------ @@ -110,7 +110,7 @@ const std::string &castor::tape::tapeserver::daemon::DriveConfig:: //------------------------------------------------------------------------------ // getLibrarySlot //------------------------------------------------------------------------------ -const castor::mediachanger::LibrarySlot &castor::tape::tapeserver::daemon:: +const cta::mediachanger::LibrarySlot &castor::tape::tapeserver::daemon:: DriveConfig::getLibrarySlot() const { if(0 == m_librarySlot) { cta::exception::Exception ex; diff --git a/tapeserver/castor/tape/tapeserver/daemon/DriveConfig.hpp b/tapeserver/castor/tape/tapeserver/daemon/DriveConfig.hpp index d34f6e0426130012a3910c668e1aad4f04d72ddc..c85a63e693259a380154f5384a83a6fca0ec48fe 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DriveConfig.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DriveConfig.hpp @@ -23,8 +23,8 @@ #pragma once -#include "tapeserver/castor/mediachanger/LibrarySlot.hpp" -#include "tapeserver/castor/mediachanger/LibrarySlotParser.hpp" +#include "mediachanger/LibrarySlot.hpp" +#include "mediachanger/LibrarySlotParser.hpp" #include <list> #include <string> @@ -113,7 +113,7 @@ public: * @return The library slot in which the tape drive is located, for example: * smc@localhost,0 */ - const mediachanger::LibrarySlot &getLibrarySlot() const; + const cta::mediachanger::LibrarySlot &getLibrarySlot() const; public: @@ -137,7 +137,7 @@ public: * The library slot in which the tape drive is located, for example: * smc@localhost,0 */ - mediachanger::LibrarySlot *m_librarySlot; + cta::mediachanger::LibrarySlot *m_librarySlot; }; // class DriveConfig diff --git a/tapeserver/castor/tape/tapeserver/daemon/DriveConfigMap.hpp b/tapeserver/castor/tape/tapeserver/daemon/DriveConfigMap.hpp index 5abf343c0ae638891c748c509df24cfefbd5fd11..12d11514d0f7d5da58f16356589bd0fe922df4d2 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DriveConfigMap.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DriveConfigMap.hpp @@ -26,7 +26,7 @@ #include "castor/tape/tapeserver/daemon/DriveConfig.hpp" #include "castor/tape/tapeserver/daemon/TpconfigLine.hpp" #include "castor/tape/tapeserver/daemon/TpconfigLines.hpp" -#include "castor/mediachanger/LibrarySlotParser.hpp" +#include "mediachanger/LibrarySlotParser.hpp" #include <map> #include <string> diff --git a/tapeserver/castor/tape/tapeserver/daemon/DriveConfigTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/DriveConfigTest.cpp index 9c531bb9d02355eececc2c48c1ba9205f3ffe919..fc2fc635e2b0e16f99478be747c3af2721dfdbcc 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DriveConfigTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DriveConfigTest.cpp @@ -51,10 +51,10 @@ TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, manual_drive_slot) { ASSERT_EQ("devFilename", config.getDevFilename()); ASSERT_NO_THROW(config.getLibrarySlot()); { - const castor::mediachanger::LibrarySlot &librarySlot = + const cta::mediachanger::LibrarySlot &librarySlot = config.getLibrarySlot(); ASSERT_EQ("manual", librarySlot.str()); - ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, + ASSERT_EQ(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, librarySlot.getLibraryType()); } } @@ -72,10 +72,10 @@ TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, copy_constructor) { ASSERT_EQ("devFilename1", config1.getDevFilename()); ASSERT_NO_THROW(config1.getLibrarySlot()); { - const castor::mediachanger::LibrarySlot &librarySlot1 = + const cta::mediachanger::LibrarySlot &librarySlot1 = config1.getLibrarySlot(); ASSERT_EQ("manual1", librarySlot1.str()); - ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, + ASSERT_EQ(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, librarySlot1.getLibraryType()); } @@ -85,10 +85,10 @@ TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, copy_constructor) { ASSERT_EQ("devFilename1", config2.getDevFilename()); ASSERT_NO_THROW(config2.getLibrarySlot()); { - const castor::mediachanger::LibrarySlot &librarySlot2 = + const cta::mediachanger::LibrarySlot &librarySlot2 = config2.getLibrarySlot(); ASSERT_EQ("manual1", librarySlot2.str()); - ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, + ASSERT_EQ(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, librarySlot2.getLibraryType()); } } @@ -106,10 +106,10 @@ TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, assignment) { ASSERT_EQ("devFilename1", config1.getDevFilename()); ASSERT_NO_THROW(config1.getLibrarySlot()); { - const castor::mediachanger::LibrarySlot &librarySlot1 = + const cta::mediachanger::LibrarySlot &librarySlot1 = config1.getLibrarySlot(); ASSERT_EQ("manual1", librarySlot1.str()); - ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, + ASSERT_EQ(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, librarySlot1.getLibraryType()); } @@ -123,10 +123,10 @@ TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, assignment) { ASSERT_EQ("devFilename2", config2.getDevFilename()); ASSERT_NO_THROW(config2.getLibrarySlot()); { - const castor::mediachanger::LibrarySlot &librarySlot2 = + const cta::mediachanger::LibrarySlot &librarySlot2 = config2.getLibrarySlot(); ASSERT_EQ("manual2", librarySlot2.str()); - ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, + ASSERT_EQ(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, librarySlot2.getLibraryType()); } @@ -137,10 +137,10 @@ TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, assignment) { ASSERT_EQ("devFilename2", config1.getDevFilename()); ASSERT_NO_THROW(config1.getLibrarySlot()); { - const castor::mediachanger::LibrarySlot &librarySlot1 = + const cta::mediachanger::LibrarySlot &librarySlot1 = config2.getLibrarySlot(); ASSERT_EQ("manual2", librarySlot1.str()); - ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, + ASSERT_EQ(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, librarySlot1.getLibraryType()); } @@ -149,10 +149,10 @@ TEST_F(castor_tape_tapeserver_daemon_DriveConfigTest, assignment) { ASSERT_EQ("devFilename2", config2.getDevFilename()); ASSERT_NO_THROW(config2.getLibrarySlot()); { - const castor::mediachanger::LibrarySlot &librarySlot2 = + const cta::mediachanger::LibrarySlot &librarySlot2 = config2.getLibrarySlot(); ASSERT_EQ("manual2", librarySlot2.str()); - ASSERT_EQ(castor::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, + ASSERT_EQ(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL, librarySlot2.getLibraryType()); } } diff --git a/tapeserver/castor/tape/tapeserver/daemon/EmptyDriveProbe.hpp b/tapeserver/castor/tape/tapeserver/daemon/EmptyDriveProbe.hpp index 67792e765b03c092e230ba3fd92c67d65fcaaf04..76a1b597b16633540143e96bec1e5a194341a80d 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/EmptyDriveProbe.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/EmptyDriveProbe.hpp @@ -25,12 +25,12 @@ #include "common/log/LogContext.hpp" #include "common/log/Logger.hpp" -#include "castor/mediachanger/MediaChangerFacade.hpp" #include "castor/tape/tapeserver/daemon/DriveConfig.hpp" #include "castor/tape/tapeserver/drive/DriveInterface.hpp" #include "castor/tape/tapeserver/file/Structures.hpp" #include "castor/tape/tapeserver/SCSI/Device.hpp" #include "castor/tape/tapeserver/system/Wrapper.hpp" +#include "mediachanger/MediaChangerFacade.hpp" #include <memory> diff --git a/tapeserver/castor/tape/tapeserver/daemon/LabelSession.cpp b/tapeserver/castor/tape/tapeserver/daemon/LabelSession.cpp index cd97517a41c1efe9a46db5b80db46a60d9bd94f9..6060a26d88b14ea3a6e2cb101097e3d02df3a519 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/LabelSession.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/LabelSession.cpp @@ -42,7 +42,7 @@ castor::tape::tapeserver::daemon::LabelSession::LabelSession( cta::server::ProcessCap &capUtils, cta::tape::daemon::TapedProxy &tapeserver, - mediachanger::MediaChangerFacade &mc, + cta::mediachanger::MediaChangerFacade &mc, const legacymsg::TapeLabelRqstMsgBody &clientRequest, cta::log::Logger &log, System::virtualWrapper &sysWrapper, @@ -213,7 +213,7 @@ std::unique_ptr<castor::tape::tapeserver::drive::DriveInterface> // mountTape //------------------------------------------------------------------------------ void castor::tape::tapeserver::daemon::LabelSession::mountTape() { - const mediachanger::LibrarySlot &librarySlot = m_driveConfig.getLibrarySlot(); + const cta::mediachanger::LibrarySlot &librarySlot = m_driveConfig.getLibrarySlot(); std::list<cta::log::Param> params; params.push_back(cta::log::Param("uid", m_request.uid)); @@ -227,7 +227,7 @@ void castor::tape::tapeserver::daemon::LabelSession::mountTape() { m_log(cta::log::INFO, "Label session mounting tape", params); m_mc.mountTapeReadWrite(m_request.vid, librarySlot); - if(mediachanger::TAPE_LIBRARY_TYPE_MANUAL == librarySlot.getLibraryType()) { + if(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL == librarySlot.getLibraryType()) { m_log(cta::log::INFO, "Label session did not mounted tape because the media" " changer is manual", params); } else { @@ -358,7 +358,7 @@ void castor::tape::tapeserver::daemon::LabelSession::unloadTape( // We implement the same policy as with the tape sessions: // if the librarySlot parameter is "manual", do nothing. - if(mediachanger::TAPE_LIBRARY_TYPE_MANUAL == + if(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL == m_driveConfig.getLibrarySlot().getLibraryType()) { m_log(cta::log::INFO, "Label session not unloading tape because media changer is" " manual", params); @@ -382,7 +382,7 @@ void castor::tape::tapeserver::daemon::LabelSession::unloadTape( //------------------------------------------------------------------------------ void castor::tape::tapeserver::daemon::LabelSession::dismountTape( const std::string &vid) { - const mediachanger::LibrarySlot &librarySlot = m_driveConfig.getLibrarySlot(); + const cta::mediachanger::LibrarySlot &librarySlot = m_driveConfig.getLibrarySlot(); std::list<cta::log::Param> params; params.push_back(cta::log::Param("uid", m_request.uid)); params.push_back(cta::log::Param("gid", m_request.gid)); @@ -396,7 +396,7 @@ void castor::tape::tapeserver::daemon::LabelSession::dismountTape( try { m_log(cta::log::INFO, "Label session dismounting tape", params); m_mc.dismountTape(vid, librarySlot); - const bool dismountWasManual = mediachanger::TAPE_LIBRARY_TYPE_MANUAL == + const bool dismountWasManual = cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL == librarySlot.getLibraryType(); if(dismountWasManual) { m_log(cta::log::INFO, "Label session did not dismount tape because media" diff --git a/tapeserver/castor/tape/tapeserver/daemon/LabelSession.hpp b/tapeserver/castor/tape/tapeserver/daemon/LabelSession.hpp index aa0718f2d036ea01dec5ab4b7a5b59e803652b45..cb2059ad075996faf342b04076d4cb47d314085b 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/LabelSession.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/LabelSession.hpp @@ -26,8 +26,6 @@ #include "castor/legacymsg/TapeLabelRqstMsgBody.hpp" #include "common/log/LogContext.hpp" #include "common/log/Logger.hpp" -#include "castor/mediachanger/MediaChangerFacade.hpp" -#include "tapeserver/daemon/TapedProxy.hpp" #include "common/processCap/ProcessCap.hpp" #include "castor/tape/tapeserver/daemon/DriveConfig.hpp" #include "castor/tape/tapeserver/daemon/Session.hpp" @@ -37,6 +35,8 @@ #include "castor/tape/tapeserver/system/Wrapper.hpp" #include "castor/tape/tapeserver/daemon/LabelSessionConfig.hpp" #include "castor/tape/tapeserver/daemon/EncryptionControl.hpp" +#include "mediachanger/MediaChangerFacade.hpp" +#include "tapeserver/daemon/TapedProxy.hpp" #include <memory> @@ -75,7 +75,7 @@ public: LabelSession( cta::server::ProcessCap &capUtils, cta::tape::daemon::TapedProxy &tapeserver, - mediachanger::MediaChangerFacade &mc, + cta::mediachanger::MediaChangerFacade &mc, const legacymsg::TapeLabelRqstMsgBody &clientRequest, cta::log::Logger &log, System::virtualWrapper &sysWrapper, @@ -109,7 +109,7 @@ private: /** * The object representing the media changer. */ - mediachanger::MediaChangerFacade &m_mc; + cta::mediachanger::MediaChangerFacade &m_mc; /** * The label request message body diff --git a/tapeserver/castor/tape/tapeserver/daemon/ProcessForker.cpp b/tapeserver/castor/tape/tapeserver/daemon/ProcessForker.cpp index 994ba6683e5a374bdf027b6dc5964ee10b156f0c..40a8dcac0bd73cfdc0e2ac944d8816682b5c5310 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/ProcessForker.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/ProcessForker.cpp @@ -22,10 +22,6 @@ *****************************************************************************/ #include "castor/acs/Constants.hpp" -#include "castor/legacymsg/RmcProxyTcpIp.hpp" -#include "castor/mediachanger/MediaChangerFacade.hpp" -#include "castor/mediachanger/MmcProxyLog.hpp" -#include "castor/messages/AcsProxyZmq.hpp" #include "castor/messages/Constants.hpp" #include "castor/messages/ForkCleaner.pb.h" #include "castor/messages/ForkDataTransfer.pb.h" @@ -44,16 +40,20 @@ #include "castor/tape/tapeserver/daemon/LabelSession.hpp" #include "castor/tape/tapeserver/daemon/ProcessForker.hpp" #include "castor/tape/tapeserver/daemon/ProcessForkerUtils.hpp" -#include "common/SmartArrayPtr.hpp" -#include "common/utils/utils.hpp" #include "catalogue/CatalogueFactory.hpp" #include "common/exception/Exception.hpp" -#include "rdbms/Sqlite.hpp" -#include "rdbms/SqliteConn.hpp" +#include "common/SmartArrayPtr.hpp" +#include "common/utils/utils.hpp" +#include "mediachanger/AcsProxyZmq.hpp" +#include "mediachanger/MediaChangerFacade.hpp" +#include "mediachanger/MmcProxyLog.hpp" +#include "mediachanger/RmcProxyTcpIp.hpp" #include "objectstore/BackendVFS.hpp" #include "objectstore/BackendFactory.hpp" #include "objectstore/BackendPopulator.hpp" #include "objectstore/RootEntry.hpp" +#include "rdbms/Sqlite.hpp" +#include "rdbms/SqliteConn.hpp" #include "remotens/EosNS.hpp" #include "scheduler/OStoreDB/OStoreDB.hpp" #include "scheduler/Scheduler.hpp" @@ -486,18 +486,18 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction messages::SmartZmqContext zmqContext(messages::SmartZmqContext::instantiateZmqContext(sizeOfIOThreadPoolForZMQ, m_log)); - messages::AcsProxyZmq acs(acs::ACS_PORT, zmqContext.get()); + cta::mediachanger::AcsProxyZmq acs(acs::ACS_PORT, zmqContext.get()); - mediachanger::MmcProxyLog mmc(m_log); + cta::mediachanger::MmcProxyLog mmc(m_log); // 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 - legacymsg::RmcProxyTcpIp rmc(m_config.rmcPort, rmcNetTimeout, + cta::mediachanger::RmcProxyTcpIp rmc(m_config.rmcPort, rmcNetTimeout, m_config.rmcMaxRqstAttempts); - mediachanger::MediaChangerFacade mediaChangerFacade(acs, mmc, rmc); + cta::mediachanger::MediaChangerFacade mediaChangerFacade(acs, mmc, rmc); castor::tape::System::realWrapper sWrapper; CleanerSession cleanerSession( @@ -542,18 +542,18 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction messages::SmartZmqContext zmqContext(messages::SmartZmqContext::instantiateZmqContext(sizeOfIOThreadPoolForZMQ, m_log)); - messages::AcsProxyZmq acs(acs::ACS_PORT, zmqContext.get()); + cta::mediachanger::AcsProxyZmq acs(acs::ACS_PORT, zmqContext.get()); - mediachanger::MmcProxyLog mmc(m_log); + cta::mediachanger::MmcProxyLog mmc(m_log); // 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 - legacymsg::RmcProxyTcpIp rmc(m_config.rmcPort, rmcNetTimeout, + cta::mediachanger::RmcProxyTcpIp rmc(m_config.rmcPort, rmcNetTimeout, m_config.rmcMaxRqstAttempts); - mediachanger::MediaChangerFacade mediaChangerFacade(acs, mmc, rmc); + cta::mediachanger::MediaChangerFacade mediaChangerFacade(acs, mmc, rmc); messages::TapeserverProxyZmq tapeserver(m_log, m_config.internalPort, zmqContext.get(), driveConfig.getUnitName()); @@ -822,18 +822,18 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction messages::TapeserverProxyZmq tapeserver(m_log, m_config.internalPort, zmqContext.get(), driveConfig.getUnitName()); - messages::AcsProxyZmq acs(acs::ACS_PORT, zmqContext.get()); + cta::mediachanger::AcsProxyZmq acs(acs::ACS_PORT, zmqContext.get()); - mediachanger::MmcProxyLog mmc(m_log); + cta::mediachanger::MmcProxyLog mmc(m_log); // 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 - legacymsg::RmcProxyTcpIp rmc(m_config.rmcPort, rmcNetTimeout, + cta::mediachanger::RmcProxyTcpIp rmc(m_config.rmcPort, rmcNetTimeout, m_config.rmcMaxRqstAttempts); - mediachanger::MediaChangerFacade mediaChangerFacade(acs, mmc, rmc); + cta::mediachanger::MediaChangerFacade mediaChangerFacade(acs, mmc, rmc); castor::tape::System::realWrapper sWrapper; LabelSession labelsession( diff --git a/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjectorTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjectorTest.cpp index f4f0c5f32ef271bf3236184be2cc9aedefeefc60..a6fd3580130e319d69fef6a82d9f7d288535780d 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjectorTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjectorTest.cpp @@ -21,11 +21,7 @@ * @author Castor Dev team, castor-dev@cern.ch *****************************************************************************/ -#include "castor/legacymsg/RmcProxyDummy.hpp" #include "common/log/StringLogger.hpp" -#include "castor/mediachanger/MediaChangerFacade.hpp" -#include "castor/mediachanger/MmcProxyDummy.hpp" -#include "castor/messages/AcsProxyDummy.hpp" #include "castor/messages/TapeserverProxyDummy.hpp" #include "common/processCap/ProcessCapDummy.hpp" #include "castor/tape/tapeserver/daemon/DiskWriteThreadPool.hpp" @@ -36,6 +32,10 @@ #include "castor/tape/tapeserver/daemon/TaskWatchDog.hpp" #include "castor/tape/tapeserver/drive/FakeDrive.hpp" #include "castor/utils/utils.hpp" +#include "mediachanger/AcsProxyDummy.hpp" +#include "mediachanger/MediaChangerFacade.hpp" +#include "mediachanger/MmcProxyDummy.hpp" +#include "mediachanger/RmcProxyDummy.hpp" #include "scheduler/SchedulerDatabase.hpp" #include "scheduler/testingMocks/MockRetrieveMount.hpp" @@ -104,7 +104,7 @@ namespace unitTests using TapeSingleThreadInterface<TapeReadTask>::m_tasks; FakeSingleTapeReadThread(tapeserver::drive::DriveInterface& drive, - castor::mediachanger::MediaChangerFacade & mc, + cta::mediachanger::MediaChangerFacade & mc, tapeserver::daemon::TapeServerReporter & tsr, const tapeserver::daemon::VolumeInfo& volInfo, cta::server::ProcessCap& cap, @@ -156,10 +156,10 @@ namespace unitTests std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm(new TestingDatabaseRetrieveMount()); MockRecallReportPacker mrrp(&trm,lc); FakeDiskWriteThreadPool diskWrite(mrrp,rwd,lc); - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); castor::messages::TapeserverProxyDummy initialProcess; castor::tape::tapeserver::daemon::VolumeInfo volume; volume.vid="V12345"; @@ -218,10 +218,10 @@ namespace unitTests std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm(new TestingDatabaseRetrieveMount()); MockRecallReportPacker mrrp(&trm,lc); FakeDiskWriteThreadPool diskWrite(mrrp,rwd,lc); - castor::messages::AcsProxyDummy acs; - castor::mediachanger::MmcProxyDummy mmc; - castor::legacymsg::RmcProxyDummy rmc; - castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); + cta::mediachanger::AcsProxyDummy acs; + cta::mediachanger::MmcProxyDummy mmc; + cta::mediachanger::RmcProxyDummy rmc; + cta::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); castor::messages::TapeserverProxyDummy initialProcess; castor::tape::tapeserver::daemon::VolumeInfo volume; volume.vid="V12345"; diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp index 01ccd9fb5e6c6f3f3088e12b03eaf844f36ab1d9..727f5cd13c7f222564824af4897497955040cf7a 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.cpp @@ -27,7 +27,7 @@ //------------------------------------------------------------------------------ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeReadSingleThread( castor::tape::tapeserver::drive::DriveInterface& drive, - mediachanger::MediaChangerFacade& mc, + cta::mediachanger::MediaChangerFacade& mc, TapeServerReporter& initialProcess, const VolumeInfo& volInfo, uint64_t maxFilesRequest, @@ -96,7 +96,7 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean goto done; } // in the special case of a "manual" mode tape, we should skip the unload too. - if (mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType()) { + if (cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType()) { m_this.m_rrp.reportDriveStatus(cta::common::dataStructures::DriveStatus::Unloading); m_this.m_drive.unloadTape(); m_this.m_logContext.log(cta::log::INFO, "TapeReadSingleThread: Tape unloaded"); @@ -113,7 +113,7 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean m_this.m_drive.disableLogicalBlockProtection(); m_this.m_rrp.reportDriveStatus(cta::common::dataStructures::DriveStatus::Up); m_this.m_stats.unmountTime += m_timer.secs(cta::utils::Timer::resetCounter); - m_this.m_logContext.log(cta::log::INFO, mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType() ? + m_this.m_logContext.log(cta::log::INFO, cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType() ? "TapeReadSingleThread : tape unmounted":"TapeReadSingleThread : tape NOT unmounted (manual mode)"); m_this.m_initialProcess.reportTapeUnmountedForRetrieve(); m_this.m_stats.waitReportingTime += m_timer.secs(cta::utils::Timer::resetCounter); diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp index ef59b4fb56517e640acc7bc0a43993004871d359..288f51dd3d10620c5fb8adcb9f21c3d6b48b57a2 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp @@ -58,7 +58,7 @@ public: * Constructor: */ TapeReadSingleThread(castor::tape::tapeserver::drive::DriveInterface & drive, - castor::mediachanger::MediaChangerFacade &mc, + cta::mediachanger::MediaChangerFacade &mc, TapeServerReporter & initialProcess, const VolumeInfo& volInfo, uint64_t maxFilesRequest, diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp index 27ad03adc7a18a6359a864f10a9a77d8ed8054aa..9003d0ab980a072d0a3424439ffa7c7eb3cb632f 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp @@ -28,7 +28,7 @@ #pragma once -#include "tapeserver/castor/mediachanger/MediaChangerFacade.hpp" +#include "mediachanger/MediaChangerFacade.hpp" #include "common/log/LogContext.hpp" #include "common/threading/BlockingQueue.hpp" #include "common/processCap/ProcessCap.hpp" @@ -71,7 +71,7 @@ protected: castor::tape::tapeserver::drive::DriveInterface & m_drive; /** Reference to the mount interface */ - mediachanger::MediaChangerFacade & m_mc; + cta::mediachanger::MediaChangerFacade & m_mc; /** Reference to the Global reporting interface */ TapeServerReporter & m_initialProcess; @@ -122,7 +122,7 @@ protected: m_mc.mountTapeReadOnly(m_volInfo.vid, m_drive.config.getLibrarySlot()); const std::string modeAsString = "R"; scoped.add("MCMountTime",timer.secs()).add("mode",modeAsString); - if(mediachanger::TAPE_LIBRARY_TYPE_MANUAL != + if(cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_drive.config.getLibrarySlot().getLibraryType()) { m_logContext.log(cta::log::INFO, "Tape mounted for read-only access"); } @@ -298,7 +298,7 @@ public: * @param lc lc The log context, later on copied */ TapeSingleThreadInterface(castor::tape::tapeserver::drive::DriveInterface & drive, - mediachanger::MediaChangerFacade &mc, + cta::mediachanger::MediaChangerFacade &mc, TapeServerReporter & tsr, const VolumeInfo& volInfo, cta::server::ProcessCap &capUtils,cta::log::LogContext & lc, diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp index 683a5e341b33c75e16f97f4e263d7e7f03b1eda0..9ba1ea8366b490204bf3c951e3cc11bcf37db21e 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp @@ -29,7 +29,7 @@ //------------------------------------------------------------------------------ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeWriteSingleThread( castor::tape::tapeserver::drive::DriveInterface & drive, - castor::mediachanger::MediaChangerFacade & mc, + cta::mediachanger::MediaChangerFacade & mc, TapeServerReporter & tsr, MigrationWatchDog & mwd, const VolumeInfo& volInfo, @@ -87,7 +87,7 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeCleaning::~TapeClea goto done; } // in the special case of a "manual" mode tape, we should skip the unload too. - if (mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType()) { + if (cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType()) { m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Unloading); m_this.m_drive.unloadTape(); m_this.m_logContext.log(cta::log::INFO, "TapeWriteSingleThread: Tape unloaded"); @@ -104,7 +104,7 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeCleaning::~TapeClea m_this.m_drive.disableLogicalBlockProtection(); m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Up); m_this.m_stats.unmountTime += m_timer.secs(cta::utils::Timer::resetCounter); - m_this.m_logContext.log(cta::log::INFO, mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType() ? + m_this.m_logContext.log(cta::log::INFO, cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.getLibrarySlot().getLibraryType() ? "TapeWriteSingleThread : tape unmounted":"TapeWriteSingleThread : tape NOT unmounted (manual mode)"); m_this.m_initialProcess.reportState(cta::tape::session::SessionState::Shutdown, cta::tape::session::SessionType::Archive); diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp index 96101af076297be4d6a534a38e3756dfb7f2b266..9529b6903cdece022254d267d11c765de335e4a3 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp @@ -61,7 +61,7 @@ public: */ TapeWriteSingleThread( castor::tape::tapeserver::drive::DriveInterface & drive, - mediachanger::MediaChangerFacade &mc, + cta::mediachanger::MediaChangerFacade &mc, TapeServerReporter & tsr, MigrationWatchDog & mwd, const VolumeInfo& volInfo, diff --git a/tapeserver/h/Castor_limits.h b/tapeserver/h/Castor_limits.h index be7c898a4fd88278265f117e4ece4d2f4715f932..c2c1f7c5e613614911a639c533a801f05012d258 100644 --- a/tapeserver/h/Castor_limits.h +++ b/tapeserver/h/Castor_limits.h @@ -57,7 +57,6 @@ #define CA_MAXTAPELIBLEN 8 /* maximum length for a tape library name */ #define CA_MAXUNMLEN 8 /* maximum length for a drive name */ #define CA_MAXUSRNAMELEN 14 /* maximum length for a login name */ -#define CA_MAXVIDLEN 6 /* maximum length for a VID */ #define CA_MAXVSNLEN 6 /* maximum length for a VSN */ #define CA_MAXCKSUMNAMELEN 15 /* maximum length for a checksum algorithm name */ #define CA_MAXCKSUMLEN 32 /* maximum length for a checksum value in an asci form */