Commit 92c49e77 authored by Steven Murray's avatar Steven Murray
Browse files

Removed unused method Catalogue::deleteArchiveFileByDiskFileId()

parent ff115ba8
......@@ -553,27 +553,6 @@ public:
virtual void deleteArchiveFile(const std::string &instanceName, const uint64_t archiveFileId,
log::LogContext &lc) = 0;
/**
* 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.
*
* @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.
*/
virtual void deleteArchiveFileByDiskFileId(const std::string &diskInstanceName, const std::string &diskFileId,
log::LogContext &lc) = 0;
/**
* Returns true if the specified user running the CTA command-line tool on
* the specified host has administrator privileges.
......
......@@ -349,10 +349,6 @@ public:
return retryOnLostConnection(m_log, [&]{return m_catalogue->deleteArchiveFile(instanceName, archiveFileId, lc);}, m_maxTriesToConnect);
}
void deleteArchiveFileByDiskFileId(const std::string &diskInstanceName, const std::string &diskFileId, log::LogContext &lc) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->deleteArchiveFileByDiskFileId(diskInstanceName, diskFileId, lc);}, m_maxTriesToConnect);
}
bool isAdmin(const common::dataStructures::SecurityIdentity &admin) const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->isAdmin(admin);}, m_maxTriesToConnect);
}
......
......@@ -9287,323 +9287,6 @@ TEST_P(cta_catalogue_CatalogueTest, deleteArchiveFile) {
ASSERT_FALSE(m_catalogue->getArchiveFiles().hasMore());
}
TEST_P(cta_catalogue_CatalogueTest, deleteArchiveFile_by_disk_file_id) {
using namespace cta;
const std::string vid1 = "VID123";
const std::string vid2 = "VID456";
const std::string logicalLibraryName = "logical_library_name";
const std::string tapePoolName = "tape_pool_name";
const std::string vo = "vo";
const uint64_t capacityInBytes = (uint64_t)10 * 1000 * 1000 * 1000 * 1000;
const bool disabledValue = true;
const bool fullValue = false;
const std::string comment = "Create tape";
m_catalogue->createLogicalLibrary(m_admin, logicalLibraryName, "Create logical library");
m_catalogue->createTapePool(m_admin, tapePoolName, vo, 2, true, "Create tape pool");
m_catalogue->createTape(m_admin, vid1, logicalLibraryName, tapePoolName, capacityInBytes, disabledValue, fullValue,
comment);
m_catalogue->createTape(m_admin, vid2, logicalLibraryName, tapePoolName, capacityInBytes, disabledValue, fullValue,
comment);
{
const std::list<common::dataStructures::Tape> tapes = m_catalogue->getTapes();
ASSERT_EQ(2, tapes.size());
const std::map<std::string, common::dataStructures::Tape> vidToTape = tapeListToMap(tapes);
{
auto it = vidToTape.find(vid1);
const common::dataStructures::Tape &tape = it->second;
ASSERT_EQ(vid1, tape.vid);
ASSERT_EQ(logicalLibraryName, tape.logicalLibraryName);
ASSERT_EQ(tapePoolName, tape.tapePoolName);
ASSERT_EQ(capacityInBytes, tape.capacityInBytes);
ASSERT_TRUE(disabledValue == tape.disabled);
ASSERT_TRUE(fullValue == tape.full);
ASSERT_FALSE(tape.lbp);
ASSERT_EQ(comment, tape.comment);
ASSERT_FALSE(tape.labelLog);
ASSERT_FALSE(tape.lastReadLog);
ASSERT_FALSE(tape.lastWriteLog);
const common::dataStructures::EntryLog creationLog = tape.creationLog;
ASSERT_EQ(m_admin.username, creationLog.username);
ASSERT_EQ(m_admin.host, creationLog.host);
const common::dataStructures::EntryLog lastModificationLog =
tape.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
{
auto it = vidToTape.find(vid2);
const common::dataStructures::Tape &tape = it->second;
ASSERT_EQ(vid2, tape.vid);
ASSERT_EQ(logicalLibraryName, tape.logicalLibraryName);
ASSERT_EQ(tapePoolName, tape.tapePoolName);
ASSERT_EQ(capacityInBytes, tape.capacityInBytes);
ASSERT_TRUE(disabledValue == tape.disabled);
ASSERT_TRUE(fullValue == tape.full);
ASSERT_FALSE(tape.lbp);
ASSERT_EQ(comment, tape.comment);
ASSERT_FALSE(tape.labelLog);
ASSERT_FALSE(tape.lastReadLog);
ASSERT_FALSE(tape.lastWriteLog);
const common::dataStructures::EntryLog creationLog = tape.creationLog;
ASSERT_EQ(m_admin.username, creationLog.username);
ASSERT_EQ(m_admin.host, creationLog.host);
const common::dataStructures::EntryLog lastModificationLog =
tape.lastModificationLog;
ASSERT_EQ(creationLog, lastModificationLog);
}
}
const uint64_t archiveFileId = 1234;
ASSERT_FALSE(m_catalogue->getArchiveFiles().hasMore());
ASSERT_THROW(m_catalogue->getArchiveFileById(archiveFileId), exception::Exception);
common::dataStructures::StorageClass storageClass;
storageClass.diskInstance = "disk_instance";
storageClass.name = "storage_class";
storageClass.nbCopies = 2;
storageClass.comment = "Create storage class";
m_catalogue->createStorageClass(m_admin, storageClass);
const uint64_t archiveFileSize = 1;
const std::string checksumType = "checksum_type";
const std::string checksumValue = "checksum_value";
const std::string tapeDrive = "tape_drive";
auto file1WrittenUP=cta::make_unique<cta::catalogue::TapeFileWritten>();
auto & file1Written = *file1WrittenUP;
std::set<cta::catalogue::TapeItemWrittenPointer> file1WrittenSet;
file1WrittenSet.insert(file1WrittenUP.release());
file1Written.archiveFileId = archiveFileId;
file1Written.diskInstance = storageClass.diskInstance;
file1Written.diskFileId = "5678";
file1Written.diskFilePath = "/public_dir/public_file";
file1Written.diskFileUser = "public_disk_user";
file1Written.diskFileGroup = "public_disk_group";
file1Written.diskFileRecoveryBlob = "opaque_disk_file_recovery_contents";
file1Written.size = archiveFileSize;
file1Written.checksumType = checksumType;
file1Written.checksumValue = checksumValue;
file1Written.storageClassName = storageClass.name;
file1Written.vid = vid1;
file1Written.fSeq = 1;
file1Written.blockId = 4321;
file1Written.compressedSize = 1;
file1Written.copyNb = 1;
file1Written.tapeDrive = tapeDrive;
m_catalogue->filesWrittenToTape(file1WrittenSet);
{
catalogue::TapeSearchCriteria searchCriteria;
searchCriteria.vid = file1Written.vid;
std::list<common::dataStructures::Tape> tapes = m_catalogue->getTapes(searchCriteria);
ASSERT_EQ(1, tapes.size());
const common::dataStructures::Tape &tape = tapes.front();
ASSERT_EQ(1, tape.lastFSeq);
}
{
auto archiveFileItor = m_catalogue->getArchiveFiles();
const auto m = archiveFileItorToMap(archiveFileItor);
ASSERT_EQ(1, m.size());
auto mItor = m.find(file1Written.archiveFileId);
ASSERT_FALSE(m.end() == mItor);
const common::dataStructures::ArchiveFile archiveFile = mItor->second;
ASSERT_EQ(file1Written.archiveFileId, archiveFile.archiveFileID);
ASSERT_EQ(file1Written.diskFileId, archiveFile.diskFileId);
ASSERT_EQ(file1Written.size, archiveFile.fileSize);
ASSERT_EQ(file1Written.checksumType, archiveFile.checksumType);
ASSERT_EQ(file1Written.checksumValue, archiveFile.checksumValue);
ASSERT_EQ(file1Written.storageClassName, archiveFile.storageClass);
ASSERT_EQ(file1Written.diskInstance, archiveFile.diskInstance);
ASSERT_EQ(file1Written.diskFilePath, archiveFile.diskFileInfo.path);
ASSERT_EQ(file1Written.diskFileUser, archiveFile.diskFileInfo.owner);
ASSERT_EQ(file1Written.diskFileGroup, archiveFile.diskFileInfo.group);
ASSERT_EQ(file1Written.diskFileRecoveryBlob, archiveFile.diskFileInfo.recoveryBlob);
ASSERT_EQ(1, archiveFile.tapeFiles.size());
auto copyNbToTapeFile1Itor = archiveFile.tapeFiles.find(1);
ASSERT_FALSE(copyNbToTapeFile1Itor == archiveFile.tapeFiles.end());
const common::dataStructures::TapeFile &tapeFile1 = copyNbToTapeFile1Itor->second;
ASSERT_EQ(file1Written.vid, tapeFile1.vid);
ASSERT_EQ(file1Written.fSeq, tapeFile1.fSeq);
ASSERT_EQ(file1Written.blockId, tapeFile1.blockId);
ASSERT_EQ(file1Written.compressedSize, tapeFile1.compressedSize);
ASSERT_EQ(file1Written.checksumType, tapeFile1.checksumType);
ASSERT_EQ(file1Written.checksumValue, tapeFile1.checksumValue);
ASSERT_EQ(file1Written.copyNb, tapeFile1.copyNb);
}
{
const common::dataStructures::ArchiveFile archiveFile = m_catalogue->getArchiveFileById(archiveFileId);
ASSERT_EQ(file1Written.archiveFileId, archiveFile.archiveFileID);
ASSERT_EQ(file1Written.diskFileId, archiveFile.diskFileId);
ASSERT_EQ(file1Written.size, archiveFile.fileSize);
ASSERT_EQ(file1Written.checksumType, archiveFile.checksumType);
ASSERT_EQ(file1Written.checksumValue, archiveFile.checksumValue);
ASSERT_EQ(file1Written.storageClassName, archiveFile.storageClass);
ASSERT_EQ(file1Written.diskInstance, archiveFile.diskInstance);
ASSERT_EQ(file1Written.diskFilePath, archiveFile.diskFileInfo.path);
ASSERT_EQ(file1Written.diskFileUser, archiveFile.diskFileInfo.owner);
ASSERT_EQ(file1Written.diskFileGroup, archiveFile.diskFileInfo.group);
ASSERT_EQ(file1Written.diskFileRecoveryBlob, archiveFile.diskFileInfo.recoveryBlob);
ASSERT_EQ(1, archiveFile.tapeFiles.size());
auto copyNbToTapeFile1Itor = archiveFile.tapeFiles.find(1);
ASSERT_FALSE(copyNbToTapeFile1Itor == archiveFile.tapeFiles.end());
const common::dataStructures::TapeFile &tapeFile1 = copyNbToTapeFile1Itor->second;
ASSERT_EQ(file1Written.vid, tapeFile1.vid);
ASSERT_EQ(file1Written.fSeq, tapeFile1.fSeq);
ASSERT_EQ(file1Written.blockId, tapeFile1.blockId);
ASSERT_EQ(file1Written.compressedSize, tapeFile1.compressedSize);
ASSERT_EQ(file1Written.checksumType, tapeFile1.checksumType);
ASSERT_EQ(file1Written.checksumValue, tapeFile1.checksumValue);
ASSERT_EQ(file1Written.copyNb, tapeFile1.copyNb);
}
auto file2WrittenUP=cta::make_unique<cta::catalogue::TapeFileWritten>();
auto & file2Written = *file2WrittenUP;
std::set<cta::catalogue::TapeItemWrittenPointer> file2WrittenSet;
file2WrittenSet.insert(file2WrittenUP.release());
file2Written.archiveFileId = file1Written.archiveFileId;
file2Written.diskInstance = file1Written.diskInstance;
file2Written.diskFileId = file1Written.diskFileId;
file2Written.diskFilePath = file1Written.diskFilePath;
file2Written.diskFileUser = file1Written.diskFileUser;
file2Written.diskFileGroup = file1Written.diskFileGroup;
file2Written.diskFileRecoveryBlob = file1Written.diskFileRecoveryBlob;
file2Written.size = archiveFileSize;
file2Written.checksumType = checksumType;
file2Written.checksumValue = checksumValue;
file2Written.storageClassName = storageClass.name;
file2Written.vid = vid2;
file2Written.fSeq = 1;
file2Written.blockId = 4331;
file2Written.compressedSize = 1;
file2Written.copyNb = 2;
file2Written.tapeDrive = tapeDrive;
m_catalogue->filesWrittenToTape(file2WrittenSet);
{
ASSERT_EQ(2, m_catalogue->getTapes().size());
catalogue::TapeSearchCriteria searchCriteria;
searchCriteria.vid = file2Written.vid;
std::list<common::dataStructures::Tape> tapes = m_catalogue->getTapes(searchCriteria);
ASSERT_EQ(1, tapes.size());
const common::dataStructures::Tape &tape = tapes.front();
ASSERT_EQ(1, tape.lastFSeq);
}
{
auto archiveFileItor = m_catalogue->getArchiveFiles();
const auto m = archiveFileItorToMap(archiveFileItor);
ASSERT_EQ(1, m.size());
{
auto mItor = m.find(file1Written.archiveFileId);
ASSERT_FALSE(m.end() == mItor);
const common::dataStructures::ArchiveFile archiveFile = mItor->second;
ASSERT_EQ(file2Written.archiveFileId, archiveFile.archiveFileID);
ASSERT_EQ(file2Written.diskFileId, archiveFile.diskFileId);
ASSERT_EQ(file2Written.size, archiveFile.fileSize);
ASSERT_EQ(file2Written.checksumType, archiveFile.checksumType);
ASSERT_EQ(file2Written.checksumValue, archiveFile.checksumValue);
ASSERT_EQ(file2Written.storageClassName, archiveFile.storageClass);
ASSERT_EQ(file2Written.diskInstance, archiveFile.diskInstance);
ASSERT_EQ(file2Written.diskFilePath, archiveFile.diskFileInfo.path);
ASSERT_EQ(file2Written.diskFileUser, archiveFile.diskFileInfo.owner);
ASSERT_EQ(file2Written.diskFileGroup, archiveFile.diskFileInfo.group);
ASSERT_EQ(file2Written.diskFileRecoveryBlob, archiveFile.diskFileInfo.recoveryBlob);
ASSERT_EQ(2, archiveFile.tapeFiles.size());
auto copyNbToTapeFile1Itor = archiveFile.tapeFiles.find(1);
ASSERT_FALSE(copyNbToTapeFile1Itor == archiveFile.tapeFiles.end());
const common::dataStructures::TapeFile &tapeFile1 = copyNbToTapeFile1Itor->second;
ASSERT_EQ(file1Written.vid, tapeFile1.vid);
ASSERT_EQ(file1Written.fSeq, tapeFile1.fSeq);
ASSERT_EQ(file1Written.blockId, tapeFile1.blockId);
ASSERT_EQ(file1Written.compressedSize, tapeFile1.compressedSize);
ASSERT_EQ(file1Written.checksumType, tapeFile1.checksumType);
ASSERT_EQ(file1Written.checksumValue, tapeFile1.checksumValue);
ASSERT_EQ(file1Written.copyNb, tapeFile1.copyNb);
auto copyNbToTapeFile2Itor = archiveFile.tapeFiles.find(2);
ASSERT_FALSE(copyNbToTapeFile2Itor == archiveFile.tapeFiles.end());
const common::dataStructures::TapeFile &tapeFile2 = copyNbToTapeFile2Itor->second;
ASSERT_EQ(file2Written.vid, tapeFile2.vid);
ASSERT_EQ(file2Written.fSeq, tapeFile2.fSeq);
ASSERT_EQ(file2Written.blockId, tapeFile2.blockId);
ASSERT_EQ(file2Written.compressedSize, tapeFile2.compressedSize);
ASSERT_EQ(file2Written.checksumType, tapeFile2.checksumType);
ASSERT_EQ(file2Written.checksumValue, tapeFile2.checksumValue);
ASSERT_EQ(file2Written.copyNb, tapeFile2.copyNb);
}
}
{
const common::dataStructures::ArchiveFile archiveFile = m_catalogue->getArchiveFileById(archiveFileId);
ASSERT_EQ(file2Written.archiveFileId, archiveFile.archiveFileID);
ASSERT_EQ(file2Written.diskFileId, archiveFile.diskFileId);
ASSERT_EQ(file2Written.size, archiveFile.fileSize);
ASSERT_EQ(file2Written.checksumType, archiveFile.checksumType);
ASSERT_EQ(file2Written.checksumValue, archiveFile.checksumValue);
ASSERT_EQ(file2Written.storageClassName, archiveFile.storageClass);
ASSERT_EQ(file2Written.diskInstance, archiveFile.diskInstance);
ASSERT_EQ(file2Written.diskFilePath, archiveFile.diskFileInfo.path);
ASSERT_EQ(file2Written.diskFileUser, archiveFile.diskFileInfo.owner);
ASSERT_EQ(file2Written.diskFileGroup, archiveFile.diskFileInfo.group);
ASSERT_EQ(file2Written.diskFileRecoveryBlob, archiveFile.diskFileInfo.recoveryBlob);
ASSERT_EQ(2, archiveFile.tapeFiles.size());
auto copyNbToTapeFile1Itor = archiveFile.tapeFiles.find(1);
ASSERT_FALSE(copyNbToTapeFile1Itor == archiveFile.tapeFiles.end());
const common::dataStructures::TapeFile &tapeFile1 = copyNbToTapeFile1Itor->second;
ASSERT_EQ(file1Written.vid, tapeFile1.vid);
ASSERT_EQ(file1Written.fSeq, tapeFile1.fSeq);
ASSERT_EQ(file1Written.blockId, tapeFile1.blockId);
ASSERT_EQ(file1Written.compressedSize, tapeFile1.compressedSize);
ASSERT_EQ(file1Written.checksumType, tapeFile1.checksumType);
ASSERT_EQ(file1Written.checksumValue, tapeFile1.checksumValue);
ASSERT_EQ(file1Written.copyNb, tapeFile1.copyNb);
auto copyNbToTapeFile2Itor = archiveFile.tapeFiles.find(2);
ASSERT_FALSE(copyNbToTapeFile2Itor == archiveFile.tapeFiles.end());
const common::dataStructures::TapeFile &tapeFile2 = copyNbToTapeFile2Itor->second;
ASSERT_EQ(file2Written.vid, tapeFile2.vid);
ASSERT_EQ(file2Written.fSeq, tapeFile2.fSeq);
ASSERT_EQ(file2Written.blockId, tapeFile2.blockId);
ASSERT_EQ(file2Written.compressedSize, tapeFile2.compressedSize);
ASSERT_EQ(file2Written.checksumType, tapeFile2.checksumType);
ASSERT_EQ(file2Written.checksumValue, tapeFile2.checksumValue);
ASSERT_EQ(file2Written.copyNb, tapeFile2.copyNb);
}
log::LogContext dummyLc(m_dummyLog);
m_catalogue->deleteArchiveFileByDiskFileId("disk_instance", file1Written.diskFileId, dummyLc);
ASSERT_FALSE(m_catalogue->getArchiveFiles().hasMore());
}
TEST_P(cta_catalogue_CatalogueTest, deleteArchiveFile_by_archive_file_id_of_another_disk_instance) {
using namespace cta;
......@@ -9927,14 +9610,6 @@ TEST_P(cta_catalogue_CatalogueTest, deleteArchiveFile_by_archive_file_id_non_exi
m_catalogue->deleteArchiveFile("disk_instance", 12345678, dummyLc);
}
TEST_P(cta_catalogue_CatalogueTest, deleteArchiveFile_by_disk_file_id_non_existant) {
using namespace cta;
ASSERT_FALSE(m_catalogue->getArchiveFiles().hasMore());
log::LogContext dummyLc(m_dummyLog);
m_catalogue->deleteArchiveFileByDiskFileId("disk_instance", "12345678", dummyLc);
}
TEST_P(cta_catalogue_CatalogueTest, getTapesByVid_non_existant_tape) {
using namespace cta;
......
......@@ -45,7 +45,6 @@ public:
void createTapePool(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const std::string & vo, const uint64_t nbPartialTapes, const bool encryptionValue, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void deleteAdminUser(const std::string& username) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void deleteArchiveFile(const std::string& instanceName, const uint64_t archiveFileId, log::LogContext &lc) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void deleteArchiveFileByDiskFileId(const std::string &diskInstanceName, const std::string &diskFileId, log::LogContext &lc) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void deleteArchiveRoute(const std::string& diskInstanceName, const std::string& storageClassName, const uint64_t copyNb) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void deleteLogicalLibrary(const std::string& name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void deleteMountPolicy(const std::string& name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -351,159 +351,6 @@ void OracleCatalogue::deleteArchiveFile(const std::string &diskInstanceName, con
}
}
//------------------------------------------------------------------------------
// deleteArchiveFileByDiskFileId
//------------------------------------------------------------------------------
void OracleCatalogue::deleteArchiveFileByDiskFileId(const std::string &diskInstanceName, const std::string &diskFileId,
log::LogContext &lc) {
try {
const char *const selectSql =
"SELECT "
"ARCHIVE_FILE.ARCHIVE_FILE_ID AS ARCHIVE_FILE_ID,"
"ARCHIVE_FILE.DISK_INSTANCE_NAME AS DISK_INSTANCE_NAME,"
"ARCHIVE_FILE.DISK_FILE_ID AS DISK_FILE_ID,"
"ARCHIVE_FILE.DISK_FILE_PATH AS DISK_FILE_PATH,"
"ARCHIVE_FILE.DISK_FILE_USER AS DISK_FILE_USER,"
"ARCHIVE_FILE.DISK_FILE_GROUP AS DISK_FILE_GROUP,"
"ARCHIVE_FILE.DISK_FILE_RECOVERY_BLOB AS DISK_FILE_RECOVERY_BLOB,"
"ARCHIVE_FILE.SIZE_IN_BYTES AS SIZE_IN_BYTES,"
"ARCHIVE_FILE.CHECKSUM_TYPE AS CHECKSUM_TYPE,"
"ARCHIVE_FILE.CHECKSUM_VALUE AS CHECKSUM_VALUE,"
"STORAGE_CLASS.STORAGE_CLASS_NAME AS STORAGE_CLASS_NAME,"
"ARCHIVE_FILE.CREATION_TIME AS ARCHIVE_FILE_CREATION_TIME,"
"ARCHIVE_FILE.RECONCILIATION_TIME AS RECONCILIATION_TIME,"
"TAPE_FILE.VID AS VID,"
"TAPE_FILE.FSEQ AS FSEQ,"
"TAPE_FILE.BLOCK_ID AS BLOCK_ID,"
"TAPE_FILE.COMPRESSED_SIZE_IN_BYTES AS COMPRESSED_SIZE_IN_BYTES,"
"TAPE_FILE.COPY_NB AS COPY_NB,"
"TAPE_FILE.CREATION_TIME AS TAPE_FILE_CREATION_TIME "
"FROM "
"ARCHIVE_FILE "
"INNER JOIN STORAGE_CLASS ON "
"ARCHIVE_FILE.STORAGE_CLASS_ID = STORAGE_CLASS.STORAGE_CLASS_ID "
"LEFT OUTER JOIN TAPE_FILE ON "
"ARCHIVE_FILE.ARCHIVE_FILE_ID = TAPE_FILE.ARCHIVE_FILE_ID "
"WHERE "
"ARCHIVE_FILE.DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND "
"ARCHIVE_FILE.DISK_FILE_ID = :DISK_FILE_ID "
"FOR UPDATE";
utils::Timer t;
auto conn = m_connPool.getConn();
const auto getConnTime = t.secs(utils::Timer::resetCounter);
auto selectStmt = conn.createStmt(selectSql, rdbms::AutocommitMode::OFF);
const auto createStmtTime = t.secs();
selectStmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName);
selectStmt.bindString(":DISK_FILE_ID", diskFileId);
t.reset();
rdbms::Rset selectRset = selectStmt.executeQuery();
const auto selectFromArchiveFileTime = t.secs();
std::unique_ptr<common::dataStructures::ArchiveFile> archiveFile;
while(selectRset.next()) {
if(nullptr == archiveFile.get()) {
archiveFile = cta::make_unique<common::dataStructures::ArchiveFile>();
archiveFile->archiveFileID = selectRset.columnUint64("ARCHIVE_FILE_ID");
archiveFile->diskInstance = selectRset.columnString("DISK_INSTANCE_NAME");
archiveFile->diskFileId = selectRset.columnString("DISK_FILE_ID");
archiveFile->diskFileInfo.path = selectRset.columnString("DISK_FILE_PATH");
archiveFile->diskFileInfo.owner = selectRset.columnString("DISK_FILE_USER");
archiveFile->diskFileInfo.group = selectRset.columnString("DISK_FILE_GROUP");
archiveFile->diskFileInfo.recoveryBlob = selectRset.columnString("DISK_FILE_RECOVERY_BLOB");
archiveFile->fileSize = selectRset.columnUint64("SIZE_IN_BYTES");
archiveFile->checksumType = selectRset.columnString("CHECKSUM_TYPE");
archiveFile->checksumValue = selectRset.columnString("CHECKSUM_VALUE");
archiveFile->storageClass = selectRset.columnString("STORAGE_CLASS_NAME");
archiveFile->creationTime = selectRset.columnUint64("ARCHIVE_FILE_CREATION_TIME");
archiveFile->reconciliationTime = selectRset.columnUint64("RECONCILIATION_TIME");
}
// If there is a tape file
if(!selectRset.columnIsNull("VID")) {
// Add the tape file to the archive file's in-memory structure
common::dataStructures::TapeFile tapeFile;
tapeFile.vid = selectRset.columnString("VID");
tapeFile.fSeq = selectRset.columnUint64("FSEQ");
tapeFile.blockId = selectRset.columnUint64("BLOCK_ID");
tapeFile.compressedSize = selectRset.columnUint64("COMPRESSED_SIZE_IN_BYTES");
tapeFile.copyNb = selectRset.columnUint64("COPY_NB");
tapeFile.creationTime = selectRset.columnUint64("TAPE_FILE_CREATION_TIME");
tapeFile.checksumType = archiveFile->checksumType; // Duplicated for convenience
tapeFile.checksumValue = archiveFile->checksumValue; // Duplicated for convenience
archiveFile->tapeFiles[selectRset.columnUint64("COPY_NB")] = tapeFile;
}
}
if(nullptr == archiveFile.get()) {
log::ScopedParamContainer spc(lc);
spc.add("diskInstanceName", diskInstanceName);
spc.add("diskFileId", diskFileId);
lc.log(log::WARNING, "Ignoring request to delete archive file because it does not exist in the catalogue");
return;
}
t.reset();
{
const char *const sql = "DELETE FROM TAPE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::OFF);
stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFile->archiveFileID);
stmt.executeNonQuery();
}
const auto deleteFromTapeFileTime = t.secs(utils::Timer::resetCounter);
{
const char *const sql = "DELETE FROM ARCHIVE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::OFF);
stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFile->archiveFileID);
stmt.executeNonQuery();
}
const auto deleteFromArchiveFileTime = t.secs(utils::Timer::resetCounter);
conn.commit();
const auto commitTime = t.secs();
log::ScopedParamContainer spc(lc);
spc.add("fileId", std::to_string(archiveFile->archiveFileID))
.add("diskInstance", archiveFile->diskInstance)
.add("diskFileId", archiveFile->diskFileId)
.add("diskFileInfo.path", archiveFile->diskFileInfo.path)
.add("diskFileInfo.owner", archiveFile->diskFileInfo.owner)
.add("diskFileInfo.group", archiveFile->diskFileInfo.group)
.add("fileSize", std::to_string(archiveFile->fileSize))
.add("checksumType", archiveFile->checksumType)
.add("checksumValue", archiveFile->checksumValue)
.add("creationTime", std::to_string(archiveFile->creationTime))
.add("reconciliationTime", std::to_string(archiveFile->reconciliationTime))
.add("storageClass", archiveFile->storageClass)
.add("getConnTime", getConnTime)
.add("createStmtTime", createStmtTime)
.add("selectFromArchiveFileTime", selectFromArchiveFileTime)
.add("deleteFromTapeFileTime", deleteFromTapeFileTime)
.add("deleteFromArchiveFileTime", deleteFromArchiveFileTime)
.add("commitTime", commitTime);
for(auto it=archiveFile->tapeFiles.begin(); it!=archiveFile->tapeFiles.end(); it++) {
std::stringstream tapeCopyLogStream;
tapeCopyLogStream << "copy number: " << it->first
<< " vid: " << it->second.vid
<< " fSeq: " << it->second.fSeq
<< " blockId: " << it->second.blockId
<< " creationTime: " << it->second.creationTime
<< " compressedSize: " << it->second.compressedSize
<< " checksumType: " << it->second.checksumType //this shouldn't be here: repeated field
<< " checksumValue: " << it->second.checksumValue //this shouldn't be here: repeated field
<< " copyNb: " << it->second.copyNb; //this shouldn't be here: repeated field
spc.add("TAPE FILE", tapeCopyLogStream.str());
}
lc.log(log::INFO, "Archive file deleted from CTA catalogue");
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// getNextArchiveFileId
//------------------------------------------------------------------------------
......
......@@ -82,27 +82,6 @@ public:
void deleteArchiveFile(const std::string &diskInstanceName, const uint64_t archiveFileId, log::LogContext &lc)
override;
/**
* 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.
*
* @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 deleteArchiveFileByDiskFileId(const std::string &diskInstanceName, const std::string &diskFileId,
log::LogContext &lc) override;
/**
* Returns a unique archive ID that can be used by a new archive file within
* the catalogue.
......
......@@ -180,88 +180,6 @@ void SqliteCatalogue::deleteArchiveFile(const std::string &diskInstanceName, con
}
}
//------------------------------------------------------------------------------
// deleteArchiveFileByDiskFileId
//------------------------------------------------------------------------------
void SqliteCatalogue::deleteArchiveFileByDiskFileId(const std::string &diskInstanceName, const std::string &diskFileId,
log::LogContext &lc) {
try {
utils::Timer t;
auto conn = m_connPool.getConn();
const auto getConnTime = t.secs();
rdbms::AutoRollback autoRollback(conn);
t.reset();
const auto archiveFile = getArchiveFileByDiskFileId(conn, diskInstanceName, diskFileId);
const auto getArchiveFileTime = t.secs();
if(nullptr == archiveFile.get()) {
log::ScopedParamContainer spc(lc);
spc.add("diskInstance", diskInstanceName);
spc.add("diskFileId", diskFileId);
lc.log(log::WARNING, "Ignoring request to delete archive file because it does not exist in the catalogue");
return;
}
t.reset();
{
const char *const sql = "DELETE FROM TAPE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID;";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::OFF);
stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFile->archiveFileID);
stmt.executeNonQuery();
}
const auto deleteFromTapeFileTime = t.secs(utils::Timer::resetCounter);