Commit 245741b4 authored by Steven Murray's avatar Steven Murray
Browse files

tapeserverd now uses mediachagner::MediaChangerFacade

parent 34ef3e7e
......@@ -42,6 +42,7 @@ set (CASTOR_LEGACYMSG_LIB_SRC_FILES
RmcMarshal.cpp
RmcMountMsgBody.cpp
RmcProxy.cpp
RmcProxyDummy.cpp
RmcProxyFactory.cpp
RmcProxyTcpIp.cpp
RmcProxyTcpIpFactory.cpp
......
......@@ -22,7 +22,7 @@
#pragma once
#include "castor/exception/Exception.hpp"
#include "castor/mediachanger/MediaChangerProxy.hpp"
#include "castor/mediachanger/ScsiLibrarySlot.hpp"
#include <string>
......@@ -30,9 +30,10 @@ namespace castor {
namespace legacymsg {
/**
* Proxy class representing the remote media-changer daemon.
* Abstract class defining the interface to a proxy object representing the
* SCSI media-changer daemon (rmcd).
*/
class RmcProxy: public mediachanger::MediaChangerProxy {
class RmcProxy {
public:
/**
......@@ -40,16 +41,6 @@ public:
*/
virtual ~RmcProxy() throw() = 0;
/**
* Requests the media changer to mount of the specified tape for read-only
* 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 mountTapeReadOnly(const std::string &vid,
const mediachanger::ConfigLibrarySlot &librarySlot) = 0;
/**
* Requests the media changer to mount of the specified tape for read/write
* access into the drive in the specified library slot.
......@@ -58,7 +49,7 @@ public:
* @param librarySlot The library slot containing the tape drive.
*/
virtual void mountTapeReadWrite(const std::string &vid,
const mediachanger::ConfigLibrarySlot &librarySlot) = 0;
const mediachanger::ScsiLibrarySlot &librarySlot) = 0;
/**
* Requests the media changer to dismount of the specified tape from the
......@@ -68,7 +59,7 @@ public:
* @param librarySlot The library slot containing the tape drive.
*/
virtual void dismountTape(const std::string &vid,
const mediachanger::ConfigLibrarySlot &librarySlot) = 0;
const mediachanger::ScsiLibrarySlot &librarySlot) = 0;
}; // class RmcProxy
......
/******************************************************************************
*
* 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"
//------------------------------------------------------------------------------
// 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) {
}
/******************************************************************************
*
* 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 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);
}; // class RmcProxyDummy
} // namespace legacymsg
} // namespace castor
......@@ -20,7 +20,6 @@
*****************************************************************************/
#include "castor/io/io.hpp"
#include "castor/mediachanger/ScsiLibrarySlot.hpp"
#include "castor/legacymsg/CommonMarshal.hpp"
#include "castor/legacymsg/RmcMarshal.hpp"
#include "castor/legacymsg/RmcProxyTcpIp.hpp"
......@@ -45,70 +44,11 @@ castor::legacymsg::RmcProxyTcpIp::RmcProxyTcpIp(log::Logger &log,
castor::legacymsg::RmcProxyTcpIp::~RmcProxyTcpIp() throw() {
}
//------------------------------------------------------------------------------
// mountTapeReadOnly
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::mountTapeReadOnly(
const std::string &vid, const mediachanger::ConfigLibrarySlot &librarySlot) {
// SCSI does not support read-only mounts
mountTapeReadWrite(vid, librarySlot);
}
//------------------------------------------------------------------------------
// mountTapeReadWrite
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::mountTapeReadWrite(
const std::string &vid, const mediachanger::ConfigLibrarySlot &librarySlot) {
try {
// Dispatch the appropriate helper method depending on library slot type
switch(librarySlot.getLibraryType()) {
case mediachanger::TAPE_LIBRARY_TYPE_ACS:
mountTapeAcs(vid, librarySlot.str());
break;
case mediachanger::TAPE_LIBRARY_TYPE_MANUAL:
mountTapeManual(vid);
break;
case mediachanger::TAPE_LIBRARY_TYPE_SCSI:
mountTapeScsi(vid, librarySlot.str());
break;
default:
{
castor::exception::Exception ex;
ex.getMessage() << "Unexpected library type"
": vid=" << vid << " librarySlot=" << librarySlot.str();
throw ex;
}
}
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to mount tape in SCSI library for read/write access:" <<
ne.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// mountTapeAcs
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::mountTapeAcs(const std::string &vid,
const std::string &librarySlot) {
}
//------------------------------------------------------------------------------
// mountTapeManual
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::mountTapeManual(const std::string &vid) {
}
//------------------------------------------------------------------------------
// mountTapeScsi
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::mountTapeScsi(const std::string &vid,
const std::string &librarySlot) {
std::ostringstream task;
task << "mount tape " << vid << " in " << librarySlot;
const std::string &vid, const mediachanger::ScsiLibrarySlot &librarySlot) {
try {
const mediachanger::ScsiLibrarySlot parsedSlot(librarySlot);
......@@ -156,7 +96,9 @@ void castor::legacymsg::RmcProxyTcpIp::mountTapeScsi(const std::string &vid,
}
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to " << task.str() << ": " <<
ex.getMessage() <<
"Failed to mount tape in SCSI tape-library for read/write access"
": vid=" << vid << " librarySlot=" << librarySlot.str() << ": " <<
ne.getMessage().str();
throw ex;
}
......@@ -166,50 +108,7 @@ void castor::legacymsg::RmcProxyTcpIp::mountTapeScsi(const std::string &vid,
// dismountTape
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::dismountTape(const std::string &vid,
const mediachanger::ConfigLibrarySlot &librarySlot) {
// Dispatch the appropriate helper method depending on library slot type
switch(librarySlot.getLibraryType()) {
case mediachanger::TAPE_LIBRARY_TYPE_ACS:
unmountTapeAcs(vid, librarySlot.str());
break;
case mediachanger::TAPE_LIBRARY_TYPE_MANUAL:
unmountTapeManual(vid);
break;
case mediachanger::TAPE_LIBRARY_TYPE_SCSI:
unmountTapeScsi(vid, librarySlot.str());
break;
default:
{
castor::exception::Exception ex;
ex.getMessage() << "Failed to unmount tape: Unexpected library slot type"
": vid=" << vid << " librarySlot=" << librarySlot.str();
throw ex;
}
}
}
//------------------------------------------------------------------------------
// unmountTapeAcs
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::unmountTapeAcs(const std::string &vid,
const std::string &librarySlot) {
}
//------------------------------------------------------------------------------
// unmountTapeManual
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::unmountTapeManual(
const std::string &vid) {
}
//------------------------------------------------------------------------------
// unmountTapeScsi
//------------------------------------------------------------------------------
void castor::legacymsg::RmcProxyTcpIp::unmountTapeScsi(const std::string &vid,
const std::string &librarySlot) {
std::ostringstream task;
task << "unmount tape " << vid << " from " << librarySlot;
const mediachanger::ScsiLibrarySlot &librarySlot) {
try {
const mediachanger::ScsiLibrarySlot parsedSlot(librarySlot);
......@@ -258,7 +157,9 @@ void castor::legacymsg::RmcProxyTcpIp::unmountTapeScsi(const std::string &vid,
}
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to " << task.str() << ": " <<
ex.getMessage() <<
"Failed to dismount tape in SCSI tape-library"
": vid=" << vid << " librarySlot=" << librarySlot.str() << ": " <<
ne.getMessage().str();
throw ex;
}
......
......@@ -55,16 +55,6 @@ public:
*/
~RmcProxyTcpIp() throw();
/**
* Requests the media changer to mount of the specified tape for read-only
* 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 mountTapeReadOnly(const std::string &vid,
const mediachanger::ConfigLibrarySlot &librarySlot);
/**
* Requests the media changer to mount of the specified tape for read/write
* access into the drive in the specified library slot.
......@@ -73,7 +63,7 @@ public:
* @param librarySlot The library slot containing the tape drive.
*/
void mountTapeReadWrite(const std::string &vid,
const mediachanger::ConfigLibrarySlot &librarySlot);
const mediachanger::ScsiLibrarySlot &librarySlot);
/**
* Requests the media changer to dismount of the specified tape from the
......@@ -83,7 +73,7 @@ public:
* @param librarySlot The library slot containing the tape drive.
*/
void dismountTape(const std::string &vid,
const mediachanger::ConfigLibrarySlot &librarySlot);
const mediachanger::ScsiLibrarySlot &librarySlot);
protected:
......@@ -108,60 +98,6 @@ protected:
*/
const int m_netTimeout;
/**
* Asks the remote media-changer daemon to mount the specified tape into the
* tape drive located in the specified ACS library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in the following form:
* "acsACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER".
*/
void mountTapeAcs(const std::string &vid, const std::string &librarySlot) ;
/**
* Logs a request to the tape-operator to manually mount the specified tape.
*
* @param vid The volume identifier of the tape.
*/
void mountTapeManual(const std::string &vid) ;
/**
* Asks the remote media-changer daemon to mount the specified tape into the
* drive located in the specified SCSI library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in the following form:
* "smc@rmc_host,drive_ordinal".
*/
void mountTapeScsi(const std::string &vid, const std::string &librarySlot) ;
/**
* Asks the remote media-changer daemon to unmount the specified tape from the
* drive located in the specified an ACS library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in the following form:
* "acsACS_NUMBER,LSM_NUMBER,PANEL_NUMBER,TRANSPORT_NUMBER".
*/
void unmountTapeAcs(const std::string &vid, const std::string &librarySlot) ;
/**
* Logs a request to the tape-operator to manually unmount the specified tape.
*
* @param vid The volume identifier of the tape.
*/
void unmountTapeManual(const std::string &vid) ;
/**
* Asks the remote media-changer daemon to unmount the specified tape from the
* drive located in the specified SCSI compatible library slot.
*
* @param vid The volume identifier of the tape.
* @param librarySlot The library slot in the following form:
* "smc@rmc_host,drive_ordinal".
*/
void unmountTapeScsi(const std::string &vid, const std::string &librarySlot) ;
/**
* Connects to the rmcd daemon.
*
......@@ -200,4 +136,3 @@ protected:
} // namespace legacymsg
} // namespace castor
......@@ -22,9 +22,10 @@ cmake_minimum_required (VERSION 2.6)
set (MEDIA_CHANGER_CLIENT_LIB_SRC_FILES
AcsLibrarySlot.cpp
ConfigLibrarySlot.cpp
ManualLibrarySlot.cpp
MediaChangerFacade.cpp
MediaChangerProxy.cpp
MediaChangerProxyDummy.cpp
MmcProxy.cpp
MmcProxyLog.cpp
ScsiLibrarySlot.cpp
TapeLibraryType.cpp)
add_library(castormediachangerclient
......
/******************************************************************************
*
* 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/ManualLibrarySlot.hpp"
#include "castor/utils/utils.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::mediachanger::ManualLibrarySlot::ManualLibrarySlot()
throw() {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::mediachanger::ManualLibrarySlot::ManualLibrarySlot(
const std::string &str): m_str(str) {
if(str.find("manual@")) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to construct ManualLibrarySlot"
": Library slot must start with manual: str=" << str;
throw ex;
}
}
//------------------------------------------------------------------------------
// str
//------------------------------------------------------------------------------
const std::string &castor::mediachanger::ManualLibrarySlot::str() const throw() {
return m_str;
}
/******************************************************************************
*
* 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 representing a slot in a manually operated tape library.
*/
class ManualLibrarySlot {
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);
/**
* Returns the string representation of the library slot.
*/
const std::string &str() const throw();
private:
/**
* The string representation of the library slot.
*/
std::string m_str;
}; // class ManualLibrarySlot
} // namespace mediachanger
} // namespace castor
......@@ -28,8 +28,8 @@
//------------------------------------------------------------------------------
castor::mediachanger::MediaChangerFacade::MediaChangerFacade(
messages::AcsProxy &acs,
MediaChangerProxy &mmc,
MediaChangerProxy &rmc) throw():
MmcProxy &mmc,
legacymsg::RmcProxy &rmc) throw():
m_acs(acs),
m_mmc(mmc),
m_rmc(rmc) {
......@@ -48,9 +48,10 @@ void castor::mediachanger::MediaChangerFacade::mountTapeReadOnly(
case TAPE_LIBRARY_TYPE_ACS:
return m_acs.mountTapeReadOnly(vid, librarySlot.str());
case TAPE_LIBRARY_TYPE_MANUAL:
return m_mmc.mountTapeReadOnly(vid, librarySlot);
return m_mmc.mountTapeReadOnly(vid, librarySlot.str());
case TAPE_LIBRARY_TYPE_SCSI:
return m_rmc.mountTapeReadOnly(vid, librarySlot);
// SCSI media-changers to not support read-only mounts
return m_rmc.mountTapeReadWrite(vid, librarySlot.str());
default:
{
// Should never get here
......@@ -80,9 +81,9 @@ void castor::mediachanger::MediaChangerFacade::mountTapeReadWrite(
case TAPE_LIBRARY_TYPE_ACS:
return m_acs.mountTapeReadWrite(vid, librarySlot.str());
case TAPE_LIBRARY_TYPE_MANUAL:
return m_mmc.mountTapeReadWrite(vid, librarySlot);
return m_mmc.mountTapeReadWrite(vid, librarySlot.str());
case TAPE_LIBRARY_TYPE_SCSI:
return m_rmc.mountTapeReadWrite(vid, librarySlot);
return m_rmc.mountTapeReadWrite(vid, librarySlot.str());
default:
{
// Should never get here
......@@ -112,9 +113,9 @@ void castor::mediachanger::MediaChangerFacade::dismountTape(
case TAPE_LIBRARY_TYPE_ACS:
return m_acs.dismountTape(vid, librarySlot.str());
case TAPE_LIBRARY_TYPE_MANUAL:
return m_mmc.dismountTape(vid, librarySlot);
return m_mmc.dismountTape(vid, librarySlot.str());
case TAPE_LIBRARY_TYPE_SCSI:
return m_rmc.dismountTape(vid, librarySlot);
return m_rmc.dismountTape(vid, librarySlot.str());
default:
{
// Should never get here
......
......@@ -21,7 +21,9 @@
#pragma once
#include "castor/mediachanger/MediaChangerProxy.hpp"
#include "castor/legacymsg/RmcProxy.hpp"
#include "castor/mediachanger/ConfigLibrarySlot.hpp"
#include "castor/mediachanger/MmcProxy.hpp"
#include "castor/messages/AcsProxy.hpp"
#include <unistd.h>
......@@ -36,7 +38,7 @@ namespace mediachanger {
* 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 MediaChangerProxy {
class MediaChangerFacade {
public:
/**
......@@ -46,10 +48,8 @@ public:
* @param mmc Proxy object representing the manual media-changer.
* @param rmc Proxy object representing the rmcd daemon.