Commit b19daf7e authored by Steven Murray's avatar Steven Murray
Browse files

Moved TapePool from common::dataStructures:: to catalogue:: because it belongs...

Moved TapePool from common::dataStructures:: to catalogue:: because it belongs to the Catalogue interface
parent 050c23a8
......@@ -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;
......
......@@ -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);
......
......@@ -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"); }
......
......@@ -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");
......
......@@ -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;
......
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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"};
......
......@@ -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())
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment