Commit 624c5f5c authored by David COME's avatar David COME
Browse files

Added RecallReportPacker reference into DiskWriteTask

Changed the constructor to take that into account, and changed the calls to the constructor where it was needed
parent 6465dc31
......@@ -29,6 +29,7 @@
#include "castor/tape/tapeserver/daemon/MemManager.hpp"
#include "castor/tape/tapeserver/daemon/DataConsumer.hpp"
#include "castor/tape/tapeserver/file/File.hpp"
#include "castor/tape/tapeserver/daemon/RecallReportPacker.hpp"
namespace castor {
namespace tape {
namespace tapeserver {
......@@ -47,9 +48,9 @@ public:
* @param blockCount: number of memory blocks that will be used
* @param mm: memory manager of the session
*/
DiskWriteTask(int fileId, int blockCount, const std::string& filePath,MemoryManager& mm):
DiskWriteTask(int fileId, int blockCount, const std::string& filePath,MemoryManager& mm,RecallReportPacker& report):
m_fifo(blockCount),m_blockCount(blockCount), m_fileId(fileId),
m_memManager(mm),m_writer(filePath){
m_memManager(mm),m_path(filePath),m_reporter(report){
mm.addClient(&m_fifo);
}
......@@ -96,12 +97,16 @@ public:
/**
* Function used to wait until the end of the write
*/
virtual void waitCompletion() { volatile castor::tape::threading::MutexLocker ml(&m_producerProtection); }
virtual void waitCompletion() {
volatile castor::tape::threading::MutexLocker ml(&m_producerProtection);
}
/**
* Destructor (also waiting for the end of the write operation)
*/
virtual ~DiskWriteTask() { volatile castor::tape::threading::MutexLocker ml(&m_producerProtection); }
virtual ~DiskWriteTask() {
volatile castor::tape::threading::MutexLocker ml(&m_producerProtection);
}
private:
......@@ -113,7 +118,7 @@ private:
/**
* Number of blocks in the fifo
*/
int m_blockCount;
const int m_blockCount;
/**
* File id of the file that will be written to disk
......@@ -130,7 +135,8 @@ private:
*/
castor::tape::threading::Mutex m_producerProtection;
tape::diskFile::WriteFile m_writer;
const std::string m_path;
RecallReportPacker& m_reporter;
};
}}}}
......@@ -252,7 +252,7 @@ void castor::tape::tapeserver::daemon::MountSession::executeRead(LogContext & lc
RecallReportPacker rrp(m_clientProxy,
m_castorConf.tapebridgeBulkRequestMigrationMaxFiles,
lc);
RecallTaskInjector rti(mm, trst, dwtp, m_clientProxy, lc);
RecallTaskInjector rti(mm, trst, dwtp, m_clientProxy, rrp, lc);
dwtp.setJobInjector(&rti);
// We are now ready to put everything in motion. First step is to check
......
......@@ -24,10 +24,10 @@ namespace daemon {
RecallTaskInjector::RecallTaskInjector(MemoryManager & mm,
TapeSingleThreadInterface<TapeReadTask> & tapeReader,
DiskThreadPoolInterface<DiskWriteTaskInterface> & diskWriter,
client::ClientInterface& client,castor::log::LogContext lc) :
client::ClientInterface& client,RecallReportPacker& report,castor::log::LogContext lc) :
m_thread(*this),m_memManager(mm),
m_tapeReader(tapeReader),m_diskWriter(diskWriter),
m_client(client),m_lc(lc)
m_client(client),m_lc(lc),m_report(report)
{}
void RecallTaskInjector::requestInjection(int maxFiles, int byteSizeThreshold, bool lastCall) {
......@@ -59,7 +59,7 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<castor::tape::tapeg
m_lc.log(LOG_INFO, "Logged file to recall");
DiskWriteTask * dwt = new DiskWriteTask((*it)->id(), blockID(**it),(*it)->path() ,m_memManager);
DiskWriteTask * dwt = new DiskWriteTask((*it)->id(), blockID(**it),(*it)->path() ,m_memManager,m_report);
TapeReadFileTask * trt = new TapeReadFileTask(*dwt, (*it)->fseq(), blockID(**it));
m_diskWriter.push(dwt);
......
......@@ -51,7 +51,7 @@ public:
RecallTaskInjector(MemoryManager & mm,
TapeSingleThreadInterface<TapeReadTask> & tapeReader,
DiskThreadPoolInterface<DiskWriteTaskInterface> & diskWriter,client::ClientInterface& client,
castor::log::LogContext lc);
RecallReportPacker& report,castor::log::LogContext lc);
/**
......@@ -138,6 +138,7 @@ private:
castor::tape::threading::Mutex m_producerProtection;
castor::tape::threading::BlockingQueue<Request> m_queue;
RecallReportPacker& m_report;
};
} //end namespace daemon
......
......@@ -65,8 +65,8 @@ TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNominal) {
FakeClient client(nbCalls);
FakeDiskWriteThreadPool diskWrite;
FakeSingleTapeReadThread tapeRead(drive);
tapeserver::daemon::RecallTaskInjector rti(mm,tapeRead,diskWrite,client,lc);
tapeserver::daemon::RecallReportPacker rrp(client,2,lc);
tapeserver::daemon::RecallTaskInjector rti(mm,tapeRead,diskWrite,client,rrp,lc);
ASSERT_EQ(true,rti.synchronousInjection(6,blockSize));
ASSERT_EQ(nbFile,diskWrite.m_tasks.size());
......@@ -108,7 +108,8 @@ TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNoFiles) {
FakeDiskWriteThreadPool diskWrite;
FakeSingleTapeReadThread tapeRead(drive);
tapeserver::daemon::RecallTaskInjector rti(mm,tapeRead,diskWrite,client,lc);
tapeserver::daemon::RecallReportPacker rrp(client,2,lc);
tapeserver::daemon::RecallTaskInjector rti(mm,tapeRead,diskWrite,client,rrp,lc);
ASSERT_EQ(false,rti.synchronousInjection(6,blockSize));
ASSERT_EQ(0U,diskWrite.m_tasks.size());
......
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