diff --git a/catalogue/Catalogue.hpp b/catalogue/Catalogue.hpp index 1a2b318f394c3a4b2595605b711540ddd4bcf661..31092e8225978c4b4eadf04d37d094681226e16d 100644 --- a/catalogue/Catalogue.hpp +++ b/catalogue/Catalogue.hpp @@ -351,6 +351,14 @@ public: * @return All tape media types. */ virtual std::list<MediaTypeWithLogs> getMediaTypes() const = 0; + + /** + * Return the media type associated to the tape corresponding to the + * vid passed in parameter + * @param vid the vid of the tape to return its media type + * @return the media type associated to the tape corresponding to the vid passed in parameter + */ + virtual MediaType getMediaTypeByVid(const std::string & vid) const = 0; /** * Modifies the name of the specified tape media type. diff --git a/catalogue/CatalogueRetryWrapper.hpp b/catalogue/CatalogueRetryWrapper.hpp index 88b9ea224aeb1f9ecb3c968c07e80c376d864720..aad203d5a26a7add525e2e0f3abd2108605ed8bb 100644 --- a/catalogue/CatalogueRetryWrapper.hpp +++ b/catalogue/CatalogueRetryWrapper.hpp @@ -175,6 +175,10 @@ public: std::list<MediaTypeWithLogs> getMediaTypes() const override { return retryOnLostConnection(m_log, [&]{return m_catalogue->getMediaTypes();}, m_maxTriesToConnect); } + + MediaType getMediaTypeByVid(const std::string & vid) const override { + return retryOnLostConnection(m_log,[&]{return m_catalogue->getMediaTypeByVid(vid);}, m_maxTriesToConnect); + } void modifyMediaTypeName(const common::dataStructures::SecurityIdentity &admin, const std::string ¤tName, const std::string &newName) override { return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyMediaTypeName(admin, currentName, newName);}, m_maxTriesToConnect); diff --git a/catalogue/CatalogueTest.cpp b/catalogue/CatalogueTest.cpp index 70e555b94e0e8b515a843f2932cc3f60f1938b2f..9b95b84b1d5ded2e133b49b4010b1bac67dc8cbd 100644 --- a/catalogue/CatalogueTest.cpp +++ b/catalogue/CatalogueTest.cpp @@ -1682,6 +1682,42 @@ TEST_P(cta_catalogue_CatalogueTest, modifyMediaTypeComment_nonExistentMediaType) ASSERT_THROW(m_catalogue->modifyMediaTypeComment(m_admin, name, comment), exception::UserError); } +TEST_P(cta_catalogue_CatalogueTest, getMediaTypeByVid_nonExistentTape) { + using namespace cta; + + ASSERT_THROW(m_catalogue->getMediaTypeByVid("DOES_NOT_EXIST"),exception::Exception); +} + +TEST_P(cta_catalogue_CatalogueTest, getMediaTypeByVid) { + using namespace cta; + + using namespace cta; + + const bool logicalLibraryIsDisabled= false; + const uint64_t nbPartialTapes = 2; + const bool isEncrypted = true; + const cta::optional<std::string> supply("value for the supply pool mechanism"); + + m_catalogue->createMediaType(m_admin, m_mediaType); + + m_catalogue->createLogicalLibrary(m_admin, m_tape1.logicalLibraryName, logicalLibraryIsDisabled, "Create logical library"); + m_catalogue->createVirtualOrganization(m_admin, m_vo); + m_catalogue->createTapePool(m_admin, m_tape1.tapePoolName, m_vo.name, nbPartialTapes, isEncrypted, supply, "Create tape pool"); + + m_catalogue->createTape(m_admin, m_tape1); + + auto tapeMediaType = m_catalogue->getMediaTypeByVid(m_tape1.vid); + ASSERT_EQ(m_mediaType.name, tapeMediaType.name); + ASSERT_EQ(m_mediaType.capacityInBytes, tapeMediaType.capacityInBytes); + ASSERT_EQ(m_mediaType.cartridge, tapeMediaType.cartridge); + ASSERT_EQ(m_mediaType.comment, tapeMediaType.comment); + ASSERT_EQ(m_mediaType.maxLPos, tapeMediaType.maxLPos); + ASSERT_EQ(m_mediaType.minLPos, tapeMediaType.minLPos); + ASSERT_EQ(m_mediaType.nbWraps, tapeMediaType.nbWraps); + ASSERT_EQ(m_mediaType.primaryDensityCode, tapeMediaType.primaryDensityCode); + ASSERT_EQ(m_mediaType.secondaryDensityCode, tapeMediaType.secondaryDensityCode); +} + TEST_P(cta_catalogue_CatalogueTest, createTapePool) { using namespace cta; diff --git a/catalogue/DummyCatalogue.hpp b/catalogue/DummyCatalogue.hpp index 9181da969c047c8e1bc60abcada5947ae32f83f4..5a0d645d356726b1294fcab70b1702afabb55d5d 100644 --- a/catalogue/DummyCatalogue.hpp +++ b/catalogue/DummyCatalogue.hpp @@ -46,6 +46,7 @@ public: void createMediaType(const common::dataStructures::SecurityIdentity &admin, const MediaType &mediaType) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteMediaType(const std::string &name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } std::list<MediaTypeWithLogs> getMediaTypes() const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + MediaType getMediaTypeByVid(const std::string & vid) const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyMediaTypeName(const common::dataStructures::SecurityIdentity &admin, const std::string ¤tName, const std::string &newName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyMediaTypeCartridge(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &cartridge) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyMediaTypeCapacityInBytes(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t capacityInBytes) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index 68256cf6a82053f17d996532d867ccba8b90d528..92a160cd422b0ddd5a42e12db9780f2583784fdd 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -1263,6 +1263,56 @@ std::list<MediaTypeWithLogs> RdbmsCatalogue::getMediaTypes() const { } } +MediaType RdbmsCatalogue::getMediaTypeByVid(const std::string& vid) const { + try { + std::list<MediaTypeWithLogs> mediaTypes; + const char *const sql = + "SELECT" "\n" + "MEDIA_TYPE_NAME AS MEDIA_TYPE_NAME," "\n" + "CARTRIDGE AS CARTRIDGE," "\n" + "CAPACITY_IN_BYTES AS CAPACITY_IN_BYTES," "\n" + "PRIMARY_DENSITY_CODE AS PRIMARY_DENSITY_CODE," "\n" + "SECONDARY_DENSITY_CODE AS SECONDARY_DENSITY_CODE," "\n" + "NB_WRAPS AS NB_WRAPS," "\n" + "MIN_LPOS AS MIN_LPOS," "\n" + "MAX_LPOS AS MAX_LPOS," "\n" + + "MEDIA_TYPE.USER_COMMENT AS USER_COMMENT " "\n" + "FROM" "\n" + "MEDIA_TYPE " "\n" + "INNER JOIN TAPE " "\n" + "ON MEDIA_TYPE.MEDIA_TYPE_ID = TAPE.MEDIA_TYPE_ID " "\n" + "WHERE " "\n" + "TAPE.VID = :VID" "\n"; + auto conn = m_connPool.getConn(); + auto stmt = conn.createStmt(sql); + stmt.bindString(":VID",vid); + auto rset = stmt.executeQuery(); + if(rset.next()){ + MediaType mediaType; + + mediaType.name = rset.columnString("MEDIA_TYPE_NAME"); + mediaType.cartridge = rset.columnString("CARTRIDGE"); + mediaType.capacityInBytes = rset.columnUint64("CAPACITY_IN_BYTES"); + mediaType.primaryDensityCode = rset.columnOptionalUint8("PRIMARY_DENSITY_CODE"); + mediaType.secondaryDensityCode = rset.columnOptionalUint8("SECONDARY_DENSITY_CODE"); + mediaType.nbWraps = rset.columnOptionalUint32("NB_WRAPS"); + mediaType.minLPos = rset.columnOptionalUint64("MIN_LPOS"); + mediaType.maxLPos = rset.columnOptionalUint64("MAX_LPOS"); + mediaType.comment = rset.columnString("USER_COMMENT"); + + return mediaType; + } else { + throw exception::Exception("The tape vid "+vid+" does not exist."); + } + } catch(exception::UserError &) { + throw; + } catch(exception::Exception &ex) { + ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str()); + throw; + } +} + //------------------------------------------------------------------------------ // modifyMediaTypeName //------------------------------------------------------------------------------ diff --git a/catalogue/RdbmsCatalogue.hpp b/catalogue/RdbmsCatalogue.hpp index ae52186670123becb64e868fddd966b4036f8599..67f2c7fe959a4e24272a10f2598c269f511580f5 100644 --- a/catalogue/RdbmsCatalogue.hpp +++ b/catalogue/RdbmsCatalogue.hpp @@ -302,6 +302,15 @@ public: * @return All tape media types. */ std::list<MediaTypeWithLogs> getMediaTypes() const override; + + /** + * Return the media type associated to the tape corresponding to the + * vid passed in parameter + * + * @param vid the vid of the tape to return its media type + * @return the media type associated to the tape corresponding to the vid passed in parameter + */ + MediaType getMediaTypeByVid(const std::string & vid) const override; /** * Modifies the name of the specified tape media type. diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index d5ba1440f6f4c7649cc12a56c6331bd14d5f0c21..49677460d82de96ee1ab95614e85967185a474bf 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -1940,4 +1940,8 @@ reportRetrieveJobsBatch(std::list<std::unique_ptr<RetrieveJob>> & retrieveJobsBa lc.log(log::ERR, "In Scheduler::reportRetrieveJobsBatch(): reported a batch of retrieve jobs."); } +cta::catalogue::Catalogue & Scheduler::getCatalogue(){ + return m_catalogue; +} + } // namespace cta diff --git a/scheduler/Scheduler.hpp b/scheduler/Scheduler.hpp index ecac5fdf64f1f0ef3ddc0d747ab9c76d919b736f..252a04b143fe8700bcefa76af7f45274680a54ad 100644 --- a/scheduler/Scheduler.hpp +++ b/scheduler/Scheduler.hpp @@ -438,6 +438,8 @@ public: double getRepackRequestExpansionTimeLimit() const; + cta::catalogue::Catalogue & getCatalogue(); + private: /** diff --git a/tapeserver/castor/tape/tapeserver/RAO/CMakeLists.txt b/tapeserver/castor/tape/tapeserver/RAO/CMakeLists.txt index 152ce09ee0fe42975106778b77ca1ebde226679c..5463a8d6984f291a13cda98b8417dc102a5364ff 100644 --- a/tapeserver/castor/tape/tapeserver/RAO/CMakeLists.txt +++ b/tapeserver/castor/tape/tapeserver/RAO/CMakeLists.txt @@ -4,7 +4,7 @@ include_directories(${PROJECT_SOURCE_DIR}/tapeserver) include_directories(${PROJECT_SOURCE_DIR}/tapeserver/h) set(CTARAO_LIBRARY_SRCS - RAOConfig.cpp + RAOConfigurationData.cpp RAOManager.cpp RAOAlgorithm.cpp EnterpriseRAOAlgorithm.cpp @@ -12,8 +12,16 @@ set(CTARAO_LIBRARY_SRCS EnterpriseRAOAlgorithmFactory.cpp LinearRAOAlgorithm.cpp RandomRAOAlgorithm.cpp - NoParamRAOAlgorithmFactory.cpp + NonConfigurableRAOAlgorithmFactory.cpp + ConfigurableRAOAlgorithmFactory.cpp RAOAlgorithmFactoryFactory.cpp + SLTFRAOAlgorithm.cpp + RAOOptions.cpp + CostHeuristic.cpp + FilePosition.cpp + Position.cpp + FilePositionEstimator.cpp + InterpolationFilePositionEstimator.cpp ) add_library (ctarao SHARED diff --git a/tapeserver/castor/tape/tapeserver/RAO/ConfigurableRAOAlgorithmFactory.cpp b/tapeserver/castor/tape/tapeserver/RAO/ConfigurableRAOAlgorithmFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..669949618e92a408bd00de2fb204bb9f4e0b59e6 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/ConfigurableRAOAlgorithmFactory.cpp @@ -0,0 +1,47 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "ConfigurableRAOAlgorithmFactory.hpp" +#include "SLTFRAOAlgorithm.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +ConfigurableRAOAlgorithmFactory::ConfigurableRAOAlgorithmFactory(drive::DriveInterface * drive, cta::catalogue::Catalogue * catalogue, const RAOConfigurationData & raoConfigurationData):m_drive(drive), + m_catalogue(catalogue), m_raoConfigurationData(raoConfigurationData){} + +ConfigurableRAOAlgorithmFactory::~ConfigurableRAOAlgorithmFactory() { +} + +std::unique_ptr<RAOAlgorithm> ConfigurableRAOAlgorithmFactory::createRAOAlgorithm() { + std::unique_ptr<RAOAlgorithm> ret; + switch(m_raoConfigurationData.getAlgorithmType()){ + case RAOConfigurationData::RAOAlgorithmType::sltf:{ + SLTFRAOAlgorithm::Builder builder(m_raoConfigurationData,m_drive,m_catalogue); + ret.reset(builder.build().release()); + break; + } + default: + throw cta::exception::Exception("Unknown type of ConfigurableRAOAlgorithm. Existing types are : sltf"); + break; + } + return ret; +} + + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/ConfigurableRAOAlgorithmFactory.hpp b/tapeserver/castor/tape/tapeserver/RAO/ConfigurableRAOAlgorithmFactory.hpp new file mode 100644 index 0000000000000000000000000000000000000000..468832337cacc82def074f59cd90de5d288a436c --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/ConfigurableRAOAlgorithmFactory.hpp @@ -0,0 +1,40 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "RAOConfigurationData.hpp" +#include "RAOAlgorithmFactory.hpp" +#include "castor/tape/tapeserver/drive/DriveInterface.hpp" +#include "RAOManager.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +class ConfigurableRAOAlgorithmFactory : public RAOAlgorithmFactory{ +public: + ConfigurableRAOAlgorithmFactory(drive::DriveInterface * drive, cta::catalogue::Catalogue * catalogue, const RAOConfigurationData & raoConfigurationData); + std::unique_ptr<RAOAlgorithm> createRAOAlgorithm() override; + virtual ~ConfigurableRAOAlgorithmFactory(); +private: + drive::DriveInterface * m_drive; + cta::catalogue::Catalogue * m_catalogue; + RAOConfigurationData m_raoConfigurationData; +}; + +}}}} + diff --git a/tapeserver/castor/tape/tapeserver/RAO/CostHeuristic.cpp b/tapeserver/castor/tape/tapeserver/RAO/CostHeuristic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7eb5bbff4aca5750089255a8d3b9bb8df8e5c3c8 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/CostHeuristic.cpp @@ -0,0 +1,32 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "CostHeuristic.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +CostHeuristic::CostHeuristic() { +} + +CostHeuristic::CostHeuristic(const CostHeuristic& orig) { +} + +CostHeuristic::~CostHeuristic() { +} + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/CostHeuristic.hpp b/tapeserver/castor/tape/tapeserver/RAO/CostHeuristic.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b3dbd930a36126d0e87d23d7e2911ec4f3593f78 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/CostHeuristic.hpp @@ -0,0 +1,32 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +class CostHeuristic { +public: + CostHeuristic(); + CostHeuristic(const CostHeuristic& orig); + virtual ~CostHeuristic(); +private: + +}; + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/FilePosition.cpp b/tapeserver/castor/tape/tapeserver/RAO/FilePosition.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bc1179b2a3269f90c868ebbd94df6e613408e91e --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/FilePosition.cpp @@ -0,0 +1,46 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "FilePosition.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +FilePosition::FilePosition() { +} + +FilePosition::~FilePosition() { +} + +void FilePosition::setStartPosition(const Position & startPosition) { + m_startPosition = startPosition; +} + +void FilePosition::setEndPosition(const Position& endPosition) { + m_endPosition = endPosition; +} + +Position FilePosition::getStartPosition() const { + return m_startPosition; +} + +Position FilePosition::getEndPosition() const { + return m_endPosition; +} + + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/FilePosition.hpp b/tapeserver/castor/tape/tapeserver/RAO/FilePosition.hpp new file mode 100644 index 0000000000000000000000000000000000000000..bff0d571db5081b8160db5d8ccab522a59096a05 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/FilePosition.hpp @@ -0,0 +1,39 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "Position.hpp" + + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +class FilePosition { +public: + FilePosition(); + void setStartPosition(const Position & startPosition); + void setEndPosition(const Position & endPosition); + Position getStartPosition() const; + Position getEndPosition() const; + virtual ~FilePosition(); +private: + Position m_startPosition; + Position m_endPosition; +}; + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/FilePositionEstimator.cpp b/tapeserver/castor/tape/tapeserver/RAO/FilePositionEstimator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..744fe829a250c5e3864672d9ae89b5c8282bfe12 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/FilePositionEstimator.cpp @@ -0,0 +1,29 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "FilePositionEstimator.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +FilePositionEstimator::FilePositionEstimator() { +} + +FilePositionEstimator::~FilePositionEstimator() { +} + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/FilePositionEstimator.hpp b/tapeserver/castor/tape/tapeserver/RAO/FilePositionEstimator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d984d3fd3d54b0694e1a648f303d2c0aeaf15018 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/FilePositionEstimator.hpp @@ -0,0 +1,35 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "FilePosition.hpp" +#include "scheduler/RetrieveJob.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +class FilePositionEstimator { +public: + FilePositionEstimator(); + virtual FilePosition getFilePosition(const cta::RetrieveJob & job) const = 0; + virtual ~FilePositionEstimator(); +private: + +}; + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/InterpolationFilePositionEstimator.cpp b/tapeserver/castor/tape/tapeserver/RAO/InterpolationFilePositionEstimator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..476b0b7221c1774ed0d727c2fbf4a3a288505214 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/InterpolationFilePositionEstimator.cpp @@ -0,0 +1,35 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "InterpolationFilePositionEstimator.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +InterpolationFilePositionEstimator::InterpolationFilePositionEstimator(const std::vector<drive::endOfWrapPosition> & endOfWrapPositions, + const cta::catalogue::MediaType & mediaType): m_endOfWrapPositions(endOfWrapPositions), m_mediaType(mediaType) { +} + +InterpolationFilePositionEstimator::~InterpolationFilePositionEstimator() { +} + +FilePosition InterpolationFilePositionEstimator::getFilePosition(const cta::RetrieveJob& job) const { + return FilePosition(); +} + + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/InterpolationFilePositionEstimator.hpp b/tapeserver/castor/tape/tapeserver/RAO/InterpolationFilePositionEstimator.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0179beeca8cd6878ebbbc9fe4ac9cb557500778b --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/InterpolationFilePositionEstimator.hpp @@ -0,0 +1,38 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "FilePositionEstimator.hpp" +#include "castor/tape/tapeserver/drive/DriveInterface.hpp" +#include "catalogue/MediaType.hpp" +#include <vector> + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +class InterpolationFilePositionEstimator : public FilePositionEstimator{ +public: + InterpolationFilePositionEstimator(const std::vector<drive::endOfWrapPosition> & endOfWrapPositions, const cta::catalogue::MediaType & mediaType); + FilePosition getFilePosition(const cta::RetrieveJob& job) const override; + virtual ~InterpolationFilePositionEstimator(); +private: + std::vector<drive::endOfWrapPosition> m_endOfWrapPositions; + cta::catalogue::MediaType m_mediaType; +}; + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/LinearRAOAlgorithm.hpp b/tapeserver/castor/tape/tapeserver/RAO/LinearRAOAlgorithm.hpp index 82a8c3ef7d85085b090dd4621fcc2a4ae7627cf5..acac8c78cfe91a0ef46d74acb7699fe741411aa2 100644 --- a/tapeserver/castor/tape/tapeserver/RAO/LinearRAOAlgorithm.hpp +++ b/tapeserver/castor/tape/tapeserver/RAO/LinearRAOAlgorithm.hpp @@ -19,19 +19,19 @@ #pragma once #include "RAOAlgorithm.hpp" -#include "NoParamRAOAlgorithmFactory.hpp" +#include "NonConfigurableRAOAlgorithmFactory.hpp" namespace castor { namespace tape { namespace tapeserver { namespace rao { -class NoParamRAOAlgorithmFactory; +class NonConfigurableRAOAlgorithmFactory; /** * This class represents a LinearRAOAlgorithm */ class LinearRAOAlgorithm : public RAOAlgorithm { public: - friend NoParamRAOAlgorithmFactory; + friend NonConfigurableRAOAlgorithmFactory; /** * This method will return the indexes of the jobs that are reoreded in a linear way (sorted by fseq ascendant) diff --git a/tapeserver/castor/tape/tapeserver/RAO/NoParamRAOAlgorithmFactory.cpp b/tapeserver/castor/tape/tapeserver/RAO/NonConfigurableRAOAlgorithmFactory.cpp similarity index 73% rename from tapeserver/castor/tape/tapeserver/RAO/NoParamRAOAlgorithmFactory.cpp rename to tapeserver/castor/tape/tapeserver/RAO/NonConfigurableRAOAlgorithmFactory.cpp index 4941d21ab6f0c29246643e5f223f6f0a7be81f82..a5b0f4127fd43dd2e75e5efa4f10597c6de3cf99 100644 --- a/tapeserver/castor/tape/tapeserver/RAO/NoParamRAOAlgorithmFactory.cpp +++ b/tapeserver/castor/tape/tapeserver/RAO/NonConfigurableRAOAlgorithmFactory.cpp @@ -16,26 +16,26 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "NoParamRAOAlgorithmFactory.hpp" +#include "NonConfigurableRAOAlgorithmFactory.hpp" #include "LinearRAOAlgorithm.hpp" #include "RandomRAOAlgorithm.hpp" namespace castor { namespace tape { namespace tapeserver { namespace rao { -NoParamRAOAlgorithmFactory::NoParamRAOAlgorithmFactory(const RAOConfig::RAOAlgorithmType & type) : m_type(type) { +NonConfigurableRAOAlgorithmFactory::NonConfigurableRAOAlgorithmFactory(const RAOConfigurationData::RAOAlgorithmType & type) : m_type(type) { } -NoParamRAOAlgorithmFactory::~NoParamRAOAlgorithmFactory() { +NonConfigurableRAOAlgorithmFactory::~NonConfigurableRAOAlgorithmFactory() { } -std::unique_ptr<RAOAlgorithm> NoParamRAOAlgorithmFactory::createRAOAlgorithm() { +std::unique_ptr<RAOAlgorithm> NonConfigurableRAOAlgorithmFactory::createRAOAlgorithm() { std::unique_ptr<RAOAlgorithm> ret; switch(m_type){ - case RAOConfig::linear:{ + case RAOConfigurationData::linear:{ ret.reset(new LinearRAOAlgorithm()); break; } - case RAOConfig::random:{ + case RAOConfigurationData::random:{ ret.reset(new RandomRAOAlgorithm()); break; } diff --git a/tapeserver/castor/tape/tapeserver/RAO/NoParamRAOAlgorithmFactory.hpp b/tapeserver/castor/tape/tapeserver/RAO/NonConfigurableRAOAlgorithmFactory.hpp similarity index 83% rename from tapeserver/castor/tape/tapeserver/RAO/NoParamRAOAlgorithmFactory.hpp rename to tapeserver/castor/tape/tapeserver/RAO/NonConfigurableRAOAlgorithmFactory.hpp index dcf05324fa45aee7249a359edb8a44000e719e6b..69c8e94015f05acbd0ca1a67cdf42eff684f0ff5 100644 --- a/tapeserver/castor/tape/tapeserver/RAO/NoParamRAOAlgorithmFactory.hpp +++ b/tapeserver/castor/tape/tapeserver/RAO/NonConfigurableRAOAlgorithmFactory.hpp @@ -18,7 +18,7 @@ #pragma once -#include "RAOConfig.hpp" +#include "RAOConfigurationData.hpp" #include "RAOAlgorithmFactory.hpp" namespace castor { namespace tape { namespace tapeserver { namespace rao { @@ -28,23 +28,23 @@ namespace castor { namespace tape { namespace tapeserver { namespace rao { * parameter to work. E.G the linear algorithm just does a sort of the fseqs, * it does not need any parameter. */ -class NoParamRAOAlgorithmFactory : public RAOAlgorithmFactory { +class NonConfigurableRAOAlgorithmFactory : public RAOAlgorithmFactory { public: /** * Constructor * @param type the type given will be used by the createRAOAlgorithm() method * to instanciate the correct algorithm regarding its type */ - NoParamRAOAlgorithmFactory(const RAOConfig::RAOAlgorithmType & type); + NonConfigurableRAOAlgorithmFactory(const RAOConfigurationData::RAOAlgorithmType & type); /** * Returns the correct instance of RAO algorithm regarding the type * given while constructing this factory. * @throws Exception if the type is unknown */ std::unique_ptr<RAOAlgorithm> createRAOAlgorithm() override; - virtual ~NoParamRAOAlgorithmFactory(); + virtual ~NonConfigurableRAOAlgorithmFactory(); private: - RAOConfig::RAOAlgorithmType m_type; + RAOConfigurationData::RAOAlgorithmType m_type; }; }}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/Position.cpp b/tapeserver/castor/tape/tapeserver/RAO/Position.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1f6a88ddb06b241617e990737b9b21cca9522d49 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/Position.cpp @@ -0,0 +1,46 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "Position.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +Position::Position():m_wrap(0),m_lpos(0) { +} + +Position::~Position() { +} + +uint32_t Position::getLPos() const { + return m_lpos; +} + +uint32_t Position::getWrap() const { + return m_wrap; + } + +void Position::setLPos(const uint32_t lpos) { + m_lpos = lpos; +} + +void Position::setWrap(const uint32_t wrap) { + m_wrap = wrap; +} + + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/Position.hpp b/tapeserver/castor/tape/tapeserver/RAO/Position.hpp new file mode 100644 index 0000000000000000000000000000000000000000..edd932cdb2e791cf85059ca085996ef20a9e5eb7 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/Position.hpp @@ -0,0 +1,38 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 <cstdint> + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +class Position { +public: + Position(); + virtual ~Position(); + uint32_t getWrap() const; + uint32_t getLPos() const; + void setWrap(const uint32_t wrap); + void setLPos(const uint32_t lpos); +private: + uint32_t m_wrap; + unsigned int m_lpos; +}; + +}}}} diff --git a/tapeserver/castor/tape/tapeserver/RAO/RAOAlgorithmFactoryFactory.cpp b/tapeserver/castor/tape/tapeserver/RAO/RAOAlgorithmFactoryFactory.cpp index b37e663f366d15a9534cad659c608c8f6b435625..2c4d946bf1a84edb93c1419cc5f06bd220955a3d 100644 --- a/tapeserver/castor/tape/tapeserver/RAO/RAOAlgorithmFactoryFactory.cpp +++ b/tapeserver/castor/tape/tapeserver/RAO/RAOAlgorithmFactoryFactory.cpp @@ -20,7 +20,8 @@ #include "RAOAlgorithmFactoryFactory.hpp" #include "common/log/LogContext.hpp" #include "EnterpriseRAOAlgorithmFactory.hpp" -#include "NoParamRAOAlgorithmFactory.hpp" +#include "NonConfigurableRAOAlgorithmFactory.hpp" +#include "ConfigurableRAOAlgorithmFactory.hpp" namespace castor { namespace tape { namespace tapeserver { namespace rao { @@ -36,27 +37,32 @@ std::unique_ptr<RAOAlgorithmFactory> RAOAlgorithmFactoryFactory::createAlgorithm ret.reset(new EnterpriseRAOAlgorithmFactory(m_raoManager.getDrive(),maxFilesSupported.value())); } } else { + RAOConfigurationData raoData = m_raoManager.getRAODataConfig(); //We will instanciate a CTA RAO algorithm - RAOConfig::RAOAlgorithmType raoAlgoType; + RAOConfigurationData::RAOAlgorithmType raoAlgoType; try { - raoAlgoType = m_raoManager.getConfig().getAlgorithmType(); + raoAlgoType = raoData.getAlgorithmType(); } catch (const cta::exception::Exception & ex) { //We failed to determine the RAOAlgorithmType, we use the linear algorithm by default //log a warning std::string msg = "In RAOAlgorithmFactoryFactory::createAlgorithmFactory(), unable to determine the RAO algorithm to use, the algorithm name provided" - " in the tapeserver configuration is " + m_raoManager.getConfig().getRAOAlgorithmName() + " the available algorithm names are " + m_raoManager.getConfig().getCTARAOAlgorithmNameAvailable() + " in the tapeserver configuration is " + raoData.getRAOAlgorithmName() + " the available algorithm names are " + raoData.getCTARAOAlgorithmNameAvailable() + ". We will apply a linear algorithm instead."; m_lc.log(cta::log::WARNING, msg); - raoAlgoType = RAOConfig::RAOAlgorithmType::linear; + raoAlgoType = RAOConfigurationData::RAOAlgorithmType::linear; } switch(raoAlgoType){ - case RAOConfig::RAOAlgorithmType::linear: - case RAOConfig::RAOAlgorithmType::random: + case RAOConfigurationData::RAOAlgorithmType::linear: + case RAOConfigurationData::RAOAlgorithmType::random: { - ret.reset(new NoParamRAOAlgorithmFactory(raoAlgoType)); + ret.reset(new NonConfigurableRAOAlgorithmFactory(raoAlgoType)); + break; + } + case RAOConfigurationData::RAOAlgorithmType::sltf: + { + ret.reset(new ConfigurableRAOAlgorithmFactory(m_raoManager.getDrive(),m_raoManager.getCatalogue(), raoData)); break; } - case RAOConfig::RAOAlgorithmType::sltf: default: break; } diff --git a/tapeserver/castor/tape/tapeserver/RAO/RAOConfig.cpp b/tapeserver/castor/tape/tapeserver/RAO/RAOConfig.cpp deleted file mode 100644 index e324b2af9ff6c1ee8d77b6bfbbffe45046de4380..0000000000000000000000000000000000000000 --- a/tapeserver/castor/tape/tapeserver/RAO/RAOConfig.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The CERN Tape Archive (CTA) project - * Copyright (C) 2019 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 "RAOConfig.hpp" -#include "common/exception/Exception.hpp" -#include "common/utils/utils.hpp" - -namespace castor { namespace tape { namespace tapeserver { namespace rao { - -const std::map<std::string,RAOConfig::RAOAlgorithmType> RAOConfig::c_raoAlgoStringTypeMap = { - {"linear",RAOConfig::RAOAlgorithmType::linear}, - {"random",RAOConfig::RAOAlgorithmType::random}, - {"sltf",RAOConfig::RAOAlgorithmType::sltf} -}; - -RAOConfig::RAOConfig(){} - -RAOConfig::RAOConfig(const bool useRAO, const std::string& raoAlgorithmName, const std::string raoAlgorithmOptions):m_useRAO(useRAO), m_raoAlgorithmName(raoAlgorithmName), m_raoAlgorithmOptions(raoAlgorithmOptions) { - -} - -bool RAOConfig::useRAO() const { - return m_useRAO; -} - -std::string RAOConfig::getRAOAlgorithmName() const { - return m_raoAlgorithmName; -} - -std::string RAOConfig::getRAOAlgorithmOptions() const { - return m_raoAlgorithmOptions; -} - -void RAOConfig::disableRAO(){ - m_useRAO = false; -} - -RAOConfig::RAOAlgorithmType RAOConfig::getAlgorithmType() const { - try { - return c_raoAlgoStringTypeMap.at(m_raoAlgorithmName); - } catch (const std::out_of_range &){ - throw cta::exception::Exception("The algorithm name provided by the RAO configuration does not match any RAO algorithm type."); - } -} - -std::string RAOConfig::getCTARAOAlgorithmNameAvailable() const { - std::string ret; - for(auto & kv: c_raoAlgoStringTypeMap){ - ret += kv.first + " "; - } - if(ret.size()){ - //remove last space - ret.resize(ret.size()-1); - } - return ret; -} - - - -}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/RAOConfigurationData.cpp b/tapeserver/castor/tape/tapeserver/RAO/RAOConfigurationData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a0a555bba421244ad47232766814f25d51fba704 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/RAOConfigurationData.cpp @@ -0,0 +1,104 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "RAOConfigurationData.hpp" +#include "common/exception/Exception.hpp" +#include "common/utils/utils.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +const std::map<std::string,RAOConfigurationData::RAOAlgorithmType> RAOConfigurationData::c_raoAlgoStringTypeMap = { + {"linear",RAOConfigurationData::RAOAlgorithmType::linear}, + {"random",RAOConfigurationData::RAOAlgorithmType::random}, + {"sltf",RAOConfigurationData::RAOAlgorithmType::sltf} +}; + +RAOConfigurationData::RAOConfigurationData():m_useRAO(false){} + +RAOConfigurationData::RAOConfigurationData(const bool useRAO, const std::string& raoAlgorithmName, const std::string & raoAlgorithmOptions, const std::string & vid):m_useRAO(useRAO), m_raoAlgorithmName(raoAlgorithmName), + m_raoAlgorithmOptions(raoAlgorithmOptions), m_vid(vid) { + +} + +RAOConfigurationData::RAOConfigurationData(const RAOConfigurationData& other) { + if(this != &other){ + m_useRAO = other.m_useRAO; + m_raoAlgorithmName = other.m_raoAlgorithmName; + m_raoAlgorithmOptions = other.m_raoAlgorithmOptions; + m_vid = other.m_vid; + } +} + +RAOConfigurationData& RAOConfigurationData::operator=(const RAOConfigurationData& other) { + if(this != &other){ + m_useRAO = other.m_useRAO; + m_raoAlgorithmName = other.m_raoAlgorithmName; + m_raoAlgorithmOptions = other.m_raoAlgorithmOptions; + m_vid = other.m_vid; + } + return *this; +} + +bool RAOConfigurationData::useRAO() const { + return m_useRAO; +} + +std::string RAOConfigurationData::getRAOAlgorithmName() const { + return m_raoAlgorithmName; +} + +RAOOptions RAOConfigurationData::getRAOAlgorithmOptions() const { + return m_raoAlgorithmOptions; +} + +void RAOConfigurationData::disableRAO(){ + m_useRAO = false; +} + +RAOConfigurationData::RAOAlgorithmType RAOConfigurationData::getAlgorithmType() const { + try { + return c_raoAlgoStringTypeMap.at(m_raoAlgorithmName); + } catch (const std::out_of_range &){ + throw cta::exception::Exception("The algorithm name provided by the RAO configuration does not match any RAO algorithm type."); + } +} + +std::string RAOConfigurationData::getCTARAOAlgorithmNameAvailable() const { + std::string ret; + for(auto & kv: c_raoAlgoStringTypeMap){ + ret += kv.first + " "; + } + if(ret.size()){ + //remove last space + ret.resize(ret.size()-1); + } + return ret; +} + +std::string RAOConfigurationData::getMountedVid() const { + if(m_vid.empty()){ + throw cta::exception::Exception("In RAOData::getMountedVid(), no mounted vid found."); + } + return m_vid; +} + + + + + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/RAOConfig.hpp b/tapeserver/castor/tape/tapeserver/RAO/RAOConfigurationData.hpp similarity index 71% rename from tapeserver/castor/tape/tapeserver/RAO/RAOConfig.hpp rename to tapeserver/castor/tape/tapeserver/RAO/RAOConfigurationData.hpp index 4c1f3987afb219a467b2bca3518ca11736889330..9a68b1c4f324b88f1335f19ba39c45ec2e79bcb6 100644 --- a/tapeserver/castor/tape/tapeserver/RAO/RAOConfig.hpp +++ b/tapeserver/castor/tape/tapeserver/RAO/RAOConfigurationData.hpp @@ -23,6 +23,8 @@ #include <memory> #include <common/log/LogContext.hpp> #include <vector> +#include "catalogue/Catalogue.hpp" +#include "RAOOptions.hpp" namespace castor { namespace tape { namespace tapeserver { namespace rao { @@ -30,7 +32,7 @@ namespace castor { namespace tape { namespace tapeserver { namespace rao { * This class contains the configuration of the CTA RAO Algorithm * It is initialized by the DataTransferSession and is filled from the configuration file of the tapeserver. */ - class RAOConfig{ + class RAOConfigurationData{ public: /** * This enum represent the RAO algorithm type implemented @@ -42,16 +44,30 @@ namespace castor { namespace tape { namespace tapeserver { namespace rao { //Short Locate Time First sltf }; - - RAOConfig(); /** - * Construct an RAO config + * Default constructor, sets useRAO to false + */ + RAOConfigurationData(); + + /** + * Construct an RAO data * @param useRAO if set to true, the RAO will be enabled. If false, not enabled. * @param raoAlgorithmName the RAO algorithm that will be executed when called * @param raoAlgorithmOptions the options that could be passed to the RAO algorithm + * @param vid the vid of the tape that is currently mounted for retrieval + */ + RAOConfigurationData(const bool useRAO, const std::string & raoAlgorithmName, const std::string & raoAlgorithmOptions, const std::string & vid); + + /** + * Copy constructor */ - RAOConfig(const bool useRAO, const std::string & raoAlgorithmName, const std::string raoAlgorithmOptions); + RAOConfigurationData(const RAOConfigurationData & other); + + /** + * Operator = + */ + RAOConfigurationData & operator=(const RAOConfigurationData & other); /** * Returns true if RAO has to be used, false otherwise @@ -59,15 +75,14 @@ namespace castor { namespace tape { namespace tapeserver { namespace rao { bool useRAO() const; /** - * Returns the RAO algorithm name of this configuration + * Returns the RAO algorithm name of this RAO data instance */ std::string getRAOAlgorithmName() const; /** - * Returns the RAO algorithm options of this configuration - * @return + * Returns the RAO algorithm options of this RAO data instance */ - std::string getRAOAlgorithmOptions() const; + RAOOptions getRAOAlgorithmOptions() const; /** * Disable RAO from this configuration @@ -82,14 +97,21 @@ namespace castor { namespace tape { namespace tapeserver { namespace rao { RAOAlgorithmType getAlgorithmType() const; /** - * Returns the CTA RAO algorithm name that can be used + * Returns the CTA RAO algorithm names that can be used */ std::string getCTARAOAlgorithmNameAvailable() const; + /** + * Returns the vid of the tape that is mounted for retrieval + */ + std::string getMountedVid() const; + private: bool m_useRAO = false; std::string m_raoAlgorithmName; - std::string m_raoAlgorithmOptions; + RAOOptions m_raoAlgorithmOptions; + std::string m_vid; + /** * Static map in order to match the string representing an algorithm name and its enum type diff --git a/tapeserver/castor/tape/tapeserver/RAO/RAOManager.cpp b/tapeserver/castor/tape/tapeserver/RAO/RAOManager.cpp index 479c081a2e312097ea016ce6b13f94f24166c169..b965e34bec3718975499113e8ccb6488bc4ca217 100644 --- a/tapeserver/castor/tape/tapeserver/RAO/RAOManager.cpp +++ b/tapeserver/castor/tape/tapeserver/RAO/RAOManager.cpp @@ -20,35 +20,40 @@ #include "RAOManager.hpp" #include "EnterpriseRAOAlgorithm.hpp" #include "EnterpriseRAOAlgorithmFactory.hpp" -#include "NoParamRAOAlgorithmFactory.hpp" +#include "NonConfigurableRAOAlgorithmFactory.hpp" #include "RAOAlgorithmFactoryFactory.hpp" +#include "catalogue/Catalogue.hpp" namespace castor { namespace tape { namespace tapeserver { namespace rao { -RAOManager::RAOManager(){ - m_config.disableRAO(); -} - -RAOManager::RAOManager(const castor::tape::tapeserver::rao::RAOConfig & config, castor::tape::tapeserver::drive::DriveInterface * drive):m_config(config),m_drive(drive) { +RAOManager::RAOManager() { + } + +RAOManager::RAOManager(const RAOConfigurationData & config, drive::DriveInterface * drive, cta::catalogue::Catalogue * catalogue):m_raoConfigurationData(config), + m_drive(drive), m_catalogue(catalogue){} RAOManager::RAOManager(const RAOManager& manager){ if(this != &manager){ - m_config = manager.m_config; + m_catalogue = manager.m_catalogue; m_drive = manager.m_drive; m_enterpriseRaoLimits = manager.m_enterpriseRaoLimits; m_hasUDS = manager.m_hasUDS; + m_isDriveEnterpriseEnabled = manager.m_isDriveEnterpriseEnabled; m_maxFilesSupported = manager.m_maxFilesSupported; + m_raoConfigurationData = manager.m_raoConfigurationData; } } RAOManager& RAOManager::operator=(const RAOManager& manager) { if(this != &manager){ - m_config = manager.m_config; + m_catalogue = manager.m_catalogue; m_drive = manager.m_drive; m_enterpriseRaoLimits = manager.m_enterpriseRaoLimits; m_hasUDS = manager.m_hasUDS; + m_isDriveEnterpriseEnabled = manager.m_isDriveEnterpriseEnabled; m_maxFilesSupported = manager.m_maxFilesSupported; + m_raoConfigurationData = manager.m_raoConfigurationData; } return *this; } @@ -58,7 +63,7 @@ RAOManager::~RAOManager() { } bool RAOManager::useRAO() const{ - return m_config.useRAO(); + return m_raoConfigurationData.useRAO(); } bool RAOManager::hasUDS() const { @@ -69,14 +74,17 @@ bool RAOManager::isDriveEnterpriseEnabled() const { return m_isDriveEnterpriseEnabled; } - castor::tape::tapeserver::drive::DriveInterface* RAOManager::getDrive() const { return m_drive; } +cta::catalogue::Catalogue* RAOManager::getCatalogue() const { + return m_catalogue; +} + void RAOManager::disableRAO(){ - m_config.disableRAO(); + m_raoConfigurationData.disableRAO(); } void RAOManager::setEnterpriseRAOUdsLimits(const SCSI::Structures::RAO::udsLimits& raoLimits) { @@ -90,11 +98,10 @@ cta::optional<uint64_t> RAOManager::getMaxFilesSupported() const{ return m_maxFilesSupported; } -RAOConfig RAOManager::getConfig() const { - return m_config; +RAOConfigurationData RAOManager::getRAODataConfig() const { + return m_raoConfigurationData; } - std::vector<uint64_t> RAOManager::queryRAO(const std::vector<std::unique_ptr<cta::RetrieveJob>> & jobs, cta::log::LogContext & lc){ RAOAlgorithmFactoryFactory raoAlgoFactoryFactory(*this,lc); std::unique_ptr<RAOAlgorithm> raoAlgo = raoAlgoFactoryFactory.createAlgorithmFactory()->createRAOAlgorithm(); diff --git a/tapeserver/castor/tape/tapeserver/RAO/RAOManager.hpp b/tapeserver/castor/tape/tapeserver/RAO/RAOManager.hpp index 0e8796a0122ef888903b8036fe351e58b44dd669..d84e395599d0135a91f03d33f05430e5e7b339de 100644 --- a/tapeserver/castor/tape/tapeserver/RAO/RAOManager.hpp +++ b/tapeserver/castor/tape/tapeserver/RAO/RAOManager.hpp @@ -19,7 +19,7 @@ #pragma once #include <vector> #include <memory> -#include "castor/tape/tapeserver/RAO/RAOConfig.hpp" +#include "castor/tape/tapeserver/RAO/RAOConfigurationData.hpp" #include "castor/tape/tapeserver/drive/DriveInterface.hpp" #include "castor/tape/tapeserver/SCSI/Structures.hpp" #include "scheduler/RetrieveJob.hpp" @@ -34,12 +34,19 @@ namespace castor { namespace tape { namespace tapeserver { namespace rao { * It centralizes all the RAO-related task that are executed during the * RecallTaskInjector lifecycle. */ +class RAOAlgorithmFactoryFactory; + class RAOManager { public: - /** - * Default constructor, disable the RAO - */ + friend RAOAlgorithmFactoryFactory; RAOManager(); + /** + * Constructor of a RAO manager + * @param config the configuration of the RAO to manage + * @param drive the DriveInterface of the drive that is mounting. + * @param catalogue the pointer to the CTA catalogue + */ + RAOManager(const RAOConfigurationData & config, castor::tape::tapeserver::drive::DriveInterface * drive, cta::catalogue::Catalogue * catalogue); /** * Copy constructor @@ -47,13 +54,6 @@ public: */ RAOManager(const RAOManager & manager); - /** - * Constructor of a RAO manager - * @param config the configuration of the RAO to manage - * @param drive the DriveInterface of the drive that is mounting - */ - RAOManager(const RAOConfig & config, castor::tape::tapeserver::drive::DriveInterface * drive); - /** * Assignment operator * */ @@ -70,27 +70,11 @@ public: */ bool hasUDS() const; - /** - * Returns true if the manager can ask for an Enterprise RAO Algorithm - * false otherwise - */ - bool isDriveEnterpriseEnabled() const; - - /** - * Returns the pointer to the interface of that is mounting - */ - castor::tape::tapeserver::drive::DriveInterface * getDrive() const; - /** * Returns the number of files that will be supported by the RAO algorithm */ cta::optional<uint64_t> getMaxFilesSupported() const; - /** - * Returns the RAOConfig that is used by this RAOManager - */ - RAOConfig getConfig() const; - /** * Disable the RAO algorithm */ @@ -116,7 +100,8 @@ public: virtual ~RAOManager(); private: - RAOConfig m_config; + //RAO Configuration Data + RAOConfigurationData m_raoConfigurationData; /** Enterprise Drive-specific RAO parameters */ SCSI::Structures::RAO::udsLimits m_enterpriseRaoLimits; //Is true if the drive have been able to get the RAO UDS limits numbers @@ -126,6 +111,29 @@ private: //Pointer to the drive interface of the drive currently used by the tapeserver castor::tape::tapeserver::drive::DriveInterface * m_drive; bool m_isDriveEnterpriseEnabled = false; + cta::catalogue::Catalogue * m_catalogue; + + /** + * Returns true if the manager can instanciate an Enterprise RAO Algorithm + * false otherwise + */ + bool isDriveEnterpriseEnabled() const; + + /** + * Returns the pointer to the interface of the drive currently mounting the tape + */ + castor::tape::tapeserver::drive::DriveInterface * getDrive() const; + + /** + * Returns the pointer to the catalogue of this manager + */ + cta::catalogue::Catalogue * getCatalogue() const; + + /** + * Returns the RAO data that is used by this RAOManager + */ + RAOConfigurationData getRAODataConfig() const; + }; }}}} diff --git a/tapeserver/castor/tape/tapeserver/RAO/RAOOptions.cpp b/tapeserver/castor/tape/tapeserver/RAO/RAOOptions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..de5f56968d058b81b2d9b40d9f1fbc89e6465d4e --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/RAOOptions.cpp @@ -0,0 +1,109 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "RAOOptions.hpp" +#include "common/utils/utils.hpp" +#include "common/exception/Exception.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + + +std::map<std::string,RAOOptions::CostHeuristicType> RAOOptions::c_mapStringCostHeuristicType = { + {"cta",RAOOptions::CostHeuristicType::cta}, +}; + +RAOOptions::RAOOptions(){} + +RAOOptions::RAOOptions(const std::string & options): m_options(options){ + cta::utils::splitString(m_options,',',m_allOptions); +} + +RAOOptions::~RAOOptions() { +} + +bool RAOOptions::getBooleanValue(const std::string& name) const { + bool ret = false; + bool found = false; + auto itor = m_allOptions.begin(); + while(itor != m_allOptions.end() && !found){ + std::vector<std::string> keyValue; + cta::utils::splitString(*itor,':',keyValue); + if(keyValue.at(0) == name){ + try { + std::string value = keyValue.at(1); + cta::utils::toLower(value); + if(value == "true"){ + ret = true; + }//Any other value than "true" will be considered false + found = true; + } catch (const std::out_of_range & ex){ + std::string errorMsg = "The RAO configuration option parameter named " + name + " does not contain any boolean value"; + throw cta::exception::Exception(errorMsg); + } + } + } + if(!found){ + std::string errorMsg = "The RAO Configuration options (" + m_options + ") do not contain the key " + name; + throw cta::exception::Exception(errorMsg); + } + return ret; +} + +std::string RAOOptions::getStringValue(const std::string& name) const { + std::string ret; + bool found = false; + auto itor = m_allOptions.begin(); + while(itor != m_allOptions.end() && !found){ + std::vector<std::string> keyValue; + cta::utils::splitString(*itor,':',keyValue); + if(keyValue.at(0) == name) { + try { + ret = keyValue.at(1); + found = true; + } catch (const std::out_of_range & ex){ + std::string errorMsg = "The RAO configuration option parameter named " + name + " does not contain any string value"; + throw cta::exception::Exception(errorMsg); + } + } + } + if(!found){ + std::string errorMsg = "The RAO Configuration options (" + m_options + ") do not contain the key " + name; + throw cta::exception::Exception(errorMsg); + } + return ret; +} + +RAOOptions::CostHeuristicType RAOOptions::getCostHeuristicType() { + try{ + std::string costHeuristicName = getStringValue("cost_heuristic_name"); + return c_mapStringCostHeuristicType.at(costHeuristicName); + } catch(const cta::exception::Exception & ex){ + throw ex; + } catch (const std::out_of_range & ex2) { + throw cta::exception::Exception("In RAOOptions::getCostHeuristic(), unable to find the cost heuristic to use from the RAOAlgorithmOptions configuration line (" + m_options + ")"); + } +} + +RAOOptions::FilePositionEstimatorType RAOOptions::getFilePositionEstimatorType() { + //For now we only support interpolation. + //This method should be modified if we want to support other types of FilePositionEstimator + return RAOOptions::FilePositionEstimatorType::interpolation; +} + + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/RAOOptions.hpp b/tapeserver/castor/tape/tapeserver/RAO/RAOOptions.hpp new file mode 100644 index 0000000000000000000000000000000000000000..31d65fe53d41f10fc9c30694835e5fceee4a2d44 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/RAOOptions.hpp @@ -0,0 +1,69 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 <string> +#include <map> +#include <vector> + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +class RAOOptions { +public: + + enum CostHeuristicType{ + cta + }; + + enum FilePositionEstimatorType { + interpolation + }; + + RAOOptions(); + RAOOptions(const std::string & options); + + CostHeuristicType getCostHeuristicType(); + + FilePositionEstimatorType getFilePositionEstimatorType(); + + virtual ~RAOOptions(); + +private: + std::string m_options; + std::vector<std::string> m_allOptions; + + /** + * Returns the boolean value of the option + * whose name is passed in parameter + * @param name the name of the option to get its boolean value + * @return the boolean value of the option. + */ + bool getBooleanValue(const std::string & name) const; + /** + * Returns the string value of the option + * whose name is passed in parameter + * @param name the name of the option to get its string value + * @return the string value of the option + */ + std::string getStringValue(const std::string & name) const; + + static std::map<std::string, CostHeuristicType> c_mapStringCostHeuristicType; +}; + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/RandomRAOAlgorithm.hpp b/tapeserver/castor/tape/tapeserver/RAO/RandomRAOAlgorithm.hpp index 7b93be12ee3be06585890bdd086530181582db03..c174b4f47471322bf5d346c95a37d50ef44ecdc1 100644 --- a/tapeserver/castor/tape/tapeserver/RAO/RandomRAOAlgorithm.hpp +++ b/tapeserver/castor/tape/tapeserver/RAO/RandomRAOAlgorithm.hpp @@ -19,11 +19,11 @@ #pragma once #include "RAOAlgorithm.hpp" -#include "NoParamRAOAlgorithmFactory.hpp" +#include "NonConfigurableRAOAlgorithmFactory.hpp" namespace castor { namespace tape { namespace tapeserver { namespace rao { -class NoParamRAOAlgorithmFactory; +class NonConfigurableRAOAlgorithmFactory; /** * This RAO Algorithm is a random one. The indexes of the jobs passed in parameter @@ -31,7 +31,7 @@ class NoParamRAOAlgorithmFactory; */ class RandomRAOAlgorithm : public RAOAlgorithm{ public: - friend NoParamRAOAlgorithmFactory; + friend NonConfigurableRAOAlgorithmFactory; /** * Returns a randomly organized vector of the indexes of the jobs passed in parameter * @param jobs the jobs to perform the random RAO on diff --git a/tapeserver/castor/tape/tapeserver/RAO/SLTFRAOAlgorithm.cpp b/tapeserver/castor/tape/tapeserver/RAO/SLTFRAOAlgorithm.cpp new file mode 100644 index 0000000000000000000000000000000000000000..128fc8861f1c652436b9c9327e00e5c5374405d3 --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/SLTFRAOAlgorithm.cpp @@ -0,0 +1,70 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "SLTFRAOAlgorithm.hpp" +#include "InterpolationFilePositionEstimator.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +SLTFRAOAlgorithm::SLTFRAOAlgorithm() {} + +std::vector<uint64_t> SLTFRAOAlgorithm::performRAO(const std::vector<std::unique_ptr<cta::RetrieveJob> >& jobs) { + std::vector<uint64_t> ret; + return ret; +} + + +SLTFRAOAlgorithm::~SLTFRAOAlgorithm() { +} + + +SLTFRAOAlgorithm::Builder::Builder(const RAOConfigurationData& data, drive::DriveInterface * drive, cta::catalogue::Catalogue * catalogue):m_data(data),m_drive(drive),m_catalogue(catalogue){ + m_algorithm.reset(new SLTFRAOAlgorithm()); +} + +std::unique_ptr<SLTFRAOAlgorithm> SLTFRAOAlgorithm::Builder::build() { + initializeFilePositionEstimator(); + initializeCostHeuristic(); + return std::move(m_algorithm); +} + +void SLTFRAOAlgorithm::Builder::initializeFilePositionEstimator() { + switch(m_data.getRAOAlgorithmOptions().getFilePositionEstimatorType()){ + case RAOOptions::FilePositionEstimatorType::interpolation: { + std::string vid = m_data.getMountedVid(); + cta::catalogue::MediaType tapeMediaType = m_catalogue->getMediaTypeByVid(vid); + std::vector<drive::endOfWrapPosition> endOfWrapPositions = m_drive->getEndOfWrapPositions(); + m_algorithm->m_filePositionEstimator.reset(new InterpolationFilePositionEstimator(endOfWrapPositions,tapeMediaType)); + break; + } + default: + throw cta::exception::Exception("In SLTFRAOAlgorithm::Builder::initializeFilePositionEstimator() unable to instanciate an estimator to estimate the position of the files on tape."); + break; + } +} + + + + +void SLTFRAOAlgorithm::Builder::initializeCostHeuristic() { + //TODO +} + + + +}}}} \ No newline at end of file diff --git a/tapeserver/castor/tape/tapeserver/RAO/SLTFRAOAlgorithm.hpp b/tapeserver/castor/tape/tapeserver/RAO/SLTFRAOAlgorithm.hpp new file mode 100644 index 0000000000000000000000000000000000000000..48d83aa5ef34af00beb91975fa0665a493ab8dde --- /dev/null +++ b/tapeserver/castor/tape/tapeserver/RAO/SLTFRAOAlgorithm.hpp @@ -0,0 +1,54 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2019 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 "RAOAlgorithm.hpp" +#include "RAOConfigurationData.hpp" +#include "CostHeuristic.hpp" +#include "FilePositionEstimator.hpp" +#include "castor/tape/tapeserver/drive/DriveInterface.hpp" + +namespace castor { namespace tape { namespace tapeserver { namespace rao { + +class SLTFRAOAlgorithm : public RAOAlgorithm { +public: + std::vector<uint64_t> performRAO(const std::vector<std::unique_ptr<cta::RetrieveJob> >& jobs) override; + virtual ~SLTFRAOAlgorithm(); + + class Builder { + public: + Builder(const RAOConfigurationData & data, drive::DriveInterface * drive, cta::catalogue::Catalogue * catalogue); + std::unique_ptr<SLTFRAOAlgorithm> build(); + private: + void initializeFilePositionEstimator(); + void initializeCostHeuristic(); + std::unique_ptr<SLTFRAOAlgorithm> m_algorithm; + RAOConfigurationData m_data; + drive::DriveInterface * m_drive; + cta::catalogue::Catalogue * m_catalogue; + }; + +private: + SLTFRAOAlgorithm(); + std::unique_ptr<FilePositionEstimator> m_filePositionEstimator; + std::unique_ptr<CostHeuristic> m_costHeuristic; +}; + +}}}} + diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp index dc97c238615b62ad667f47fd777c42ac09e672cd..2aa0e43c6b3106b89dc706e11df4450694ba2127 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp @@ -39,7 +39,7 @@ #include "castor/tape/tapeserver/SCSI/Device.hpp" #include "common/exception/Exception.hpp" #include "scheduler/RetrieveMount.hpp" -#include "castor/tape/tapeserver/RAO/RAOConfig.hpp" +#include "castor/tape/tapeserver/RAO/RAOConfigurationData.hpp" #include <google/protobuf/stubs/common.h> #include <memory> @@ -56,7 +56,7 @@ castor::tape::tapeserver::daemon::DataTransferSession::DataTransferSession( cta::tape::daemon::TapedProxy & initialProcess, cta::server::ProcessCap & capUtils, const DataTransferConfig & castorConf, - cta::Scheduler & scheduler): + cta::Scheduler & scheduler): m_log(log), m_sysWrapper(sysWrapper), m_driveConfig(driveConfig), @@ -273,9 +273,8 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction // The RecallTaskInjector and the TapeReadSingleThread share the promise if (m_castorConf.useRAO) { - //castor::tape::tapeserver::rao::RAOConfig config; - castor::tape::tapeserver::rao::RAOConfig config(true, m_castorConf.raoLtoAlgorithm, m_castorConf.raoLtoAlgorithmOptions); - rti.initRAO(config); + castor::tape::tapeserver::rao::RAOConfigurationData raoDataConfig(m_castorConf.useRAO,m_castorConf.raoLtoAlgorithm, m_castorConf.raoLtoAlgorithmOptions,m_volInfo.vid); + rti.initRAO(raoDataConfig, &m_scheduler.getCatalogue()); } bool noFilesToRecall = false; if (rti.synchronousFetch(noFilesToRecall)) { //adapt the recall task injector (starting from synchronousFetch) diff --git a/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.cpp b/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.cpp index 4da74d9ff00a90aa26a41885f6bb4ad31da45052..0efaa4d37cf78eb75ba7e953f86a5300110206a1 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.cpp @@ -93,8 +93,8 @@ void RecallTaskInjector::setDriveInterface(castor::tape::tapeserver::drive::Driv //------------------------------------------------------------------------------ //initRAO //------------------------------------------------------------------------------ -void RecallTaskInjector::initRAO(const castor::tape::tapeserver::rao::RAOConfig & config) { - this->m_raoManager = castor::tape::tapeserver::rao::RAOManager(config,m_drive); +void RecallTaskInjector::initRAO(const castor::tape::tapeserver::rao::RAOConfigurationData & dataConfig, cta::catalogue::Catalogue * catalogue) { + m_raoManager = castor::tape::tapeserver::rao::RAOManager(dataConfig,m_drive,catalogue); m_raoFuture = m_raoPromise.get_future(); } //------------------------------------------------------------------------------ @@ -145,7 +145,6 @@ void RecallTaskInjector::injectBulkRecalls() { bool useRAO = m_raoManager.useRAO(); if (useRAO) { - std::list<castor::tape::SCSI::Structures::RAO::blockLims> files; m_lc.log(cta::log::INFO, "Performing RAO reordering"); raoOrder = m_raoManager.queryRAO(m_jobs,m_lc); diff --git a/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.hpp b/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.hpp index ade4ae5561c795b53bce16a63de5a17d8408273c..581ad80a695b7a0f7fbf8b315c3a9a1c85fcca04 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.hpp @@ -30,7 +30,7 @@ #include "scheduler/RetrieveJob.hpp" #include "scheduler/RetrieveMount.hpp" #include "castor/tape/tapeserver/drive/DriveInterface.hpp" -#include "castor/tape/tapeserver/RAO/RAOConfig.hpp" +#include "castor/tape/tapeserver/RAO/RAOConfigurationData.hpp" #include "castor/tape/tapeserver/RAO/RAOManager.hpp" #include <future> @@ -124,7 +124,7 @@ public: /** * Initialize Recommended Access Order parameters */ - void initRAO(const castor::tape::tapeserver::rao::RAOConfig & config); + void initRAO(const castor::tape::tapeserver::rao::RAOConfigurationData & dataConfig, cta::catalogue::Catalogue * catalogue); void waitForPromise();