Commit 3ee27bc0 authored by Eric Cano's avatar Eric Cano
Browse files

Moved classes away from "root" namespace into more apropiate ones.

Removed unecessary old code, including propagation of the moved port
Put inplace "make unittests" which now run the unittests through valgrind and helgrind.
parent 9a9b2393
......@@ -102,8 +102,10 @@ endif (${COMPILE_PACKAGING} STREQUAL "1")
# COMMENT "Not running the unit tests" VERBATIM)
configure_file(tests/valgrind.suppr tests/valgrind.suppr COPYONLY)
add_custom_target(test tests/unittests
#
COMMAND valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/unittests
DEPENDS tests/unittests tests/valgrind.suppr
COMMENT "Running unit tests" VERBATIM)
add_custom_target(unittests
tests/unitTests
COMMAND valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 --suppressions=tests/valgrind.suppr tests/unitTests
COMMAND valgrind --tool=helgrind -v --demangle=no --conflict-cache-size=30000000 --error-exitcode=1 tests/unitTests
DEPENDS tests/unittests tests/valgrind.suppr
COMMENT "Running unit tests" VERBATIM)
......@@ -30,13 +30,13 @@
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
CTACopyCmd::CTACopyCmd() throw() {
cta::cmdline::CTACopyCmd::CTACopyCmd() throw() {
}
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
int CTACopyCmd::main(const int argc, const char **argv) const throw() {
int cta::cmdline::CTACopyCmd::main(const int argc, const char **argv) const throw() {
try {
return sendCommand(argc, argv);
} catch(cta::exception::Exception &ex) {
......@@ -54,7 +54,7 @@ int CTACopyCmd::main(const int argc, const char **argv) const throw() {
//------------------------------------------------------------------------------
// sendCommand
//------------------------------------------------------------------------------
int CTACopyCmd::sendCommand(const int argc, const char **argv) const {
int cta::cmdline::CTACopyCmd::sendCommand(const int argc, const char **argv) const {
XrdCl::PropertyList properties;
properties.Set("source", formatCommandPath(argc, argv));
properties.Set("target", "-"); //destination is stdout
......@@ -85,7 +85,7 @@ int CTACopyCmd::sendCommand(const int argc, const char **argv) const {
//------------------------------------------------------------------------------
// formatCommandPath
//------------------------------------------------------------------------------
std::string CTACopyCmd::formatCommandPath(const int argc, const char **argv) const {
std::string cta::cmdline::CTACopyCmd::formatCommandPath(const int argc, const char **argv) const {
std::string cmdPath = "root://"+castor::common::CastorConfiguration::getConfig().getConfEntString("TapeServer", "CTAFrontendHostAndPort")+"//";
for(int i=0; i<argc; i++) {
if(i) cmdPath += "&";
......@@ -97,7 +97,7 @@ std::string CTACopyCmd::formatCommandPath(const int argc, const char **argv) con
//------------------------------------------------------------------------------
// replaceAll
//------------------------------------------------------------------------------
void CTACopyCmd::replaceAll(std::string& str, const std::string& from, const std::string& to) const {
void cta::cmdline::CTACopyCmd::replaceAll(std::string& str, const std::string& from, const std::string& to) const {
if(from.empty() || str.empty())
return;
size_t start_pos = 0;
......@@ -110,7 +110,7 @@ void CTACopyCmd::replaceAll(std::string& str, const std::string& from, const std
//------------------------------------------------------------------------------
// encode
//------------------------------------------------------------------------------
std::string CTACopyCmd::encode(const std::string msg) const {
std::string cta::cmdline::CTACopyCmd::encode(const std::string msg) const {
std::string ret;
const bool noNewLineInBase64Output = false;
CryptoPP::StringSource ss1(msg, true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(ret), noNewLineInBase64Output));
......
......@@ -20,6 +20,8 @@
#include <string>
namespace cta { namespace cmdline {
/**
* Class implementing the business logic of the archive command-line tool.
*/
......@@ -83,3 +85,6 @@ private:
std::string encode(const std::string msg) const;
}; // class CTACopyCmd
}}
......@@ -23,7 +23,7 @@
//------------------------------------------------------------------------------
int main(const int argc, const char **argv) {
CTACopyCmd command;
cta::cmdline::CTACopyCmd command;
return command.main(argc, argv);
}
......@@ -55,15 +55,6 @@ typedef uint64_t U_HYPER;
#define bitsof(t) sizeof(t)*BITSOFBYTE /* number of bits in a type*/
typedef char* bitvct; /* bit vector type definition */
/*
* Allocate enough memory for a 'bitvct' type variable containing
* 'size' bits
*/
#define bitalloc(size) (bitvct)malloc(size/BITSOFBYTE + \
((size%BITSOFBYTE) ? 1 : 0))
/*
* Set the bit 'bit-th' starting from the byte pointed to by 'ptr'
......
......@@ -20,6 +20,8 @@
#include "objectstore/RootEntry.hpp"
#include "objectstore/BackendPopulator.hpp"
namespace cta { namespace objectstore {
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
......@@ -52,4 +54,6 @@ BackendPopulator::~BackendPopulator() throw() {
//------------------------------------------------------------------------------
cta::objectstore::Agent & BackendPopulator::getAgent() {
return m_agent;
}
\ No newline at end of file
}
}}
\ No newline at end of file
......@@ -21,6 +21,8 @@
#include "objectstore/Agent.hpp"
#include "objectstore/Backend.hpp"
namespace cta { namespace objectstore {
class BackendPopulator {
public:
......@@ -53,4 +55,6 @@ private:
* The agent
*/
cta::objectstore::Agent m_agent;
};
\ No newline at end of file
};
}}
\ No newline at end of file
......@@ -18,7 +18,7 @@
#include <google/protobuf/service.h>
namespace cta::objectstore {
namespace cta { namespace objectstore {
/**
* This singleton class will check the compatibility of the runtime library
* with the headers it was compiled against on construction (library load)
......@@ -35,4 +35,4 @@ class ProtobufCleaner {
}
} g_protobufCleaner;
} // end of namespaces
\ No newline at end of file
}} // end of namespaces
......@@ -21,13 +21,13 @@
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
OStoreDBWithAgent::OStoreDBWithAgent(cta::objectstore::Backend & be, cta::objectstore::Agent & ag): cta::OStoreDB(be) {
cta::OStoreDBWithAgent::OStoreDBWithAgent(cta::objectstore::Backend & be, cta::objectstore::Agent & ag): cta::OStoreDB(be) {
cta::OStoreDB::setAgent(ag);
}
//------------------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------------------
OStoreDBWithAgent::~OStoreDBWithAgent() throw () {
cta::OStoreDBWithAgent::~OStoreDBWithAgent() throw () {
cta::OStoreDB::setAgent(*((cta::objectstore::Agent *)NULL));
}
\ No newline at end of file
......@@ -22,6 +22,8 @@
#include "objectstore/Backend.hpp"
#include "scheduler/OStoreDB/OStoreDB.hpp"
namespace cta {
class OStoreDBWithAgent: public cta::OStoreDB {
public:
......@@ -37,4 +39,6 @@ public:
* Destructor
*/
virtual ~OStoreDBWithAgent() throw ();
};
\ No newline at end of file
};
}
......@@ -27,7 +27,7 @@
#include "IConverter.hpp"
/** the unique and single factory table */
castor::Converters* ConvertersInstance = NULL;
castor::Converters* g_ConvertersInstance = NULL;
/** The janitor in charge of clening up the converters instance:
* it might or might not give the initial kick that triggers the
......@@ -72,10 +72,10 @@ castor::Converters::~Converters() {
// instance
//-----------------------------------------------------------------------------
castor::Converters* castor::Converters::instance() {
if (0 == ConvertersInstance) {
ConvertersInstance = new castor::Converters();
if (0 == g_ConvertersInstance) {
g_ConvertersInstance = new castor::Converters();
}
return ConvertersInstance;
return g_ConvertersInstance;
}
//-----------------------------------------------------------------------------
......
......@@ -26,7 +26,7 @@
#include "ISvcFactory.hpp"
/** the unique and single factory table */
castor::Factories* FactoriesInstance = NULL;
castor::Factories* g_FactoriesInstance = NULL;
/** The janitor in charge of clening up the factories instance:
* it might or might not give the initial kick that triggers the
......@@ -60,19 +60,19 @@ castor::Factories::~Factories() throw() {
// instance
//-----------------------------------------------------------------------------
castor::Factories* castor::Factories::instance() {
if (0 == FactoriesInstance) {
FactoriesInstance = new Factories();
if (0 == g_FactoriesInstance) {
g_FactoriesInstance = new Factories();
}
return FactoriesInstance;
return g_FactoriesInstance;
}
//-----------------------------------------------------------------------------
// finalize
//-----------------------------------------------------------------------------
void castor::Factories::finalize() throw() {
if (0 != FactoriesInstance) {
delete FactoriesInstance;
FactoriesInstance = 0;
if (0 != g_FactoriesInstance) {
delete g_FactoriesInstance;
g_FactoriesInstance = 0;
}
}
......
......@@ -97,6 +97,7 @@ const int castor::client::HIGH_CLIENT_PORT_RANGE = 30100;
#endif
#define SIXMONTHS (6*30*24*60*60)
namespace {
static char strftime_format_sixmonthsold[] = "%b %e %Y";
static char strftime_format[] = "%b %e %H:%M:%S";
......@@ -117,6 +118,7 @@ void BaseClient_util_time(time_t then, char *timestr) {
strftime(timestr,64,strftime_format,tp);
}
}
}
//------------------------------------------------------------------------------
// constructor
......
......@@ -25,7 +25,6 @@
#include "castor/tape/tapeserver/daemon/DataTransferConfig.hpp"
#include "castor/tape/tapeserver/daemon/Constants.hpp"
#include "castor/tape/tapeserver/TapeBridgeConstants.hpp"
#include "movers/moveropenclose.h"
//------------------------------------------------------------------------------
// constructor
......@@ -40,8 +39,7 @@ castor::tape::tapeserver::daemon::DataTransferConfig::DataTransferConfig()
bulkRequestRecallMaxFiles(0),
maxBytesBeforeFlush(0),
maxFilesBeforeFlush(0),
nbDiskThreads(0),
moverHandlerPort(0) {
nbDiskThreads(0) {
}
//------------------------------------------------------------------------------
......@@ -84,8 +82,6 @@ castor::tape::tapeserver::daemon::DataTransferConfig
"TapeServer", "RemoteFileProtocol", "RFIO", log);
config.xrootPrivateKey = castorConf.getConfEntString(
"TapeServer", "XrootPrivateKey", "/etc/castor/xrd_tape_key.pem", log);
config.moverHandlerPort = castorConf.getConfEntInt(
"DiskManager", "MoverHandlerPort", MOVERHANDLERPORT, log);
return config;
}
......@@ -114,12 +114,6 @@ struct DataTransferConfig {
*/
std::string xrootPrivateKey;
/**
* The TCP/IP port on which the disk manager listens for data-transfer
* notifications from XROOT server.
*/
uint16_t moverHandlerPort;
/**
* Constructor that sets all integer member-variables to 0 and all string
* member-variables to the empty string.
......
......@@ -159,8 +159,7 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
rwd,
lc,
m_castorConf.remoteFileProtocol,
m_castorConf.xrootPrivateKey,
m_castorConf.moverHandlerPort);
m_castorConf.xrootPrivateKey);
RecallTaskInjector rti(mm, trst, dwtp, *retrieveMount,
m_castorConf.bulkRequestRecallMaxFiles,
m_castorConf.bulkRequestRecallMaxBytes,lc);
......@@ -255,8 +254,7 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
mwd,
lc,
m_castorConf.remoteFileProtocol,
m_castorConf.xrootPrivateKey,
m_castorConf.moverHandlerPort);
m_castorConf.xrootPrivateKey);
MigrationTaskInjector mti(mm, drtp, twst, *archiveMount,
m_castorConf.bulkRequestMigrationMaxFiles,
m_castorConf.bulkRequestMigrationMaxBytes,lc);
......
......@@ -1105,7 +1105,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
for(int fseq=1; fseq <= 10 ; fseq ++) {
// Create a path to a remote destination file
std::ostringstream remoteFilePath;
remoteFilePath << "file:" << "/test" << fseq;
remoteFilePath << "file://test" << fseq;
remoteFilePaths.push_back(remoteFilePath.str());
// Create the entry in the remote namespace (same user id of the requester)
......@@ -1224,7 +1224,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
for(int fseq=1; fseq <= 10 ; fseq ++) {
// Create a path to a remote destination file
std::ostringstream remoteFilePath;
remoteFilePath << "file:" << "/test" << fseq;
remoteFilePath << "file://test" << fseq;
remoteFilePaths.push_back(remoteFilePath.str());
// Create the entry in the remote namespace (same user id of the requester)
......
......@@ -132,7 +132,7 @@ namespace unitTests{
FakeTapeWriteTask ftwt;
ftwt.pushDataBlock(new MemBlock(1,blockSize));
castor::tape::tapeserver::daemon::DiskReadTask drt(ftwt,&file,blockNeeded,flag);
DiskFileFactory fileFactory("RFIO","",0);
DiskFileFactory fileFactory("RFIO","");
castor::messages::TapeserverProxyDummy tspd;
MockMigrationWatchDog mmwd(1.0, 1.0, tspd, "", lc);
drt.execute(lc,fileFactory,mmwd);
......
......@@ -39,9 +39,8 @@ namespace daemon {
DiskReadThreadPool::DiskReadThreadPool(int nbThread, uint64_t maxFilesReq,uint64_t maxBytesReq,
castor::tape::tapeserver::daemon::MigrationWatchDog & migrationWatchDog,
castor::log::LogContext lc, const std::string & remoteFileProtocol,
const std::string & xrootPrivateKeyPath,
uint16_t moverHandlerPort) :
m_diskFileFactory(remoteFileProtocol, xrootPrivateKeyPath, moverHandlerPort),
const std::string & xrootPrivateKeyPath) :
m_diskFileFactory(remoteFileProtocol, xrootPrivateKeyPath),
m_watchdog(migrationWatchDog),
m_lc(lc),m_maxFilesReq(maxFilesReq),
m_maxBytesReq(maxBytesReq), m_nbActiveThread(0) {
......
......@@ -54,7 +54,7 @@ public:
DiskReadThreadPool(int nbThread, uint64_t maxFilesReq,uint64_t maxBytesReq,
castor::tape::tapeserver::daemon::MigrationWatchDog & migrationWatchDog,
castor::log::LogContext lc, const std::string & remoteFileProtocol,
const std::string & xrootPrivateKeyPath, uint16_t moverHandlerPort);
const std::string & xrootPrivateKeyPath);
/**
* Destructor.
......
Markdown is supported
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