Skip to content
Snippets Groups Projects
Commit 828ad7d0 authored by Steven Murray's avatar Steven Murray
Browse files

Added TapeFileWritten event class

parent 440cb27d
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ set (CATALOGUE_LIB_SRC_FILES
Catalogue.cpp
ColumnNameToIdx.cpp
DbLogin.cpp
TapeFileWritten.cpp
OcciConn.cpp
OcciEnv.cpp
OcciRset.cpp
......
/*
* 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/TapeFileWritten.hpp"
namespace cta {
namespace catalogue {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
TapeFileWritten::TapeFileWritten() :
archiveFileId(0),
size(0),
fSeq(0),
blockId(0),
compressedSize(0),
copyNb(0) {
}
//------------------------------------------------------------------------------
// operator==
//------------------------------------------------------------------------------
bool TapeFileWritten::operator==(const TapeFileWritten &rhs) const {
return
archiveFileId == rhs.archiveFileId &&
diskInstance == rhs.diskInstance &&
diskFileId == rhs.diskFileId &&
diskFilePath == rhs.diskFilePath &&
diskFileUser == rhs.diskFileUser &&
diskFileGroup == rhs.diskFileGroup &&
diskFileRecoveryBlob == rhs.diskFileRecoveryBlob &&
size == rhs.size &&
checksum == rhs.checksum &&
storageClassName == rhs.storageClassName &&
vid == rhs.vid &&
fSeq == rhs.fSeq &&
blockId == rhs.blockId &&
compressedSize == rhs.compressedSize &&
copyNb == rhs.copyNb;
}
//------------------------------------------------------------------------------
// operator<<
//------------------------------------------------------------------------------
std::ostream &operator<<(std::ostream &os, const TapeFileWritten &event) {
os <<
"{"
"archiveFileId=" << event.archiveFileId <<
"diskInstance=" << event.diskInstance <<
"diskFileId=" << event.diskFileId <<
"diskFilePath=" << event.diskFilePath <<
"diskFileUser=" << event.diskFileUser <<
"diskFileGroup=" << event.diskFileGroup <<
"diskFileRecoveryBlob=" << event.diskFileRecoveryBlob <<
"size=" << event.size <<
"checksum=" << event.checksum <<
"storageClassName=" << event.storageClassName <<
"vid=" << event.vid <<
"fSeq=" << event.fSeq <<
"blockId=" << event.blockId <<
"compressedSize=" << event.compressedSize <<
"copyNb=" << event.copyNb <<
"}";
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/Checksum.hpp"
#include <stdint.h>
#include <string>
namespace cta {
namespace catalogue {
/**
* Structure describing the event of having written a file to tape.
*/
struct TapeFileWritten {
/**
* Constructor.
*
* Sets the value of all integer member-variables to zero.
*/
TapeFileWritten();
/**
* Equality operator.
*
* @param ths The right hand side of the operator.
*/
bool operator==(const TapeFileWritten &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 path of the source disk file within its host disk system.
*/
std::string diskFilePath;
/**
* The user name of the source disk file within its host disk system.
*/
std::string diskFileUser;
/**
* The group name of the source disk file within its host disk system.
*/
std::string diskFileGroup;
/**
* Opaque blob containing the metadata of the source disk file within its host
* disk system. This blob can be used in a disaster recovery scenario to
* contribute to reconstructing the namespace of the host disk system.
*/
std::string diskFileRecoveryBlob;
/**
* The uncompressed size of the tape file in bytes.
*/
uint64_t size;
/**
* The checksum of the tape file.
*/
Checksum checksum;
/**
* The name of the file's storage class.
*/
std::string storageClassName;
/**
* The volume identifier of the tape on which the file has been written.
*/
std::string vid;
/**
* The position of the file on tape in the form of its file sequence number.
*/
uint64_t fSeq;
/**
* The position of the file on tape in the form of its logical block
* identifier.
*/
uint64_t blockId;
/**
* The compressed size of the tape file in bytes. In other words the actual
* number of bytes it occupies on tape.
*/
uint64_t compressedSize;
/**
* The copy number of the tape file.
*/
uint64_t copyNb;
}; // struct TapeFileWritten
/**
* Output stream operator for the TapeFileWritten.
*
* This function writes a human readable form of the specified TapeFileWritten
* event to the specified output stream.
*
* @param os The output stream.
* @param event The TapeFileWritten event.
*/
std::ostream &operator<<(std::ostream &os, const TapeFileWritten &event);
} // namespace catalogue
} // namespace cta
......@@ -92,3 +92,11 @@ std::string cta::Checksum::str() const {
}
return oss.str();
}
//------------------------------------------------------------------------------
// operator<<
//------------------------------------------------------------------------------
std::ostream &cta::operator<<(std::ostream &os, const Checksum &checksum) {
os << checksum.str();
return os;
}
......@@ -18,9 +18,11 @@
#pragma once
#include "common/exception/Exception.hpp"
#include <ostream>
#include <sstream>
#include <typeinfo>
#include "common/exception/Exception.hpp"
namespace cta {
......@@ -143,4 +145,12 @@ private:
}; // class Checksum
/**
* Writes the specified Checksum object to the specified ooutput stream.
*
* @param os The output stream.
* @param checksum The checksum.
*/
std::ostream &operator<<(std::ostream &os, const Checksum &checksum);
} // namespace cta
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment