Commit b4e9a33d authored by Eric Cano's avatar Eric Cano
Browse files

Added handling for communication errors in synchronous task injection.

This situation boils down to an empty mount, and should not put the drive down.
Also renamed a few variables so that recall and migrations use similar names.
parent 3c593ec9
...@@ -58,7 +58,7 @@ namespace daemon { ...@@ -58,7 +58,7 @@ namespace daemon {
uint64_t maxFiles, uint64_t byteSizeThreshold,castor::log::LogContext lc): uint64_t maxFiles, uint64_t byteSizeThreshold,castor::log::LogContext lc):
m_thread(*this),m_memManager(mm),m_tapeWriter(tapeWriter), m_thread(*this),m_memManager(mm),m_tapeWriter(tapeWriter),
m_diskReader(diskReader),m_client(client),m_lc(lc), m_diskReader(diskReader),m_client(client),m_lc(lc),
m_maxFiles(maxFiles), m_maxByte(byteSizeThreshold) m_maxFiles(maxFiles), m_maxBytes(byteSizeThreshold)
{ {
} }
...@@ -117,7 +117,7 @@ namespace daemon { ...@@ -117,7 +117,7 @@ namespace daemon {
void MigrationTaskInjector::requestInjection( bool lastCall) { void MigrationTaskInjector::requestInjection( bool lastCall) {
castor::tape::threading::MutexLocker ml(&m_producerProtection); castor::tape::threading::MutexLocker ml(&m_producerProtection);
if(!m_errorFlag) { if(!m_errorFlag) {
m_queue.push(Request(m_maxFiles, m_maxByte, lastCall)); m_queue.push(Request(m_maxFiles, m_maxBytes, lastCall));
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -126,8 +126,24 @@ namespace daemon { ...@@ -126,8 +126,24 @@ namespace daemon {
bool MigrationTaskInjector::synchronousInjection() { bool MigrationTaskInjector::synchronousInjection() {
client::ClientProxy::RequestReport reqReport; client::ClientProxy::RequestReport reqReport;
std::auto_ptr<tapegateway::FilesToMigrateList> std::auto_ptr<tapegateway::FilesToMigrateList>
filesToMigrateList(m_client.getFilesToMigrate(m_maxFiles, filesToMigrateList;
m_maxByte,reqReport)); try {
filesToMigrateList.reset(m_client.getFilesToMigrate(m_maxFiles,
m_maxBytes,reqReport));
} catch (castor::exception::Exception & ex) {
castor::log::ScopedParamContainer scoped(m_lc);
scoped.add("transactionId", reqReport.transactionId)
.add("byteSizeThreshold",m_maxBytes)
.add("maxFiles", m_maxFiles)
.add("message", ex.getMessageValue());
m_lc.log(LOG_ERR, "Failed to getFiledToRecall.");
return false;
}
castor::log::ScopedParamContainer scoped(m_lc);
scoped.add("sendRecvDuration", reqReport.sendRecvDuration)
.add("byteSizeThreshold",m_maxBytes)
.add("transactionId", reqReport.transactionId)
.add("maxFiles", m_maxFiles);
if(NULL == filesToMigrateList.get()) { if(NULL == filesToMigrateList.get()) {
m_lc.log(LOG_ERR, "No files to migrate: empty mount"); m_lc.log(LOG_ERR, "No files to migrate: empty mount");
return false; return false;
......
...@@ -186,7 +186,7 @@ private: ...@@ -186,7 +186,7 @@ private:
const uint64_t m_maxFiles; const uint64_t m_maxFiles;
/// Same as m_maxFilesReq for size per request. (in bytes)) /// Same as m_maxFilesReq for size per request. (in bytes))
const uint64_t m_maxByte; const uint64_t m_maxBytes;
/**The last fseq used on the tape. We should not see this but /**The last fseq used on the tape. We should not see this but
* IT is computed by subtracting 1 to fSeg of the first file to migrate we * IT is computed by subtracting 1 to fSeg of the first file to migrate we
......
...@@ -42,7 +42,7 @@ RecallTaskInjector::RecallTaskInjector(RecallMemoryManager & mm, ...@@ -42,7 +42,7 @@ RecallTaskInjector::RecallTaskInjector(RecallMemoryManager & mm,
uint64_t maxFiles, uint64_t byteSizeThreshold,castor::log::LogContext lc) : uint64_t maxFiles, uint64_t byteSizeThreshold,castor::log::LogContext lc) :
m_thread(*this),m_memManager(mm), m_thread(*this),m_memManager(mm),
m_tapeReader(tapeReader),m_diskWriter(diskWriter), m_tapeReader(tapeReader),m_diskWriter(diskWriter),
m_client(client),m_lc(lc),m_maxFiles(maxFiles),m_byteSizeThreshold(byteSizeThreshold) m_client(client),m_lc(lc),m_maxFiles(maxFiles),m_maxBytes(byteSizeThreshold)
{} {}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//destructor //destructor
...@@ -63,7 +63,7 @@ void RecallTaskInjector::finish(){ ...@@ -63,7 +63,7 @@ void RecallTaskInjector::finish(){
void RecallTaskInjector::requestInjection(bool lastCall) { void RecallTaskInjector::requestInjection(bool lastCall) {
//@TODO where shall we acquire the lock ? There of just before the push ? //@TODO where shall we acquire the lock ? There of just before the push ?
castor::tape::threading::MutexLocker ml(&m_producerProtection); castor::tape::threading::MutexLocker ml(&m_producerProtection);
m_queue.push(Request(m_maxFiles, m_byteSizeThreshold, lastCall)); m_queue.push(Request(m_maxFiles, m_maxBytes, lastCall));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//waitThreads //waitThreads
...@@ -119,15 +119,23 @@ bool RecallTaskInjector::synchronousInjection() ...@@ -119,15 +119,23 @@ bool RecallTaskInjector::synchronousInjection()
client::ClientProxy::RequestReport reqReport; client::ClientProxy::RequestReport reqReport;
std::auto_ptr<castor::tape::tapegateway::FilesToRecallList> std::auto_ptr<castor::tape::tapegateway::FilesToRecallList>
filesToRecallList(m_client.getFilesToRecall(m_maxFiles,m_byteSizeThreshold,reqReport)); filesToRecallList;
try {
filesToRecallList.reset(m_client.getFilesToRecall(m_maxFiles,m_maxBytes,reqReport));
} catch (castor::exception::Exception & ex) {
castor::log::ScopedParamContainer scoped(m_lc);
scoped.add("transactionId", reqReport.transactionId)
.add("byteSizeThreshold",m_maxBytes)
.add("maxFiles", m_maxFiles)
.add("message", ex.getMessageValue());
m_lc.log(LOG_ERR, "Failed to getFiledToRecall.");
return false;
}
castor::log::ScopedParamContainer scoped(m_lc); castor::log::ScopedParamContainer scoped(m_lc);
scoped.add("sendRecvDuration", reqReport.sendRecvDuration) scoped.add("sendRecvDuration", reqReport.sendRecvDuration)
.add("byteSizeThreshold",m_byteSizeThreshold) .add("byteSizeThreshold",m_maxBytes)
.add("transactionId", reqReport.transactionId) .add("transactionId", reqReport.transactionId)
.add("sendRecvDuration", reqReport.sendRecvDuration)
.add("maxFiles", m_maxFiles); .add("maxFiles", m_maxFiles);
if(NULL==filesToRecallList.get()) { if(NULL==filesToRecallList.get()) {
m_lc.log(LOG_ERR, "No files to recall: empty mount"); m_lc.log(LOG_ERR, "No files to recall: empty mount");
return false; return false;
......
...@@ -181,7 +181,7 @@ private: ...@@ -181,7 +181,7 @@ private:
const uint64_t m_maxFiles; const uint64_t m_maxFiles;
//maximal number of cumulated byte requested. at once //maximal number of cumulated byte requested. at once
const uint64_t m_byteSizeThreshold; const uint64_t m_maxBytes;
}; };
} //end namespace daemon } //end namespace daemon
......
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