Commit 0c53e15d authored by Cedric CAFFY's avatar Cedric CAFFY
Browse files

Honoured NB_MASTER_FILES, MASTER_DATA_IN_BYTES and DIRTY in the catalogue and in the CTA frontend

parent 87e8805a
......@@ -10690,6 +10690,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_1_archive_file_1_tape_cop
ASSERT_EQ(1, tapes.size());
const common::dataStructures::Tape &tape = tapes.front();
ASSERT_EQ(1, tape.lastFSeq);
ASSERT_TRUE(tape.dirty);
}
 
{
......@@ -12503,7 +12504,11 @@ TEST_P(cta_catalogue_CatalogueTest, deleteArchiveFile) {
 
log::LogContext dummyLc(m_dummyLog);
m_catalogue->deleteArchiveFile("disk_instance", archiveFileId, dummyLc);
for(auto &tape:m_catalogue->getTapes()){
ASSERT_TRUE(tape.dirty);
}
ASSERT_FALSE(m_catalogue->getArchiveFilesItor().hasMore());
}
 
......@@ -14617,6 +14622,7 @@ TEST_P(cta_catalogue_CatalogueTest, reclaimTape_full_lastFSeq_0_no_tape_files) {
ASSERT_FALSE(tape.labelLog);
ASSERT_FALSE(tape.lastReadLog);
ASSERT_FALSE(tape.lastWriteLog);
ASSERT_TRUE(tape.dirty);
 
const common::dataStructures::EntryLog creationLog = tape.creationLog;
ASSERT_EQ(m_admin.username, creationLog.username);
......
......@@ -524,6 +524,12 @@ void MysqlCatalogue::deleteArchiveFile(const std::string &diskInstanceName, cons
stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt.executeNonQuery();
}
for(auto &tapeFile: archiveFile->tapeFiles){
//We deleted the TAPE_FILE so the tapes containing them should be set as dirty
setTapeDirty(conn,tapeFile.vid);
}
const auto deleteFromTapeFileTime = t.secs(utils::Timer::resetCounter);
{
......@@ -533,7 +539,6 @@ void MysqlCatalogue::deleteArchiveFile(const std::string &diskInstanceName, cons
stmt.executeNonQuery();
}
const auto deleteFromArchiveFileTime = t.secs(utils::Timer::resetCounter);
conn.commit();
const auto commitTime = t.secs();
......
......@@ -869,6 +869,12 @@ void OracleCatalogue::deleteArchiveFile(const std::string &diskInstanceName, con
stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt.executeNonQuery();
}
for(auto &tapeFile: archiveFile->tapeFiles){
//We deleted the TAPE_FILE so the tapes containing them should be set as dirty
setTapeDirty(conn,tapeFile.vid);
}
const auto deleteFromTapeFileTime = t.secs(utils::Timer::resetCounter);
{
......
......@@ -808,6 +808,12 @@ void PostgresCatalogue::deleteArchiveFile(const std::string &diskInstanceName, c
stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt.executeNonQuery();
}
for(auto &tapeFile: archiveFile->tapeFiles){
//We deleted the TAPE_FILE so the tapes containing them should be set as dirty
setTapeDirty(conn,tapeFile.vid);
}
const auto deleteFromTapeFileTime = t.secs(utils::Timer::resetCounter);
{
......
......@@ -2361,11 +2361,14 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
"TAPE.ENCRYPTION_KEY_NAME AS ENCRYPTION_KEY_NAME,"
"TAPE.CAPACITY_IN_BYTES AS CAPACITY_IN_BYTES,"
"TAPE.DATA_IN_BYTES AS DATA_IN_BYTES,"
"TAPE.NB_MASTER_FILES AS NB_MASTER_FILES,"
"TAPE.MASTER_DATA_IN_BYTES AS MASTER_DATA_IN_BYTES,"
"TAPE.LAST_FSEQ AS LAST_FSEQ,"
"TAPE.IS_DISABLED AS IS_DISABLED,"
"TAPE.IS_FULL AS IS_FULL,"
"TAPE.IS_READ_ONLY AS IS_READ_ONLY,"
"TAPE.IS_FROM_CASTOR AS IS_FROM_CASTOR,"
"TAPE.DIRTY AS DIRTY,"
"TAPE.LABEL_DRIVE AS LABEL_DRIVE,"
"TAPE.LABEL_TIME AS LABEL_TIME,"
......@@ -2517,12 +2520,15 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(rdbms::Conn &co
tape.encryptionKeyName = rset.columnOptionalString("ENCRYPTION_KEY_NAME");
tape.capacityInBytes = rset.columnUint64("CAPACITY_IN_BYTES");
tape.dataOnTapeInBytes = rset.columnUint64("DATA_IN_BYTES");
tape.nbMasterFiles = rset.columnUint64("NB_MASTER_FILES");
tape.masterDataInBytes = rset.columnUint64("MASTER_DATA_IN_BYTES");
tape.lastFSeq = rset.columnUint64("LAST_FSEQ");
tape.disabled = rset.columnBool("IS_DISABLED");
tape.full = rset.columnBool("IS_FULL");
tape.readOnly = rset.columnBool("IS_READ_ONLY");
tape.isFromCastor = rset.columnBool("IS_FROM_CASTOR");
tape.dirty = rset.columnBool("DIRTY");
tape.labelLog = getTapeLogFromRset(rset, "LABEL_DRIVE", "LABEL_TIME");
tape.lastReadLog = getTapeLogFromRset(rset, "LAST_READ_DRIVE", "LAST_READ_TIME");
tape.lastWriteLog = getTapeLogFromRset(rset, "LAST_WRITE_DRIVE", "LAST_WRITE_TIME");
......@@ -2857,6 +2863,20 @@ void RdbmsCatalogue::deleteTapeFiles(rdbms::Conn& conn, const std::string& vid)
}
}
void RdbmsCatalogue::setTapeDirty(rdbms::Conn& conn, const std::string& vid) const {
try {
const char * const sql =
"UPDATE TAPE SET DIRTY='1' WHERE VID = :VID";
auto stmt = conn.createStmt(sql);
stmt.bindString(":VID", vid);
stmt.executeNonQuery();
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
void RdbmsCatalogue::resetTapeCounters(rdbms::Conn& conn, const common::dataStructures::SecurityIdentity& admin, const std::string& vid) const {
try {
const time_t now = time(nullptr);
......@@ -2867,7 +2887,8 @@ void RdbmsCatalogue::resetTapeCounters(rdbms::Conn& conn, const common::dataStru
"IS_FULL = '0',"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME,"
"DIRTY = '1' "
"WHERE "
"VID = :VID";
auto stmt = conn.createStmt(sql);
......@@ -6112,7 +6133,8 @@ void RdbmsCatalogue::updateTape(
"LAST_FSEQ = :LAST_FSEQ,"
"DATA_IN_BYTES = DATA_IN_BYTES + :DATA_IN_BYTES,"
"LAST_WRITE_DRIVE = :LAST_WRITE_DRIVE,"
"LAST_WRITE_TIME = :LAST_WRITE_TIME "
"LAST_WRITE_TIME = :LAST_WRITE_TIME,"
"DIRTY='1' "
"WHERE "
"VID = :VID";
auto stmt = conn.createStmt(sql);
......
......@@ -425,6 +425,13 @@ public:
*/
void deleteTapeFiles(rdbms::Conn &conn, const std::string& vid) const;
/**
* Set the DIRTY flag to true
* @param conn the database connection
* @param vid the vid in which we want to set it as dirty
*/
void setTapeDirty(rdbms::Conn &conn, const std::string &vid) const;
/**
* Reset the counters of a tape
* @param conn the database connection
......
......@@ -127,6 +127,12 @@ void SqliteCatalogue::deleteArchiveFile(const std::string &diskInstanceName, con
stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt.executeNonQuery();
}
for(auto &tapeFile: archiveFile->tapeFiles){
//We deleted the TAPE_FILE so the tapes containing them should be set as dirty
setTapeDirty(conn,tapeFile.vid);
}
const auto deleteFromTapeFileTime = t.secs(utils::Timer::resetCounter);
{
......
......@@ -31,9 +31,12 @@ Tape::Tape():
lastFSeq(0),
capacityInBytes(0),
dataOnTapeInBytes(0),
nbMasterFiles(0),
masterDataInBytes(0),
full(false),
disabled(false),
readOnly(false) {}
readOnly(false)
{}
//------------------------------------------------------------------------------
// operator==
......
......@@ -51,6 +51,8 @@ struct Tape {
std::string vo;
uint64_t capacityInBytes;
uint64_t dataOnTapeInBytes;
uint64_t nbMasterFiles;
uint64_t masterDataInBytes;
/**
* The optional name of the encryption key.
......@@ -63,7 +65,8 @@ struct Tape {
bool full;
bool disabled;
bool readOnly;
bool isFromCastor;
bool isFromCastor;
bool dirty;
uint64_t readMountCount;
uint64_t writeMountCount;
EntryLog creationLog;
......
......@@ -114,7 +114,10 @@ int TapeLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) {
tape_item->set_from_castor(tape.isFromCastor);
tape_item->set_read_mount_count(tape.readMountCount);
tape_item->set_write_mount_count(tape.writeMountCount);
tape_item->set_nb_master_files(tape.nbMasterFiles);
tape_item->set_master_data_in_bytes(tape.masterDataInBytes);
tape_item->set_dirty(tape.dirty);
if(tape.labelLog) {
::cta::common::TapeLog * labelLog = tape_item->mutable_label_log();
labelLog->set_drive(tape.labelLog.value().drive);
......
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