Skip to content
Snippets Groups Projects
Commit 1298826a authored by Eric Cano's avatar Eric Cano
Browse files

Created the skeleton of the OStoreDB and created the unit test for it.

parent 4509bab1
Branches
Tags
No related merge requests found
......@@ -62,5 +62,11 @@ add_library (ctaschedulertest SHARED
SchedulerTest.cpp
UserIdentityTest.cpp)
include_directories(${CMAKE_BINARY_DIR})
add_library(ctaOStoreSchedulerDB SHARED
OStoreDB/OStoreDB.cpp
OStoreDB/OStoreDBFactory.cpp)
target_link_libraries(ctaschedulertest
ctascheduler)
ctascheduler
ctaOStoreSchedulerDB)
\ No newline at end of file
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "OStoreDB.hpp"
#include "scheduler/SecurityIdentity.hpp"
#include "objectstore/RootEntry.hpp"
#include "common/exception/Exception.hpp"
#include "scheduler/StorageClass.hpp"
namespace cta {
using namespace objectstore;
OStoreDB::OStoreDB(objectstore::Backend& be):
m_objectStore(be) {}
OStoreDB::~OStoreDB() throw() { }
void OStoreDB::createAdminHost(const SecurityIdentity& requester,
const std::string& hostName, const std::string& comment) {
RootEntry re(m_objectStore);
CreationLog cl;
cl.uid = requester.getUser().getUid();
cl.gid = requester.getUser().getGid();
cl.hostname = requester.getHost();
cl.comment = comment;
cl.time = time(NULL);
ScopedExclusiveLock rel(re);
re.fetch();
re.addAdminHost(hostName, cl);
re.commit();
}
std::list<AdminHost> OStoreDB::getAdminHosts() const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::deleteAdminHost(const SecurityIdentity& requester,
const std::string& hostName) {
RootEntry re(m_objectStore);
ScopedExclusiveLock rel(re);
re.fetch();
re.removeAdminHost(hostName);
re.commit();
}
void OStoreDB::createAdminUser(const SecurityIdentity& requester,
const cta::UserIdentity& user, const std::string& comment) {
throw exception::Exception("Not Implemented");
}
void OStoreDB::deleteAdminUser(const SecurityIdentity& requester,
const cta::UserIdentity& user) {
throw exception::Exception("Not Implemented");
}
std::list<AdminUser> OStoreDB::getAdminUsers() const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::assertIsAdminOnAdminHost(const SecurityIdentity& id) const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::createStorageClass(const SecurityIdentity& requester,
const std::string& name, const uint16_t nbCopies, const std::string& comment) {
throw exception::Exception("Not Implemented");
}
StorageClass OStoreDB::getStorageClass(const std::string& name) const {
throw exception::Exception("Not Implemented");
}
std::list<StorageClass> OStoreDB::getStorageClasses() const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::deleteStorageClass(const SecurityIdentity& requester,
const std::string& name) {
throw exception::Exception("Not Implemented");
}
void OStoreDB::createArchivalRoute(const SecurityIdentity& requester,
const std::string& storageClassName, const uint16_t copyNb,
const std::string& tapePoolName, const std::string& comment) {
throw exception::Exception("Not Implemented");
}
std::list<ArchivalRoute>
OStoreDB::getArchivalRoutes(const std::string& storageClassName) const {
throw exception::Exception("Not Implemented");
}
std::list<ArchivalRoute> OStoreDB::getArchivalRoutes() const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::deleteArchivalRoute(const SecurityIdentity& requester,
const std::string& storageClassName, const uint16_t copyNb) {
throw exception::Exception("Not Implemented");
}
void OStoreDB::createTapePool(const SecurityIdentity& requester,
const std::string& name, const uint32_t nbPartialTapes,
const std::string& comment) {
throw exception::Exception("Not Implemented");
}
std::list<TapePool> OStoreDB::getTapePools() const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::deleteTapePool(const SecurityIdentity& requester,
const std::string& name) {
throw exception::Exception("Not Implemented");
}
void OStoreDB::createTape(const SecurityIdentity& requester,
const std::string& vid, const std::string& logicalLibraryName,
const std::string& tapePoolName, const uint64_t capacityInBytes,
const std::string& comment) {
throw exception::Exception("Not Implemented");
}
std::list<Tape> OStoreDB::getTapes() const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::deleteTape(const SecurityIdentity& requester,
const std::string& vid) {
throw exception::Exception("Not Implemented");
}
void OStoreDB::createLogicalLibrary(const SecurityIdentity& requester,
const std::string& name, const std::string& comment) {
throw exception::Exception("Not Implemented");
}
std::list<LogicalLibrary> OStoreDB::getLogicalLibraries() const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::deleteLogicalLibrary(const SecurityIdentity& requester,
const std::string& name) {
throw exception::Exception("Not Implemented");
}
void OStoreDB::queue(const ArchiveToFileRequest& rqst) {
throw exception::Exception("Not Implemented");
}
void OStoreDB::queue(const ArchiveToDirRequest& rqst) {
throw exception::Exception("Not Implemented");
}
void OStoreDB::deleteArchiveToFileRequest(const SecurityIdentity& requester,
const std::string& archiveFile) {
throw exception::Exception("Not Implemented");
}
std::map<TapePool, std::list<ArchiveToTapeCopyRequest> >
OStoreDB::getArchiveRequests() const {
throw exception::Exception("Not Implemented");
}
std::list<ArchiveToTapeCopyRequest>
OStoreDB::getArchiveRequests(const std::string& tapePoolName) const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::queue(const RetrieveToFileRequest& rqst) {
throw exception::Exception("Not Implemented");
}
void OStoreDB::queue(const RetrieveToDirRequest& rqst) {
throw exception::Exception("Not Implemented");
}
std::list<RetrievalJob> OStoreDB::getRetrievalJobs(const std::string& vid) const {
throw exception::Exception("Not Implemented");
}
std::map<Tape, std::list<RetrievalJob> > OStoreDB::getRetrievalJobs() const {
throw exception::Exception("Not Implemented");
}
void OStoreDB::deleteRetrievalJob(const SecurityIdentity& requester,
const std::string& remoteFile) {
throw exception::Exception("Not Implemented");
}
}
\ No newline at end of file
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "scheduler/SchedulerDatabase.hpp"
namespace cta {
namespace objectstore {
class Backend;
}
class OStoreDB: public SchedulerDatabase {
public:
OStoreDB(objectstore::Backend & be);
virtual ~OStoreDB() throw();
/* === Admin host handling ================================================ */
virtual void createAdminHost(const SecurityIdentity& requester,
const std::string& hostName, const std::string& comment);
virtual std::list<AdminHost> getAdminHosts() const;
virtual void deleteAdminHost(const SecurityIdentity& requester,
const std::string& hostName);
/* === Admin host handling ================================================ */
virtual void createAdminUser(const SecurityIdentity& requester,
const UserIdentity& user, const std::string& comment);
virtual std::list<AdminUser> getAdminUsers() const;
virtual void deleteAdminUser(const SecurityIdentity& requester,
const UserIdentity& user);
/* === Admin access handling ============================================== */
virtual void assertIsAdminOnAdminHost(const SecurityIdentity& id) const;
/* === Storage class handling ============================================ */
virtual void createStorageClass(const SecurityIdentity& requester,
const std::string& name, const uint16_t nbCopies, const std::string& comment);
virtual StorageClass getStorageClass(const std::string& name) const;
virtual std::list<StorageClass> getStorageClasses() const;
virtual void deleteStorageClass(const SecurityIdentity& requester,
const std::string& name);
/* === Archival routes handling ========================================== */
virtual void createArchivalRoute(const SecurityIdentity& requester,
const std::string& storageClassName, const uint16_t copyNb,
const std::string& tapePoolName, const std::string& comment);
virtual std::list<ArchivalRoute> getArchivalRoutes(const std::string& storageClassName) const;
virtual std::list<ArchivalRoute> getArchivalRoutes() const;
virtual void deleteArchivalRoute(const SecurityIdentity& requester,
const std::string& storageClassName, const uint16_t copyNb);
/* === Tape pools handling =============================================== */
virtual void createTapePool(const SecurityIdentity& requester,
const std::string& name, const uint32_t nbPartialTapes,
const std::string& comment);
virtual std::list<TapePool> getTapePools() const;
virtual void deleteTapePool(const SecurityIdentity& requester, const std::string& name);
/* === Tapes handling ==================================================== */
virtual void createTape(const SecurityIdentity& requester,
const std::string& vid, const std::string& logicalLibraryName,
const std::string& tapePoolName, const uint64_t capacityInBytes,
const std::string& comment);
virtual std::list<Tape> getTapes() const;
virtual void deleteTape(const SecurityIdentity& requester, const std::string& vid);
/* === Libraries handling ================================================ */
virtual void createLogicalLibrary(const SecurityIdentity& requester,
const std::string& name, const std::string& comment);
virtual std::list<LogicalLibrary> getLogicalLibraries() const;
virtual void deleteLogicalLibrary(const SecurityIdentity& requester, const std::string& name);
/* === Archival requests handling ======================================== */
virtual void queue(const ArchiveToFileRequest& rqst);
virtual void queue(const ArchiveToDirRequest& rqst);
virtual void deleteArchiveToFileRequest(const SecurityIdentity& requester,
const std::string& archiveFile);
virtual std::map<TapePool, std::list<ArchiveToTapeCopyRequest> >
getArchiveRequests() const;
virtual std::list<ArchiveToTapeCopyRequest>
getArchiveRequests(const std::string& tapePoolName) const;
/* === Retrieve requests handling ======================================== */
virtual void queue(const RetrieveToFileRequest& rqst_);
virtual void queue(const RetrieveToDirRequest& rqst);
virtual std::list<RetrievalJob> getRetrievalJobs(const std::string& vid) const;
virtual std::map<Tape, std::list<RetrievalJob> > getRetrievalJobs() const;
virtual void deleteRetrievalJob(const SecurityIdentity& requester,
const std::string& remoteFile);
private:
objectstore::Backend & m_objectStore;
};
}
\ No newline at end of file
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "OStoreDBFactory.hpp"
#include "OStoreDB.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::
OStoreDBFactory::OStoreDBFactory(objectstore::Backend& backend):
m_backend(backend) {}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::OStoreDBFactory::~OStoreDBFactory() throw() {
}
//------------------------------------------------------------------------------
// create
//------------------------------------------------------------------------------
std::unique_ptr<cta::SchedulerDatabase> cta::OStoreDBFactory::
create() const {
return std::unique_ptr<SchedulerDatabase>(new OStoreDB(m_backend));
}
\ No newline at end of file
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "scheduler/SchedulerDatabaseFactory.hpp"
namespace cta {
namespace objectstore {
class Backend;
}
/**
* A conncret implementation of a scheduler database factory that creates mock
* scheduler database objects.
*/
class OStoreDBFactory: public SchedulerDatabaseFactory {
public:
/**
* Constructor
*/
OStoreDBFactory(objectstore::Backend & backend);
/**
* Destructor.
*/
~OStoreDBFactory() throw();
/**
* Returns a newly created scheduler database object.
*
* @return A newly created scheduler database object.
*/
std::unique_ptr<SchedulerDatabase> create() const;
private:
/**
* Reference to the backend store.
*/
objectstore::Backend & m_backend;
}; // class MockSchedulerDatabaseFactory
} // namespace cta
\ No newline at end of file
......@@ -26,6 +26,9 @@
#include "scheduler/SecurityIdentity.hpp"
#include "scheduler/UserIdentity.hpp"
#include "objectstore/BackendVFS.hpp"
#include "OStoreDB/OStoreDBFactory.hpp"
#include <exception>
#include <gtest/gtest.h>
......@@ -379,4 +382,10 @@ static cta::MockSchedulerDatabaseFactory mockDbFactory;
INSTANTIATE_TEST_CASE_P(MockSchedulerDatabaseTest, SchedulerDatabaseTest,
::testing::Values(SchedulerDatabaseTestParam(mockDbFactory)));
static cta::objectstore::BackendVFS be;
static cta::OStoreDBFactory OStoreDBFactory(be);
INSTANTIATE_TEST_CASE_P(OStoreSchedulerDatabaseTest, SchedulerDatabaseTest,
::testing::Values(SchedulerDatabaseTestParam(OStoreDBFactory)));
} // namespace unitTests
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment