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

tapeserverd listening ports can now be set in castor.conf

parent 1117589b
......@@ -615,6 +615,23 @@
# tapeserverd daemon.
#TapeServer VdqmDriveSyncInterval 600
# The TCP/IP port on which the tape server daemon listens for incoming
# connections and jobs from the VDQM server.
#
#TapeServer JobPort 5070
# The TCP/IP port on which the tape server daemon listens for incoming
# connections from the tpconfig admin command.
#TapeServer AdminPort 5011
# The TCP/IP port on which the tape server daemon listens for incoming
# connections from the tape labeling command.
#TapeServer LabelPort 54321
# The TCP/IP port on which ZMQ sockets will bind for internal communication
# between forked sessions and the parent tapeserverd process.
#TapeServer InternalPort 54322;
## Tape Bridge Clients: dumptp, readtp and writetp #############################
# The inclusive low port of the tapebridge client callback port number range.
......
......@@ -21,17 +21,17 @@
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/tape/label/LabelCmd.hpp"
#include "castor/tape/label/ParsedTpLabelCommandLine.hpp"
#include "castor/tape/tpcp/Constants.hpp"
#include "castor/common/CastorConfiguration.hpp"
#include "castor/io/io.hpp"
#include "castor/legacymsg/CommonMarshal.hpp"
#include "castor/legacymsg/GenericMarshal.hpp"
#include "castor/legacymsg/TapeMarshal.hpp"
#include "castor/legacymsg/TapeLabelRqstMsgBody.hpp"
#include "castor/io/io.hpp"
#include "castor/tape/label/LabelCmd.hpp"
#include "castor/tape/label/ParsedTpLabelCommandLine.hpp"
#include "castor/tape/tapeserver/daemon/Constants.hpp"
#include "h/Ctape.h"
#include "castor/tape/tpcp/Constants.hpp"
#include "castor/legacymsg/GenericMarshal.hpp"
#include "h/Ctape.h"
#include <getopt.h>
#include <iostream>
......@@ -288,6 +288,10 @@ int castor::tape::label::LabelCmd::executeCommand() {
// writeTapeLabelRequest
//------------------------------------------------------------------------------
void castor::tape::label::LabelCmd::writeTapeLabelRequest(const int timeout) {
common::CastorConfiguration &castorConf =
common::CastorConfiguration::getConfig();
const unsigned short tapeServerLabelPort = castorConf.getConfEntInt(
"TapeServer", "LabelPort", tapeserver::daemon::TAPESERVER_LABEL_PORT);
castor::legacymsg::TapeLabelRqstMsgBody body;
body.uid = m_userId;
body.gid = m_groupId;
......@@ -298,8 +302,9 @@ void castor::tape::label::LabelCmd::writeTapeLabelRequest(const int timeout) {
char buf[REQBUFSZ];
const size_t len = castor::legacymsg::marshal(buf, sizeof(buf), body);
m_smartClientConnectionSock.reset(castor::io::connectWithTimeout("127.0.0.1",
tapeserver::daemon::TAPESERVER_LABELCMD_LISTENING_PORT, timeout));
tapeServerLabelPort, timeout));
try {
castor::io::writeBytes(m_smartClientConnectionSock.get(), timeout, len, buf);
......
......@@ -48,7 +48,6 @@ add_library(castorTapeServerDaemon
MigrationTaskInjector.cpp
DataTransferSession.cpp
ProcessForker.cpp
ProcessForkerConfig.cpp
ProcessForkerConnectionHandler.cpp
ProcessForkerProxy.cpp
ProcessForkerProxyDummy.cpp
......
......@@ -28,27 +28,27 @@ namespace daemon {
/**
* The TCP/IP port on which the tape server daemon listens for incoming
* connections from the VDQM server.
* connections and jobs from the VDQM server.
*/
const unsigned short TAPESERVER_VDQM_LISTENING_PORT = 5070;
const unsigned short TAPESERVER_JOB_PORT = 5070;
/**
* The TCP/IP port on which the tape server daemon listens for incoming
* connections from the tpconfig admin command.
*/
const unsigned short TAPESERVER_ADMIN_LISTENING_PORT = 5011;
const unsigned short TAPESERVER_ADMIN_PORT = 5011;
/**
* The TCP/IP port on which the tape server daemon listens for incoming
* connections from the label command.
* connections from the tape labeling command.
*/
const unsigned short TAPESERVER_LABELCMD_LISTENING_PORT = 54321;
const unsigned short TAPESERVER_LABEL_PORT = 54321;
/*
* The port on which ZMQ sockets will bind for internal communication between
* forked sessions and the parent tapeserverd process.
/**
* The TCP/IP port on which ZMQ sockets will bind for internal communication
* between forked sessions and the parent tapeserverd process.
*/
const unsigned short TAPESERVER_INTERNAL_LISTENING_PORT = 54322;
const unsigned short TAPESERVER_INTERNAL_PORT = 54322;
/**
* The compile-time default value for the maximum time in seconds that the
......
......@@ -66,7 +66,7 @@ castor::tape::tapeserver::daemon::ProcessForker::ProcessForker(
const int reaperSocket,
const std::string &hostName,
char *const argv0,
const ProcessForkerConfig &config) throw():
const TapeDaemonConfig &config) throw():
m_log(log),
m_cmdSocket(cmdSocket),
m_reaperSocket(reaperSocket),
......@@ -538,8 +538,8 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
mediachanger::MediaChangerFacade mediaChangerFacade(acs, mmc, rmc);
messages::TapeserverProxyZmq tapeserver(m_log,
TAPESERVER_INTERNAL_LISTENING_PORT, zmqContext.get());
messages::TapeserverProxyZmq tapeserver(m_log, m_config.internalPort,
zmqContext.get());
castor::tape::System::realWrapper sysWrapper;
......@@ -847,8 +847,8 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
const int sizeOfIOThreadPoolForZMQ = 1;
messages::SmartZmqContext
zmqContext(instantiateZmqContext(sizeOfIOThreadPoolForZMQ));
messages::TapeserverProxyZmq tapeserver(m_log,
TAPESERVER_INTERNAL_LISTENING_PORT, zmqContext.get());
messages::TapeserverProxyZmq tapeserver(m_log, m_config.internalPort,
zmqContext.get());
messages::AcsProxyZmq acs(acs::ACS_PORT, zmqContext.get());
......
......@@ -29,8 +29,8 @@
#include "castor/messages/ForkDataTransfer.pb.h"
#include "castor/messages/ForkLabel.pb.h"
#include "castor/tape/tapeserver/daemon/DataTransferSession.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerConfig.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerFrame.hpp"
#include "castor/tape/tapeserver/daemon/TapeDaemonConfig.hpp"
#include <stdint.h>
......@@ -60,12 +60,12 @@ public:
* @param hostName The name of the host on which the tapeserverd daemon is
* running.
* @param argv0 Pointer to argv[0], the command-line.
* @param config The CASTOR configuration parameters used by the
* ProcessForker for the entire lifetime of the process.
* @param config The CASTOR configuration parameters used by the tapeserverd
* daemon.
*/
ProcessForker(log::Logger &log, const int cmdSocket, const int reaperSocket,
const std::string &hostName, char *const argv0,
const ProcessForkerConfig &config) throw();
const TapeDaemonConfig &config) throw();
/**
* Destructor.
......@@ -116,9 +116,9 @@ private:
char *const m_argv0;
/**
* The CASTOR configuration parameters used by the ProcessForker.
* The CASTOR configuration parameters used by the tapeserverd daemon.
*/
const ProcessForkerConfig m_config;
const TapeDaemonConfig m_config;
/**
* Idempotent method that closes the socket used for receving commands
......
/******************************************************************************
*
* 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/daemon/ProcessForkerConfig.hpp"
#include "h/rmc_constants.h"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::tape::tapeserver::daemon::ProcessForkerConfig::
ProcessForkerConfig():
rmcPort(0) {
}
//------------------------------------------------------------------------------
// createFromCastorConfig
//------------------------------------------------------------------------------
castor::tape::tapeserver::daemon::ProcessForkerConfig
castor::tape::tapeserver::daemon::ProcessForkerConfig::
createFromCastorConf(log::Logger *const log) {
common::CastorConfiguration &castorConf =
common::CastorConfiguration::getConfig();
ProcessForkerConfig config;
config.rmcPort = castorConf.getConfEntInt("RMC", "PORT",
(unsigned short)RMC_PORT, log);
config.dataTransfer = DataTransferConfig::createFromCastorConf(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/tape/tapeserver/daemon/DataTransferConfig.hpp"
namespace castor {
namespace tape {
namespace tapeserver {
namespace daemon {
/**
* Structure containing the CASTOR configuration parameters used by the
* ProcessForker.
*/
struct ProcessForkerConfig {
/**
* The TCP/IP port on which the rmcd daemon is listening.
*/
unsigned short rmcPort;
/**
* The configuration parameters required by a data-transfer session.
*/
DataTransferConfig dataTransfer;
/**
* Constructor that sets all integer member-variables to 0 and all string
* member-variables to the emptry string.
*/
ProcessForkerConfig();
/**
* 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 ProcessForkerConfig createFromCastorConf(
log::Logger *const log = NULL);
}; // class ProcessForkerConfig
} // namespace daemon
} // namespace tapeserver
} // namespace tape
} // namespace castor
......@@ -60,11 +60,11 @@ TEST_F(castor_tape_tapeserver_daemon_ProcessForkerTest, constructor) {
const std::string hostName = "hostName";
castor::log::DummyLogger log(programName);
char argv0[12] = "tapeserverd";
ProcessForkerConfig processForkerConfig;
TapeDaemonConfig config;
std::auto_ptr<ProcessForker> processForker;
ASSERT_NO_THROW(processForker.reset(
new ProcessForker(log, cmdReceiverSocket.get(), reaperSenderSocket.get(),
hostName, argv0, processForkerConfig)));
hostName, argv0, config)));
cmdReceiverSocket.release();
}
......@@ -85,11 +85,11 @@ TEST_F(castor_tape_tapeserver_daemon_ProcessForkerTest, socketproxy) {
const std::string hostName = "hostName";
castor::log::DummyLogger log(programName);
char argv0[12] = "tapeserverd";
ProcessForkerConfig processForkerConfig;
TapeDaemonConfig config;
std::auto_ptr<ProcessForker> processForker;
ASSERT_NO_THROW(processForker.reset(
new ProcessForker(log, cmdReceiverSocket.get(), reaperSenderSocket.get(),
hostName, argv0, processForkerConfig)));
hostName, argv0, config)));
cmdReceiverSocket.release();
std::auto_ptr<ProcessForkerProxySocket> processForkerProxy;
......
......@@ -533,7 +533,7 @@ int castor::tape::tapeserver::daemon::TapeDaemon::runProcessForker(
const int cmdReceiverSocket, const int reaperSenderSocket) throw() {
try {
ProcessForker processForker(m_log, cmdReceiverSocket, reaperSenderSocket,
m_hostName, m_argv[0], m_tapeDaemonConfig.processForkerConfig);
m_hostName, m_argv[0], m_tapeDaemonConfig);
processForker.execute();
return 0;
} catch(castor::exception::Exception &ex) {
......@@ -685,7 +685,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
try {
castor::utils::SmartFd listenSock;
try {
listenSock.reset(io::createListenerSock(TAPESERVER_VDQM_LISTENING_PORT));
listenSock.reset(io::createListenerSock(m_tapeDaemonConfig.jobPort));
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex(ne.code());
ex.getMessage() << "Failed to create socket to listen for vdqm connections"
......@@ -694,7 +694,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
}
{
log::Param params[] = {
log::Param("listeningPort", TAPESERVER_VDQM_LISTENING_PORT)};
log::Param("listeningPort", m_tapeDaemonConfig.jobPort)};
m_log(LOG_INFO, "Listening for connections from the vdqmd daemon", params);
}
......@@ -729,7 +729,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
try {
castor::utils::SmartFd listenSock;
try {
listenSock.reset(io::createListenerSock(TAPESERVER_ADMIN_LISTENING_PORT));
listenSock.reset(io::createListenerSock(m_tapeDaemonConfig.adminPort));
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex(ne.code());
ex.getMessage() <<
......@@ -739,7 +739,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
}
{
log::Param params[] = {
log::Param("listeningPort", TAPESERVER_ADMIN_LISTENING_PORT)};
log::Param("listeningPort", m_tapeDaemonConfig.adminPort)};
m_log(LOG_INFO, "Listening for connections from the admin commands",
params);
}
......@@ -776,7 +776,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
castor::utils::SmartFd listenSock;
try {
listenSock.reset(
io::createListenerSock(TAPESERVER_LABELCMD_LISTENING_PORT));
io::createListenerSock(m_tapeDaemonConfig.labelPort));
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex(ne.code());
ex.getMessage() <<
......@@ -786,7 +786,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
}
{
log::Param params[] = {
log::Param("listeningPort", TAPESERVER_LABELCMD_LISTENING_PORT)};
log::Param("listeningPort", m_tapeDaemonConfig.labelPort)};
m_log(LOG_INFO, "Listening for connections from label command",
params);
}
......@@ -822,8 +822,9 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
try {
std::auto_ptr<TapeMessageHandler> handler;
try {
handler.reset(new TapeMessageHandler(m_reactor, m_log, *m_catalogue,
m_hostName, m_vdqm, m_vmgr, m_zmqContext));
handler.reset(new TapeMessageHandler(m_tapeDaemonConfig.internalPort,
m_reactor, m_log, *m_catalogue, m_hostName, m_vdqm, m_vmgr,
m_zmqContext));
} catch(std::bad_alloc &ba) {
castor::exception::BadAlloc ex;
ex.getMessage() <<
......
......@@ -34,7 +34,6 @@
#include "castor/tape/reactor/ZMQReactor.hpp"
#include "castor/tape/tapeserver/daemon/Catalogue.hpp"
#include "castor/tape/tapeserver/daemon/DriveConfigMap.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerConfig.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerProxy.hpp"
#include "castor/tape/tapeserver/daemon/TapeDaemonConfig.hpp"
#include "castor/utils/utils.hpp"
......
......@@ -25,6 +25,18 @@
#include "castor/tape/tapeserver/Constants.hpp"
#include "castor/tape/tapeserver/daemon/Constants.hpp"
#include "castor/tape/tapeserver/daemon/TapeDaemonConfig.hpp"
#include "h/rmc_constants.h"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::tape::tapeserver::daemon::TapeDaemonConfig::TapeDaemonConfig():
rmcPort(0),
jobPort(0),
adminPort(0),
labelPort(0),
internalPort(0) {
}
//------------------------------------------------------------------------------
// createFromCastorConf
......@@ -37,11 +49,22 @@ 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.rmcPort = castorConf.getConfEntInt("RMC", "PORT",
(unsigned short)RMC_PORT, log);
config.jobPort = castorConf.getConfEntInt("TapeServer", "JobPort",
TAPESERVER_JOB_PORT, log);
config.adminPort = castorConf.getConfEntInt("TapeServer", "AdminPort",
TAPESERVER_ADMIN_PORT, log);
config.labelPort = castorConf.getConfEntInt("TapeServer", "LabelPort",
TAPESERVER_LABEL_PORT, log);
config.internalPort = castorConf.getConfEntInt("TapeServer", "InternalPort",
TAPESERVER_INTERNAL_PORT, log);
config.dataTransfer = DataTransferConfig::createFromCastorConf(log);
return config;
}
......@@ -25,7 +25,7 @@
#include "castor/log/Logger.hpp"
#include "castor/tape/tapeserver/daemon/CatalogueConfig.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerConfig.hpp"
#include "castor/tape/tapeserver/daemon/DataTransferConfig.hpp"
#include <stdint.h>
#include <string>
......@@ -40,11 +40,6 @@ namespace daemon {
*/
struct TapeDaemonConfig {
/**
* The CASTOR configuration parameters used by the ProcessForker.
*/
ProcessForkerConfig processForkerConfig;
/**
* The CASTOR configuration parameters used by the Catalogue.
*/
......@@ -65,6 +60,48 @@ struct TapeDaemonConfig {
*/
std::string vmgrHost;
/**
* The TCP/IP port on which the rmcd daemon is listening.
*/
unsigned short rmcPort;
/**
* The TCP/IP port on which the tape server daemon listens for incoming
* connections from the VDQM server.
*/
unsigned short jobPort;
/**
* The TCP/IP port on which the tape server daemon listens for incoming
* connections from the tpconfig admin command.
*/
unsigned short adminPort;
/**
* The TCP/IP port on which the tape server daemon listens for incoming
* connections from the label command.
*/
unsigned short labelPort;
/**
* The port on which ZMQ sockets will bind for internal communication between
* forked sessions and the parent tapeserverd process.
*/
unsigned short internalPort;
/**
* The configuration parameters required by a data-transfer session.
*/
DataTransferConfig dataTransfer;
/**
* Constructor.
*
* Initializes all integer values to 0 and all string values to the empty
* string.
*/
TapeDaemonConfig();
/**
* Returns a configuration structure based on the contents of
* /etc/castor/castor.conf and compile-time constants.
......
......@@ -51,6 +51,7 @@
// constructor
//------------------------------------------------------------------------------
castor::tape::tapeserver::daemon::TapeMessageHandler::TapeMessageHandler(
const unsigned short internalPort,
reactor::ZMQReactor &reactor,
log::Logger &log,Catalogue &driveCatalogue,
const std::string &hostName,
......@@ -66,7 +67,7 @@ castor::tape::tapeserver::daemon::TapeMessageHandler::TapeMessageHandler(
m_vmgr(vmgr) {
std::ostringstream endpoint;
endpoint << "tcp://127.0.0.1:" << TAPESERVER_INTERNAL_LISTENING_PORT;
endpoint << "tcp://127.0.0.1:" << internalPort;
try {
m_socket.bind(endpoint.str().c_str());
......
......@@ -52,6 +52,9 @@ public:
/**
* Constructor.
*
* @param internalPort The TCP/IP port on which ZMQ sockets will bind for
* internal communication between forked sessions and the parent tapeserverd
* process.
* @param reactor The reactor to which new Vdqm connection handlers are to
* be registered.
* @param log The object representing the API of the CASTOR logging system.
......@@ -62,6 +65,7 @@ public:
* @param zmqContext The ZMQ context.
*/
TapeMessageHandler(
const unsigned short internalPort,
reactor::ZMQReactor &reactor,
log::Logger &log,
Catalogue &driveCatalogue,
......
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