Commit 4d3317d2 authored by David COME's avatar David COME
Browse files

Properly clone FileToRecallStruct into RecallTaskInjector

and thus changed the type to an auto_ptr into DiskWriteTask
parent 3077b50d
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "castor/tape/tapeserver/daemon/DataConsumer.hpp" #include "castor/tape/tapeserver/daemon/DataConsumer.hpp"
#include "castor/tape/tapeserver/file/File.hpp" #include "castor/tape/tapeserver/file/File.hpp"
#include "castor/tape/tapegateway/FileToRecallStruct.hpp" #include "castor/tape/tapegateway/FileToRecallStruct.hpp"
#include <memory>
namespace { namespace {
uint32_t blockID(const castor::tape::tapegateway::FileToRecallStruct& ftr) uint32_t blockID(const castor::tape::tapegateway::FileToRecallStruct& ftr)
...@@ -72,8 +72,8 @@ public: ...@@ -72,8 +72,8 @@ public:
* @param blockCount: number of memory blocks that will be used * @param blockCount: number of memory blocks that will be used
* @param mm: memory manager of the session * @param mm: memory manager of the session
*/ */
DiskWriteTask(const tape::tapegateway::FileToRecallStruct& file,MemoryManager& mm): DiskWriteTask(tape::tapegateway::FileToRecallStruct* file,MemoryManager& mm):
m_blockCount(blockID(file)),m_fifo(m_blockCount),m_recallingFile(file),m_memManager(mm){ m_blockCount(blockID(*file)),m_fifo(m_blockCount),m_recallingFile(file),m_memManager(mm){
mm.addClient(&m_fifo); mm.addClient(&m_fifo);
} }
...@@ -95,17 +95,17 @@ public: ...@@ -95,17 +95,17 @@ public:
using log::LogContext; using log::LogContext;
using log::Param; using log::Param;
try{ try{
tape::diskFile::WriteFile writer(m_recallingFile.path()); tape::diskFile::WriteFile writer(m_recallingFile->path());
int blockId = 0; int blockId = 0;
while(!m_fifo.finished()) { while(!m_fifo.finished()) {
MemBlock *mb = m_fifo.popDataBlock(); MemBlock *mb = m_fifo.popDataBlock();
AutoReleaseBlock releaser(mb,m_memManager); AutoReleaseBlock releaser(mb,m_memManager);
if(m_recallingFile.fileid() != static_cast<unsigned int>(mb->m_fileid) if(m_recallingFile->fileid() != static_cast<unsigned int>(mb->m_fileid)
|| blockId != mb->m_fileBlock){ || blockId != mb->m_fileBlock){
LogContext::ScopedParam sp[]={ LogContext::ScopedParam sp[]={
LogContext::ScopedParam(lc, Param("expectedFILEID",m_recallingFile.fileid())), LogContext::ScopedParam(lc, Param("expectedFILEID",m_recallingFile->fileid())),
LogContext::ScopedParam(lc, Param("receivedFILEID", mb->m_fileid)), LogContext::ScopedParam(lc, Param("receivedFILEID", mb->m_fileid)),
LogContext::ScopedParam(lc, Param("expectedFBLOCKId", blockId)), LogContext::ScopedParam(lc, Param("expectedFBLOCKId", blockId)),
LogContext::ScopedParam(lc, Param("receivedFBLOCKId", mb->m_fileBlock)), LogContext::ScopedParam(lc, Param("receivedFBLOCKId", mb->m_fileBlock)),
...@@ -118,11 +118,11 @@ public: ...@@ -118,11 +118,11 @@ public:
} }
writer.close(); writer.close();
//a log is done in m_reporter while processing reportCompletedJob //a log is done in m_reporter while processing reportCompletedJob
reporter.reportCompletedJob(m_recallingFile); reporter.reportCompletedJob(*m_recallingFile);
} }
catch(const castor::exception::Exception& e){ catch(const castor::exception::Exception& e){
//a log is done in m_reporter while processing reportFailedJob //a log is done in m_reporter while processing reportFailedJob
reporter.reportFailedJob(m_recallingFile,e.getMessageValue(),e.code()); reporter.reportFailedJob(*m_recallingFile,e.getMessageValue(),e.code());
} }
} }
...@@ -169,7 +169,7 @@ private: ...@@ -169,7 +169,7 @@ private:
/** /**
* All we need to know about the file we are currently recalling * All we need to know about the file we are currently recalling
*/ */
tape::tapegateway::FileToRecallStruct m_recallingFile; std::auto_ptr<tape::tapegateway::FileToRecallStruct> m_recallingFile;
/** /**
* Reference to the Memory Manager in use * Reference to the Memory Manager in use
......
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
using castor::log::LogContext; using castor::log::LogContext;
using castor::log::Param; using castor::log::Param;
namespace{
castor::tape::tapegateway::FileToRecallStruct* removeOwningList(castor::tape::tapegateway::FileToRecallStruct* ptr){
ptr->setFilesToRecallList(NULL);
return ptr;
}
}
namespace castor{ namespace castor{
namespace tape{ namespace tape{
...@@ -53,7 +59,7 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<castor::tape::tapeg ...@@ -53,7 +59,7 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<castor::tape::tapeg
m_lc.log(LOG_INFO, "Logged file to recall"); m_lc.log(LOG_INFO, "Logged file to recall");
DiskWriteTask * dwt = new DiskWriteTask(**it ,m_memManager); DiskWriteTask * dwt = new DiskWriteTask(removeOwningList(dynamic_cast<tape::tapegateway::FileToRecallStruct*>((*it)->clone())) ,m_memManager);
TapeReadFileTask * trt = new TapeReadFileTask(*dwt, (*it)->fseq(), blockID(**it)); TapeReadFileTask * trt = new TapeReadFileTask(*dwt, (*it)->fseq(), blockID(**it));
m_diskWriter.push(dwt); m_diskWriter.push(dwt);
......
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