diff --git a/catalogue/Catalogue.hpp b/catalogue/Catalogue.hpp index 6da0e0ff1b4057d1777b6f5c3a2c8f77410a33da..bdddd9746c18c8be659fda82ebe079d2f6f1cc5a 100644 --- a/catalogue/Catalogue.hpp +++ b/catalogue/Catalogue.hpp @@ -22,6 +22,7 @@ #include "catalogue/TapeFileSearchCriteria.hpp" #include "catalogue/TapeFileWritten.hpp" #include "catalogue/TapeForWriting.hpp" +#include "catalogue/TapePool.hpp" #include "catalogue/TapeSearchCriteria.hpp" #include "common/dataStructures/AdminHost.hpp" #include "common/dataStructures/AdminUser.hpp" @@ -51,7 +52,6 @@ #include "common/dataStructures/Tape.hpp" #include "common/dataStructures/TapeCopyToPoolMap.hpp" #include "common/dataStructures/TapeFile.hpp" -#include "common/dataStructures/TapePool.hpp" #include "common/dataStructures/UpdateFileInfoRequest.hpp" #include "common/dataStructures/UserIdentity.hpp" #include "common/dataStructures/VerifyInfo.hpp" @@ -255,7 +255,7 @@ public: virtual void createTapePool(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t nbPartialTapes, const bool encryptionValue, const std::string &comment) = 0; virtual void deleteTapePool(const std::string &name) = 0; - virtual std::list<common::dataStructures::TapePool> getTapePools() const = 0; + virtual std::list<TapePool> getTapePools() const = 0; virtual void modifyTapePoolNbPartialTapes(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t nbPartialTapes) = 0; virtual void modifyTapePoolComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0; virtual void setTapePoolEncryption(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool encryptionValue) = 0; diff --git a/catalogue/CatalogueTest.cpp b/catalogue/CatalogueTest.cpp index 6d854d42c141af47399991c9e320720a065115fa..df7b788e296de155c9296e0166b196b4f06ef902 100644 --- a/catalogue/CatalogueTest.cpp +++ b/catalogue/CatalogueTest.cpp @@ -113,7 +113,7 @@ void cta_catalogue_CatalogueTest::SetUp() { } } { - const std::list<common::dataStructures::TapePool> tapePools = m_catalogue->getTapePools(); + const std::list<TapePool> tapePools = m_catalogue->getTapePools(); for(auto &tapePool: tapePools) { m_catalogue->deleteTapePool(tapePool.name); } @@ -796,12 +796,11 @@ TEST_P(cta_catalogue_CatalogueTest, createTapePool) { ASSERT_TRUE(m_catalogue->tapePoolExists(tapePoolName)); - const std::list<common::dataStructures::TapePool> pools = - m_catalogue->getTapePools(); + const std::list<catalogue::TapePool> pools = m_catalogue->getTapePools(); ASSERT_EQ(1, pools.size()); - const common::dataStructures::TapePool pool = pools.front(); + const catalogue::TapePool pool = pools.front(); ASSERT_EQ(tapePoolName, pool.name); ASSERT_EQ(nbPartialTapes, pool.nbPartialTapes); ASSERT_EQ(isEncrypted, pool.encryption); @@ -841,12 +840,11 @@ TEST_P(cta_catalogue_CatalogueTest, deleteTapePool) { m_catalogue->createTapePool(m_admin, tapePoolName, nbPartialTapes, isEncrypted, comment); - const std::list<common::dataStructures::TapePool> pools = - m_catalogue->getTapePools(); + const std::list<catalogue::TapePool> pools = m_catalogue->getTapePools(); ASSERT_EQ(1, pools.size()); - const common::dataStructures::TapePool pool = pools.front(); + const catalogue::TapePool pool = pools.front(); ASSERT_EQ(tapePoolName, pool.name); ASSERT_EQ(nbPartialTapes, pool.nbPartialTapes); ASSERT_EQ(isEncrypted, pool.encryption); @@ -883,11 +881,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyTapePoolNbPartialTapes) { m_catalogue->createTapePool(m_admin, tapePoolName, nbPartialTapes, isEncrypted, comment); { - const std::list<common::dataStructures::TapePool> pools = m_catalogue->getTapePools(); + const std::list<catalogue::TapePool> pools = m_catalogue->getTapePools(); ASSERT_EQ(1, pools.size()); - const common::dataStructures::TapePool pool = pools.front(); + const catalogue::TapePool pool = pools.front(); ASSERT_EQ(tapePoolName, pool.name); ASSERT_EQ(nbPartialTapes, pool.nbPartialTapes); ASSERT_EQ(isEncrypted, pool.encryption); @@ -905,11 +903,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyTapePoolNbPartialTapes) { m_catalogue->modifyTapePoolNbPartialTapes(m_admin, tapePoolName, modifiedNbPartialTapes); { - const std::list<common::dataStructures::TapePool> pools = m_catalogue->getTapePools(); + const std::list<catalogue::TapePool> pools = m_catalogue->getTapePools(); ASSERT_EQ(1, pools.size()); - const common::dataStructures::TapePool pool = pools.front(); + const catalogue::TapePool pool = pools.front(); ASSERT_EQ(tapePoolName, pool.name); ASSERT_EQ(modifiedNbPartialTapes, pool.nbPartialTapes); ASSERT_EQ(isEncrypted, pool.encryption); @@ -944,11 +942,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyTapePoolComment) { m_catalogue->createTapePool(m_admin, tapePoolName, nbPartialTapes, isEncrypted, comment); { - const std::list<common::dataStructures::TapePool> pools = m_catalogue->getTapePools(); + const std::list<catalogue::TapePool> pools = m_catalogue->getTapePools(); ASSERT_EQ(1, pools.size()); - const common::dataStructures::TapePool pool = pools.front(); + const catalogue::TapePool pool = pools.front(); ASSERT_EQ(tapePoolName, pool.name); ASSERT_EQ(nbPartialTapes, pool.nbPartialTapes); ASSERT_EQ(isEncrypted, pool.encryption); @@ -966,11 +964,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyTapePoolComment) { m_catalogue->modifyTapePoolComment(m_admin, tapePoolName, modifiedComment); { - const std::list<common::dataStructures::TapePool> pools = m_catalogue->getTapePools(); + const std::list<catalogue::TapePool> pools = m_catalogue->getTapePools(); ASSERT_EQ(1, pools.size()); - const common::dataStructures::TapePool pool = pools.front(); + const catalogue::TapePool pool = pools.front(); ASSERT_EQ(tapePoolName, pool.name); ASSERT_EQ(nbPartialTapes, pool.nbPartialTapes); ASSERT_EQ(isEncrypted, pool.encryption); @@ -1004,11 +1002,11 @@ TEST_P(cta_catalogue_CatalogueTest, setTapePoolEncryption) { m_catalogue->createTapePool(m_admin, tapePoolName, nbPartialTapes, isEncrypted, comment); { - const std::list<common::dataStructures::TapePool> pools = m_catalogue->getTapePools(); + const std::list<catalogue::TapePool> pools = m_catalogue->getTapePools(); ASSERT_EQ(1, pools.size()); - const common::dataStructures::TapePool pool = pools.front(); + const catalogue::TapePool pool = pools.front(); ASSERT_EQ(tapePoolName, pool.name); ASSERT_EQ(nbPartialTapes, pool.nbPartialTapes); ASSERT_EQ(isEncrypted, pool.encryption); @@ -1026,11 +1024,11 @@ TEST_P(cta_catalogue_CatalogueTest, setTapePoolEncryption) { m_catalogue->setTapePoolEncryption(m_admin, tapePoolName, modifiedIsEncrypted); { - const std::list<common::dataStructures::TapePool> pools = m_catalogue->getTapePools(); + const std::list<catalogue::TapePool> pools = m_catalogue->getTapePools(); ASSERT_EQ(1, pools.size()); - const common::dataStructures::TapePool pool = pools.front(); + const catalogue::TapePool pool = pools.front(); ASSERT_EQ(tapePoolName, pool.name); ASSERT_EQ(nbPartialTapes, pool.nbPartialTapes); ASSERT_EQ(modifiedIsEncrypted, pool.encryption); diff --git a/catalogue/DummyCatalogue.hpp b/catalogue/DummyCatalogue.hpp index 8855e6c5c4e7e0f8fab9a0ffc16c451b1f911052..1e84cf92ad86f38bf87a15faa58e339c9838da4f 100644 --- a/catalogue/DummyCatalogue.hpp +++ b/catalogue/DummyCatalogue.hpp @@ -68,7 +68,7 @@ public: std::list<common::dataStructures::RequesterMountRule> getRequesterMountRules() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } std::list<common::dataStructures::StorageClass> getStorageClasses() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } common::dataStructures::ArchiveFileSummary getTapeFileSummary(const TapeFileSearchCriteria& searchCriteria) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - std::list<common::dataStructures::TapePool> getTapePools() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + std::list<TapePool> getTapePools() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } std::list<common::dataStructures::Tape> getTapes(const TapeSearchCriteria& searchCriteria) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } // getTapesByVid is implemented below (and works). std::list<TapeForWriting> getTapesForWriting(const std::string& logicalLibraryName) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index a73bc58724e4d15a5cd9c26470e4e907eeb12db4..e728e83c5eb73b4b02b91d81ac07764aaedc60f4 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -946,9 +946,9 @@ void RdbmsCatalogue::deleteTapePool(const std::string &name) { //------------------------------------------------------------------------------ // getTapePools //------------------------------------------------------------------------------ -std::list<common::dataStructures::TapePool> RdbmsCatalogue::getTapePools() const { +std::list<TapePool> RdbmsCatalogue::getTapePools() const { try { - std::list<common::dataStructures::TapePool> pools; + std::list<TapePool> pools; const char *const sql = "SELECT " "TAPE_POOL_NAME AS TAPE_POOL_NAME," @@ -972,7 +972,7 @@ std::list<common::dataStructures::TapePool> RdbmsCatalogue::getTapePools() const auto stmt = conn.createStmt(sql, rdbms::Stmt::AutocommitMode::OFF); auto rset = stmt->executeQuery(); while (rset.next()) { - common::dataStructures::TapePool pool; + TapePool pool; pool.name = rset.columnString("TAPE_POOL_NAME"); pool.nbPartialTapes = rset.columnUint64("NB_PARTIAL_TAPES"); diff --git a/catalogue/RdbmsCatalogue.hpp b/catalogue/RdbmsCatalogue.hpp index 6853f39b778d3462ecc0f6a2a39745ff93e80f1f..c2318545d96d3c20d090006cec5525241161f905 100644 --- a/catalogue/RdbmsCatalogue.hpp +++ b/catalogue/RdbmsCatalogue.hpp @@ -244,7 +244,7 @@ public: void createTapePool(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t nbPartialTapes, const bool encryptionValue, const std::string &comment) override; void deleteTapePool(const std::string &name) override; - std::list<common::dataStructures::TapePool> getTapePools() const override; + std::list<TapePool> getTapePools() const override; void modifyTapePoolNbPartialTapes(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t nbPartialTapes) override; void modifyTapePoolComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) override; void setTapePoolEncryption(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool encryptionValue) override; diff --git a/common/dataStructures/TapePool.cpp b/catalogue/TapePool.cpp similarity index 80% rename from common/dataStructures/TapePool.cpp rename to catalogue/TapePool.cpp index 83b0afbecfc43a28c9c4d15e7102750eccd1d2e9..fd03c1316fcbce1bf852e5bdba12a172fff3fd90 100644 --- a/common/dataStructures/TapePool.cpp +++ b/catalogue/TapePool.cpp @@ -16,30 +16,24 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "common/dataStructures/TapePool.hpp" -#include "common/dataStructures/utils.hpp" -#include "common/exception/Exception.hpp" +#include "catalogue/TapePool.hpp" namespace cta { -namespace common { -namespace dataStructures { +namespace catalogue { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ TapePool::TapePool(): - nbPartialTapes(0) {} + nbPartialTapes(0), + encryption(false) { +} //------------------------------------------------------------------------------ // operator== //------------------------------------------------------------------------------ bool TapePool::operator==(const TapePool &rhs) const { - return name==rhs.name - && nbPartialTapes==rhs.nbPartialTapes - && encryption==rhs.encryption - && creationLog==rhs.creationLog - && lastModificationLog==rhs.lastModificationLog - && comment==rhs.comment; + return name == rhs.name; } //------------------------------------------------------------------------------ @@ -62,6 +56,5 @@ std::ostream &operator<<(std::ostream &os, const TapePool &obj) { return os; } -} // namespace dataStructures -} // namespace common +} // namespace catalogue } // namespace cta diff --git a/common/dataStructures/TapePool.hpp b/catalogue/TapePool.hpp similarity index 55% rename from common/dataStructures/TapePool.hpp rename to catalogue/TapePool.hpp index f7f05be909786684a1037a46e927fce5629c81c4..e3cfe20093f00a56f2edc63a210a4133a5cfe7fa 100644 --- a/common/dataStructures/TapePool.hpp +++ b/catalogue/TapePool.hpp @@ -18,16 +18,14 @@ #pragma once -#include <list> -#include <map> +#include <ostream> #include <stdint.h> #include <string> #include "common/dataStructures/EntryLog.hpp" namespace cta { -namespace common { -namespace dataStructures { +namespace catalogue { /** * A tape pool is a logical grouping of tapes, it is used to separate VOs, types @@ -35,23 +33,68 @@ namespace dataStructures { */ struct TapePool { + /** + * Constructor that sets all integer member-variables to 0 and booleans to + * false. + */ TapePool(); + /** + * Comparison operator. + * + * @return True if the names of both tape pools are equal. + */ bool operator==(const TapePool &rhs) const; + /** + * Comparison operator. + * + * @return True if the names of both tape pools are not equal. + */ bool operator!=(const TapePool &rhs) const; + /** + * The name of the tape pool. + */ std::string name; + + /** + * The desired number of tapes that should be empty or partially filled. + */ uint64_t nbPartialTapes; + + /** + * True if the tapes within this tape pool should be encrypted. + */ bool encryption; - EntryLog creationLog; - EntryLog lastModificationLog; + + /** + * The creation log. + */ + common::dataStructures::EntryLog creationLog; + + /** + * The last modification log. + */ + common::dataStructures::EntryLog lastModificationLog; + + /** + * The comment. + */ std::string comment; }; // struct TapePool +/** + * Output stream operator for a TapePool object. + * + * This function writes a human readable form of the specified object to the + * specified output stream. + * + * @param os The output stream. + * @param obj The object. + */ std::ostream &operator<<(std::ostream &os, const TapePool &obj); -} // namespace dataStructures -} // namespace common +} // namespace catalogue } // namespace cta diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index e3c32e713a91f79f22c5973a0c050cdf5c45d157..8e101bb96863acef974adb3f7c0a7651ab8292cf 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -61,7 +61,7 @@ set (COMMON_LIB_SRC_FILES dataStructures/Tape.cpp dataStructures/TapeFile.cpp dataStructures/TapeLog.cpp - dataStructures/TapePool.cpp + ../catalogue/TapePool.cpp dataStructures/TestSourceType.cpp dataStructures/UpdateFileInfoRequest.cpp dataStructures/UpdateFileStorageClassRequest.cpp diff --git a/xroot_plugins/XrdCtaFile.cpp b/xroot_plugins/XrdCtaFile.cpp index d0882e0d96c989527b05fe35712a9e84e5493aa8..f1949287208ba4b7efa3a2ba4b8f7be4eca51e5e 100644 --- a/xroot_plugins/XrdCtaFile.cpp +++ b/xroot_plugins/XrdCtaFile.cpp @@ -836,7 +836,7 @@ std::string XrdCtaFile::xCom_tapepool() { } } else if("ls" == m_requestTokens.at(2)) { //ls - std::list<cta::common::dataStructures::TapePool> list= m_catalogue->getTapePools(); + const std::list<cta::catalogue::TapePool> list= m_catalogue->getTapePools(); if(list.size()>0) { std::vector<std::vector<std::string>> responseTable; std::vector<std::string> header = {"name","# partial tapes","encrypt","c.user","c.host","c.time","m.user","m.host","m.time","comment"}; diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp index 1a1adc7b79c6e7bc2126c511031d7fc00e032052..fdf2dec4986ab964d12f04a83fe96393708ce382 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp @@ -1936,7 +1936,7 @@ void RequestMessage::processTapePool_Ls(const cta::admin::AdminCmd &admincmd, ct std::stringstream cmdlineOutput; - std::list<cta::common::dataStructures::TapePool> list= m_catalogue.getTapePools(); + const std::list<cta::catalogue::TapePool> list= m_catalogue.getTapePools(); if(!list.empty()) {