Commit 61866b43 authored by Steven Murray's avatar Steven Murray
Browse files

Added ArchiveFileRowWithoutTimestamps

parent 92ac1485
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "catalogue/ArchiveFileRowWithoutTimestamps.hpp"
namespace cta {
namespace catalogue {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
ArchiveFileRowWithoutTimestamps::ArchiveFileRowWithoutTimestamps() :
archiveFileId(0),
size(0) {
}
//------------------------------------------------------------------------------
// operator==
//------------------------------------------------------------------------------
bool ArchiveFileRowWithoutTimestamps::operator==(const ArchiveFileRowWithoutTimestamps &rhs) const {
return
archiveFileId == rhs.archiveFileId &&
diskInstance == rhs.diskInstance &&
diskFileId == rhs.diskFileId &&
diskFileOwnerUid == rhs.diskFileOwnerUid &&
diskFileGid == rhs.diskFileGid &&
size == rhs.size &&
checksumBlob == rhs.checksumBlob &&
storageClassName == rhs.storageClassName;
}
//------------------------------------------------------------------------------
// operator<<
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os, const ArchiveFileRowWithoutTimestamps &obj) {
os <<
"{"
"archiveFileId=" << obj.archiveFileId <<
"diskInstance=" << obj.diskInstance <<
"diskFileId=" << obj.diskFileId <<
"diskFileOwnerUid=" << obj.diskFileOwnerUid <<
"diskFileGid=" << obj.diskFileGid <<
"size=" << obj.size <<
"checksumBlob=" << obj.checksumBlob <<
"storageClassName=" << obj.storageClassName <<
"}";
return os;
}
} // namespace catalogue
} // namespace cta
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/checksum/ChecksumBlob.hpp"
#include <stdint.h>
#include <string>
namespace cta {
namespace catalogue {
/**
* A row in the ArchiveFile table without the timestamp columns, namely
* CREATION_TIME and RECONCILIATION_TIME.
*/
struct ArchiveFileRowWithoutTimestamps {
/**
* Constructor.
*
* Sets the value of all integer member-variables to zero.
*/
ArchiveFileRowWithoutTimestamps();
/**
* Equality operator.
*
* @param ths The right hand side of the operator.
*/
bool operator==(const ArchiveFileRowWithoutTimestamps &rhs) const;
/**
* The unique identifier of the file being archived.
*/
uint64_t archiveFileId;
/**
* The instance name of the source disk system.
*/
std::string diskInstance;
/**
* 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 diskInstance and diskFileId must be
* globally unique, in other words unique within the CTA catalogue.
*/
std::string diskFileId;
/**
* The user ID of the owner of the source disk file within its host disk system.
*/
uint32_t diskFileOwnerUid;
/**
* The group ID of the source disk file within its host disk system.
*/
uint32_t diskFileGid;
/**
* The uncompressed size of the tape file in bytes.
*/
uint64_t size;
/**
* Set of checksum types and values
*/
checksum::ChecksumBlob checksumBlob;
/**
* The name of the file's storage class.
*/
std::string storageClassName;
}; // struct ArchiveFileRowWithoutTimestamps
/**
* Output stream operator for an ArchiveFileRowWithoutTimestamps object.
*
* This function writes a human readable form of the specified object to the
* specified output stream.
*
* @param os The output stream.
* @param obj The object.
*/
std::ostream &operator<<(std::ostream &os, const ArchiveFileRowWithoutTimestamps &obj);
} // namespace catalogue
} // namespace cta
......@@ -29,6 +29,7 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
set (CATALOGUE_LIB_SRC_FILES
ArchiveFileBuilder.cpp
ArchiveFileRow.cpp
ArchiveFileRowWithoutTimestamps.cpp
Catalogue.cpp
CatalogueFactory.cpp
CatalogueFactoryFactory.cpp
......
......@@ -17,6 +17,7 @@
*/
#include "catalogue/ArchiveFileRow.hpp"
#include "catalogue/ArchiveFileRowWithoutTimestamps.hpp"
#include "catalogue/MysqlCatalogueSchema.hpp"
#include "catalogue/MysqlCatalogue.hpp"
#include "common/exception/Exception.hpp"
......@@ -438,7 +439,7 @@ void MysqlCatalogue::fileWrittenToTape(rdbms::Conn &conn, const TapeFileWritten
// Try to insert a row into the ARCHIVE_FILE table - it is normal this will
// fail if another tape copy has already been written to tape
try {
ArchiveFileRow row;
ArchiveFileRowWithoutTimestamps row;
row.archiveFileId = event.archiveFileId;
row.diskFileId = event.diskFileId;
row.diskInstance = event.diskInstance;
......
......@@ -17,6 +17,7 @@
*/
#include "catalogue/ArchiveFileRow.hpp"
#include "catalogue/ArchiveFileRowWithoutTimestamps.hpp"
#include "catalogue/RdbmsCatalogue.hpp"
#include "catalogue/RdbmsCatalogueGetArchiveFilesItor.hpp"
#include "catalogue/RdbmsCatalogueGetArchiveFilesForRepackItor.hpp"
......@@ -6448,7 +6449,7 @@ void RdbmsCatalogue::modifyDiskSystemSleepTime(const common::dataStructures::Sec
//------------------------------------------------------------------------------
// insertArchiveFile
//------------------------------------------------------------------------------
void RdbmsCatalogue::insertArchiveFile(rdbms::Conn &conn, const ArchiveFileRow &row) {
void RdbmsCatalogue::insertArchiveFile(rdbms::Conn &conn, const ArchiveFileRowWithoutTimestamps &row) {
try {
if(!storageClassExists(conn, row.storageClassName)) {
throw exception::UserError(std::string("Storage class ") + row.diskInstance + ":" + row.storageClassName +
......
......@@ -48,6 +48,11 @@ namespace catalogue {
*/
class ArchiveFileRow;
/**
* Forward declaration.
*/
class ArchiveFileRowWithoutTimestamps;
/**
* Forward declaration.
*/
......@@ -1297,7 +1302,7 @@ protected:
* @param conn The database connection.
* @param row The row to be inserted.
*/
void insertArchiveFile(rdbms::Conn &conn, const ArchiveFileRow &row);
void insertArchiveFile(rdbms::Conn &conn, const ArchiveFileRowWithoutTimestamps &row);
/**
* Creates the database schema.
......
......@@ -17,10 +17,12 @@
*/
#include "catalogue/ArchiveFileRow.hpp"
#include "catalogue/ArchiveFileRowWithoutTimestamps.hpp"
#include "catalogue/SqliteCatalogueSchema.hpp"
#include "catalogue/SqliteCatalogue.hpp"
#include "common/exception/Exception.hpp"
#include "common/exception/UserError.hpp"
#include "common/log/TimingList.hpp"
#include "common/make_unique.hpp"
#include "common/threading/MutexLocker.hpp"
#include "common/Timer.hpp"
......@@ -28,7 +30,6 @@
#include "rdbms/AutoRollback.hpp"
#include "rdbms/ConstraintError.hpp"
#include "rdbms/PrimaryKeyError.hpp"
#include "common/log/TimingList.hpp"
namespace cta {
namespace catalogue {
......@@ -505,7 +506,7 @@ void SqliteCatalogue::fileWrittenToTape(rdbms::Conn &conn, const TapeFileWritten
// Try to insert a row into the ARCHIVE_FILE table - it is normal this will
// fail if another tape copy has already been written to tape
try {
ArchiveFileRow row;
ArchiveFileRowWithoutTimestamps row;
row.archiveFileId = event.archiveFileId;
row.diskFileId = event.diskFileId;
row.diskInstance = event.diskInstance;
......
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