Commit 3c603051 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Removed classes nested in functions, added debug information when no new mount is available

parent 3e1289a1
......@@ -74,7 +74,7 @@ add_library(castorTapeServerDaemon
TpconfigLine.cpp
TpconfigLines.cpp)
target_link_libraries(castorTapeServerDaemon castormessages castortapereactor ctacommon ctanameserver ctaremotens ctaOStoreSchedulerDB protobuf CTAObjectStore ctascheduler)
target_link_libraries(castorTapeServerDaemon castormessages castortapereactor ctacommon ctanameserver ctaremotens ctaOStoreSchedulerDB protobuf CTAObjectStore ctascheduler XrdCtaOfs)
add_dependencies(castorTapeServerDaemon castormessagesprotobuf)
add_executable(tapeserverd TapeDaemon.cpp)
......
......@@ -97,8 +97,10 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
return MARK_DRIVE_AS_DOWN;
}
// No mount to be done found, that was fast...
if (!tapeMount.get())
if (!tapeMount.get()) {
lc.log(LOG_INFO, "No new mount found!");
return MARK_DRIVE_AS_UP;
}
m_volInfo.vid=tapeMount->getVid();
m_volInfo.mountType=tapeMount->getMountType();
m_volInfo.nbFiles=tapeMount->getNbFiles();
......
......@@ -54,8 +54,9 @@
#include "scheduler/OStoreDB/OStoreDB.hpp"
#include "scheduler/Scheduler.hpp"
#include "serrno.h"
#include "nameserver/mockNS/MockNameServer.hpp"
#include "xroot_plugins/BackendPopulator.hpp"
#include "xroot_plugins/OStoreDBWithAgent.hpp"
#include <errno.h>
#include <memory>
......@@ -555,60 +556,13 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
messages::TapeserverProxyZmq tapeserver(m_log, m_config.internalPort,
zmqContext.get());
/************BEGIN: boilerplate code to prepare the objectstoreDB object**************/
cta::objectstore::BackendVFS g_backend(m_config.objectStoreBackendPath);
// Make sure we will not delete the contents of objectstore when deleting the object
g_backend.noDeleteOnExit();
class BackendPopulator {
public:
BackendPopulator(cta::objectstore::Backend & be): m_backend(be),
m_agent(m_backend) {
// We need to populate the root entry before using.
cta::objectstore::RootEntry re(m_backend);
cta::objectstore::ScopedExclusiveLock rel(re);
re.fetch();
m_agent.generateName("OStoreDBFactory");
m_agent.initialize();
cta::objectstore::CreationLog cl(cta::UserIdentity(1111, 1111), "systemhost",
time(NULL), "Initial creation of the object store structures");
re.addOrGetAgentRegisterPointerAndCommit(m_agent,cl);
rel.release();
m_agent.insertAndRegisterSelf();
rel.lock(re);
re.addOrGetDriveRegisterPointerAndCommit(m_agent, cl);
rel.release();
}
virtual ~BackendPopulator() throw() {
cta::objectstore::ScopedExclusiveLock agl(m_agent);
m_agent.fetch();
m_agent.removeAndUnregisterSelf();
}
cta::objectstore::Agent & getAgent() { return m_agent; }
private:
cta::objectstore::Backend & m_backend;
cta::objectstore::Agent m_agent;
} g_backendPopulator(g_backend);
class OStoreDBWithAgent: public cta::OStoreDB {
public:
OStoreDBWithAgent(cta::objectstore::Backend & be, cta::objectstore::Agent & ag):
cta::OStoreDB(be) {
cta::OStoreDB::setAgent(ag);
}
virtual ~OStoreDBWithAgent() throw () {
cta::OStoreDB::setAgent(*((cta::objectstore::Agent *)NULL));
}
} g_OStoreDB(g_backend, g_backendPopulator.getAgent());
/************END: boilerplate code to prepare the objectstoreDB object**************/
cta::EosNS eosNs("localhost:1094");
cta::CastorNameServer castorNs;
cta::MockNameServer mockNs(castor::common::CastorConfiguration::getConfig().getConfEntString("TapeServer", "MockNameServerPath"));
cta::objectstore::BackendVFS backend(castor::common::CastorConfiguration::getConfig().getConfEntString("TapeServer", "ObjectStoreBackendPath"));
BackendPopulator backendPopulator(backend);
OStoreDBWithAgent osdb(backend, backendPopulator.getAgent());
cta::Scheduler scheduler(castorNs, g_OStoreDB, eosNs);
cta::Scheduler scheduler(mockNs, osdb, eosNs);
castor::tape::System::realWrapper sysWrapper;
......
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