Commit 3293bbf8 authored by David COME's avatar David COME
Browse files

Big refactor of names of classes

DiskReadTask -> DiskReadTaskInterface, DiskReadFileTask -> DiskReadTask, same thing for the write side. Changed the includes files accordingly
parent 2fc7bf87
......@@ -24,7 +24,7 @@
#pragma once
#include "castor/tape/tapeserver/daemon/DiskReadTask.hpp"
#include "castor/tape/tapeserver/daemon/DiskReadTaskInterface.hpp"
#include "castor/tape/tapeserver/daemon/DataFifo.hpp"
#include "castor/tape/tapeserver/daemon/DataConsumer.hpp"
......@@ -33,9 +33,9 @@ namespace tape {
namespace tapeserver {
namespace daemon {
class DiskReadFileTask :public DiskReadTask {
class DiskReadTask :public DiskReadTaskInterface {
public:
DiskReadFileTask(DataConsumer & destination, int fileId, int nbBlocks): m_fileId(fileId),
DiskReadTask(DataConsumer & destination, int fileId, int nbBlocks): m_fileId(fileId),
m_nbBlocks(nbBlocks), m_fifo(destination) {}
/* Implementation of the DiskReadTask interface*/
virtual bool endOfWork() { return false; }
......
......@@ -31,13 +31,13 @@ namespace tape {
namespace tapeserver {
namespace daemon {
class DiskReadTask {
class DiskReadTaskInterface {
public:
virtual bool endOfWork() = 0;
virtual void execute() {
throw MemException("Tring to execute a non-execuatble DiskReadTask");
};
virtual ~DiskReadTask() {}
virtual ~DiskReadTaskInterface() {}
};
}}}}
......@@ -24,7 +24,7 @@
#pragma once
#include "castor/tape/tapeserver/daemon/DiskReadTask.hpp"
#include "castor/tape/tapeserver/daemon/DiskReadTaskInterface.hpp"
#include "castor/tape/tapeserver/threading/BlockingQueue.hpp"
#include "castor/tape/tapeserver/threading/Threading.hpp"
#include "castor/tape/tapeserver/daemon/DiskThreadPoolInterface.hpp"
......@@ -35,7 +35,7 @@ namespace tape {
namespace tapeserver {
namespace daemon {
class DiskReadThreadPool : public DiskThreadPoolInterface<DiskReadTask> {
class DiskReadThreadPool : public DiskThreadPoolInterface<DiskReadTaskInterface> {
public:
DiskReadThreadPool(int nbThread) {
for(int i=0; i<nbThread; i++) {
......@@ -61,7 +61,7 @@ public:
(*i)->waitThreads();
}
}
virtual void push(DiskReadTask *t) { m_tasks.push(t); }
virtual void push(DiskReadTaskInterface *t) { m_tasks.push(t); }
void finish() {
/* Insert one endOfSession per thread */
for (size_t i=0; i<m_threads.size(); i++) {
......@@ -79,7 +79,7 @@ private:
DiskReadThreadPool & m_manager;
virtual void run() {
while(1) {
DiskReadTask * task = m_manager.m_tasks.pop();
DiskReadTaskInterface * task = m_manager.m_tasks.pop();
bool end = task->endOfWork();
if (!end) task->execute();
delete task;
......
......@@ -39,7 +39,7 @@ namespace daemon {
* session. Being a consumer of memory blocks, it inherits from the DataConsumer class. It also
* inherits several methods from the DiskWriteTask (TODO: do we really need this base class?).
*/
class DiskWriteFileTask: public DiskWriteTask, public DataConsumer {
class DiskWriteTask: public DiskWriteTaskInterface, public DataConsumer {
public:
/**
* Constructor
......@@ -47,7 +47,7 @@ public:
* @param blockCount: number of memory blocks that will be used
* @param mm: memory manager of the session
*/
DiskWriteFileTask(int fileId, int blockCount, MemoryManager& mm): m_fifo(blockCount),
DiskWriteTask(int fileId, int blockCount, MemoryManager& mm): m_fifo(blockCount),
m_blockCount(blockCount), m_fileId(fileId),
m_memManager(mm) { mm.addClient(&m_fifo); }
......@@ -104,7 +104,7 @@ public:
/**
* Destructor (also waiting for the end of the write operation)
*/
virtual ~DiskWriteFileTask() { volatile castor::tape::threading::MutexLocker ml(&m_producerProtection); }
virtual ~DiskWriteTask() { volatile castor::tape::threading::MutexLocker ml(&m_producerProtection); }
private:
......
......@@ -35,7 +35,7 @@ namespace daemon {
* Abstract class describing the interface for a task that wants to write to disk.
* This is inherited exclusively by DiskWriteFileTask.
*/
class DiskWriteTask {
class DiskWriteTaskInterface {
public:
/**
......@@ -68,7 +68,7 @@ public:
/**
* Destructor
*/
virtual ~DiskWriteTask() {};
virtual ~DiskWriteTaskInterface() {};
};
}}}}
......@@ -24,7 +24,7 @@
#pragma once
#include "castor/tape/tapeserver/daemon/DiskWriteTask.hpp"
#include "castor/tape/tapeserver/daemon/DiskWriteTaskInterface.hpp"
#include "castor/tape/tapeserver/threading/BlockingQueue.hpp"
#include "castor/tape/tapeserver/threading/Threading.hpp"
#include "castor/tape/tapeserver/daemon/TaskInjector.hpp"
......@@ -38,7 +38,7 @@ namespace tape {
namespace tapeserver {
namespace daemon {
class DiskWriteThreadPool : public DiskThreadPoolInterface<DiskWriteTask> {
class DiskWriteThreadPool : public DiskThreadPoolInterface<DiskWriteTaskInterface> {
public:
DiskWriteThreadPool(int nbThread, int maxFilesReq, int maxBlocksReq):
m_jobInjector(NULL), m_filesQueued(0), m_blocksQueued(0),
......@@ -67,7 +67,7 @@ public:
(*i)->waitThreads();
}
}
virtual void push(DiskWriteTask *t) {
virtual void push(DiskWriteTaskInterface *t) {
{
castor::tape::threading::MutexLocker ml(&m_counterProtection);
m_filesQueued += t->files();
......@@ -98,8 +98,8 @@ private:
bool crossingDownFileThreshod(int filesPopped) {
return (m_filesQueued >= m_maxFilesReq/2) && (m_filesQueued - filesPopped < m_maxFilesReq/2);
}
DiskWriteTask * popAndRequestMoreJobs() {
DiskWriteTask * ret = m_tasks.pop();
DiskWriteTaskInterface * popAndRequestMoreJobs() {
DiskWriteTaskInterface * ret = m_tasks.pop();
{
castor::tape::threading::MutexLocker ml(&m_counterProtection);
/* We are about to go to empty: request a last call job injection */
......@@ -129,7 +129,7 @@ private:
DiskWriteThreadPool & m_manager;
virtual void run() {
while(1) {
DiskWriteTask * task = m_manager.popAndRequestMoreJobs();
DiskWriteTaskInterface * task = m_manager.popAndRequestMoreJobs();
bool end = task->endOfWork();
if (!end) task->execute();
delete task;
......
......@@ -25,7 +25,6 @@
#pragma once
#include "castor/tape/tapeserver/threading/BlockingQueue.hpp"
#include "castor/tape/tapeserver/daemon/MigrationJob.hpp"
#include "castor/tape/tapeserver/client/ClientInterface.hpp"
#include "castor/tape/tapegateway/FileToMigrateStruct.hpp"
#include "castor/tape/tapeserver/daemon/ReportPackerInterface.hpp"
......
......@@ -23,7 +23,7 @@ namespace daemon {
RecallTaskInjector::RecallTaskInjector(MemoryManager & mm,
TapeSingleThreadInterface<TapeReadTask> & tapeReader,
DiskThreadPoolInterface<DiskWriteTask> & diskWriter,
DiskThreadPoolInterface<DiskWriteTaskInterface> & diskWriter,
client::ClientInterface& client,castor::log::LogContext lc) :
m_thread(*this),m_memManager(mm),
m_tapeReader(tapeReader),m_diskWriter(diskWriter),
......@@ -59,7 +59,7 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<castor::tape::tapeg
m_lc.log(LOG_INFO, "Logged file to recall");
DiskWriteFileTask * dwt = new DiskWriteFileTask((*it)->id(), blockID(**it), m_memManager);
DiskWriteTask * dwt = new DiskWriteTask((*it)->id(), blockID(**it), m_memManager);
TapeReadFileTask * trt = new TapeReadFileTask(*dwt, (*it)->fseq(), blockID(**it));
m_diskWriter.push(dwt);
......
......@@ -31,7 +31,7 @@
#include "castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp"
#include "castor/tape/tapeserver/daemon/TapeReadFileTask.hpp"
#include "castor/tape/tapeserver/daemon/DiskWriteThreadPool.hpp"
#include "castor/tape/tapeserver/daemon/DiskWriteFileTask.hpp"
#include "castor/tape/tapeserver/daemon/DiskWriteTask.hpp"
#include "castor/tape/tapeserver/daemon/TapeWriteFileTask.hpp"
#include "castor/tape/tapeserver/client/ClientProxy.hpp"
#include "castor/tape/tapegateway/FileToRecallStruct.hpp"
......@@ -50,7 +50,7 @@ public:
RecallTaskInjector(MemoryManager & mm,
TapeSingleThreadInterface<TapeReadTask> & tapeReader,
DiskThreadPoolInterface<DiskWriteTask> & diskWriter,client::ClientInterface& client,
DiskThreadPoolInterface<DiskWriteTaskInterface> & diskWriter,client::ClientInterface& client,
castor::log::LogContext lc);
......@@ -128,7 +128,7 @@ private:
TapeSingleThreadInterface<TapeReadTask> & m_tapeReader;
DiskThreadPoolInterface<DiskWriteTask> & m_diskWriter;
DiskThreadPoolInterface<DiskWriteTaskInterface> & m_diskWriter;
client::ClientInterface& m_client;
/**
......
......@@ -12,16 +12,16 @@ using namespace castor::tape::tapeserver::daemon;
using namespace castor::tape;
const int blockSize=4096;
class FakeDiskWriteThreadPool : public DiskThreadPoolInterface<DiskWriteTask>
class FakeDiskWriteThreadPool : public DiskThreadPoolInterface<DiskWriteTaskInterface>
{
public:
using tapeserver::daemon::DiskThreadPoolInterface<DiskWriteTask>::m_tasks;
using tapeserver::daemon::DiskThreadPoolInterface<DiskWriteTaskInterface>::m_tasks;
virtual void finish()
{
m_tasks.push(new endOfSession);
}
virtual void push(DiskWriteTask* t){
virtual void push(DiskWriteTaskInterface* t){
m_tasks.push(t);
}
~FakeDiskWriteThreadPool(){
......@@ -89,7 +89,7 @@ TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNominal) {
for(int i=0;i<1;++i)
{
DiskWriteTask* diskWriteTask=diskWrite.m_tasks.pop();
DiskWriteTaskInterface* diskWriteTask=diskWrite.m_tasks.pop();
TapeReadTask* tapeReadTask=tapeRead.m_tasks.pop();
ASSERT_EQ(diskWriteTask->endOfWork(),true);
......
......@@ -28,7 +28,6 @@
#include "castor/tape/tapeserver/daemon/TapeWriteTask.hpp"
#include "castor/tape/tapeserver/threading/Threading.hpp"
#include "castor/tape/tapeserver/daemon/MigrationReportPacker.hpp"
#include "castor/tape/tapeserver/daemon/MigrationJob.hpp"
#include "castor/tape/tapeserver/drive/Drive.hpp"
#include "castor/tape/tapeserver/daemon/TapeSingleThreadInterface.hpp"
#include <iostream>
......
......@@ -26,9 +26,9 @@
#include "castor/tape/tapeserver/daemon/TapeWriteSingleThread.hpp"
#include "castor/tape/tapeserver/daemon/TapeWriteFileTask.hpp"
#include "castor/tape/tapeserver/daemon/DiskReadThreadPool.hpp"
#include "castor/tape/tapeserver/daemon/DiskReadFileTask.hpp"
#include "castor/tape/tapeserver/daemon/DiskReadTask.hpp"
#include "castor/tape/tapeserver/daemon/DiskWriteThreadPool.hpp"
#include "castor/tape/tapeserver/daemon/DiskWriteFileTask.hpp"
#include "castor/tape/tapeserver/daemon/DiskWriteTask.hpp"
#include "castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp"
#include "castor/tape/tapeserver/daemon/TapeReadFileTask.hpp"
#include "castor/tape/tapeserver/daemon/RecallTaskInjector.hpp"
......
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