Commit 1aa3751e authored by Steven Murray's avatar Steven Murray Committed by Steven Murray
Browse files

Added the top directory named mediachanger

parent a11009d8
// 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 cta.mediachanger;
message AcsDismountTape {
required string vid = 1;
required uint32 acs = 2;
required uint32 lsm = 3;
required uint32 panel = 4;
required uint32 drive = 5;
}
// 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 cta.mediachanger;
message AcsForceDismountTape {
required string vid = 1;
required uint32 acs = 2;
required uint32 lsm = 3;
required uint32 panel = 4;
required uint32 drive = 5;
}
/******************************************************************************
*
* 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 "mediachanger/AcsLibrarySlot.hpp"
#include <sstream>
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::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 cta::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
//------------------------------------------------------------------------------
cta::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
//------------------------------------------------------------------------------
cta::mediachanger::AcsLibrarySlot::~AcsLibrarySlot() throw() {
}
//------------------------------------------------------------------------------
// clone
//------------------------------------------------------------------------------
cta::mediachanger::LibrarySlot *cta::mediachanger::AcsLibrarySlot::
clone() {
return new AcsLibrarySlot(*this);
}
//------------------------------------------------------------------------------
// getAcs
//------------------------------------------------------------------------------
uint32_t cta::mediachanger::AcsLibrarySlot::getAcs() const throw () {
return m_acs;
}
//------------------------------------------------------------------------------
// getLsm
//------------------------------------------------------------------------------
uint32_t cta::mediachanger::AcsLibrarySlot::getLsm() const throw () {
return m_lsm;
}
//------------------------------------------------------------------------------
// getPanel
//------------------------------------------------------------------------------
uint32_t cta::mediachanger::AcsLibrarySlot::getPanel() const throw () {
return m_panel;
}
//------------------------------------------------------------------------------
// getDrive
//------------------------------------------------------------------------------
uint32_t cta::mediachanger::AcsLibrarySlot::getDrive() const throw () {
return m_drive;
}
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include "common/exception/InvalidArgument.hpp"
#include "mediachanger/LibrarySlot.hpp"
#include <stdint.h>
namespace cta {
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 cta
/******************************************************************************
*
* 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 "mediachanger/AcsLibrarySlot.hpp"
#include <gtest/gtest.h>
#include <memory>
namespace unitTests {
class cta_mediachanger_AcsLibrarySlotTest : public ::testing::Test {
protected:
virtual void SetUp() {
}
virtual void TearDown() {
}
};
TEST_F(cta_mediachanger_AcsLibrarySlotTest, goodDay) {
using namespace cta::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(cta_mediachanger_AcsLibrarySlotTest, clone) {
using namespace cta::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
// 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 cta.mediachanger;
message AcsMountTapeReadOnly {
required string vid = 1;
required uint32 acs = 2;
required uint32 lsm = 3;
required uint32 panel = 4;
required uint32 drive = 5;
}
// 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 cta.mediachanger;
message AcsMountTapeReadWrite {
required string vid = 1;
required uint32 acs = 2;
required uint32 lsm = 3;
required uint32 panel = 4;
required uint32 drive = 5;
}
/******************************************************************************
*
* 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 "mediachanger/AcsProxy.hpp"
//-----------------------------------------------------------------------------
// destructor
//-----------------------------------------------------------------------------
cta::mediachanger::AcsProxy::~AcsProxy() {
}
/******************************************************************************
*
* 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 "mediachanger/AcsLibrarySlot.hpp"
#include <stdint.h>
#include <string>
namespace cta {
namespace mediachanger {
/**
* 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 cta::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 cta::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 cta::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 cta::mediachanger::AcsLibrarySlot &librarySlot) = 0;
}; // class AcsProxy
} // namespace mediachanger
} // namespace cta
/******************************************************************************
*
* 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 "mediachanger/AcsProxyDummy.hpp"
//------------------------------------------------------------------------------
// mountTapeReadOnly
//------------------------------------------------------------------------------
void cta::mediachanger::AcsProxyDummy::mountTapeReadOnly(const std::string &vid,
const cta::mediachanger::AcsLibrarySlot &librarySlot) {
}
//------------------------------------------------------------------------------
// mountTapeForMigration
//------------------------------------------------------------------------------
void cta::mediachanger::AcsProxyDummy::mountTapeReadWrite(const std::string &vid,
const cta::mediachanger::AcsLibrarySlot &librarySlot) {
}
//------------------------------------------------------------------------------
// dismountTape
//------------------------------------------------------------------------------
void cta::mediachanger::AcsProxyDummy::dismountTape(const std::string &vid,
const cta::mediachanger::AcsLibrarySlot &librarySlot) {
}
//------------------------------------------------------------------------------
// dismountTape
//------------------------------------------------------------------------------
void cta::mediachanger::AcsProxyDummy::forceDismountTape(const std::string &vid,
const cta::mediachanger::AcsLibrarySlot &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
*****************************************************************************/