Commit b579ca75 authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

#533: Add methods to modify DISK_SYSTEM table values to the catalogue interface.

Implement methods to modify values for FILE_REGEXP, FREE_SPACE_QUERY_URL, REFRESH_INTERVAL, TARGETED_FREE_SPACE, USER_COMMENT
parent b70d060b
......@@ -530,8 +530,19 @@ public:
*
* @param name The name of the disk system.
*/
virtual void deleteDiskSystem(const std::string &name) = 0;
virtual void deleteDiskSystem(const std::string &name) = 0;
virtual void modifyDiskSystemFileRegexp(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &fileRegexp) = 0;
virtual void modifyDiskSystemFreeSpaceQueryURL(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &freeSpaceQueryURL) = 0;
virtual void modifyDiskSystemRefreshInterval(const common::dataStructures::SecurityIdentity &admin,
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 modifyDiskSystemComment(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &comment) = 0;
/**
* Returns the specified archive files. Please note that the list of files
* is ordered by archive file ID.
......
......@@ -368,10 +368,31 @@ public:
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);
}
void modifyDiskSystemFileRegexp(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &fileRegexp) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyDiskSystemFileRegexp(admin, name, fileRegexp);}, m_maxTriesToConnect);
}
void modifyDiskSystemFreeSpaceQueryURL(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &freeSpaceQueryURL) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyDiskSystemFreeSpaceQueryURL(admin, name, freeSpaceQueryURL);}, m_maxTriesToConnect);
}
void modifyDiskSystemRefreshInterval(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t refreshInterval) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyDiskSystemRefreshInterval(admin, name, refreshInterval);}, m_maxTriesToConnect);
}
void modifyDiskSystemTargetedFreeSpace(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t targetedFreeSpace) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyDiskSystemTargetedFreeSpace(admin, name, targetedFreeSpace);}, m_maxTriesToConnect);
}
void modifyDiskSystemComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyDiskSystemComment(admin, name, comment);}, m_maxTriesToConnect);
}
ArchiveFileItor getArchiveFilesItor(const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria()) const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->getArchiveFilesItor(searchCriteria);}, m_maxTriesToConnect);
}
......
This diff is collapsed.
......@@ -59,7 +59,12 @@ public:
std::list<common::dataStructures::ActivitiesFairShareWeights> getActivitiesFairShareWeights() const { 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"); }
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 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"); }
ArchiveFileItor getArchiveFilesItor(const TapeFileSearchCriteria& searchCriteria) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -4430,6 +4430,211 @@ void RdbmsCatalogue::deleteDiskSystem(const std::string &name) {
}
}
void RdbmsCatalogue::modifyDiskSystemFileRegexp(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &fileRegexp) {
try {
if(name.empty()) {
throw UserSpecifiedAnEmptyStringDiskSystemName("Cannot modify disk system"
" because the disk system name is an empty string");
}
if(fileRegexp.empty()) {
throw UserSpecifiedAnEmptyStringFileRegexp("Cannot modify disk system "
"because the new fileRegexp is an empty string");
}
const time_t now = time(nullptr);
const char *const sql =
"UPDATE DISK_SYSTEM SET "
"FILE_REGEXP = :FILE_REGEXP,"
"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.bindString(":FILE_REGEXP", fileRegexp);
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;
}
}
void RdbmsCatalogue::modifyDiskSystemFreeSpaceQueryURL(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &freeSpaceQueryURL) {
try {
if(name.empty()) {
throw UserSpecifiedAnEmptyStringDiskSystemName("Cannot modify disk system"
" because the disk system name is an empty string");
}
if(freeSpaceQueryURL.empty()) {
throw UserSpecifiedAnEmptyStringFreeSpaceQueryURL("Cannot modify disk system "
"because the new freeSpaceQueryURL is an empty string");
}
const time_t now = time(nullptr);
const char *const sql =
"UPDATE DISK_SYSTEM SET "
"FREE_SPACE_QUERY_URL = :FREE_SPACE_QUERY_URL,"
"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.bindString(":FREE_SPACE_QUERY_URL", freeSpaceQueryURL);
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;
}
}
void RdbmsCatalogue::modifyDiskSystemRefreshInterval(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const uint64_t refreshInterval) {
try {
if(name.empty()) {
throw UserSpecifiedAnEmptyStringDiskSystemName("Cannot modify disk system"
" because the disk system name is an empty string");
}
if(0 == refreshInterval) {
throw UserSpecifiedAZeroRefreshInterval("Cannot modify disk system "
"because the new refresh interval has zero value");
}
const time_t now = time(nullptr);
const char *const sql =
"UPDATE DISK_SYSTEM SET "
"REFRESH_INTERVAL = :REFRESH_INTERVAL,"
"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(":REFRESH_INTERVAL", refreshInterval);
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;
}
}
void RdbmsCatalogue::modifyDiskSystemTargetedFreeSpace(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const uint64_t targetedFreeSpace) {
try {
if(name.empty()) {
throw UserSpecifiedAnEmptyStringDiskSystemName("Cannot modify disk system"
" because the disk system name is an empty string");
}
if(0 == targetedFreeSpace) {
throw UserSpecifiedAZeroTargetedFreeSpace("Cannot modify disk system "
"because the new targeted free space has zero value");
}
const time_t now = time(nullptr);
const char *const sql =
"UPDATE DISK_SYSTEM SET "
"TARGETED_FREE_SPACE = :TARGETED_FREE_SPACE,"
"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(":TARGETED_FREE_SPACE", targetedFreeSpace);
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;
}
}
void RdbmsCatalogue::modifyDiskSystemComment(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &comment) {
try {
if(name.empty()) {
throw UserSpecifiedAnEmptyStringDiskSystemName("Cannot modify disk system"
" because the disk system name is an empty string");
}
if(comment.empty()) {
throw UserSpecifiedAnEmptyStringComment("Cannot modify disk system "
"because the new comment is an empty string");
}
const time_t now = time(nullptr);
const char *const sql =
"UPDATE DISK_SYSTEM SET "
"USER_COMMENT = :USER_COMMENT,"
"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.bindString(":USER_COMMENT", comment);
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
//------------------------------------------------------------------------------
......
......@@ -543,7 +543,18 @@ public:
*
* @param name The name of the disk system.
*/
void deleteDiskSystem(const std::string &name) override;
void deleteDiskSystem(const std::string &name) override;
void modifyDiskSystemFileRegexp(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &fileRegexp) override;
void modifyDiskSystemFreeSpaceQueryURL(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const std::string &freeSpaceQueryURL) override;
void modifyDiskSystemRefreshInterval(const common::dataStructures::SecurityIdentity &admin,
const std::string &name, const uint64_t refreshInterval) override;
void modifyDiskSystemTargetedFreeSpace(const common::dataStructures::SecurityIdentity &admin,
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;
/**
* Throws a UserError exception if the specified searchCriteria is not valid
......
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