diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index 2baf65eea8fa41de4e0e73840bf3fcd7aa5b59dd..22ca8e470d785f15ea3cdfee11700749c72b1c9a 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -84,6 +84,27 @@ void Scheduler::authorizeAdmin(const common::dataStructures::SecurityIdentity &c lc.log(log::INFO, "In Scheduler::authorizeAdmin(): success."); } +//------------------------------------------------------------------------------ +// checkAndGetNextArchiveFileId +//------------------------------------------------------------------------------ +uint64_t Scheduler::checkAndGetNextArchiveFileId(const std::string &instanceName, + const std::string &storageClassName, const common::dataStructures::UserIdentity &user, log::LogContext &lc) { + cta::utils::Timer t; + const uint64_t archiveFileId = m_catalogue.checkAndGetNextArchiveFileId(instanceName, storageClassName, user); + const auto catalogueTime = t.secs(); + const auto schedulerDbTime = catalogueTime; + + log::ScopedParamContainer spc(lc); + spc.add("instanceName", instanceName) + .add("storageClass", storageClassName) + .add("fileId", archiveFileId) + .add("catalogueTime", catalogueTime) + .add("schedulerDbTime", schedulerDbTime); + lc.log(log::INFO, "Checked request and got next archive file ID"); + + return archiveFileId; +} + //------------------------------------------------------------------------------ // queueArchive //------------------------------------------------------------------------------ diff --git a/scheduler/Scheduler.hpp b/scheduler/Scheduler.hpp index 6c2018581dc5ff94e113e6cc52a84d4e29d74981..de3d37266c498b0b8fa0549545208b0147636008 100644 --- a/scheduler/Scheduler.hpp +++ b/scheduler/Scheduler.hpp @@ -87,6 +87,28 @@ public: */ void ping(log::LogContext & lc); + /** + * Checks the specified archival could take place and returns a new and + * unique archive file identifier that can be used by a new archive file + * within the catalogue. + * + * @param diskInstanceName The name of the disk instance to which the + * storage class belongs. + * @param storageClassName The name of the storage class of the file to be + * archived. The storage class name is only guaranteed to be unique within + * its disk instance. The storage class name will be used by the Catalogue + * to determine the destination tape pool for each tape copy. + * @param user The user for whom the file is to be archived. This will be + * used by the Catalogue to determine the mount policy to be used when + * archiving the file. + * @return The new archive file identifier. + */ + uint64_t checkAndGetNextArchiveFileId( + const std::string &diskInstanceName, + const std::string &storageClassName, + const common::dataStructures::UserIdentity &user, + log::LogContext &lc); + /** * Queue an archive request and return the CTA file ID. * Throws a UserError exception in case of wrong request parameters (ex. no route to tape)