Commit c604dcd6 authored by Victor Kotlyar's avatar Victor Kotlyar Committed by Michael Davis
Browse files

Add getSchemaVersion to the RdbmsCatalogue.

parent 4c26430f
......@@ -73,7 +73,7 @@ namespace catalogue {
/**
* Abstract class defining the interface to the CTA catalogue responsible for
* storing crticial information about archive files, tapes and tape files.
* storing critical information about archive files, tapes and tape files.
*/
class Catalogue {
public:
......@@ -585,6 +585,14 @@ public:
* Checks that the most trivial query goes through. Throws an exception if not.
*/
virtual void ping() = 0;
/**
* Returns the map of strings to uint64 for the SCHEMA_VERSION_MAJOR
* and SCHEMA_VERSION_MINOR.
*
* @return The map for SCHEMA_VERSION_MAJOR and SCHEMA_VERSION_MINOR values.
*/
virtual std::map<std::string, uint64_t> getSchemaVersion() const = 0;
/**
* Returns true if the specified tape pool exists.
......
......@@ -394,6 +394,10 @@ public:
return retryOnLostConnection(m_log, [&]{return m_catalogue->ping();}, m_maxTriesToConnect);
}
std::map<std::string, uint64_t> getSchemaVersion() const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->getSchemaVersion();}, m_maxTriesToConnect);
}
bool tapePoolExists(const std::string &tapePoolName) const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->tapePoolExists(tapePoolName);}, m_maxTriesToConnect);
}
......
......@@ -106,6 +106,7 @@ public:
void modifyTapeTapePoolName(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const std::string& tapePoolName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void noSpaceLeftOnTape(const std::string& vid) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void ping() override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
std::map<std::string, uint64_t> getSchemaVersion() const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
uint64_t checkAndGetNextArchiveFileId(const std::string &diskInstanceName, const std::string &storageClassName, const common::dataStructures::UserIdentity &user) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
common::dataStructures::ArchiveFileQueueCriteria getArchiveFileQueueCriteria(const std::string &diskInstanceName,
const std::string &storageClassName, const common::dataStructures::UserIdentity &user) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -5759,6 +5759,38 @@ void RdbmsCatalogue::ping() {
}
}
//------------------------------------------------------------------------------
// getSchemaVersion
//------------------------------------------------------------------------------
std::map<std::string, uint64_t> RdbmsCatalogue::getSchemaVersion() const {
try {
std::map<std::string, uint64_t> schemaVersion;
const char *const sql =
"SELECT "
"CTA_CATALOGUE.SCHEMA_VERSION_MAJOR AS SCHEMA_VERSION_MAJOR,"
"CTA_CATALOGUE.SCHEMA_VERSION_MINOR AS SCHEMA_VERSION_MINOR,"
"FROM "
"CTA_CATALOGUE";
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery();
if(rset.next()) {
schemaVersion.insert(std::make_pair("SCHEMA_VERSION_MAJOR", rset.columnUint64("SCHEMA_VERSION_MAJOR")));
schemaVersion.insert(std::make_pair("SCHEMA_VERSION_MINOR", rset.columnUint64("SCHEMA_VERSION_MINOR")));
return schemaVersion;
} else {
throw exception::Exception("SCHEMA_VERSION_MAJOR,SCHEMA_VERSION_MINOR not found in the CTA_CATALOGUE");
}
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// getTableNames
//------------------------------------------------------------------------------
......
......@@ -587,6 +587,14 @@ public:
* @return True if the query went through.
*/
void ping() override;
/**
* Returns the map of strings to uint64 for the SCHEMA_VERSION_MAJOR
* and SCHEMA_VERSION_MINOR.
*
* @return The map for SCHEMA_VERSION_MAJOR and SCHEMA_VERSION_MINOR values.
*/
std::map<std::string, uint64_t> getSchemaVersion() const override;
/**
* Returns the names of all the tables in the database schema in alphabetical
......
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