Commit c90e34c5 authored by Steven Murray's avatar Steven Murray
Browse files

Added SqliteCatalogue::getTapeCopyToPoolMap()

parent 7cde027e
......@@ -174,13 +174,6 @@ public:
virtual void setDriveStatus(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const bool up, const bool force) = 0;
/**
* Returns the next identifier to be used for a new archive file.
*
* @return The next identifier to be used for a new archive file.
*/
virtual uint64_t getNextArchiveFileId() = 0;
/**
* Prepares the catalogue for a new archive file and returns the information
* required to queue the associated archive request.
......@@ -207,7 +200,7 @@ public:
const cta::common::dataStructures::ArchiveRequest &archiveRequest,
const cta::common::dataStructures::TapeFileLocation &tapeFileLocation) = 0;
virtual std::map<uint64_t,std::string> getCopyNbToTapePoolMap(const std::string &storageClass) const = 0;
virtual cta::common::dataStructures::TapeCopyToPoolMap getTapeCopyToPoolMap(const std::string &storageClass) const = 0;
virtual cta::common::dataStructures::MountPolicy getArchiveMountPolicy(const cta::common::dataStructures::UserIdentity &requester) const = 0;
virtual cta::common::dataStructures::MountPolicy getRetrieveMountPolicy(const cta::common::dataStructures::UserIdentity &requester) const = 0;
virtual bool isAdmin(const cta::common::dataStructures::SecurityIdentity &cliIdentity) const = 0;
......
......@@ -423,13 +423,6 @@ cta::common::dataStructures::ArchiveFile cta::catalogue::DummyCatalogue::getArch
//------------------------------------------------------------------------------
void cta::catalogue::DummyCatalogue::setDriveStatus(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const bool up, const bool force) {}
//------------------------------------------------------------------------------
// getNextArchiveFileId
//------------------------------------------------------------------------------
uint64_t cta::catalogue::DummyCatalogue::getNextArchiveFileId() {
return 0;
}
//------------------------------------------------------------------------------
// fileWrittenToTape
//------------------------------------------------------------------------------
......@@ -448,11 +441,11 @@ cta::common::dataStructures::ArchiveFileQueueCriteria
}
//------------------------------------------------------------------------------
// getCopyNbToTapePoolMap
// getTapeCopyToPoolMap
//------------------------------------------------------------------------------
std::map<uint64_t,std::string> cta::catalogue::DummyCatalogue::
getCopyNbToTapePoolMap(const std::string &storageClass) const {
return std::map<uint64_t,std::string>();
cta::common::dataStructures::TapeCopyToPoolMap cta::catalogue::DummyCatalogue::
getTapeCopyToPoolMap(const std::string &storageClass) const {
return cta::common::dataStructures::TapeCopyToPoolMap();
}
//------------------------------------------------------------------------------
......
......@@ -130,12 +130,6 @@ public:
virtual cta::common::dataStructures::ArchiveFile getArchiveFileById(const uint64_t id);
virtual void setDriveStatus(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const bool up, const bool force);
/**
* Returns the next identifier to be used for a new archive file.
*
* @return The next identifier to be used for a new archive file.
*/
virtual uint64_t getNextArchiveFileId();
/**
* Notifies the catalogue that a file has been written to tape.
......@@ -162,8 +156,8 @@ public:
virtual cta::common::dataStructures::ArchiveFileQueueCriteria
prepareForNewFile(const std::string &storageClass, const std::string &user);
std::map<uint64_t,std::string> getCopyNbToTapePoolMap(const std::string &storageClass) const;
virtual cta::common::dataStructures::TapeCopyToPoolMap getTapeCopyToPoolMap(const std::string &storageClass) const;
virtual cta::common::dataStructures::MountPolicy getArchiveMountPolicy(const cta::common::dataStructures::UserIdentity &requester) const;
virtual cta::common::dataStructures::MountPolicy getRetrieveMountPolicy(const cta::common::dataStructures::UserIdentity &requester) const;
virtual bool isAdmin(const cta::common::dataStructures::SecurityIdentity &cliIdentity) const;
......
This diff is collapsed.
......@@ -18,6 +18,7 @@
#pragma once
#include <atomic>
#include "catalogue/Catalogue.hpp"
#include "catalogue/SqliteConn.hpp"
......@@ -150,13 +151,6 @@ public:
virtual void setDriveStatus(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const bool up, const bool force);
/**
* Returns the next identifier to be used for a new archive file.
*
* @return The next identifier to be used for a new archive file.
*/
virtual uint64_t getNextArchiveFileId();
/**
* Notifies the catalogue that a file has been written to tape.
*
......@@ -181,8 +175,8 @@ public:
*/
virtual cta::common::dataStructures::ArchiveFileQueueCriteria
prepareForNewFile(const std::string &storageClass, const std::string &user);
virtual std::map<uint64_t,std::string> getCopyNbToTapePoolMap(const std::string &storageClass) const;
virtual cta::common::dataStructures::TapeCopyToPoolMap getTapeCopyToPoolMap(const std::string &storageClass) const;
virtual cta::common::dataStructures::MountPolicy getArchiveMountPolicy(const cta::common::dataStructures::UserIdentity &requester) const;
virtual cta::common::dataStructures::MountPolicy getRetrieveMountPolicy(const cta::common::dataStructures::UserIdentity &requester) const;
virtual bool isAdmin(const cta::common::dataStructures::SecurityIdentity &cliIdentity) const;
......@@ -194,6 +188,11 @@ private:
*/
mutable SqliteConn m_conn;
/**
* The next unique identifier to be used for an archive file.
*/
std::atomic<uint64_t> m_nextArchiveFileId;
/**
* Creates the database schema.
*/
......@@ -230,6 +229,16 @@ private:
uint64_t getArchiveFileId(const std::string &diskInstance,
const std::string &diskFileId) const;
/**
* Returns the expected number of archive routes for the specified storage
* class as specified by the call to the createStorageClass() method as
* opposed to the actual number entered so far using the createArchiveRoute()
* method.
*
* @return The expected number of archive routes.
*/
uint64_t getExpectedNbArchiveRoutes(const std::string &storageClass) const;
}; // class SqliteCatalogue
} // namespace catalogue
......
......@@ -493,6 +493,13 @@ TEST_F(cta_catalogue_SqliteCatalogueTest, createArchiveRoute) {
const common::dataStructures::EntryLog lastModificationLog =
route.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
common::dataStructures::TapeCopyToPoolMap copyToPoolMap =
catalogue.getTapeCopyToPoolMap(storageClassName);
ASSERT_EQ(1, copyToPoolMap.size());
std::pair<uint64_t, std::string> maplet = *(copyToPoolMap.begin());
ASSERT_EQ(copyNb, maplet.first);
ASSERT_EQ(tapePoolName, maplet.second);
}
TEST_F(cta_catalogue_SqliteCatalogueTest, createArchiveRouteTapePool_same_twice) {
......
......@@ -24,3 +24,15 @@
cta::common::dataStructures::ArchiveFileQueueCriteria::
ArchiveFileQueueCriteria(): fileId(0) {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::common::dataStructures::ArchiveFileQueueCriteria::ArchiveFileQueueCriteria(
const uint64_t fileId,
const TapeCopyToPoolMap &copyToPoolMap,
const MountPolicy &mountPolicy):
fileId(fileId),
copyToPoolMap(copyToPoolMap),
mountPolicy(mountPolicy) {
}
......@@ -40,6 +40,18 @@ struct ArchiveFileQueueCriteria {
*/
ArchiveFileQueueCriteria();
/**
* Constructor.
*
* @param fileId The unique archive-file identifier.
* @param copyToPoolMap The map from tape copy number to tape pool name.
* @param mountPolicy The mount policy.
*/
ArchiveFileQueueCriteria(
const uint64_t fileId,
const TapeCopyToPoolMap &copyToPoolMap,
const MountPolicy &mountPolicy);
/**
* The unique archive-file identifier.
*/
......
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