Commit 650d81c0 authored by Eric Cano's avatar Eric Cano
Browse files

#533 Added support for disk system sleep time in catalogue.

parent 2535618a
......@@ -523,6 +523,7 @@ public:
const std::string &freeSpaceQueryURL,
const uint64_t refreshInterval,
const uint64_t targetedFreeSpace,
const uint64_t sleepTime,
const std::string &comment) = 0;
/**
......@@ -540,6 +541,8 @@ public:
const std::string &name, const uint64_t refreshInterval) = 0;
virtual void modifyDiskSystemTargetedFreeSpace(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const uint64_t targetedFreeSpace) = 0;
virtual void modifyDiskSystemSleepTime(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const uint64_t sleepTime) = 0;
virtual void modifyDiskSystemComment(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &comment) = 0;
......@@ -674,6 +677,7 @@ public:
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringActivity);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnOutOfRangeActivityWeight);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAZeroSleepTime);
} // namespace catalogue
} // namespace cta
......@@ -365,8 +365,8 @@ public:
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 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 uint64_t sleepTime, const std::string &comment) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->createDiskSystem(admin, name, fileRegexp, freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);}, m_maxTriesToConnect);
}
void deleteDiskSystem(const std::string &name) override {
......@@ -393,6 +393,10 @@ public:
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyDiskSystemComment(admin, name, comment);}, m_maxTriesToConnect);
}
void modifyDiskSystemSleepTime(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const uint64_t sleepTime) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyDiskSystemSleepTime(admin, name, sleepTime);}, m_maxTriesToConnect);
}
ArchiveFileItor getArchiveFilesItor(const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria()) const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->getArchiveFilesItor(searchCriteria);}, m_maxTriesToConnect);
}
......
......@@ -11453,6 +11453,7 @@ TEST_P(cta_catalogue_CatalogueTest, getAllDiskSystems_many_diskSystems) {
const std::string freeSpaceQueryURL = "free_space_query_URL";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const uint32_t nbDiskSystems = 16;
......@@ -11461,7 +11462,7 @@ TEST_P(cta_catalogue_CatalogueTest, getAllDiskSystems_many_diskSystems) {
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);
freeSpaceQueryURL, refreshInterval + i, targetedFreeSpace + i, sleepTime + i, diskSystemComment);
}
 
auto diskSystemsList = m_catalogue->getAllDiskSystems();
......@@ -11503,10 +11504,11 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_emptyStringDiskSystemName)
const std::string freeSpaceQueryURL = "free_space_query_URL";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "Create disk system";
 
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment),
catalogue::UserSpecifiedAnEmptyStringDiskSystemName);
}
 
......@@ -11520,10 +11522,11 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_emptyStringFileRegexp) {
const std::string freeSpaceQueryURL = "free_space_query_URL";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "Create disk system";
 
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment),
catalogue::UserSpecifiedAnEmptyStringFileRegexp);
}
 
......@@ -11537,10 +11540,11 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_emptyStringFresSpaceQueryUR
const std::string freeSpaceQueryURL = "";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "Create disk system";
 
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment),
catalogue::UserSpecifiedAnEmptyStringFreeSpaceQueryURL);
}
 
......@@ -11555,10 +11559,11 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_zeroRefreshInterval) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 0;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "Create disk system";
 
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment),
catalogue::UserSpecifiedAZeroRefreshInterval);
}
 
......@@ -11572,10 +11577,11 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_zeroTargetedFreeSpace) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 0;
const uint64_t sleepTime = 15*60;
const std::string comment = "Create disk system";
 
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment),
catalogue::UserSpecifiedAZeroTargetedFreeSpace);
}
 
......@@ -11589,10 +11595,11 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_emptyStringComment) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "";
 
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment),
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment),
catalogue::UserSpecifiedAnEmptyStringComment);
}
 
......@@ -11607,10 +11614,11 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_9_exabytes_targetedFreeSpac
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 uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
const auto diskSystemList = m_catalogue->getAllDiskSystems();
 
......@@ -11623,6 +11631,7 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_9_exabytes_targetedFreeSpac
ASSERT_EQ(freeSpaceQueryURL, diskSystem.freeSpaceQueryURL);
ASSERT_EQ(refreshInterval, diskSystem.refreshInterval);
ASSERT_EQ(targetedFreeSpace, diskSystem.targetedFreeSpace);
ASSERT_EQ(sleepTime, diskSystem.sleepTime);
ASSERT_EQ(comment, diskSystem.comment);
 
const auto creationLog = diskSystem.creationLog;
......@@ -11634,6 +11643,50 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_9_exabytes_targetedFreeSpac
}
}
 
TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_sleepTimeHandling) {
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 uint64_t sleepTime = 0;
const std::string comment = "disk system comment";
ASSERT_THROW(m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment),
catalogue::UserSpecifiedAZeroSleepTime);
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, std::numeric_limits<int64_t>::max(), 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(std::numeric_limits<int64_t>::max(), diskSystem.sleepTime);
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;
 
......@@ -11644,16 +11697,17 @@ TEST_P(cta_catalogue_CatalogueTest, createDiskSystem_same_twice) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, 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);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment), exception::UserError);
 
}
 
......@@ -11667,10 +11721,11 @@ TEST_P(cta_catalogue_CatalogueTest, deleteDiskSystem) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
const auto diskSystemList = m_catalogue->getAllDiskSystems();
 
......@@ -11712,10 +11767,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemFileRegexp) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......@@ -11790,10 +11846,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemFileRegexp_emptyStringFileRe
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......@@ -11830,10 +11887,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemFreeSpaceQueryURL) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......@@ -11908,10 +11966,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemFreeSpaceQueryURL_emptyStrin
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......@@ -11948,10 +12007,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemRefreshInterval) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......@@ -12026,10 +12086,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemRefreshInterval_zeroRefreshI
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......@@ -12066,10 +12127,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemTargetedFreeSpace) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......@@ -12144,10 +12206,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemTargetedFreeSpace_zeroTarget
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......@@ -12184,10 +12247,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemComment) {
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......@@ -12262,10 +12326,11 @@ TEST_P(cta_catalogue_CatalogueTest, modifyDiskSystemCommentL_emptyStringComment)
const std::string freeSpaceQueryURL = "free_space_query_url";
const uint64_t refreshInterval = 32;
const uint64_t targetedFreeSpace = 64;
const uint64_t sleepTime = 15*60;
const std::string comment = "disk system comment";
 
m_catalogue->createDiskSystem(m_admin, name, fileRegexp,
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, comment);
freeSpaceQueryURL, refreshInterval, targetedFreeSpace, sleepTime, comment);
{
const auto diskSystemList = m_catalogue->getAllDiskSystems();
......
......@@ -58,12 +58,13 @@ public:
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"); }
disk::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 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 uint64_t sleepTime, 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"); }
void modifyDiskSystemFileRegexp(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &fileRegexp) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");}
void modifyDiskSystemFreeSpaceQueryURL(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &freeSpaceQueryURL) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");}
void modifyDiskSystemRefreshInterval(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t refreshInterval) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");}
void modifyDiskSystemTargetedFreeSpace(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t targetedFreeSpace) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");}
void modifyDiskSystemSleepTime(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const uint64_t sleepTime) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented");}
void modifyDiskSystemComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) 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"); }
......
......@@ -4257,6 +4257,7 @@ disk::DiskSystemList RdbmsCatalogue::getAllDiskSystems() const {
"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.SLEEP_TIME AS SLEEP_TIME,"
"DISK_SYSTEM.USER_COMMENT AS USER_COMMENT,"
......@@ -4281,6 +4282,7 @@ disk::DiskSystemList RdbmsCatalogue::getAllDiskSystems() const {
diskSystem.freeSpaceQueryURL = rset.columnString("FREE_SPACE_QUERY_URL");
diskSystem.refreshInterval = rset.columnUint64("REFRESH_INTERVAL");
diskSystem.targetedFreeSpace = rset.columnUint64("TARGETED_FREE_SPACE");
diskSystem.sleepTime = rset.columnUint64("SLEEP_TIME");
diskSystem.comment = rset.columnString("USER_COMMENT");
diskSystem.creationLog.username = rset.columnString("CREATION_LOG_USER_NAME");
diskSystem.creationLog.host = rset.columnString("CREATION_LOG_HOST_NAME");
......@@ -4309,6 +4311,7 @@ void RdbmsCatalogue::createDiskSystem(
const std::string &freeSpaceQueryURL,
const uint64_t refreshInterval,
const uint64_t targetedFreeSpace,
const uint64_t sleepTime,
const std::string &comment) {
try {
if(name.empty()) {
......@@ -4326,6 +4329,9 @@ void RdbmsCatalogue::createDiskSystem(
if(0 == targetedFreeSpace) {
throw UserSpecifiedAZeroTargetedFreeSpace("Cannot create disk system because the targeted free space is zero");
}
if (0 == sleepTime) {
throw UserSpecifiedAZeroSleepTime("Cannot create disk system because the sleep time is zero");
}
if(comment.empty()) {
throw UserSpecifiedAnEmptyStringComment("Cannot create disk system because the comment is an empty string");
}
......@@ -4344,6 +4350,7 @@ void RdbmsCatalogue::createDiskSystem(
"FREE_SPACE_QUERY_URL,"
"REFRESH_INTERVAL,"
"TARGETED_FREE_SPACE,"
"SLEEP_TIME,"
"USER_COMMENT,"
......@@ -4360,6 +4367,7 @@ void RdbmsCatalogue::createDiskSystem(
":FREE_SPACE_QUERY_URL,"
":REFRESH_INTERVAL,"
":TARGETED_FREE_SPACE,"
":SLEEP_TIME,"
":USER_COMMENT,"
......@@ -4377,6 +4385,7 @@ void RdbmsCatalogue::createDiskSystem(
stmt.bindString(":FREE_SPACE_QUERY_URL", freeSpaceQueryURL);
stmt.bindUint64(":REFRESH_INTERVAL", refreshInterval);
stmt.bindUint64(":TARGETED_FREE_SPACE", targetedFreeSpace);
stmt.bindUint64(":SLEEP_TIME", sleepTime);
stmt.bindString(":USER_COMMENT", comment);
......@@ -4635,6 +4644,50 @@ void RdbmsCatalogue::modifyDiskSystemComment(const common::dataStructures::Secur
}
}
//------------------------------------------------------------------------------
// modifyDiskSystemSleepTime
//------------------------------------------------------------------------------
void RdbmsCatalogue::modifyDiskSystemSleepTime(const common::dataStructures::SecurityIdentity& admin, const std::string& name,
const uint64_t sleepTime) {
try {
if(name.empty()) {
throw UserSpecifiedAnEmptyStringDiskSystemName("Cannot modify disk system"
" because the disk system name is an empty string");
}
if(sleepTime == 0) {
throw UserSpecifiedAZeroSleepTime("Cannot modify disk system "
"because the new sleep time is zero");
}
const time_t now = time(nullptr);
const char *const sql =
"UPDATE DISK_SYSTEM SET "
"SLEEP_TIME = :SLEEP_TIME,"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"WHERE "
"DISK_SYSTEM_NAME = :DISK_SYSTEM_NAME";
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindUint64(":SLEEP_TIME", sleepTime);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
stmt.bindString(":DISK_SYSTEM_NAME", name);
stmt.executeNonQuery();
if(0 == stmt.getNbAffectedRows()) {
throw UserSpecifiedANonExistentDiskSystem(std::string("Cannot modify disk system ") + name + " because it does not exist");
}
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// insertArchiveFile
//------------------------------------------------------------------------------
......
......@@ -536,6 +536,7 @@ public:
const std::string &freeSpaceQueryURL,
const uint64_t refreshInterval,
const uint64_t targetedFreeSpace,
const uint64_t sleepTime,
const std::string &comment) override;
/**
......@@ -555,6 +556,9 @@ public:
const std::string &name, const uint64_t targetedFreeSpace) override;
void modifyDiskSystemComment(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &comment) override;
void modifyDiskSystemSleepTime(const common::dataStructures::SecurityIdentity& admin,
const std::string& name, const uint64_t sleepTime) override;
/**
* Throws a UserError exception if the specified searchCriteria is not valid
......
......@@ -19,6 +19,7 @@ CREATE TABLE DISK_SYSTEM(
FREE_SPACE_QUERY_URL VARCHAR(1000) CONSTRAINT DISK_SYSTEM_FSQU_NN NOT NULL,
REFRESH_INTERVAL NUMERIC(20, 0) CONSTRAINT DISK_SYSTEM_RI_NN NOT NULL,
TARGETED_FREE_SPACE NUMERIC(20, 0) CONSTRAINT DISK_SYSTEM_TFS_NN NOT NULL,
SLEEP_TIME NUMERIC(20, 0) CONSTRAINT DISK_SYSTEM_ST_NN NOT NULL,
USER_COMMENT VARCHAR(1000) CONSTRAINT DISK_SYSTEM_UC_NN NOT NULL,
CREATION_LOG_USER_NAME VARCHAR(100) CONSTRAINT DISK_SYSTEM_CLUN_NN NOT NULL,
CREATION_LOG_HOST_NAME VARCHAR(100) CONSTRAINT DISK_SYSTEM_CLHN_NN NOT NULL,
......
......@@ -279,7 +279,8 @@ const std::map<std::string, OptionUInt64::Key> uint64Options = {
{ "--retrievepriority", OptionUInt64::RETRIEVE_PRIORITY },
{ "--size", OptionUInt64::FILE_SIZE },
{ "--refreshinterval", OptionUInt64::REFRESH_INTERVAL },
{ "--targetedfreespace", OptionUInt64::TARGETED_FREE_SPACE }
{ "--targetedfreespace", OptionUInt64::TARGETED_FREE_SPACE },
{ "--sleeptime", OptionUInt64::SLEEP_TIME }
};
......@@ -432,6 +433,7 @@ const Option opt_file_regexp { Option::OPT_STR, "--fileregexp",
const Option opt_free_space_query_url { Option::OPT_STR, "--freespacequeryurl", "-u", " <free_space_query_url>" };
const Option opt_refresh_interval { Option::OPT_UINT, "--refreshinterval", "-i", " <refresh_intreval>" };
const Option opt_targeted_free_space { Option::OPT_UINT, "--targetedfreespace", "-f", " <targeted_free_space>" };
const Option opt_sleep_time { Option::OPT_UINT, "--sleeptime", "-s", " <sleep time in s>" };
/*!
* Map valid options to commands
......@@ -544,11 +546,11 @@ const std::map<cmd_key_t, cmd_val_t> cmdOptions = {
{{ AdminCmd::CMD_TAPEPOOL, AdminCmd::SUBCMD_LS }, { }},
/*----------------------------------------------------------------------------------------------------*/
{{ AdminCmd::CMD_DISKSYSTEM, AdminCmd::SUBCMD_ADD },
{ opt_disksystem, opt_file_regexp, opt_free_space_query_url, opt_refresh_interval, opt_targeted_free_space,
{ opt_disksystem, opt_file_regexp, opt_free_space_query_url, opt_refresh_interval, opt_targeted_free_space, opt_sleep_time,
opt_comment }},
{{ AdminCmd::CMD_DISKSYSTEM, AdminCmd::SUBCMD_CH },
{ opt_disksystem, opt_file_regexp.optional(), opt_free_space_query_url.optional(), opt_refresh_interval.optional(),
opt_targeted_free_space.optional(), opt_comment.optional() }},
opt_targeted_free_space.optional(), opt_sleep_time.optional(), opt_comment.optional() }},
{{ AdminCmd::CMD_DISKSYSTEM, AdminCmd::SUBCMD_RM }, { opt_disksystem }},
{{ AdminCmd::CMD_DISKSYSTEM, AdminCmd::SUBCMD_LS }, { }},
};
......
......@@ -856,6 +856,7 @@ void TextFormatter::printDiskSystemLsHeader() {
"url",
"refresh",
"space",
"sleep",
"c.user",
"c.host",
"c.time",
......@@ -874,6 +875,7 @@ void TextFormatter::print(const DiskSystemLsItem &dsls_item)
dsls_item.free_space_query_url(),
dsls_item.refresh_interval(),
dsls_item.targeted_free_space(),
dsls_item.sleep_time(),
dsls_item.creation_log().username(),
dsls_item.creation_log().host(),
timeToStr(dsls_item.creation_log().time()),
......
......@@ -54,6 +54,7 @@ struct QueueAndMountSummary {
struct SleepForSpaceInfo {
time_t startTime;
std::string diskSystemName;
time_t sleepTime;
};
optional<SleepForSpaceInfo> sleepForSpaceInfo;
......
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