Commit 7a9dd62c authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

Add notification from taped to the catalogue when tape mounted for read

or write.

Implements setTapeMounted in the scheduler interface for RetrieveMount
and ArchiveMount.
parent b71c78eb
......@@ -278,6 +278,25 @@ void cta::ArchiveMount::setTapeSessionStats(const castor::tape::tapeserver::daem
m_dbMount->setTapeSessionStats(stats);
}
//------------------------------------------------------------------------------
// setTapeMounted()
//------------------------------------------------------------------------------
void cta::ArchiveMount::setTapeMounted(cta::log::LogContext& logContext) const {
utils::Timer t;
log::ScopedParamContainer spc(logContext);
try {
m_catalogue.tapeMountedForArchive(m_dbMount->getMountInfo().vid, m_dbMount->getMountInfo().drive);
auto catalogueTime = t.secs(cta::utils::Timer::resetCounter);
spc.add("catalogueTime", catalogueTime);
logContext.log(log::INFO, "In ArchiveMount::setTapeMounted(): success.");
} catch (cta::exception::Exception &ex) {
auto catalogueTimeFailed = t.secs(cta::utils::Timer::resetCounter);
spc.add("catalogueTime", catalogueTimeFailed);
logContext.log(cta::log::WARNING,
"Failed to update catalogue for the tape mounted for archive.");
}
}
//------------------------------------------------------------------------------
// setTapeFull()
//------------------------------------------------------------------------------
......
......@@ -41,12 +41,15 @@ namespace cta {
/**
* Constructor.
*
* @param catalogue The file catalogue interface.
*/
ArchiveMount(catalogue::Catalogue & catalogue);
/**
* Constructor.
*
* @param catalogue The file catalogue interface.
* @param dbMount The database representation of this mount.
*/
ArchiveMount(catalogue::Catalogue & catalogue, std::unique_ptr<cta::SchedulerDatabase::ArchiveMount> dbMount);
......@@ -113,6 +116,12 @@ namespace cta {
*/
void setTapeSessionStats(const castor::tape::tapeserver::daemon::TapeSessionStats &stats) override;
/**
* Report a tape mounted event
* @param logContext
*/
void setTapeMounted(log::LogContext &logContext) const override;
/**
* Report that the tape is full.
*/
......
......@@ -65,6 +65,11 @@ void LabelMount::setTapeSessionStats(const castor::tape::tapeserver::daemon::Tap
// TODO
}
void LabelMount::setTapeMounted(log::LogContext &logContext) const {
throw 0;
// TODO
}
LabelMount::LabelMount(catalogue::Catalogue& catalogue, std::unique_ptr<cta::SchedulerDatabase::LabelMount> dbMount):
m_catalogue(catalogue) {
throw 0;
......
......@@ -96,6 +96,12 @@ namespace cta {
* Report a tape session statistics
*/
void setTapeSessionStats(const castor::tape::tapeserver::daemon::TapeSessionStats &stats) override;
/**
* Report a tape mounted event
* @param logContext
*/
void setTapeMounted(log::LogContext &logContext) const override;
CTA_GENERATE_EXCEPTION_CLASS(SessionNotRunning);
......
......@@ -23,15 +23,16 @@
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::RetrieveMount::RetrieveMount():
m_sessionRunning(false) {}
cta::RetrieveMount::RetrieveMount(cta::catalogue::Catalogue &catalogue): m_sessionRunning(false), m_catalogue(catalogue) {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::RetrieveMount::RetrieveMount(
cta::catalogue::Catalogue &catalogue,
std::unique_ptr<SchedulerDatabase::RetrieveMount> dbMount):
m_sessionRunning(false) {
m_sessionRunning(false), m_catalogue(catalogue) {
m_dbMount.reset(dbMount.release());
}
......@@ -281,6 +282,25 @@ void cta::RetrieveMount::setTapeSessionStats(const castor::tape::tapeserver::dae
m_dbMount->setTapeSessionStats(stats);
}
//------------------------------------------------------------------------------
// setTapeMounted()
//------------------------------------------------------------------------------
void cta::RetrieveMount::setTapeMounted(cta::log::LogContext& logContext) const {
utils::Timer t;
log::ScopedParamContainer spc(logContext);
try {
m_catalogue.tapeMountedForRetrieve(m_dbMount->getMountInfo().vid, m_dbMount->getMountInfo().drive);
auto catalogueTime = t.secs(cta::utils::Timer::resetCounter);
spc.add("catalogueTime", catalogueTime);
logContext.log(log::INFO, "In RetrieveMount::setTapeMounted(): success.");
} catch (cta::exception::Exception &ex) {
auto catalogueTimeFailed = t.secs(cta::utils::Timer::resetCounter);
spc.add("catalogueTime", catalogueTimeFailed);
logContext.log(cta::log::WARNING,
"Failed to update catalogue for the tape mounted for retrieve.");
}
}
//------------------------------------------------------------------------------
// bothSidesComplete()
//------------------------------------------------------------------------------
......
......@@ -24,6 +24,7 @@
#include "scheduler/SchedulerDatabase.hpp"
#include "scheduler/TapeMount.hpp"
#include "disk/DiskReporterFactory.hpp"
#include "catalogue/Catalogue.hpp"
#include <memory>
#include <queue>
......@@ -37,18 +38,19 @@ namespace cta {
*/
class RetrieveMount: public TapeMount {
friend class Scheduler;
protected:
protected:
/**
* Trivial constructor
* Constructor.
* @param catalogue The file catalogue interface.
*/
RetrieveMount();
RetrieveMount(cta::catalogue::Catalogue &catalogue);
/**
* Constructor.
*
* @param catalogue The file catalogue interface.
* @param dbMount The database representation of this mount.
*/
RetrieveMount(std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbMount);
RetrieveMount(cta::catalogue::Catalogue &catalogue, std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbMount);
public:
......@@ -131,7 +133,13 @@ namespace cta {
* Report a tape session statistics
*/
virtual void setTapeSessionStats(const castor::tape::tapeserver::daemon::TapeSessionStats &stats);
/**
* Report a tape mounted event
* @param logContext
*/
virtual void setTapeMounted(log::LogContext &logContext) const;
/**
* Indicates that the disk thread of the mount was completed. This
* will implicitly trigger the transition from DrainingToDisk to Up if necessary.
......@@ -221,6 +229,10 @@ namespace cta {
/** An initialized-once factory for archive reports (indirectly used by ArchiveJobs) */
disk::DiskReporterFactory m_reporterFactory;
/**
* A pointer to the file catalogue.
*/
cta::catalogue::Catalogue &m_catalogue;
}; // class RetrieveMount
......
......@@ -1240,8 +1240,8 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
m->activityNameAndWeightedMountCount.value().activity,
m->activityNameAndWeightedMountCount.value().weight };
}
std::unique_ptr<RetrieveMount> internalRet (
new RetrieveMount(mountInfo->createRetrieveMount(m->vid,
std::unique_ptr<RetrieveMount> internalRet(new RetrieveMount(m_catalogue));
internalRet->m_dbMount.reset(mountInfo->createRetrieveMount(m->vid,
m->tapePool,
driveName,
logicalLibraryName,
......@@ -1250,7 +1250,7 @@ std::unique_ptr<TapeMount> Scheduler::getNextMount(const std::string &logicalLib
m->mediaType,
m->vendor,
m->capacityInBytes,
time(NULL), actvityAndWeight)));
time(NULL), actvityAndWeight).release());
mountCreationTime += timer.secs(utils::Timer::resetCounter);
internalRet->m_sessionRunning = true;
internalRet->m_diskRunning = true;
......
......@@ -21,6 +21,7 @@
#include "common/dataStructures/MountType.hpp"
#include "common/dataStructures/DriveStatus.hpp"
#include "common/optional.hpp"
#include "common/log/LogContext.hpp"
#include "tapeserver/castor/tape/tapeserver/daemon/TapeSessionStats.hpp"
#include <string>
......@@ -96,6 +97,12 @@ namespace cta {
*/
virtual void setTapeSessionStats(const castor::tape::tapeserver::daemon::TapeSessionStats &stats) = 0;
/**
* Report a tape mounted event
* @param LogContext
*/
virtual void setTapeMounted(cta::log::LogContext &logContext) const = 0;
/**
* Destructor.
*/
......
......@@ -58,6 +58,7 @@ class TapeMountDummy: public TapeMount {
void setDriveStatus(cta::common::dataStructures::DriveStatus status) override {}
void setTapeSessionStats(const castor::tape::tapeserver::daemon::TapeSessionStats &stats) override {};
void setTapeMounted(log::LogContext &logContext) const override {};
};
}
\ No newline at end of file
......@@ -21,6 +21,7 @@
#include "scheduler/RetrieveMount.hpp"
#include "scheduler/RetrieveJob.hpp"
#include "scheduler/testingMocks/MockRetrieveJob.hpp"
#include "catalogue/DummyCatalogue.hpp"
#include <memory>
namespace cta {
......@@ -28,7 +29,7 @@ namespace cta {
public:
int getJobs;
int completes;
MockRetrieveMount(): getJobs(0), completes(0) {}
MockRetrieveMount(cta::catalogue::Catalogue &catalogue): RetrieveMount(catalogue), getJobs(0), completes(0) {}
~MockRetrieveMount() throw() {
}
......@@ -68,6 +69,8 @@ namespace cta {
void setTapeSessionStats(const castor::tape::tapeserver::daemon::TapeSessionStats &stats) override {};
void setTapeMounted(log::LogContext &logContext) const override {};
void flushAsyncSuccessReports(std::queue<std::unique_ptr<cta::RetrieveJob> >& successfulRetrieveJobs, cta::log::LogContext& logContext) override {};
private:
......
......@@ -601,7 +601,7 @@ TEST_P(DataTransferSessionTest, DataTransferSessionWrongRecall) {
// Write the file to tape
const uint64_t archiveFileSize = 1000;
cta::MockArchiveMount mam(catalogue);
cta::MockRetrieveMount mrm;
cta::MockRetrieveMount mrm(catalogue);
std::unique_ptr<cta::ArchiveJob> aj(new cta::MockArchiveJob(&mam, catalogue));
aj->tapeFile.fSeq = fseq;
aj->archiveFile.archiveFileID = 1000 + fseq;
......
......@@ -51,7 +51,7 @@ namespace unitTests{
class TestingRetrieveMount: public cta::RetrieveMount {
public:
TestingRetrieveMount(std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm): RetrieveMount(std::move(dbrm)) {
TestingRetrieveMount(cta::catalogue::Catalogue &catalogue, std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm): RetrieveMount(catalogue, std::move(dbrm)) {
}
};
......@@ -101,13 +101,14 @@ namespace unitTests{
cta::log::LogContext lc(log);
std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm(new TestingDatabaseRetrieveMount());
TestingRetrieveMount trm(std::move(dbrm));
std::unique_ptr<cta::catalogue::Catalogue> catalogue(new cta::catalogue::DummyCatalogue);
TestingRetrieveMount trm(*catalogue, std::move(dbrm));
MockRecallReportPacker report(&trm,lc);
RecallMemoryManager mm(10,100,lc);
cta::disk::RadosStriperPool striperPool;
DiskFileFactory fileFactory("", 0, striperPool);
cta::MockRetrieveMount mrm;
cta::MockRetrieveMount mrm(*catalogue);
std::unique_ptr<TestingRetrieveJob> fileToRecall(new TestingRetrieveJob(mrm));
fileToRecall->retrieveRequest.archiveFileID = 1;
fileToRecall->selectedCopyNb=1;
......
......@@ -30,6 +30,7 @@
#include "castor/tape/tapeserver/daemon/MemBlock.hpp"
#include "castor/messages/TapeserverProxyDummy.hpp"
#include "scheduler/TapeMountDummy.hpp"
#include "catalogue/DummyCatalogue.hpp"
#include <gtest/gtest.h>
namespace unitTests{
......@@ -45,7 +46,7 @@ namespace unitTests{
class TestingRetrieveMount: public cta::RetrieveMount {
public:
TestingRetrieveMount(std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm): RetrieveMount(std::move(dbrm)) {
TestingRetrieveMount(cta::catalogue::Catalogue &catalogue, std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm): RetrieveMount(catalogue, std::move(dbrm)) {
}
};
......@@ -100,7 +101,8 @@ namespace unitTests{
cta::log::LogContext lc(log);
std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm(new TestingDatabaseRetrieveMount);
TestingRetrieveMount trm(std::move(dbrm));
std::unique_ptr<cta::catalogue::Catalogue> catalogue(new cta::catalogue::DummyCatalogue);
TestingRetrieveMount trm(*catalogue, std::move(dbrm));
MockRecallReportPacker report(&trm,lc);
RecallMemoryManager mm(10,100,lc);
......
......@@ -66,7 +66,8 @@ protected:
};
TEST_F(castor_tape_tapeserver_daemon_RecallReportPackerTest, RecallReportPackerNominal) {
cta::MockRetrieveMount retrieveMount;
auto catalogue = cta::catalogue::DummyCatalogue();
cta::MockRetrieveMount retrieveMount(catalogue);
......@@ -111,7 +112,8 @@ TEST_F(castor_tape_tapeserver_daemon_RecallReportPackerTest, RecallReportPackerN
}
TEST_F(castor_tape_tapeserver_daemon_RecallReportPackerTest, RecallReportPackerBadBadEnd) {
cta::MockRetrieveMount retrieveMount;
auto catalogue = cta::catalogue::DummyCatalogue();
cta::MockRetrieveMount retrieveMount(catalogue);
::testing::InSequence dummy;
std::unique_ptr<cta::RetrieveJob> job1;
......
......@@ -146,7 +146,8 @@ namespace unitTests
RecallMemoryManager mm(50U, 50U, lc);
castor::tape::tapeserver::drive::FakeDrive drive;
cta::MockRetrieveMount trm;
auto catalogue = cta::catalogue::DummyCatalogue();
cta::MockRetrieveMount trm(catalogue);
trm.createRetrieveJobs(nbJobs);
//EXPECT_CALL(trm, internalGetNextJob()).Times(nbJobs+1);
......@@ -206,8 +207,8 @@ namespace unitTests
cta::log::LogContext lc(log);
RecallMemoryManager mm(50U, 50U, lc);
castor::tape::tapeserver::drive::FakeDrive drive;
cta::MockRetrieveMount trm;
auto catalogue = cta::catalogue::DummyCatalogue();
cta::MockRetrieveMount trm(catalogue);
trm.createRetrieveJobs(0);
//EXPECT_CALL(trm, internalGetNextJob()).Times(1); //no work: single call to getnextjob
......
......@@ -256,6 +256,7 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() {
scoped.add("mountTime", m_stats.mountTime);
m_logContext.log(cta::log::INFO, "Tape mounted and drive ready");
}
m_retrieveMount.setTapeMounted(m_logContext);
try {
currentErrorToCount = "Error_tapeEncryptionEnable";
// We want those scoped params to last for the whole mount.
......
......@@ -336,6 +336,7 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() {
scoped.add("mountTime", m_stats.mountTime);
m_logContext.log(cta::log::INFO, "Tape mounted and drive ready");
}
m_archiveMount.setTapeMounted(m_logContext);
try {
currentErrorToCount = "Error_tapeEncryptionEnable";
// We want those scoped params to last for the whole mount.
......
Markdown is supported
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