Commit e5c83023 authored by Eric Cano's avatar Eric Cano
Browse files

Merge remote-tracking branch 'origin/master' into shardedQueues

parents 8f8f50a7 174a2b69
......@@ -25,8 +25,10 @@ set (CATALOGUE_LIB_SRC_FILES
ArchiveFileItor.cpp
ArchiveFileItorImpl.cpp
Catalogue.cpp
CatalogueFactory.cpp
CmdLineTool.cpp
InMemoryCatalogue.cpp
OracleCatalogue.cpp
SqliteCatalogueSchema.cpp
TapeFileWritten.cpp
RdbmsArchiveFileItorImpl.cpp
......@@ -35,11 +37,6 @@ set (CATALOGUE_LIB_SRC_FILES
SqliteCatalogue.cpp
TapeForWriting.cpp)
set (CATALOGUE_LIB_SRC_FILES
${CATALOGUE_LIB_SRC_FILES}
CatalogueFactory.cpp
OracleCatalogue.cpp)
add_library (ctacatalogue SHARED
${CATALOGUE_LIB_SRC_FILES})
set_property(TARGET ctacatalogue PROPERTY SOVERSION "${CTA_SOVERSION}")
......
......@@ -21,12 +21,6 @@
namespace cta {
namespace catalogue {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
Catalogue::Catalogue(log::Logger &log): m_log(log) {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
......
......@@ -77,12 +77,6 @@ namespace catalogue {
*/
class Catalogue {
public:
/**
* Constructor.
*
* @param log Object representing the API to the CTA logging system.
*/
Catalogue(log::Logger &log);
/**
* Destructor.
......@@ -128,6 +122,7 @@ public:
* disabled, not full and are in the specified logical library.
*
* @param logicalLibraryName The name of the logical library.
* @return The list of tapes for writing.
*/
virtual std::list<TapeForWriting> getTapesForWriting(const std::string &logicalLibraryName) const = 0;
......@@ -585,13 +580,6 @@ public:
*/
virtual bool tapeExists(const std::string &vid) const = 0;
protected:
/**
* Object representing the API to the CTA logging system.
*/
log::Logger &m_log;
}; // class Catalogue
} // namespace catalogue
......
......@@ -33,16 +33,18 @@ std::unique_ptr<Catalogue> CatalogueFactory::create(
log::Logger &log,
const rdbms::Login &login,
const uint64_t nbConns,
const uint64_t nbArchiveFileListingConns) {
const uint64_t nbArchiveFileListingConns,
const uint32_t maxTriesToConnect) {
try {
switch(login.dbType) {
case rdbms::Login::DBTYPE_IN_MEMORY:
return cta::make_unique<InMemoryCatalogue>(log, nbConns, nbArchiveFileListingConns);
return cta::make_unique<InMemoryCatalogue>(log, nbConns, nbArchiveFileListingConns, maxTriesToConnect);
case rdbms::Login::DBTYPE_ORACLE:
return cta::make_unique<OracleCatalogue>(log, login.username, login.password, login.database, nbConns,
nbArchiveFileListingConns);
nbArchiveFileListingConns, maxTriesToConnect);
case rdbms::Login::DBTYPE_SQLITE:
return cta::make_unique<SqliteCatalogue>(log, login.database, nbConns, nbArchiveFileListingConns);
return cta::make_unique<SqliteCatalogue>(log, login.database, nbConns, nbArchiveFileListingConns,
maxTriesToConnect);
case rdbms::Login::DBTYPE_NONE:
throw exception::Exception("Cannot create a catalogue without a database type");
default:
......
......@@ -51,12 +51,16 @@ public:
* listing archive files.
* @return The newly created CTA catalogue object. Please note that it is the
* responsibility of the caller to delete the returned CTA catalogue object.
* @param maxTriesToConnext The maximum number of times a single method should
* try to connect to the database in the event of LostDatabaseConnection
* exceptions being thrown.
*/
static std::unique_ptr<Catalogue> create(
log::Logger &log,
const rdbms::Login &login,
const uint64_t nbConns,
const uint64_t nbArchiveFileListingConns);
const uint64_t nbArchiveFileListingConns,
const uint32_t maxTriesToConnect = 3);
}; // class CatalogueFactory
......
......@@ -31,7 +31,7 @@ namespace catalogue {
*/
class DummyCatalogue: public Catalogue {
public:
DummyCatalogue(log::Logger &l): Catalogue(l) {}
DummyCatalogue() {}
virtual ~DummyCatalogue() { }
void createAdminHost(const common::dataStructures::SecurityIdentity& admin, const std::string& hostName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -27,8 +27,10 @@ namespace catalogue {
InMemoryCatalogue::InMemoryCatalogue(
log::Logger &log,
const uint64_t nbConns,
const uint64_t nbArchiveFileListingConns):
SchemaCreatingSqliteCatalogue(log, "file::memory:?cache=shared", nbConns, nbArchiveFileListingConns) {
const uint64_t nbArchiveFileListingConns,
const uint32_t maxTriesToConnect):
SchemaCreatingSqliteCatalogue(log, "file::memory:?cache=shared", nbConns, nbArchiveFileListingConns,
maxTriesToConnect) {
}
//------------------------------------------------------------------------------
......
......@@ -41,11 +41,15 @@ public:
* @param nbArchiveFileListingConns The maximum number of concurrent
* connections to the underlying relational database for the sole purpose of
* listing archive files.
* @param maxTriesToConnext The maximum number of times a single method should
* try to connect to the database in the event of LostDatabaseConnection
* exceptions being thrown.
*/
InMemoryCatalogue(
log::Logger &log,
const uint64_t nbConns,
const uint64_t nbArchiveFileListingConns);
const uint64_t nbArchiveFileListingConns,
const uint32_t maxTriesToConnect);
/**
* Destructor.
......
......@@ -39,15 +39,16 @@ TEST_F(cta_catalogue_InMemoryCatalogue, createSameSchemaInTwoSeparateInMemoryDat
log::DummyLogger dummyLog("dummy");
const uint64_t nbConns = 1;
const uint64_t nbArchiveFileListingConns = 0;
const uint32_t maxTriesToConnect = 1;
// First in-memory database
{
catalogue::InMemoryCatalogue inMemoryCatalogue(dummyLog, nbConns, nbArchiveFileListingConns);
catalogue::InMemoryCatalogue inMemoryCatalogue(dummyLog, nbConns, nbArchiveFileListingConns, maxTriesToConnect);
}
// Second in-memory database
{
catalogue::InMemoryCatalogue inMemoryCatalogue(dummyLog, nbConns, nbArchiveFileListingConns);
catalogue::InMemoryCatalogue inMemoryCatalogue(dummyLog, nbConns, nbArchiveFileListingConns, maxTriesToConnect);
}
}
......
......@@ -18,8 +18,10 @@
#include "catalogue/ArchiveFileRow.hpp"
#include "catalogue/OracleCatalogue.hpp"
#include "common/exception/UserError.hpp"
#include "catalogue/retryOnLostConnection.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/LostDatabaseConnection.hpp"
#include "common/exception/UserError.hpp"
#include "common/make_unique.hpp"
#include "common/threading/MutexLocker.hpp"
#include "common/Timer.hpp"
......@@ -118,13 +120,14 @@ OracleCatalogue::OracleCatalogue(
const std::string &password,
const std::string &database,
const uint64_t nbConns,
const uint64_t nbArchiveFileListingConns):
const uint64_t nbArchiveFileListingConns,
const uint32_t maxTriesToConnect):
RdbmsCatalogue(
log,
rdbms::Login(rdbms::Login::DBTYPE_ORACLE, username, password, database),
nbConns,
nbArchiveFileListingConns) {
nbArchiveFileListingConns,
maxTriesToConnect) {
}
//------------------------------------------------------------------------------
......@@ -137,6 +140,15 @@ OracleCatalogue::~OracleCatalogue() {
// deleteArchiveFile
//------------------------------------------------------------------------------
void OracleCatalogue::deleteArchiveFile(const std::string &diskInstanceName, const uint64_t archiveFileId,
log::LogContext &lc) {
return retryOnLostConnection(m_log, [&]{return deleteArchiveFileInternal(diskInstanceName, archiveFileId, lc);},
m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// deleteArchiveFileInternal
//------------------------------------------------------------------------------
void OracleCatalogue::deleteArchiveFileInternal(const std::string &diskInstanceName, const uint64_t archiveFileId,
log::LogContext &lc) {
try {
const char *selectSql =
......@@ -169,6 +181,7 @@ void OracleCatalogue::deleteArchiveFile(const std::string &diskInstanceName, con
"FOR UPDATE";
utils::Timer t;
auto conn = m_connPool.getConn();
rdbms::AutoRollback autoRollback(conn);
const auto getConnTime = t.secs(utils::Timer::resetCounter);
auto selectStmt = conn.createStmt(selectSql, rdbms::AutocommitMode::OFF);
const auto createStmtTime = t.secs();
......@@ -315,6 +328,8 @@ void OracleCatalogue::deleteArchiveFile(const std::string &diskInstanceName, con
spc.add("TAPE FILE", tapeCopyLogStream.str());
}
lc.log(log::INFO, "Archive file deleted from CTA catalogue");
} catch(exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str());
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
......@@ -327,8 +342,17 @@ void OracleCatalogue::deleteArchiveFile(const std::string &diskInstanceName, con
//------------------------------------------------------------------------------
void OracleCatalogue::deleteArchiveFileByDiskFileId(const std::string &diskInstanceName, const std::string &diskFileId,
log::LogContext &lc) {
return retryOnLostConnection(m_log, [&]{return deleteArchiveFileByDiskFileIdInternal(diskInstanceName, diskFileId,
lc);}, m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// deleteArchiveFileByDiskFileIdInternal
//------------------------------------------------------------------------------
void OracleCatalogue::deleteArchiveFileByDiskFileIdInternal(const std::string &diskInstanceName,
const std::string &diskFileId, log::LogContext &lc) {
try {
const char *selectSql =
const char *const selectSql =
"SELECT "
"ARCHIVE_FILE.ARCHIVE_FILE_ID AS ARCHIVE_FILE_ID,"
"ARCHIVE_FILE.DISK_INSTANCE_NAME AS DISK_INSTANCE_NAME,"
......@@ -465,6 +489,8 @@ void OracleCatalogue::deleteArchiveFileByDiskFileId(const std::string &diskInsta
spc.add("TAPE FILE", tapeCopyLogStream.str());
}
lc.log(log::INFO, "Archive file deleted from CTA catalogue");
} catch(exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str());
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
......@@ -591,6 +617,13 @@ common::dataStructures::Tape OracleCatalogue::selectTapeForUpdate(rdbms::Conn &c
// filesWrittenToTape
//------------------------------------------------------------------------------
void OracleCatalogue::filesWrittenToTape(const std::set<TapeFileWritten> &events) {
return retryOnLostConnection(m_log, [&]{return filesWrittenToTapeInternal(events);}, m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// filesWrittenToTapeInternal
//------------------------------------------------------------------------------
void OracleCatalogue::filesWrittenToTapeInternal(const std::set<TapeFileWritten> &events) {
try {
if (events.empty()) {
return;
......@@ -692,6 +725,8 @@ void OracleCatalogue::filesWrittenToTape(const std::set<TapeFileWritten> &events
conn.commit();
} catch(exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str());
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
} catch(std::exception &se) {
......
......@@ -21,14 +21,9 @@
#include "catalogue/RdbmsCatalogue.hpp"
#include "rdbms/Conn.hpp"
#include <occi.h>
#include <string.h>
namespace cta {
namespace catalogue {
class CatalogueFactory;
/**
* An Oracle based implementation of the CTA catalogue.
*/
......@@ -48,6 +43,9 @@ public:
* @param nbArchiveFileListingConns The maximum number of concurrent
* connections to the underlying relational database for the sole purpose of
* listing archive files.
* @param maxTriesToConnext The maximum number of times a single method should
* try to connect to the database in the event of LostDatabaseConnection
* exceptions being thrown.
*/
OracleCatalogue(
log::Logger &log,
......@@ -55,7 +53,8 @@ public:
const std::string &password,
const std::string &database,
const uint64_t nbConns,
const uint64_t nbArchiveFileListingConns);
const uint64_t nbArchiveFileListingConns,
const uint32_t maxTriesToConnect = 3);
/**
* Destructor.
......@@ -127,6 +126,64 @@ public:
private:
/**
* Deletes the specified archive file and its associated tape copies from the
* catalogue.
*
* Please note that the name of the disk instance is specified in order to
* prevent a disk instance deleting an archive file that belongs to another
* disk instance.
*
* Please note that this method is idempotent. If the file to be deleted does
* not exist in the CTA catalogue then this method returns without error.
*
* This internal method can be re-tried if it throws a LostDatabaseConnection
* exception.
*
* @param instanceName The name of the instance from where the deletion request
* originated
* @param archiveFileId The unique identifier of the archive file.
* @param lc The log context.
* @return The metadata of the deleted archive file including the metadata of
* the associated and also deleted tape copies.
*/
void deleteArchiveFileInternal(const std::string &diskInstanceName, const uint64_t archiveFileId,
log::LogContext &lc);
/**
* Deletes the specified archive file and its associated tape copies from the
* catalogue.
*
* Please note that this method is idempotent. If the file to be deleted does
* not exist in the CTA catalogue then this method returns without error.
*
* This internal method can be re-tried if it throws a LostDatabaseConnection
* exception.
*
* @param diskInstanceName The name of the instance from where the deletion
* request originated
* @param diskFileId The identifier of the source disk file which is unique
* within it's host disk system. Two files from different disk systems may
* have the same identifier. The combination of diskInstanceName and
* diskFileId must be globally unique, in other words unique within the CTA
* catalogue.
* @param lc The log context.
* @return The metadata of the deleted archive file including the metadata of
* the associated and also deleted tape copies.
*/
void deleteArchiveFileByDiskFileIdInternal(const std::string &diskInstanceName, const std::string &diskFileId,
log::LogContext &lc);
/**
* Notifies the catalogue that the specified files have been written to tape.
*
* This internal method can be re-tried if it throws a LostDatabaseConnection
* exception.
*
* @param events The tape file written events.
*/
void filesWrittenToTapeInternal(const std::set<TapeFileWritten> &events);
/**
* Selects the specified tape within the Tape table for update.
*
......
......@@ -19,6 +19,7 @@
#include "catalogue/ArchiveFileRow.hpp"
#include "catalogue/RdbmsArchiveFileItorImpl.hpp"
#include "catalogue/RdbmsCatalogue.hpp"
#include "catalogue/retryOnLostConnection.hpp"
#include "catalogue/SqliteCatalogueSchema.hpp"
#include "common/dataStructures/TapeFile.hpp"
#include "common/exception/Exception.hpp"
......@@ -32,6 +33,7 @@
#include <ctype.h>
#include <memory>
#include <time.h>
#include <common/exception/LostDatabaseConnection.hpp>
namespace cta {
namespace catalogue {
......@@ -43,10 +45,12 @@ RdbmsCatalogue::RdbmsCatalogue(
log::Logger &log,
const rdbms::Login &login,
const uint64_t nbConns,
const uint64_t nbArchiveFileListingConns):
Catalogue(log),
const uint64_t nbArchiveFileListingConns,
const uint32_t maxTriesToConnect):
m_log(log),
m_connPool(login, nbConns),
m_archiveFileListingConnPool(login, nbArchiveFileListingConns) {
m_archiveFileListingConnPool(login, nbArchiveFileListingConns),
m_maxTriesToConnect(maxTriesToConnect) {
}
//------------------------------------------------------------------------------
......@@ -2190,6 +2194,13 @@ void RdbmsCatalogue::modifyTapeEncryptionKey(const common::dataStructures::Secur
// tapeMountedForArchive
//------------------------------------------------------------------------------
void RdbmsCatalogue::tapeMountedForArchive(const std::string &vid, const std::string &drive) {
return retryOnLostConnection(m_log, [&]{return tapeMountedForArchiveInternal(vid, drive);}, m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// tapeMountedForArchiveInternal
//------------------------------------------------------------------------------
void RdbmsCatalogue::tapeMountedForArchiveInternal(const std::string &vid, const std::string &drive) {
try {
const time_t now = time(nullptr);
const char *const sql =
......@@ -2205,9 +2216,11 @@ void RdbmsCatalogue::tapeMountedForArchive(const std::string &vid, const std::st
stmt.bindString(":VID", vid);
stmt.executeNonQuery();
if(0 == stmt.getNbAffectedRows()) {
if (0 == stmt.getNbAffectedRows()) {
throw exception::UserError(std::string("Cannot modify tape ") + vid + " because it does not exist");
}
} catch(exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + "failed: " + le.getMessage().str());
} catch(exception::UserError &) {
throw;
} catch (exception::Exception &ex) {
......@@ -2219,6 +2232,13 @@ void RdbmsCatalogue::tapeMountedForArchive(const std::string &vid, const std::st
// tapeMountedForRetrieve
//------------------------------------------------------------------------------
void RdbmsCatalogue::tapeMountedForRetrieve(const std::string &vid, const std::string &drive) {
return retryOnLostConnection(m_log, [&]{return tapeMountedForRetrieveInternal(vid, drive);}, m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// tapeMountedForRetrieveInternal
//------------------------------------------------------------------------------
void RdbmsCatalogue::tapeMountedForRetrieveInternal(const std::string &vid, const std::string &drive) {
try {
const time_t now = time(nullptr);
const char *const sql =
......@@ -2237,6 +2257,8 @@ void RdbmsCatalogue::tapeMountedForRetrieve(const std::string &vid, const std::s
if(0 == stmt.getNbAffectedRows()) {
throw exception::UserError(std::string("Cannot modify tape ") + vid + " because it does not exist");
}
} catch(exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + "failed: " + le.getMessage().str());
} catch(exception::UserError &) {
throw;
} catch (exception::Exception &ex) {
......@@ -2282,6 +2304,13 @@ void RdbmsCatalogue::setTapeFull(const common::dataStructures::SecurityIdentity
// noSpaceLeftOnTape
//------------------------------------------------------------------------------
void RdbmsCatalogue::noSpaceLeftOnTape(const std::string &vid) {
return retryOnLostConnection(m_log, [&]{return noSpaceLeftOnTapeInternal(vid);}, m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// noSpaceLeftOnTapeInternal
//------------------------------------------------------------------------------
void RdbmsCatalogue::noSpaceLeftOnTapeInternal(const std::string &vid) {
try {
const char *const sql =
"UPDATE TAPE SET "
......@@ -2293,9 +2322,11 @@ void RdbmsCatalogue::noSpaceLeftOnTape(const std::string &vid) {
stmt.bindString(":VID", vid);
stmt.executeNonQuery();
if(0 == stmt.getNbAffectedRows()) {
if (0 == stmt.getNbAffectedRows()) {
throw exception::Exception(std::string("Tape ") + vid + " does not exist");
}
} catch (exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str());
} catch (exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
}
......@@ -3747,6 +3778,13 @@ common::dataStructures::ArchiveFile RdbmsCatalogue::getArchiveFileById(const uin
// tapeLabelled
//------------------------------------------------------------------------------
void RdbmsCatalogue::tapeLabelled(const std::string &vid, const std::string &drive, const bool lbpIsOn) {
return retryOnLostConnection(m_log, [&]{return tapeLabelledInternal(vid, drive, lbpIsOn);}, m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// tapeLabelledInternal
//------------------------------------------------------------------------------
void RdbmsCatalogue::tapeLabelledInternal(const std::string &vid, const std::string &drive, const bool lbpIsOn) {
try {
const time_t now = time(nullptr);
const char *const sql =
......@@ -3767,6 +3805,8 @@ void RdbmsCatalogue::tapeLabelled(const std::string &vid, const std::string &dri
if(0 == stmt.getNbAffectedRows()) {
throw exception::UserError(std::string("Cannot modify tape ") + vid + " because it does not exist");
}
} catch(exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str());
} catch(exception::UserError &) {
throw;
} catch (exception::Exception &ex) {
......@@ -3779,6 +3819,16 @@ void RdbmsCatalogue::tapeLabelled(const std::string &vid, const std::string &dri
//------------------------------------------------------------------------------
common::dataStructures::ArchiveFileQueueCriteria RdbmsCatalogue::prepareForNewFile(const std::string &diskInstanceName,
const std::string &storageClassName, const common::dataStructures::UserIdentity &user) {
return retryOnLostConnection( m_log, [&]{return prepareForNewFileInternal(diskInstanceName, storageClassName, user);},
m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// prepareForNewFileInternal
//------------------------------------------------------------------------------
common::dataStructures::ArchiveFileQueueCriteria RdbmsCatalogue::prepareForNewFileInternal(
const std::string &diskInstanceName, const std::string &storageClassName,
const common::dataStructures::UserIdentity &user) {
try {
auto conn = m_connPool.getConn();
const common::dataStructures::TapeCopyToPoolMap copyToPoolMap = getTapeCopyToPoolMap(conn, diskInstanceName,
......@@ -3816,10 +3866,12 @@ common::dataStructures::ArchiveFileQueueCriteria RdbmsCatalogue::prepareForNewFi
}
// Now that we have both the archive routes and the mount policy it's safe to
// consume an archive file identifierarchiveFileId
// consume an archive file identifier
const uint64_t archiveFileId = getNextArchiveFileId(conn);
return common::dataStructures::ArchiveFileQueueCriteria(archiveFileId, copyToPoolMap, mountPolicy);
} catch(exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str());
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
......@@ -3922,6 +3974,18 @@ void RdbmsCatalogue::updateTape(
// prepareToRetrieveFile
//------------------------------------------------------------------------------
common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetrieveFile(
const std::string &diskInstanceName,
const uint64_t archiveFileId,
const common::dataStructures::UserIdentity &user,
log::LogContext &lc) {
return retryOnLostConnection( m_log, [&]{return prepareToRetrieveFileInternal(diskInstanceName, archiveFileId, user,
lc);}, m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// prepareToRetrieveFileInternal
//------------------------------------------------------------------------------
common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetrieveFileInternal(
const std::string &diskInstanceName,
const uint64_t archiveFileId,
const common::dataStructures::UserIdentity &user,
......@@ -3975,6 +4039,8 @@ common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetri
criteria.archiveFile = *archiveFile;
criteria.mountPolicy = mountPolicy;
return criteria;
} catch(exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str());
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
......@@ -3986,6 +4052,18 @@ common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetri
// prepareToRetrieveFileByDiskFileId
//------------------------------------------------------------------------------
common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetrieveFileByDiskFileId(
const std::string &diskInstanceName,
const std::string &diskFileId,
const common::dataStructures::UserIdentity &user,
log::LogContext &lc) {
return retryOnLostConnection( m_log, [&]{return prepareToRetrieveFileByDiskFileIdInternal(diskInstanceName,
diskFileId, user, lc);}, m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// prepareToRetrieveFileByDiskFileIdInternal
//------------------------------------------------------------------------------
common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetrieveFileByDiskFileIdInternal(
const std::string &diskInstanceName,
const std::string &diskFileId,
const common::dataStructures::UserIdentity &user,
......@@ -4033,6 +4111,8 @@ common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetri
criteria.archiveFile = *archiveFile;
criteria.mountPolicy = mountPolicy;
return criteria;
} catch(exception::LostDatabaseConnection &le) {
throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str());
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
......@@ -4146,8 +4226,23 @@ RequesterAndGroupMountPolicies RdbmsCatalogue::getMountPolicies(
// isAdmin
//------------------------------------------------------------------------------
bool RdbmsCatalogue::isAdmin(const common::dataStructures::SecurityIdentity &admin) const {
auto conn = m_connPool.getConn();
return userIsAdmin(conn, admin.username) && hostIsAdmin(conn, admin.host);
return retryOnLostConnection(m_log, [&]{return isAdminInternal(admin);}, m_maxTriesToConnect);
}
//------------------------------------------------------------------------------
// isAdminInternal
//------------------------------------------------------------------------------
bool RdbmsCatalogue::isAdminInternal(const common::dataStructures::SecurityIdentity &admin) const {
try {