diff --git a/CMakeLists.txt b/CMakeLists.txt index 01ba939ffc99df502d15958aa6a8e529c1816499..889a2065c659033fa5bab09434e438e6ba02bd50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ add_subdirectory(utils) add_subdirectory(objectstore) add_subdirectory(middletier) add_subdirectory(nameserver) +add_subdirectory(scheduler) add_subdirectory(tests) add_subdirectory(ctacmd) add_subdirectory(xroot_plugins) diff --git a/middletier/CMakeLists.txt b/middletier/CMakeLists.txt index 53d6ed6925df16aed8fed21cf133c556a77745f7..c34abd3f0bddaf990b75ec7808ecdef097f3b5a3 100644 --- a/middletier/CMakeLists.txt +++ b/middletier/CMakeLists.txt @@ -4,7 +4,7 @@ find_package (sqlite REQUIRED) include_directories (${SQLITE3_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}) -set (MIDDLE_TIER_COMMON_SRC_FILES +set (CTA_COMMON_SRC_FILES common/AdminHost.cpp common/AdminUser.cpp common/ArchivalFileTransfer.cpp @@ -54,8 +54,8 @@ set (MIDDLE_TIER_COMMON_SRC_FILES common/UserRequest.cpp common/VO.cpp) -add_library (ctamiddletier SHARED - ${MIDDLE_TIER_COMMON_SRC_FILES}) +add_library (ctacommon SHARED + ${CTA_COMMON_SRC_FILES}) set (MIDDLE_TIER_COMMON_UNIT_TESTS_LIB_SRC_FILES sharedtest/MiddleTierAdminAbstractTest.cpp diff --git a/middletier/common/ArchiveToDirRequest.cpp b/middletier/common/ArchiveToDirRequest.cpp index 6b7585d07aa05f936d5f221ead293079bedf75ec..4318e4cddcfd42ec31bf928ab5ad2b78e8ac7c64 100644 --- a/middletier/common/ArchiveToDirRequest.cpp +++ b/middletier/common/ArchiveToDirRequest.cpp @@ -21,19 +21,19 @@ //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::ArchiveToDirRquest::ArchiveToDirRquest() { +cta::ArchiveToDirRequest::ArchiveToDirRequest() { } //------------------------------------------------------------------------------ // destructor //------------------------------------------------------------------------------ -cta::ArchiveToDirRquest::~ArchiveToDirRquest() throw() { +cta::ArchiveToDirRequest::~ArchiveToDirRequest() throw() { } //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::ArchiveToDirRquest::ArchiveToDirRquest( +cta::ArchiveToDirRequest::ArchiveToDirRequest( const std::string &archiveDir, const std::string &storageClassName, const std::string &id, @@ -47,7 +47,7 @@ cta::ArchiveToDirRquest::ArchiveToDirRquest( //------------------------------------------------------------------------------ // getArchiveToFileRequests //------------------------------------------------------------------------------ -const std::list<cta::ArchiveToFileRequest> &cta::ArchiveToDirRquest:: +const std::list<cta::ArchiveToFileRequest> &cta::ArchiveToDirRequest:: getArchiveToFileRequests() const throw() { return m_archiveToFileRequests; } @@ -55,7 +55,7 @@ const std::list<cta::ArchiveToFileRequest> &cta::ArchiveToDirRquest:: //------------------------------------------------------------------------------ // getArchiveToFileRequests //------------------------------------------------------------------------------ -std::list<cta::ArchiveToFileRequest> &cta::ArchiveToDirRquest:: +std::list<cta::ArchiveToFileRequest> &cta::ArchiveToDirRequest:: getArchiveToFileRequests() throw() { return m_archiveToFileRequests; } diff --git a/middletier/common/ArchiveToDirRequest.hpp b/middletier/common/ArchiveToDirRequest.hpp index b9d67680bacdf84aa7692b64c6aaa3a39e9907b8..6119e654b5fa2d317a60b4ebb7d1cb94408e462f 100644 --- a/middletier/common/ArchiveToDirRequest.hpp +++ b/middletier/common/ArchiveToDirRequest.hpp @@ -30,18 +30,18 @@ namespace cta { * Class representing a user request to archive one or more remote files to an * archive directory. */ -class ArchiveToDirRquest: public ArchivalRequest { +class ArchiveToDirRequest: public ArchivalRequest { public: /** * Constructor. */ - ArchiveToDirRquest(); + ArchiveToDirRequest(); /** * Destructor. */ - ~ArchiveToDirRquest() throw(); + ~ArchiveToDirRequest() throw(); /** * Constructor. @@ -54,7 +54,7 @@ public: * @param creationTime Optionally the absolute time at which the user request * was created. If no value is given then the current time is used. */ - ArchiveToDirRquest( + ArchiveToDirRequest( const std::string &archiveDir, const std::string &storageClassName, const std::string &id, @@ -101,6 +101,6 @@ private: */ std::list<ArchiveToFileRequest> m_archiveToFileRequests; -}; // class ArchiveToDirRquest +}; // class ArchiveToDirRequest } // namespace cta diff --git a/scheduler/CMakeLists.txt b/scheduler/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e16bf4b392bf0e614523dbbdfff635fb294911dd --- /dev/null +++ b/scheduler/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.6) + +add_library (ctascheduler SHARED + Scheduler.cpp) + +target_link_libraries(ctascheduler + ctacommon) diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..55fc606bf0dcb76a0c50f526e8c57f3681a3dbf7 --- /dev/null +++ b/scheduler/Scheduler.cpp @@ -0,0 +1,25 @@ +/* + * 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 "scheduler/Scheduler.hpp" + +//------------------------------------------------------------------------------ +// destructor +//------------------------------------------------------------------------------ +cta::Scheduler::~Scheduler() throw() { +} diff --git a/scheduler/Scheduler.hpp b/scheduler/Scheduler.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5fd5127fbc0cd32573e680551124f1896e116f35 --- /dev/null +++ b/scheduler/Scheduler.hpp @@ -0,0 +1,151 @@ +/* + * 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 <list> +#include <map> +#include <string> + +namespace cta { + +// Forward declarations for opaque references. +class ArchivalJob; +class ArchiveToDirRequest; +class ArchiveToFileRequest; +class RetrievalJob; +class RetrieveToDirRequest; +class RetrieveToFileRequest; +class SecurityIdentity; +class Tape; +class TapePool; +class NameServer; + +/** + * Abstract class defining the interface to a tape resource scheduler. + */ +class Scheduler { +public: + + /** + * Destructor. + */ + virtual ~Scheduler() throw() = 0; + + /** + * Queues the specified request. + * + * @param rqst The request to be queued. + */ + virtual void queue(const ArchiveToDirRequest &rqst) = 0; + + /** + * Queues the specified request. + * + * @param rqst The request to be queued. + */ + virtual void queue(const ArchiveToFileRequest &rqst) = 0; + + /** + * Returns all of the existing archival jobs grouped by tape pool and then + * sorted by creation time in ascending order (oldest first). + * + * @param requester The identity of the user requesting the list. + * @return All of the existing archival jobs grouped by tape pool and then + * sorted by creation time in ascending order (oldest first). + */ + virtual std::map<TapePool, std::list<ArchivalJob> > getArchivalJobs( + const SecurityIdentity &requester) const = 0; + + /** + * Returns the list of archival jobs associated with the specified tape pool + * sorted by creation time in ascending order (oldest first). + * + * @param requester The identity of the user requesting the list. + * @param tapePoolName The name of the tape pool. + * @return The list of archival jobs associated with the specified tape pool + * sorted by creation time in ascending order (oldest first). + */ + virtual std::list<ArchivalJob> getArchivalJobs( + const SecurityIdentity &requester, + const std::string &tapePoolName) const = 0; + + /** + * Deletes the specified archival job. + * + * @param requester The identity of the user requesting the deletion of the + * tape. + * @param dstPath The absolute path of the destination file within the + * archive namespace. + */ + virtual void deleteArchivalJob( + const SecurityIdentity &requester, + const std::string &dstPath) = 0; + + /** + * Queues the specified request. + * + * @param rqst The request to be queued. + */ + virtual void queue(RetrieveToDirRequest &rqst) = 0; + + /** + * Queues the specified request. + * + * @param rqst The request to be queued. + */ + virtual void queue(RetrieveToFileRequest &rqst) = 0; + + /** + * Returns all of the existing retrieval jobs grouped by tape and then + * sorted by creation time in ascending order (oldest first). + * + * @param requester The identity of the user requesting the list. + * @return All of the existing retrieval jobs grouped by tape and then + * sorted by creation time in ascending order (oldest first). + */ + virtual std::map<Tape, std::list<RetrievalJob> > getRetrievalJobs( + const SecurityIdentity &requester) const = 0; + + /** + * Returns the list of retrieval jobs associated with the specified tape + * sorted by creation time in ascending order (oldest first). + * + * @param requester The identity of the user requesting the list. + * @param vid The volume identifier of the tape. + * @return The list of retrieval jobs associated with the specified tape + * sorted by creation time in ascending order (oldest first). + */ + virtual std::list<RetrievalJob> getRetrievalJobs( + const SecurityIdentity &requester, + const std::string &vid) const = 0; + + /** + * Deletes the specified retrieval job. + * + * @param requester The identity of the user requesting the deletion of the + * tape. + * @param dstUrl The URL of the destination file or directory. + */ + virtual void deleteRetrievalJob( + const SecurityIdentity &requester, + const std::string &dstUrl) = 0; + +}; // class Scheduler + +} // namespace cta diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 10fb505b032f9dcb82bdb7125684016de645540f..5cdd308a1178b57fa6546e7033e42a8f8cece94a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,11 +8,11 @@ add_executable(unittests unit_tests.cpp) target_link_libraries(unittests + ctacommon ctautils ctautilsunittests CTAObjectStore ctaobjectstoreunittests - ctamiddletier ctamiddletierunittests ctamiddletiersqlite ctamiddletiersqliteunittests diff --git a/xroot_plugins/CMakeLists.txt b/xroot_plugins/CMakeLists.txt index 27db9fbb4979715f05b0f7c58a59f0bd3e3bccfa..0d2720f7a7016eed2c7018e0d8eb77d5806c3a25 100644 --- a/xroot_plugins/CMakeLists.txt +++ b/xroot_plugins/CMakeLists.txt @@ -7,4 +7,4 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../middletier) include_directories (${XROOTD_INCLUDE_DIR} ${XROOTD_PRIVATE_INCLUDE_DIR}) add_library (XrdProFst MODULE XrdProFilesystem.cpp XrdProFile.cpp XrdProDir.cpp ParsedRequest.cpp) -target_link_libraries (XrdProFst ctamiddletier) +target_link_libraries (XrdProFst ctacommon)