Commit 467902f8 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Using the OSDB for the xrootd server plugin

parent be7ed427
......@@ -132,10 +132,13 @@ void cta::CastorNameServer::clearDirStorageClass(
char no_class[]="NO_CLASS";
struct Cns_fileclass fc;
bzero(&fc, sizeof(struct Cns_fileclass));
strncpy(fc.name, no_class, CA_MAXCLASNAMELEN);
fc.nbcopies = 0;
fc.classid = time(NULL)%10000; //should be 5 digits allowed but it actually works only if you provide 4 digits... go figure!
Cns_enterclass(const_cast<char *>(m_server.c_str()), &fc); //we don't care if this fails: the class might already exist
if(Cns_queryclass(const_cast<char *>(m_server.c_str()), 0, no_class, &fc)) {
bzero(&fc, sizeof(struct Cns_fileclass));
strncpy(fc.name, no_class, CA_MAXCLASNAMELEN);
fc.nbcopies = 0;
fc.classid = 1;
exception::Errnum::throwOnMinusOne(Cns_enterclass(const_cast<char *>(m_server.c_str()), &fc), std::string(__FUNCTION__) + " - Cns_enterclass");
}
cta::exception::Errnum::throwOnMinusOne(Cns_chclass(path.c_str(), 0, no_class), __FUNCTION__);
}
......
......@@ -11,7 +11,7 @@ set (CTAProtoFiles
PROTOBUF_GENERATE_CPP(CTAProtoSources CTAProtoHeaders ${CTAProtoFiles})
add_library (CTAObjectStore SHARED
add_library (CTAObjectStore
${CTAProtoSources}
RootEntry.cpp
Agent.cpp
......@@ -39,4 +39,4 @@ set(ObjectStoreUnitTests
add_library(ctaobjectstoreunittests SHARED ${ObjectStoreUnitTests})
target_link_libraries(ctaobjectstoreunittests
protobuf rados ctacommon gtest gmock)
protobuf rados ctacommon gtest gmock CTAObjectStore)
......@@ -63,6 +63,9 @@ include_directories(${CMAKE_BINARY_DIR})
add_library(ctaOStoreSchedulerDB SHARED
OStoreDB/OStoreDB.cpp)
target_link_libraries(ctaOStoreSchedulerDB
CTAObjectStore)
target_link_libraries(ctaschedulertest
ctascheduler
ctaOStoreSchedulerDB)
......@@ -2,8 +2,9 @@ cmake_minimum_required (VERSION 2.6)
list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package (xrootd REQUIRED)
include_directories (${CMAKE_SOURCE_DIR})
include_directories (${XROOTD_INCLUDE_DIR} ${XROOTD_PRIVATE_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${XROOTD_INCLUDE_DIR} ${XROOTD_PRIVATE_INCLUDE_DIR})
include_directories(${CMAKE_BINARY_DIR})
add_library (XrdProFst MODULE XrdProFilesystem.cpp XrdProFile.cpp)
target_link_libraries (XrdProFst ctascheduler ctacommon ctanameserver ctaremotens)
target_link_libraries (XrdProFst ctascheduler ctacommon ctanameserver ctaremotens ctaOStoreSchedulerDB protobuf CTAObjectStore)
......@@ -26,6 +26,7 @@
#include "scheduler/ArchivalRoute.hpp"
#include "scheduler/ArchiveToTapeCopyRequest.hpp"
#include "scheduler/LogicalLibrary.hpp"
#include "scheduler/OStoreDB/OStoreDB.hpp"
#include "scheduler/MockSchedulerDatabase.hpp"
#include "scheduler/RetrieveFromTapeCopyRequest.hpp"
#include "scheduler/StorageClass.hpp"
......@@ -37,6 +38,8 @@
#include "XrdOuc/XrdOucString.hh"
#include "XrdSec/XrdSecEntity.hh"
#include "XrdVersion.hh"
#include "objectstore/BackendVFS.hpp"
#include "objectstore/RootEntry.hpp"
#include <memory>
#include <iostream>
......@@ -46,13 +49,61 @@
XrdVERSIONINFO(XrdSfsGetFileSystem,XrdPro)
cta::objectstore::BackendVFS g_backend;
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);
re.initialize();
re.insert();
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());
extern "C"
{
XrdSfsFileSystem *XrdSfsGetFileSystem (XrdSfsFileSystem* native_fs, XrdSysLogger* lp, const char* configfn)
{
return new XrdProFilesystem(
new cta::CastorNameServer(),
new cta::MockSchedulerDatabase(),
& g_OStoreDB,
new cta::MockRemoteNS());
}
}
......@@ -265,6 +316,5 @@ XrdProFilesystem::XrdProFilesystem(
XrdProFilesystem::~XrdProFilesystem() {
delete m_scheduler;
delete m_ns;
delete m_scheddb;
delete m_remoteStorage;
}
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