Commit 15a1bc62 authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

#533: Add DISK_SYSTEM table to the catalogue schema.

Implement catalogue createDiskSystem,
getAllDiskSystems, deleteDiskSystem methods.
parent 4350d29e
......@@ -54,8 +54,15 @@ set (CATALOGUE_LIB_SRC_FILES
TapeForWriting.cpp
UserSpecifiedANonEmptyTape.cpp
UserSpecifiedANonExistentTape.cpp
UserSpecifiedANonExistentDiskSystem.cpp
UserSpecifiedANonEmptyDiskSystemAfterDelete.cpp
UserSpecifiedAnEmptyStringComment.cpp
UserSpecifiedAnEmptyStringDiskInstanceName.cpp
UserSpecifiedAnEmptyStringDiskSystemName.cpp
UserSpecifiedAnEmptyStringFileRegexp.cpp
UserSpecifiedAnEmptyStringFreeSpaceQueryURL.cpp
UserSpecifiedAZeroRefreshInterval.cpp
UserSpecifiedAZeroTargetedFreeSpace.cpp
UserSpecifiedAnEmptyStringLogicalLibraryName.cpp
UserSpecifiedAnEmptyStringMediaType.cpp
UserSpecifiedAnEmptyStringStorageClassName.cpp
......
......@@ -55,11 +55,11 @@
#include "common/dataStructures/UserIdentity.hpp"
#include "common/dataStructures/VidToTapeMap.hpp"
#include "common/dataStructures/WriteTestResult.hpp"
#include "common/dataStructures/DiskSystem.hpp"
#include "common/exception/UserError.hpp"
#include "common/log/LogContext.hpp"
#include "common/log/Logger.hpp"
#include "common/optional.hpp"
#include "disk/DiskSystem.hpp"
#include <list>
#include <map>
......@@ -492,8 +492,46 @@ public:
virtual void deleteActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity &admin, const std::string & diskInstanceName, const std::string & acttivity) = 0;
virtual std::list<common::dataStructures::ActivitiesFairShareWeights> getActivitiesFairShareWeights() const = 0;
/**
* Returns all the disk systems within the CTA catalogue.
*
* @return The disk systems.
* requester group.
*/
virtual common::dataStructures::DiskSystemList getAllDiskSystems() const = 0;
/**
* Creates a disk system.
*
* @param admin The administrator.
* @param name The name of the disk system.
* @param fileRegexp The regular expression allowing matching destination URLs
* for this disk system.
* @param freeSpaceQueryURL The query URL that describes a method to query the
* free space from the disk system.
* @param refreshInterval The refresh interval (seconds) defining how long do
* we use a free space value.
* @param targetedFreeSpace The targeted free space (margin) based on the free
* space update latency (inherent to the file system and induced by the refresh
* interval), and the expected external bandwidth from sources external to CTA.
* @param comment Comment.
*/
virtual void createDiskSystem(
const common::dataStructures::SecurityIdentity &admin,
const std::string &name,
const std::string &fileRegexp,
const std::string &freeSpaceQueryURL,
const uint64_t refreshInterval,
const uint64_t targetedFreeSpace,
const std::string &comment) = 0;
/**
* Deletes a disk system.
*
* @param name The name of the disk system.
*/
virtual void deleteDiskSystem(const std::string &name) = 0;
virtual cta::disk::DiskSystemList getDiskSystems() const = 0;
/**
* Returns the specified archive files. Please note that the list of files
* is ordered by archive file ID.
......@@ -612,6 +650,14 @@ public:
* @return True if the tape exists.
*/
virtual bool tapeExists(const std::string &vid) const = 0;
/**
* Returns true if the specified disk system exists.
*
* @param name The name identifier of the disk system.
* @return True if the tape exists.
*/
virtual bool diskSystemExists(const std::string &name) const = 0;
}; // class Catalogue
......
......@@ -361,10 +361,16 @@ public:
return retryOnLostConnection(m_log, [&]{return m_catalogue->getActivitiesFairShareWeights();}, m_maxTriesToConnect);
}
cta::disk::DiskSystemList getDiskSystems() const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->getDiskSystems();}, m_maxTriesToConnect);
common::dataStructures::DiskSystemList getAllDiskSystems() const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->getAllDiskSystems();}, m_maxTriesToConnect);
}
void createDiskSystem(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &fileRegexp, const std::string &freeSpaceQueryURL, const uint64_t refreshInterval, const uint64_t targetedFreeSpace, const std::string &comment) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->createDiskSystem(admin, name, fileRegexp, freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);}, m_maxTriesToConnect);
}
void deleteDiskSystem(const std::string &name) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->deleteDiskSystem(name);}, m_maxTriesToConnect);
}
ArchiveFileItor getArchiveFilesItor(const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria()) const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->getArchiveFilesItor(searchCriteria);}, m_maxTriesToConnect);
......@@ -410,6 +416,10 @@ public:
return retryOnLostConnection(m_log, [&]{return m_catalogue->tapeExists(vid);}, m_maxTriesToConnect);
}
bool diskSystemExists(const std::string &name) const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->diskSystemExists(name);}, m_maxTriesToConnect);
};
protected:
/**
......
......@@ -23,6 +23,12 @@
#include "catalogue/FileSizeMismatch.hpp"
#include "catalogue/UserSpecifiedANonEmptyTape.hpp"
#include "catalogue/UserSpecifiedANonExistentTape.hpp"
#include "catalogue/UserSpecifiedANonExistentDiskSystem.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringDiskSystemName.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringFileRegexp.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringFreeSpaceQueryURL.hpp"
#include "catalogue/UserSpecifiedAZeroRefreshInterval.hpp"
#include "catalogue/UserSpecifiedAZeroTargetedFreeSpace.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringComment.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringDiskInstanceName.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringLogicalLibraryName.hpp"
......@@ -11432,6 +11438,270 @@ TEST_P(cta_catalogue_CatalogueTest, getAllTapes_many_tapes) {
}
}
TEST_P(cta_catalogue_CatalogueTest, getAllDiskSystems_no_systems) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
}
TEST_P(cta_catalogue_CatalogueTest, getAllDiskSystems_many_diskSystems) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string fileRegexp = "file_regexp";
const std::string freeSpaceQueryURL = "free_space_query_URL";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint32_t nbDiskSystems = 16;
for(uint32_t i = 0; i < nbDiskSystems; i++) {
std::ostringstream name;
name << "DiskSystem" << std::setfill('0') << std::setw(5) << i;
const std::string diskSystemComment = "Create disk system " + name.str();
m_catalogue->createDiskSystem(m_admin, name.str(), fileRegexp,
freeSpaceQueryURL, refreshInterval + i, targetedFreeSpace + i, diskSystemComment);
}
auto diskSystemsList = m_catalogue->getAllDiskSystems();
ASSERT_EQ(nbDiskSystems, diskSystemsList.size());
for(uint32_t i = 0; i < nbDiskSystems; i++) {
std::ostringstream name;
name << "DiskSystem" << std::setfill('0') << std::setw(5) << i;
const std::string diskSystemComment = "Create disk system " + name.str();
ASSERT_NO_THROW(diskSystemsList.at(name.str()));
const auto diskSystem = diskSystemsList.at(name.str());
ASSERT_EQ(name.str(), diskSystem.name);
ASSERT_EQ(fileRegexp, diskSystem.fileRegexp);
ASSERT_EQ(freeSpaceQueryURL, diskSystem.freeSpaceQueryURL);
ASSERT_EQ(refreshInterval + i, diskSystem.refreshInterval );
ASSERT_EQ(targetedFreeSpace + i, diskSystem.targetedFreeSpace);
ASSERT_EQ(diskSystemComment, diskSystem.comment);
}
}
TEST_P(cta_catalogue_CatalogueTest, diskSystemExists_emptyString) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "";
ASSERT_THROW(m_catalogue->diskSystemExists(name), exception::Exception);
}
TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_emptyStringDiskSystemName) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "";
const std::string fileRegexp = "file_regexp";
const std::string freeSpaceQueryURL = "free_space_query_URL";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const std::string comment = "Create disk system";
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
catalogue::UserSpecifiedAnEmptyStringDiskSystemName);
}
TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_emptyStringFileRegexp) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "disk_system_name";
const std::string fileRegexp = "";
const std::string freeSpaceQueryURL = "free_space_query_URL";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const std::string comment = "Create disk system";
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
catalogue::UserSpecifiedAnEmptyStringFileRegexp);
}
TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_emptyStringFresSpaceQueryURL) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "disk_system_name";
const std::string fileRegexp = "file_regexp";
const std::string freeSpaceQueryURL = "";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const std::string comment = "Create disk system";
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
catalogue::UserSpecifiedAnEmptyStringFreeSpaceQueryURL);
}
TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_zeroRefreshInterval) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "disk_system_name";
const std::string fileRegexp = "file_regexp";
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 0;
const uint64_t targetedFreeSpace = 64;
const std::string comment = "Create disk system";
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
catalogue::UserSpecifiedAZeroRefreshInterval);
}
TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_zeroTargetedFreeSpace) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "disk_system_name";
const std::string fileRegexp = "file_regexp";
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 0;
const std::string comment = "Create disk system";
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
catalogue::UserSpecifiedAZeroTargetedFreeSpace);
}
TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_emptyStringComment) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "disk_system_name";
const std::string fileRegexp = "file_regexp";
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const std::string comment = "";
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
catalogue::UserSpecifiedAnEmptyStringComment);
}
TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_9_exabytes_targetedFreeSpace) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "disk_system_name";
const std::string fileRegexp = "file_regexp";
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
// The maximum size of an SQLite integer is a signed 64-bit integer
const uint64_t targetedFreeSpace = 9L * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const std::string comment = "disk system comment";
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
const auto diskSystemList = m_catalogue->getAllDiskSystems();
ASSERT_EQ(1, diskSystemList.size());
{
const auto &diskSystem = diskSystemList.front();
ASSERT_EQ(name, diskSystem.name);
ASSERT_EQ(fileRegexp, diskSystem.fileRegexp);
ASSERT_EQ(freeSpaceQueryURL, diskSystem.freeSpaceQueryURL);
ASSERT_EQ(refreshInterval, diskSystem.refreshInterval);
ASSERT_EQ(targetedFreeSpace, diskSystem.targetedFreeSpace);
ASSERT_EQ(comment, diskSystem.comment);
const auto creationLog = diskSystem.creationLog;
ASSERT_EQ(m_admin.username, creationLog.username);
ASSERT_EQ(m_admin.host, creationLog.host);
const auto lastModificationLog = diskSystem.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
}
TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_same_twice) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "disk_system_name";
const std::string fileRegexp = "file_regexp";
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const std::string comment = "disk system comment";
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
const auto diskSystemList = m_catalogue->getAllDiskSystems();
ASSERT_EQ(1, diskSystemList.size());
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment), exception::UserError);
}
TEST_P(cta_catalogue_CatalogueTest, deleteDiskSystem) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
const std::string name = "disk_system_name";
const std::string fileRegexp = "file_regexp";
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const std::string comment = "disk system comment";
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
const auto diskSystemList = m_catalogue->getAllDiskSystems();
ASSERT_EQ(1, diskSystemList.size());
const auto &diskSystem = diskSystemList.front();
ASSERT_EQ(name, diskSystem.name);
ASSERT_EQ(fileRegexp, diskSystem.fileRegexp);
ASSERT_EQ(freeSpaceQueryURL, diskSystem.freeSpaceQueryURL);
ASSERT_EQ(refreshInterval, diskSystem.refreshInterval);
ASSERT_EQ(targetedFreeSpace, diskSystem.targetedFreeSpace);
ASSERT_EQ(comment, diskSystem.comment);
const auto creationLog = diskSystem.creationLog;
ASSERT_EQ(m_admin.username, creationLog.username);
ASSERT_EQ(m_admin.host, creationLog.host);
const auto lastModificationLog = diskSystem.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
m_catalogue->deleteDiskSystem(diskSystem.name);
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
}
TEST_P(cta_catalogue_CatalogueTest, deleteDiskSystem_non_existant) {
using namespace cta;
ASSERT_TRUE(m_catalogue->getAllDiskSystems().empty());
ASSERT_THROW(m_catalogue->deleteDiskSystem("non_exsitant_disk_system"), catalogue::UserSpecifiedANonExistentDiskSystem);
}
TEST_P(cta_catalogue_CatalogueTest, reclaimTape_full_lastFSeq_0_no_tape_files) {
using namespace cta;
......
......@@ -149,7 +149,8 @@ void DropSchemaCmd::dropSqliteCatalogueSchema(rdbms::Conn &conn) {
"MOUNT_POLICY",
"ACTIVITIES_WEIGHTS",
"USAGESTATS",
"EXPERIMENTS"
"EXPERIMENTS",
"DISK_SYSTEM"
};
dropDatabaseTables(conn, tablesToDrop);
} catch(exception::Exception &ex) {
......@@ -180,7 +181,8 @@ void DropSchemaCmd::dropMysqlCatalogueSchema(rdbms::Conn &conn) {
"MOUNT_POLICY",
"ACTIVITIES_WEIGHTS",
"USAGESTATS",
"EXPERIMENTS"
"EXPERIMENTS",
"DISK_SYSTEM"
};
dropDatabaseTables(conn, tablesToDrop);
......@@ -248,7 +250,8 @@ void DropSchemaCmd::dropOracleCatalogueSchema(rdbms::Conn &conn) {
"MOUNT_POLICY",
"ACTIVITIES_WEIGHTS",
"USAGESTATS",
"EXPERIMENTS"
"EXPERIMENTS",
"DISK_SYSTEM"
};
dropDatabaseTables(conn, tablesToDrop);
......@@ -282,7 +285,8 @@ void DropSchemaCmd::dropPostgresCatalogueSchema(rdbms::Conn &conn) {
"MOUNT_POLICY",
"ACTIVITIES_WEIGHTS",
"USAGESTATS",
"EXPERIMENTS"
"EXPERIMENTS",
"DISK_SYSTEM"
};
dropDatabaseTables(conn, tablesToDrop);
......
......@@ -57,7 +57,9 @@ public:
void deleteTapePool(const std::string& name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void filesWrittenToTape(const std::set<TapeItemWrittenPointer>& event) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
std::list<common::dataStructures::ActivitiesFairShareWeights> getActivitiesFairShareWeights() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
cta::disk::DiskSystemList getDiskSystems() const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
common::dataStructures::DiskSystemList getAllDiskSystems() const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void createDiskSystem(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &fileRegexp, const std::string &freeSpaceQueryURL, const uint64_t refreshInterval, const uint64_t targetedFreeSpace, const std::string &comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void deleteDiskSystem(const std::string &name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
std::list<common::dataStructures::AdminUser> getAdminUsers() const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
common::dataStructures::ArchiveFile getArchiveFileById(const uint64_t id) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
ArchiveFileItor getArchiveFilesItor(const TapeFileSearchCriteria& searchCriteria) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......@@ -117,6 +119,7 @@ public:
void setTapeFull(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const bool fullValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setTapePoolEncryption(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const bool encryptionValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
bool tapeExists(const std::string& vid) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
bool diskSystemExists(const std::string& name) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void tapeLabelled(const std::string& vid, const std::string& drive) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void tapeMountedForArchive(const std::string& vid, const std::string& drive) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void tapeMountedForRetrieve(const std::string& vid, const std::string& drive) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -22,9 +22,16 @@
#include "catalogue/RdbmsCatalogueGetArchiveFilesForRepackItor.hpp"
#include "catalogue/retryOnLostConnection.hpp"
#include "catalogue/SqliteCatalogueSchema.hpp"
#include "catalogue/UserSpecifiedANonExistentDiskSystem.hpp"
#include "catalogue/UserSpecifiedANonEmptyDiskSystemAfterDelete.hpp"
#include "catalogue/UserSpecifiedANonEmptyTape.hpp"
#include "catalogue/UserSpecifiedANonExistentTape.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringComment.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringDiskSystemName.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringFileRegexp.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringFreeSpaceQueryURL.hpp"
#include "catalogue/UserSpecifiedAZeroRefreshInterval.hpp"
#include "catalogue/UserSpecifiedAZeroTargetedFreeSpace.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringDiskInstanceName.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringLogicalLibraryName.hpp"
#include "catalogue/UserSpecifiedAnEmptyStringMediaType.hpp"
......@@ -1891,6 +1898,45 @@ bool RdbmsCatalogue::tapeExists(rdbms::Conn &conn, const std::string &vid) const
}
}
//------------------------------------------------------------------------------
// diskSystemExists
//------------------------------------------------------------------------------
bool RdbmsCatalogue::diskSystemExists(const std::string &name) const {
try {
auto conn = m_connPool.getConn();
return diskSystemExists(conn, name);
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// diskSystemExists
//------------------------------------------------------------------------------
bool RdbmsCatalogue::diskSystemExists(rdbms::Conn &conn, const std::string &name) const {
try {
const char *const sql =
"SELECT "
"DISK_SYSTEM_NAME AS DISK_SYSTEM_NAME "
"FROM "
"DISK_SYSTEM "
"WHERE "
"DISK_SYSTEM_NAME = :DISK_SYSTEM_NAME";
auto stmt = conn.createStmt(sql);
stmt.bindString(":DISK_SYSTEM_NAME", name);
auto rset = stmt.executeQuery();
return rset.next();
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// deleteTape
//------------------------------------------------------------------------------
......@@ -4199,10 +4245,189 @@ std::list<common::dataStructures::ActivitiesFairShareWeights> RdbmsCatalogue::ge
}
//------------------------------------------------------------------------------
// getDiskSystems
// getAllDiskSystems
//------------------------------------------------------------------------------
cta::disk::DiskSystemList RdbmsCatalogue::getDiskSystems() const {
return cta::disk::DiskSystemList();
common::dataStructures::DiskSystemList RdbmsCatalogue::getAllDiskSystems() const {
try {
common::dataStructures::DiskSystemList diskSystemList;
std::string sql =
"SELECT "
"DISK_SYSTEM.DISK_SYSTEM_NAME AS DISK_SYSTEM_NAME,"
"DISK_SYSTEM.FILE_REGEXP AS FILE_REGEXP,"
"DISK_SYSTEM.FREE_SPACE_QUERY_URL AS FREE_SPACE_QUERY_URL,"
"DISK_SYSTEM.REFRESH_INTERVAL AS REFRESH_INTERVAL,"
"DISK_SYSTEM.TARGETED_FREE_SPACE AS TARGETED_FREE_SPACE,"
"DISK_SYSTEM.USER_COMMENT AS USER_COMMENT,"
"DISK_SYSTEM.CREATION_LOG_USER_NAME AS CREATION_LOG_USER_NAME,"
"DISK_SYSTEM.CREATION_LOG_HOST_NAME AS CREATION_LOG_HOST_NAME,"
"DISK_SYSTEM.CREATION_LOG_TIME AS CREATION_LOG_TIME,"
"DISK_SYSTEM.LAST_UPDATE_USER_NAME AS LAST_UPDATE_USER_NAME,"
"DISK_SYSTEM.LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME,"
"DISK_SYSTEM.LAST_UPDATE_TIME AS LAST_UPDATE_TIME "
"FROM "
"DISK_SYSTEM";
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery();
while (rset.next()) {
common::dataStructures::DiskSystem diskSystem;
diskSystem.name = rset.columnString("DISK_SYSTEM_NAME");
diskSystem.fileRegexp = rset.columnString("FILE_REGEXP");
diskSystem.freeSpaceQueryURL = rset.columnString("FREE_SPACE_QUERY_URL");
diskSystem.refreshInterval = rset.columnUint64("REFRESH_INTERVAL");
diskSystem.targetedFreeSpace = rset.columnUint64("TARGETED_FREE_SPACE");
diskSystem.comment = rset.columnString("USER_COMMENT");
diskSystem.creationLog.username = rset.columnString("CREATION_LOG_USER_NAME");
diskSystem.creationLog.host = rset.columnString("CREATION_LOG_HOST_NAME");
diskSystem.creationLog.time = rset.columnUint64("CREATION_LOG_TIME");
diskSystem.lastModificationLog.username = rset.columnString("LAST_UPDATE_USER_NAME");
diskSystem.lastModificationLog.host = rset.columnString("LAST_UPDATE_HOST_NAME");
diskSystem.lastModificationLog.time = rset.columnUint64("LAST_UPDATE_TIME");
diskSystemList.push_back(diskSystem);
}
return diskSystemList;
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// createDiskSystem
//------------------------------------------------------------------------------
void RdbmsCatalogue::createDiskSystem(
const common::dataStructures::SecurityIdentity &admin,
const std::string &name,
const std::string &fileRegexp,
const std::string &freeSpaceQueryURL,
const uint64_t refreshInterval,
const uint64_t targetedFreeSpace,
const std::string &comment) {
try {
if(name.empty()) {
throw UserSpecifiedAnEmptyStringDiskSystemName("Cannot create disk system because the name is an empty string");
}
if(fileRegexp.empty()) {
throw UserSpecifiedAnEmptyStringFileRegexp("Cannot create disk system because the file regexp is an empty string");
}
if(freeSpaceQueryURL.empty()) {
throw UserSpecifiedAnEmptyStringFreeSpaceQueryURL("Cannot create disk system because the free space query URL is an empty string");
}
if(0 == refreshInterval) {
throw UserSpecifiedAZeroRefreshInterval("Cannot create disk system because the refresh interval is zero");