Commit bd4bd68d authored by Steven Murray's avatar Steven Murray
Browse files

Added the CatalogueConfig class

parent 68e267a7
......@@ -15,6 +15,7 @@ add_library(castorTapeServerDaemon
CatalogueLabelSession.cpp
CatalogueTransferSession.cpp
CatalogueCleanerSession.cpp
CatalogueConfig.cpp
TapeServerReporter.cpp
LabelCmdAcceptHandler.cpp
LabelCmdConnectionHandler.cpp
......
......@@ -39,9 +39,7 @@ castor::tape::tapeserver::daemon::Catalogue::Catalogue(
legacymsg::VdqmProxy &vdqm,
legacymsg::VmgrProxy &vmgr,
const std::string &hostName,
const time_t waitJobTimeoutInSecs,
const time_t mountTimeoutInSecs,
const time_t blockMoveTimeoutInSecs):
const CatalogueConfig &catalogueConfig):
m_netTimeout(netTimeout),
m_log(log),
m_processForker(processForker),
......@@ -49,9 +47,7 @@ castor::tape::tapeserver::daemon::Catalogue::Catalogue(
m_vdqm(vdqm),
m_vmgr(vmgr),
m_hostName(hostName),
m_waitJobTimeoutInSecs(waitJobTimeoutInSecs),
m_mountTimeoutInSecs(mountTimeoutInSecs),
m_blockMoveTimeoutInSecs(blockMoveTimeoutInSecs) {
m_catalogueConfig(catalogueConfig) {
}
//-----------------------------------------------------------------------------
......@@ -145,8 +141,9 @@ void castor::tape::tapeserver::daemon::Catalogue::enterDriveConfig(
// Insert it
m_drives[driveConfig.unitName] = new CatalogueDrive(m_netTimeout,
m_log, m_processForker, m_cupv, m_vdqm, m_vmgr, m_hostName, driveConfig,
CatalogueDrive::DRIVE_STATE_DOWN, m_waitJobTimeoutInSecs,
m_mountTimeoutInSecs, m_blockMoveTimeoutInSecs);
CatalogueDrive::DRIVE_STATE_DOWN, m_catalogueConfig.waitJobTimeoutInSecs,
m_catalogueConfig.mountTimeoutInSecs,
m_catalogueConfig.blockMoveTimeoutInSecs);
// Else the drive is already in the catalogue
} else {
castor::exception::Exception ex;
......
......@@ -32,6 +32,7 @@
#include "castor/log/Logger.hpp"
#include "castor/tape/utils/DriveConfigMap.hpp"
#include "castor/tape/tapeserver/client/ClientProxy.hpp"
#include "castor/tape/tapeserver/daemon/CatalogueConfig.hpp"
#include "castor/tape/tapeserver/daemon/CatalogueDrive.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerProxy.hpp"
......@@ -63,12 +64,8 @@ public:
* @param vmgr Proxy object representing the vmgrd daemon.
* @param hostName The name of the host on which the daemon is running. This
* name is needed to fill in messages to be sent to the vdqmd daemon.
* @param waitJobTimeoutInSecs The maximum time in seconds that the
* data-transfer session can take to get the transfer job from the client.
* @param mountTimeoutInSecs The maximum time in seconds that the
* data-transfer session can take to mount a tape.
* @param blockMoveTimeoutInSecs The maximum time in seconds that the
* data-transfer session can cease to move data blocks.
* @param catalogueConfig The CASTOR configuration parameters to be used by
* the catalogue.
*/
Catalogue(
const int netTimeout,
......@@ -78,9 +75,7 @@ public:
legacymsg::VdqmProxy &vdqm,
legacymsg::VmgrProxy &vmgr,
const std::string &hostName,
const time_t waitJobTimeoutInSecs,
const time_t mountTimeoutInSecs,
const time_t blockMoveTimeoutInSecs);
const CatalogueConfig &catalogueConfig);
/**
* Destructor.
......@@ -213,22 +208,9 @@ private:
const std::string m_hostName;
/**
* The maximum time in seconds that the data-transfer session can take to get
* the transfer job from the client.
* The CASTOR configuration parameters to be used by the catalogue.
*/
const time_t m_waitJobTimeoutInSecs;
/**
* The maximum time in seconds that the data-transfer session can take to
* mount a tape.
*/
const time_t m_mountTimeoutInSecs;
/**
* The maximum time in seconds that the data-transfer session can cease to
* move data blocks.
*/
const time_t m_blockMoveTimeoutInSecs;
const CatalogueConfig m_catalogueConfig;
/**
* Type that maps the unit name of a tape drive to the catalogue entry of
......
/******************************************************************************
*
* 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/common/CastorConfiguration.hpp"
#include "castor/tape/tapeserver/Constants.hpp"
#include "castor/tape/tapeserver/daemon/Constants.hpp"
#include "castor/tape/tapeserver/daemon/CatalogueConfig.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::tape::tapeserver::daemon::CatalogueConfig::CatalogueConfig() throw():
waitJobTimeoutInSecs(0),
mountTimeoutInSecs(0),
blockMoveTimeoutInSecs(0) {
}
//------------------------------------------------------------------------------
// createFromCastorConf
//------------------------------------------------------------------------------
castor::tape::tapeserver::daemon::CatalogueConfig
castor::tape::tapeserver::daemon::CatalogueConfig::createFromCastorConf(
log::Logger *const log) {
common::CastorConfiguration &castorConf =
common::CastorConfiguration::getConfig();
CatalogueConfig config;
config.waitJobTimeoutInSecs = castorConf.getConfEntInt("TapeServer",
"WaitJobTimeout", (time_t)TAPESERVER_WAITJOBTIMEOUT_DEFAULT, log);
config.mountTimeoutInSecs = castorConf.getConfEntInt("TapeServer",
"MountTimeout", (time_t)TAPESERVER_MOUNTTIMEOUT_DEFAULT, log);
config.blockMoveTimeoutInSecs = castorConf.getConfEntInt("TapeServer",
"BlkMoveTimeout", (time_t)TAPESERVER_BLKMOVETIMEOUT_DEFAULT, log);
return config;
}
/******************************************************************************
*
* 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/log/Logger.hpp"
#include <stdint.h>
#include <string>
namespace castor {
namespace tape {
namespace tapeserver {
namespace daemon {
/**
* The contents of the castor.conf file to be used by the tape-drive catalogue
* of the tape-server daemon.
*/
struct CatalogueConfig {
/**
* The maximum time in seconds that the data-transfer session can take to get
* the transfer job from the client.
*/
time_t waitJobTimeoutInSecs;
/**
* The maximum time in seconds that the data-transfer session can take to
* mount a tape.
*/
time_t mountTimeoutInSecs;
/**
* The maximum time in seconds the data-transfer session of tapeserverd can
* cease to move data blocks
*/
time_t blockMoveTimeoutInSecs;
/**
* Constructor that sets all integer member-variables to 0 and all string
* member-variables to the empty string.
*/
CatalogueConfig() throw();
/**
* Returns a configuration structure based on the contents of
* /etc/castor/castor.conf and compile-time constants.
*
* @param log pointer to NULL or an optional logger object.
* @return The configuration structure.
*/
static CatalogueConfig createFromCastorConf(
log::Logger *const log = NULL);
}; // CatalogueConfig
} // namespace daemon
} // namespace tapeserver
} // namespace tape
} // namespace castor
......@@ -62,12 +62,10 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, goodDayPopulate) {
castor::legacymsg::VdqmProxyDummy vdqm;
castor::legacymsg::VmgrProxyDummy vmgr;
const std::string hostName = "";
const time_t waitJobTimeoutInSecs = 1;
const time_t mountTimeoutInSecs = 1;
const time_t blockMoveTimeoutInSecs = 1;
const CatalogueConfig catalogueConfig;
const int netTimeout = 1;
Catalogue catalogue(netTimeout, log, processForker, cupv, vdqm, vmgr,
hostName, waitJobTimeoutInSecs, mountTimeoutInSecs, blockMoveTimeoutInSecs);
hostName, catalogueConfig);
ASSERT_NO_THROW(catalogue.populate(driveConfigs));
{
......@@ -137,11 +135,9 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest,
castor::legacymsg::VdqmProxyDummy vdqm;
castor::legacymsg::VmgrProxyDummy vmgr;
const std::string hostName = "";
const time_t waitJobTimeoutInSecs = 1;
const time_t mountTimeoutInSecs = 1;
const time_t blockMoveTimeoutInSecs = 1;
const CatalogueConfig catalogueConfig;
Catalogue catalogue(netTimeout, log, processForker, cupv, vdqm, vmgr,
hostName, waitJobTimeoutInSecs, mountTimeoutInSecs, blockMoveTimeoutInSecs);
hostName, catalogueConfig);
ASSERT_THROW(catalogue.findDrive(unitName), castor::exception::Exception);
}
......@@ -161,11 +157,9 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, dgnMismatchStart) {
castor::legacymsg::VdqmProxyDummy vdqm;
castor::legacymsg::VmgrProxyDummy vmgr;
const std::string hostName = "";
const time_t waitJobTimeoutInSecs = 1;
const time_t mountTimeoutInSecs = 1;
const time_t blockMoveTimeoutInSecs = 1;
const CatalogueConfig catalogueConfig;
Catalogue catalogue(netTimeout, log, processForker, cupv, vdqm, vmgr,
hostName, waitJobTimeoutInSecs, mountTimeoutInSecs, blockMoveTimeoutInSecs);
hostName, catalogueConfig);
ASSERT_NO_THROW(catalogue.populate(driveConfigs));
CatalogueDrive &unit = catalogue.findDrive("UNIT");
ASSERT_EQ(CatalogueDrive::DRIVE_STATE_DOWN, unit.getState());
......@@ -202,11 +196,9 @@ TEST_F(castor_tape_tapeserver_daemon_CatalogueTest, getUnitNames) {
castor::legacymsg::VdqmProxyDummy vdqm;
castor::legacymsg::VmgrProxyDummy vmgr;
const std::string hostName = "";
const time_t waitJobTimeoutInSecs = 1;
const time_t mountTimeoutInSecs = 1;
const time_t blockMoveTimeoutInSecs = 1;
const CatalogueConfig catalogueConfig;
Catalogue catalogue(netTimeout, log, processForker, cupv, vdqm, vmgr,
hostName, waitJobTimeoutInSecs, mountTimeoutInSecs, blockMoveTimeoutInSecs);
hostName, catalogueConfig);
ASSERT_NO_THROW(catalogue.populate(driveConfigs));
{
......
......@@ -216,9 +216,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::exceptionThrowingMain(
m_vdqm,
m_vmgr,
m_hostName,
m_tapeDaemonConfig.waitJobTimeoutInSecs,
m_tapeDaemonConfig.mountTimeoutInSecs,
m_tapeDaemonConfig.blockMoveTimeoutInSec);
m_tapeDaemonConfig.catalogueConfig);
m_catalogue->populate(m_driveConfigs);
......
......@@ -26,15 +26,6 @@
#include "castor/tape/tapeserver/daemon/Constants.hpp"
#include "castor/tape/tapeserver/daemon/TapeDaemonConfig.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::tape::tapeserver::daemon::TapeDaemonConfig::TapeDaemonConfig() throw():
waitJobTimeoutInSecs(0),
mountTimeoutInSecs(0),
blockMoveTimeoutInSec(0) {
}
//------------------------------------------------------------------------------
// createFromCastorConf
//------------------------------------------------------------------------------
......@@ -47,15 +38,10 @@ castor::tape::tapeserver::daemon::TapeDaemonConfig
TapeDaemonConfig config;
config.processForkerConfig = ProcessForkerConfig::createFromCastorConf(log);
config.catalogueConfig = CatalogueConfig::createFromCastorConf(log);
config.cupvHost = castorConf.getConfEntString("UPV" , "HOST", log);
config.vdqmHost = castorConf.getConfEntString("VDQM", "HOST", log);
config.vmgrHost = castorConf.getConfEntString("VMGR", "HOST", log);
config.waitJobTimeoutInSecs = castorConf.getConfEntInt("TapeServer",
"WaitJobTimeout", (time_t)TAPESERVER_WAITJOBTIMEOUT_DEFAULT, log);
config.mountTimeoutInSecs = castorConf.getConfEntInt("TapeServer",
"MountTimeout", (time_t)TAPESERVER_MOUNTTIMEOUT_DEFAULT, log);
config.blockMoveTimeoutInSec = castorConf.getConfEntInt("TapeServer",
"BlkMoveTimeout", (time_t)TAPESERVER_BLKMOVETIMEOUT_DEFAULT, log);
return config;
}
......@@ -24,6 +24,7 @@
#pragma once
#include "castor/log/Logger.hpp"
#include "castor/tape/tapeserver/daemon/CatalogueConfig.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerConfig.hpp"
#include <stdint.h>
......@@ -44,6 +45,11 @@ struct TapeDaemonConfig {
*/
ProcessForkerConfig processForkerConfig;
/**
* The CASTOR configuration parameters used by the Catalogue.
*/
CatalogueConfig catalogueConfig;
/**
* The network name of the host on which the cupv daemon is running.
*/
......@@ -59,30 +65,6 @@ struct TapeDaemonConfig {
*/
std::string vmgrHost;
/**
* The maximum time in seconds that the data-transfer session can take to get
* the transfer job from the client.
*/
time_t waitJobTimeoutInSecs;
/**
* The maximum time in seconds that the data-transfer session can take to
* mount a tape.
*/
time_t mountTimeoutInSecs;
/**
* The maximum time in seconds the data-transfer session of tapeserverd can
* cease to move data blocks
*/
time_t blockMoveTimeoutInSec;
/**
* Constructor that sets all integer member-variables to 0 and all string
* member-variables to the empty string.
*/
TapeDaemonConfig() throw();
/**
* Returns a configuration structure based on the contents of
* /etc/castor/castor.conf and compile-time constants.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment