Commit 27763e3b authored by Steven Murray's avatar Steven Murray
Browse files

Added mediachanger::AcsLibrarySlot

parent 01af991b
/******************************************************************************
*
* 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 <sstream>
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::mediachanger::AcsLibrarySlot::AcsLibrarySlot() throw():
m_acs(0),
m_lsm(0),
m_panel(0),
m_drive(0) {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::mediachanger::AcsLibrarySlot::AcsLibrarySlot(const std::string &str) {
// TO BE DONE
m_acs = 1;
m_lsm = 2;
m_panel = 3;
m_drive = 4;
}
//------------------------------------------------------------------------------
// 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;
}
//------------------------------------------------------------------------------
// str
//------------------------------------------------------------------------------
std::string castor::mediachanger::AcsLibrarySlot::str() const {
std::ostringstream oss;
oss << "acs= " << m_acs << " lsm=" << m_lsm << " panel=" << m_panel <<
" drive=" << m_drive;
return oss.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 <stdint.h>
#include <string>
namespace castor {
namespace mediachanger {
/**
* Class reprsenting a slot in an ACS tape-library.
*/
class AcsLibrarySlot {
public:
/**
* Default constructor that sets all integer members to 0.
*/
AcsLibrarySlot() throw();
/**
* Constructor.
*
* This method throws a castor::exceptiuon::Exception if the specified stringi
* reprsentation is invalid.
*
* @param The string representation of a slot in an ACS tape-library.
*/
AcsLibrarySlot(const std::string &str);
/**
* 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 ();
/**
* Returns the representation of the slot.
*/
std::string str() const;
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;
}; // class AcsProxy
} // namespace mediachanger
} // namespace castor
......@@ -20,6 +20,7 @@
cmake_minimum_required (VERSION 2.6)
set (MEDIA_CHANGER_CLIENT_LIB_SRC_FILES
AcsLibrarySlot.cpp
MediaChangerFacade.cpp
MediaChangerProxy.cpp
MediaChangerProxyDummy.cpp
......
......@@ -27,7 +27,7 @@
// constructor
//------------------------------------------------------------------------------
castor::mediachanger::MediaChangerFacade::MediaChangerFacade(
MediaChangerProxy &acs,
messages::AcsProxy &acs,
MediaChangerProxy &mmc,
MediaChangerProxy &rmc) throw():
m_acs(acs),
......@@ -46,7 +46,7 @@ void castor::mediachanger::MediaChangerFacade::mountTapeReadOnly(
// Dispatch the appropriate helper method depending on library slot type
switch(libraryType) {
case TAPE_LIBRARY_TYPE_ACS:
return m_acs.mountTapeReadOnly(vid, librarySlot);
return m_acs.mountTapeReadOnly(vid, librarySlot.str());
case TAPE_LIBRARY_TYPE_MANUAL:
return m_mmc.mountTapeReadOnly(vid, librarySlot);
case TAPE_LIBRARY_TYPE_SCSI:
......@@ -78,7 +78,7 @@ void castor::mediachanger::MediaChangerFacade::mountTapeReadWrite(
// Dispatch the appropriate helper method depending on library slot type
switch(libraryType) {
case TAPE_LIBRARY_TYPE_ACS:
return m_acs.mountTapeReadWrite(vid, librarySlot);
return m_acs.mountTapeReadWrite(vid, librarySlot.str());
case TAPE_LIBRARY_TYPE_MANUAL:
return m_mmc.mountTapeReadWrite(vid, librarySlot);
case TAPE_LIBRARY_TYPE_SCSI:
......@@ -110,7 +110,7 @@ void castor::mediachanger::MediaChangerFacade::dismountTape(
// Dispatch the appropriate helper method depending on library slot type
switch(libraryType) {
case TAPE_LIBRARY_TYPE_ACS:
return m_acs.dismountTape(vid, librarySlot);
return m_acs.dismountTape(vid, librarySlot.str());
case TAPE_LIBRARY_TYPE_MANUAL:
return m_mmc.dismountTape(vid, librarySlot);
case TAPE_LIBRARY_TYPE_SCSI:
......
......@@ -22,6 +22,7 @@
#pragma once
#include "castor/mediachanger/MediaChangerProxy.hpp"
#include "castor/messages/AcsProxy.hpp"
#include <unistd.h>
#include <sys/types.h>
......@@ -46,7 +47,7 @@ public:
* @param rmc Proxy object representing the rmcd daemon.
*/
MediaChangerFacade(
MediaChangerProxy &acs,
messages::AcsProxy &acs,
MediaChangerProxy &mmc,
MediaChangerProxy &rmc) throw();
......@@ -85,7 +86,7 @@ private:
/**
* Proxy object representing the CASTOR ACS daemon.
*/
MediaChangerProxy &m_acs;
messages::AcsProxy &m_acs;
/**
* Proxy object representing the manual media-changer.
......
......@@ -32,6 +32,7 @@
namespace unitTests {
/*
class castor_mediachanger_MediaChangerFacadeTest : public ::testing::Test {
protected:
......@@ -269,4 +270,6 @@ TEST_F(castor_mediachanger_MediaChangerFacadeTest, dismountTapeRmc) {
ASSERT_EQ(1, m_rmc.nbTimesDismountTapeCalled);
}
*/
} // namespace unitTests
......@@ -21,6 +21,8 @@
#pragma once
#include "castor/mediachanger/AcsLibrarySlot.hpp"
#include <stdint.h>
#include <string>
......@@ -40,40 +42,34 @@ public:
virtual ~AcsProxy() = 0;
/**
* Request the CASTOR ACS daemon to mount the specifed tape for recall.
* 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 tape to be mounted.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.
* @param panel The panel identifier.
* @param drive The drive identifier.
* @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 mountTapeForRecall(const std::string &vid, const uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive) = 0;
virtual void mountTapeReadOnly(const std::string &vid,
const mediachanger::AcsLibrarySlot &librarySlot) = 0;
/**
* Request the CASTOR ACS daemon to mount the specifed tape for migration.
* 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 tape to be mounted.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.
* @param panel The panel identifier.
* @param drive The drive identifier.
* @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 mountTapeForMigration(const std::string &vid, const uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive) = 0;
virtual void mountTapeReadWrite(const std::string &vid,
const mediachanger::AcsLibrarySlot &librarySlot) = 0;
/**
* Request the CASTOR ACS daemon to dismount the specifed tape.
* Request the CASTOR ACS daemon to dismount the specifed tape from the tape
* drive in the specified library slot.
*
* @param vid The tape to be dismounted.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.
* @param panel The panel identifier.
* @param drive The drive identifier.
* @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 uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive) = 0;
virtual void dismountTape(const std::string &vid,
const mediachanger::AcsLibrarySlot &librarySlot) = 0;
}; // class AcsProxy
......
......@@ -22,25 +22,22 @@
#include "castor/messages/AcsProxyDummy.hpp"
//------------------------------------------------------------------------------
// mountTapeForRecall
// mountTapeReadOnly
//------------------------------------------------------------------------------
void castor::messages::AcsProxyDummy::mountTapeForRecall(const std::string &vid,
const uint32_t acs, const uint32_t lsm, const uint32_t panel,
const uint32_t drive) {
void castor::messages::AcsProxyDummy::mountTapeReadOnly(const std::string &vid,
const mediachanger::AcsLibrarySlot &librarySlot) {
}
//------------------------------------------------------------------------------
// mountTapeForMigration
//------------------------------------------------------------------------------
void castor::messages::AcsProxyDummy::mountTapeForMigration(const std::string &vid,
const uint32_t acs, const uint32_t lsm, const uint32_t panel,
const uint32_t drive) {
void castor::messages::AcsProxyDummy::mountTapeReadWrite(const std::string &vid,
const mediachanger::AcsLibrarySlot &librarySlot) {
}
//------------------------------------------------------------------------------
// dismountTape
//------------------------------------------------------------------------------
void castor::messages::AcsProxyDummy::dismountTape(const std::string &vid,
const uint32_t acs, const uint32_t lsm, const uint32_t panel,
const uint32_t drive) {
}
\ No newline at end of file
const mediachanger::AcsLibrarySlot &librarySlot) {
}
......@@ -33,41 +33,34 @@ class AcsProxyDummy: public AcsProxy {
public:
/**
* Request the CASTOR ACS daemon to mount the specifed tape for recall.
* 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 tape to be mounted.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.
* @param panel The panel identifier.
* @param drive The drive identifier.
* @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 mountTapeForRecall(const std::string &vid, const uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive);
/**
* Request the CASTOR ACS daemon to mount the specifed tape for migration.
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 tape to be mounted.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.
* @param panel The panel identifier.
* @param drive The drive identifier.
* @param vid The volume identifier of the tape to be mounted.
* @param librarySlot The slot in the library that contains the tape drive.
*/
void mountTapeForMigration(const std::string &vid, const uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive);
/**
* Request the CASTOR ACS daemon to dismount the specifed tape.
*
* @param vid The tape to be mounted.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.
* @param panel The panel identifier.
* @param drive The drive identifier.
*/
void dismountTape(const std::string &vid, const uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive);
void dismountTape(const std::string &vid,
const mediachanger::AcsLibrarySlot &librarySlot);
}; // class AcsProxyDummy
......
......@@ -37,14 +37,12 @@ castor::messages::AcsProxyZmq::AcsProxyZmq(log::Logger &log,
}
//------------------------------------------------------------------------------
// mountTapeForRecall
// mountTapeReadOnly
//------------------------------------------------------------------------------
void castor::messages::AcsProxyZmq::mountTapeForRecall(const std::string &vid,
const uint32_t acs, const uint32_t lsm, const uint32_t panel,
const uint32_t drive) {
void castor::messages::AcsProxyZmq::mountTapeReadOnly(const std::string &vid,
const mediachanger::AcsLibrarySlot &librarySlot) {
try {
const Frame rqst = createAcsMountTapeForRecallFrame(vid, acs, lsm, panel,
drive);
const Frame rqst = createAcsMountTapeForRecallFrame(vid, librarySlot);
sendFrame(m_serverSocket, rqst);
ReturnValue reply;
......@@ -60,8 +58,7 @@ void castor::messages::AcsProxyZmq::mountTapeForRecall(const std::string &vid,
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to request CASTOR ACS daemon to mount tape for recall: " <<
"vid=" << vid << " acs=" << acs << " lsm=" << lsm << " panel=" << panel <<
" drive=" << drive << ": " << ne.getMessage().str();
librarySlot.str() << ": " << ne.getMessage().str();
throw ex;
}
}
......@@ -70,8 +67,9 @@ void castor::messages::AcsProxyZmq::mountTapeForRecall(const std::string &vid,
// createAcsMountTapeForRecallFrame
//------------------------------------------------------------------------------
castor::messages::Frame castor::messages::AcsProxyZmq::
createAcsMountTapeForRecallFrame(const std::string &vid, const uint32_t acs,
const uint32_t lsm, const uint32_t panel, const uint32_t drive) {
createAcsMountTapeForRecallFrame(const std::string &vid,
const mediachanger::AcsLibrarySlot &librarySlot) {
/*
try {
Frame frame;
......@@ -88,23 +86,25 @@ castor::messages::Frame castor::messages::AcsProxyZmq::
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to create AcsMountTapeForRecall frame: " <<
ne.getMessage().str();
throw ex;
}
*/
return Frame();
}
//------------------------------------------------------------------------------
// mountTapeForMigration
// mountTapeReadWrite
//------------------------------------------------------------------------------
void castor::messages::AcsProxyZmq::mountTapeForMigration(const std::string &vid,
const uint32_t acs, const uint32_t lsm, const uint32_t panel,
const uint32_t drive) {
void castor::messages::AcsProxyZmq::mountTapeReadWrite(const std::string &vid,
const mediachanger::AcsLibrarySlot &librarySlot) {
try {
const Frame rqst = createAcsMountTapeForMigrationFrame(vid, acs, lsm, panel,
drive);
const Frame rqst = createAcsMountTapeForMigrationFrame(vid, librarySlot);
sendFrame(m_serverSocket, rqst);
ReturnValue reply;
......@@ -120,8 +120,7 @@ void castor::messages::AcsProxyZmq::mountTapeForMigration(const std::string &vid
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to request CASTOR ACS daemon to mount tape for migration: " <<
"vid=" << vid << " acs=" << acs << " lsm=" << lsm << " panel=" << panel <<
" drive=" << drive << ": " << ne.getMessage().str();
librarySlot.str() << ": " << ne.getMessage().str();
throw ex;
}
}
......@@ -131,8 +130,8 @@ void castor::messages::AcsProxyZmq::mountTapeForMigration(const std::string &vid
//------------------------------------------------------------------------------
castor::messages::Frame castor::messages::AcsProxyZmq::
createAcsMountTapeForMigrationFrame(const std::string &vid,
const uint32_t acs,const uint32_t lsm, const uint32_t panel,
const uint32_t drive) {
const mediachanger::AcsLibrarySlot &librarySlot) {
/*
try {
Frame frame;
......@@ -149,22 +148,25 @@ castor::messages::Frame castor::messages::AcsProxyZmq::
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to create AcsMountTapeForMigration frame: " <<
ne.getMessage().str();
throw ex;
}
*/
return Frame();
}
//------------------------------------------------------------------------------
// dismountTape
//------------------------------------------------------------------------------
void castor::messages::AcsProxyZmq::dismountTape(const std::string &vid,
const uint32_t acs, const uint32_t lsm, const uint32_t panel,
const uint32_t drive) {
const mediachanger::AcsLibrarySlot &librarySlot) {
try {
const Frame rqst = createAcsDismountTapeFrame(vid, acs, lsm, panel,
drive);
const Frame rqst = createAcsDismountTapeFrame(vid, librarySlot);
sendFrame(m_serverSocket, rqst);
ReturnValue reply;
......@@ -180,8 +182,7 @@ void castor::messages::AcsProxyZmq::dismountTape(const std::string &vid,
castor::exception::Exception ex;
ex.getMessage() <<
"Failed to request CASTOR ACS daemon to dismount tape: " <<
"vid=" << vid << " acs=" << acs << " lsm=" << lsm << " panel=" << panel <<
" drive=" << drive << ": " << ne.getMessage().str();
librarySlot.str() << ": " << ne.getMessage().str();
throw ex;
}
}
......@@ -191,8 +192,8 @@ void castor::messages::AcsProxyZmq::dismountTape(const std::string &vid,
//------------------------------------------------------------------------------
castor::messages::Frame castor::messages::AcsProxyZmq::
createAcsDismountTapeFrame(const std::string &vid,
const uint32_t acs,const uint32_t lsm, const uint32_t panel,
const uint32_t drive) {
const mediachanger::AcsLibrarySlot &librarySlot) {
/*
try {
Frame frame;
......@@ -209,10 +210,14 @@ castor::messages::Frame castor::messages::AcsProxyZmq::
frame.serializeProtocolBufferIntoBody(body);
return frame;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() << "Failed to create AcsDismountTape frame: " <<
ne.getMessage().str();
throw ex;
}
*/
return Frame();
}
......@@ -47,40 +47,34 @@ public:
void *const zmqContext) throw();
/**
* Request the CASTOR ACS daemon to mount the specifed tape for recall.
* 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 tape to be mounted.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.