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

Added 'not implemented' Catalogue::prepareToRetrieveFile()

parent 6554fca5
......@@ -46,6 +46,7 @@
#include "common/dataStructures/RepackInfo.hpp"
#include "common/dataStructures/RepackType.hpp"
#include "common/dataStructures/Requester.hpp"
#include "common/dataStructures/RetrieveFileQueueCriteria.hpp"
#include "common/dataStructures/RetrieveJob.hpp"
#include "common/dataStructures/RetrieveRequest.hpp"
#include "common/dataStructures/SecurityIdentity.hpp"
......@@ -210,9 +211,9 @@ public:
* archiving the file.
* @return The information required to queue the associated archive request.
*/
virtual common::dataStructures::ArchiveFileQueueCriteria
prepareForNewFile(const std::string &storageClass, const common::dataStructures::UserIdentity &user)
= 0;
virtual common::dataStructures::ArchiveFileQueueCriteria prepareForNewFile(
const std::string &storageClass,
const common::dataStructures::UserIdentity &user) = 0;
/**
* Notifies the catalogue that a file has been written to tape.
......@@ -221,6 +222,22 @@ public:
*/
virtual void fileWrittenToTape(const TapeFileWritten &event) = 0;
/**
* Prepares for a file retrieval by returning the information required to
* queue the associated retrieve request(s).
*
* @param archiveFileId The unique identifier of the archived file that is
* to be retrieved.
* @param user The user for whom the file is to be retrieved. This will be
* used by the Catalogue to determine the mount policy to be used when
* retrieving the file.
*
* @return The information required to queue the associated retrieve request(s).
*/
virtual common::dataStructures::RetrieveFileQueueCriteria prepareToRetrieveFile(
const uint64_t archiveFileId,
common::dataStructures::UserIdentity &user) = 0;
virtual common::dataStructures::TapeCopyToPoolMap getTapeCopyToPoolMap(const std::string &storageClass) const = 0;
/**
......
......@@ -1895,106 +1895,6 @@ void RdbmsCatalogue::setDriveStatus(const common::dataStructures::SecurityIdenti
throw exception::Exception(std::string(__FUNCTION__) + " not implemented");
}
//------------------------------------------------------------------------------
// fileWrittenToTape
//------------------------------------------------------------------------------
void RdbmsCatalogue::fileWrittenToTape(const TapeFileWritten &event) {
try {
const time_t now = time(NULL);
std::lock_guard<std::mutex> m_lock(m_mutex);
std::unique_ptr<common::dataStructures::ArchiveFile> archiveFile = getArchiveFile(event.archiveFileId);
// If the archive file does not already exist
if(NULL == archiveFile.get()) {
// Create one
ArchiveFileRow row;
row.archiveFileId = event.archiveFileId;
row.diskFileId = event.diskFileId;
row.diskInstance = event.diskInstance;
row.size = event.size;
row.storageClassName = event.storageClassName;
row.diskFilePath = event.diskFilePath;
row.diskFileUser = event.diskFileUser;
row.diskFileGroup = event.diskFileGroup;
row.diskFileRecoveryBlob = event.diskFileRecoveryBlob;
insertArchiveFile(row);
} else {
throwIfCommonEventDataMismatch(*archiveFile, event);
}
// Create the tape file
common::dataStructures::TapeFile tapeFile;
tapeFile.vid = event.vid;
tapeFile.fSeq = event.fSeq;
tapeFile.blockId = event.blockId;
tapeFile.compressedSize = event.compressedSize;
tapeFile.copyNb = event.copyNb;
tapeFile.creationTime = now;
createTapeFile(tapeFile, event.archiveFileId);
} catch(exception::Exception &ex) {
exception::Exception ex;
ex.getMessage() << __FUNCTION__ << " failed: " << ex.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// throwIfCommonEventDataMismatch
//------------------------------------------------------------------------------
void RdbmsCatalogue::throwIfCommonEventDataMismatch(const common::dataStructures::ArchiveFile &expected,
const TapeFileWritten &actual) const {
// Throw an exception if the common disk information of this tape file
// written event does not match the previous
if(expected.diskFileID != actual.diskFileId) {
exception::Exception ex;
ex.getMessage() << "Disk file ID mismatch: expected=" << expected.diskFileID << " actual=" <<
actual.diskFileId;
throw ex;
}
if(expected.fileSize != actual.size) {
exception::Exception ex;
ex.getMessage() << "File size mismatch: expected=" << expected.fileSize << " actual=" << actual.size;
throw ex;
}
if(expected.storageClass != actual.storageClassName) {
exception::Exception ex;
ex.getMessage() << "Storage class mismatch: expected=" << expected.storageClass << " actual=" <<
actual.storageClassName;
throw ex;
}
if(expected.diskInstance != actual.diskInstance) {
exception::Exception ex;
ex.getMessage() << "Disk instance mismatch: expected=" << expected.diskInstance << " actual=" <<
actual.diskInstance;
throw ex;
}
if(expected.drData.drPath != actual.diskFilePath) {
exception::Exception ex;
ex.getMessage() << "Disk file path mismatch: expected=" << expected.drData.drPath << " actual=" <<
actual.diskFilePath;
throw ex;
}
if(expected.drData.drOwner != actual.diskFileUser) {
exception::Exception ex;
ex.getMessage() << "Disk file user mismatch: expected=" << expected.drData.drOwner << " actual=" <<
actual.diskFileUser;
throw ex;
}
if(expected.drData.drGroup != actual.diskFileGroup) {
exception::Exception ex;
ex.getMessage() << "Disk file group mismatch: expected=" << expected.drData.drGroup << " actual=" <<
actual.diskFileGroup;
throw ex;
}
if(expected.drData.drGroup != actual.diskFileGroup) {
exception::Exception ex;
ex.getMessage() << "Disk recovery blob mismatch";
throw ex;
}
}
//------------------------------------------------------------------------------
// prepareForNewFile
//------------------------------------------------------------------------------
......@@ -2161,6 +2061,115 @@ common::dataStructures::MountPolicy RdbmsCatalogue::
}
}
//------------------------------------------------------------------------------
// fileWrittenToTape
//------------------------------------------------------------------------------
void RdbmsCatalogue::fileWrittenToTape(const TapeFileWritten &event) {
try {
const time_t now = time(NULL);
std::lock_guard<std::mutex> m_lock(m_mutex);
std::unique_ptr<common::dataStructures::ArchiveFile> archiveFile = getArchiveFile(event.archiveFileId);
// If the archive file does not already exist
if(NULL == archiveFile.get()) {
// Create one
ArchiveFileRow row;
row.archiveFileId = event.archiveFileId;
row.diskFileId = event.diskFileId;
row.diskInstance = event.diskInstance;
row.size = event.size;
row.storageClassName = event.storageClassName;
row.diskFilePath = event.diskFilePath;
row.diskFileUser = event.diskFileUser;
row.diskFileGroup = event.diskFileGroup;
row.diskFileRecoveryBlob = event.diskFileRecoveryBlob;
insertArchiveFile(row);
} else {
throwIfCommonEventDataMismatch(*archiveFile, event);
}
// Create the tape file
common::dataStructures::TapeFile tapeFile;
tapeFile.vid = event.vid;
tapeFile.fSeq = event.fSeq;
tapeFile.blockId = event.blockId;
tapeFile.compressedSize = event.compressedSize;
tapeFile.copyNb = event.copyNb;
tapeFile.creationTime = now;
createTapeFile(tapeFile, event.archiveFileId);
} catch(exception::Exception &ex) {
exception::Exception ex;
ex.getMessage() << __FUNCTION__ << " failed: " << ex.getMessage().str();
throw ex;
}
}
//------------------------------------------------------------------------------
// throwIfCommonEventDataMismatch
//------------------------------------------------------------------------------
void RdbmsCatalogue::throwIfCommonEventDataMismatch(const common::dataStructures::ArchiveFile &expected,
const TapeFileWritten &actual) const {
// Throw an exception if the common disk information of this tape file
// written event does not match the previous
if(expected.diskFileID != actual.diskFileId) {
exception::Exception ex;
ex.getMessage() << "Disk file ID mismatch: expected=" << expected.diskFileID << " actual=" <<
actual.diskFileId;
throw ex;
}
if(expected.fileSize != actual.size) {
exception::Exception ex;
ex.getMessage() << "File size mismatch: expected=" << expected.fileSize << " actual=" << actual.size;
throw ex;
}
if(expected.storageClass != actual.storageClassName) {
exception::Exception ex;
ex.getMessage() << "Storage class mismatch: expected=" << expected.storageClass << " actual=" <<
actual.storageClassName;
throw ex;
}
if(expected.diskInstance != actual.diskInstance) {
exception::Exception ex;
ex.getMessage() << "Disk instance mismatch: expected=" << expected.diskInstance << " actual=" <<
actual.diskInstance;
throw ex;
}
if(expected.drData.drPath != actual.diskFilePath) {
exception::Exception ex;
ex.getMessage() << "Disk file path mismatch: expected=" << expected.drData.drPath << " actual=" <<
actual.diskFilePath;
throw ex;
}
if(expected.drData.drOwner != actual.diskFileUser) {
exception::Exception ex;
ex.getMessage() << "Disk file user mismatch: expected=" << expected.drData.drOwner << " actual=" <<
actual.diskFileUser;
throw ex;
}
if(expected.drData.drGroup != actual.diskFileGroup) {
exception::Exception ex;
ex.getMessage() << "Disk file group mismatch: expected=" << expected.drData.drGroup << " actual=" <<
actual.diskFileGroup;
throw ex;
}
if(expected.drData.drGroup != actual.diskFileGroup) {
exception::Exception ex;
ex.getMessage() << "Disk recovery blob mismatch";
throw ex;
}
}
//------------------------------------------------------------------------------
// prepareToRetreiveFile
//------------------------------------------------------------------------------
common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetrieveFile(
const uint64_t archiveFileId,
common::dataStructures::UserIdentity &user) {
throw exception::Exception(std::string(__FUNCTION__) + " not implemented");
}
//------------------------------------------------------------------------------
// isAdmin
//------------------------------------------------------------------------------
......
......@@ -176,14 +176,6 @@ public:
virtual common::dataStructures::ArchiveFile getArchiveFileById(const uint64_t id);
virtual void setDriveStatus(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const bool up, const bool force);
/**
* Notifies the catalogue that a file has been written to tape.
*
* @param event The tape file written event.
*/
virtual void fileWrittenToTape(const TapeFileWritten &event);
/**
* Prepares the catalogue for a new archive file and returns the information
* required to queue the associated archive request.
......@@ -196,8 +188,32 @@ public:
* archiving the file.
* @return The information required to queue the associated archive request.
*/
virtual common::dataStructures::ArchiveFileQueueCriteria
prepareForNewFile(const std::string &storageClass, const common::dataStructures::UserIdentity &user);
virtual common::dataStructures::ArchiveFileQueueCriteria prepareForNewFile(
const std::string &storageClass,
const common::dataStructures::UserIdentity &user);
/**
* Notifies the catalogue that a file has been written to tape.
*
* @param event The tape file written event.
*/
virtual void fileWrittenToTape(const TapeFileWritten &event);
/**
* Prepares for a file retrieval by returning the information required to
* queue the associated retrieve request(s).
*
* @param archiveFileId The unique identifier of the archived file that is
* to be retrieved.
* @param user The user for whom the file is to be retrieved. This will be
* used by the Catalogue to determine the mount policy to be used when
* retrieving the file.
*
* @return The information required to queue the associated retrieve request(s).
*/
virtual common::dataStructures::RetrieveFileQueueCriteria prepareToRetrieveFile(
const uint64_t archiveFileId,
common::dataStructures::UserIdentity &user);
virtual common::dataStructures::TapeCopyToPoolMap getTapeCopyToPoolMap(const std::string &storageClass) const;
......
......@@ -46,6 +46,7 @@ set (COMMON_LIB_SRC_FILES
dataStructures/RepackInfo.cpp
dataStructures/RepackType.cpp
dataStructures/Requester.cpp
dataStructures/RetrieveFileQueueCriteria.cpp
dataStructures/RetrieveJob.cpp
dataStructures/RetrieveRequest.cpp
dataStructures/SecurityIdentity.cpp
......
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