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

Improved logging of the various threads of the mount session:

added a thread logging parameter, indicating the thread involved
added startup and finish log messages for threads.
parent 36a5c950
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include "castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp" #include "castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp"
#include "log.h"
namespace castor { namespace castor {
namespace tape { namespace tape {
namespace tapeserver { namespace tapeserver {
...@@ -80,6 +81,8 @@ namespace daemon { ...@@ -80,6 +81,8 @@ namespace daemon {
return ret; return ret;
} }
void DiskReadThreadPool::DiskReadWorkerThread::run() { void DiskReadThreadPool::DiskReadWorkerThread::run() {
_this.m_lc.pushOrReplace(log::Param("thread", "DiskRead"));
_this.m_lc.log(LOG_DEBUG, "Starting DiskReadWorkerThread");
std::auto_ptr<DiskReadTaskInterface> task; std::auto_ptr<DiskReadTaskInterface> task;
while(1) { while(1) {
task.reset( _this.popAndRequestMore()); task.reset( _this.popAndRequestMore());
...@@ -90,6 +93,7 @@ namespace daemon { ...@@ -90,6 +93,7 @@ namespace daemon {
break; break;
} }
} //end of while(1) } //end of while(1)
_this.m_lc.log(LOG_DEBUG, "Finishing of DiskReadWorkerThread");
} }
tape::threading::AtomicCounter<int> DiskReadThreadPool::DiskReadWorkerThread::m_nbActiveThread(0); tape::threading::AtomicCounter<int> DiskReadThreadPool::DiskReadWorkerThread::m_nbActiveThread(0);
......
...@@ -100,7 +100,8 @@ namespace daemon { ...@@ -100,7 +100,8 @@ namespace daemon {
return ret; return ret;
} }
void DiskWriteThreadPool::DiskWriteWorkerThread::run() { void DiskWriteThreadPool::DiskWriteWorkerThread::run() {
m_lc.log(LOG_INFO, "Starting disk write thread"); m_lc.pushOrReplace(log::Param("thread", "diskWrite"));
m_lc.log(LOG_INFO, "Starting DiskWriteWorkerThread");
std::auto_ptr<DiskWriteTaskInterface> task; std::auto_ptr<DiskWriteTaskInterface> task;
while(1) { while(1) {
task.reset(m_parentThreadPool. m_tasks.pop()); task.reset(m_parentThreadPool. m_tasks.pop());
...@@ -127,7 +128,7 @@ namespace daemon { ...@@ -127,7 +128,7 @@ namespace daemon {
m_parentThreadPool.m_reporter.reportEndOfSessionWithErrors("A thread failed to write a file",SEINTERNAL); m_parentThreadPool.m_reporter.reportEndOfSessionWithErrors("A thread failed to write a file",SEINTERNAL);
} }
} }
m_lc.log(LOG_INFO, "Disk write thread exiting"); m_lc.log(LOG_INFO, "Finishing DiskWriteWorkerThread");
} }
}}}} }}}}
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp" #include "castor/tape/tapeserver/daemon/MigrationTaskInjector.hpp"
#include "castor/tape/tapegateway/FilesToMigrateList.hpp" #include "castor/tape/tapegateway/FilesToMigrateList.hpp"
#include "log.h"
namespace{ namespace{
...@@ -103,6 +104,8 @@ namespace daemon { ...@@ -103,6 +104,8 @@ namespace daemon {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void MigrationTaskInjector::WorkerThread::run(){ void MigrationTaskInjector::WorkerThread::run(){
_this.m_lc.pushOrReplace(Param("thread", "MigrationTaskInjector"));
_this.m_lc.log(LOG_DEBUG, "Starting MigrationTaskInjector thread");
while(1){ while(1){
Request req = _this.m_queue.pop(); Request req = _this.m_queue.pop();
client::ClientProxy::RequestReport reqReport; client::ClientProxy::RequestReport reqReport;
...@@ -121,6 +124,7 @@ namespace daemon { ...@@ -121,6 +124,7 @@ namespace daemon {
_this.injectBulkMigrations(filesToMigrateList->filesToMigrate()); _this.injectBulkMigrations(filesToMigrateList->filesToMigrate());
} }
} }
_this.m_lc.log(LOG_DEBUG, "Finishing MigrationTaskInjector thread");
} }
......
...@@ -53,6 +53,8 @@ void castor::tape::tapeserver::daemon::MountSession::execute() ...@@ -53,6 +53,8 @@ void castor::tape::tapeserver::daemon::MountSession::execute()
throw (castor::tape::Exception) { throw (castor::tape::Exception) {
// 1) Prepare the logging environment // 1) Prepare the logging environment
LogContext lc(m_logger); LogContext lc(m_logger);
// Create a sticky thread name, which will be overridden by the other threads
lc.pushOrReplace(Param("thread", "mainThread"));
LogContext::ScopedParam sp01(lc, Param("clientHost", m_request.clientHost)); LogContext::ScopedParam sp01(lc, Param("clientHost", m_request.clientHost));
LogContext::ScopedParam sp02(lc, Param("clientPort", m_request.clientPort)); LogContext::ScopedParam sp02(lc, Param("clientPort", m_request.clientPort));
LogContext::ScopedParam sp03(lc, Param("mountTransactionId", m_request.volReqId)); LogContext::ScopedParam sp03(lc, Param("mountTransactionId", m_request.volReqId));
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "castor/tape/tapegateway/FileRecalledNotificationStruct.hpp" #include "castor/tape/tapegateway/FileRecalledNotificationStruct.hpp"
#include "castor/tape/tapegateway/FileRecalledNotificationStruct.hpp" #include "castor/tape/tapegateway/FileRecalledNotificationStruct.hpp"
#include "castor/log/Logger.hpp" #include "castor/log/Logger.hpp"
#include "log.h"
namespace{ namespace{
struct failedReportRecallResult : public castor::tape::Exception{ struct failedReportRecallResult : public castor::tape::Exception{
...@@ -94,9 +95,9 @@ void RecallReportPacker::flush(){ ...@@ -94,9 +95,9 @@ void RecallReportPacker::flush(){
client::ClientInterface::RequestReport chrono; client::ClientInterface::RequestReport chrono;
try{ try{
m_client.reportRecallResults(*m_listReports,chrono); m_client.reportRecallResults(*m_listReports,chrono);
logRequestReport(chrono,"reportRecallResults'is successful"); logRequestReport(chrono,"RecallReportList successfully transmitted to client (contents follow)");
logReport(m_listReports->failedRecalls(),"file failed to be recalled"); logReport(m_listReports->failedRecalls(),"A file failed to be recalled");
logReport(m_listReports->successfulRecalls(),"A file was successfully recalled"); logReport(m_listReports->successfulRecalls(),"A file was successfully recalled");
} }
catch(const castor::tape::Exception& e){ catch(const castor::tape::Exception& e){
...@@ -162,6 +163,8 @@ m_parent(parent) { ...@@ -162,6 +163,8 @@ m_parent(parent) {
} }
void RecallReportPacker::WorkerThread::run(){ void RecallReportPacker::WorkerThread::run(){
m_parent.m_lc.pushOrReplace(Param("thread", "RecallReportPacker"));
m_parent.m_lc.log(LOG_DEBUG, "Starting RecallReportPacker thread");
client::ClientInterface::RequestReport chrono; client::ClientInterface::RequestReport chrono;
try{ try{
while(1) { while(1) {
...@@ -196,5 +199,6 @@ void RecallReportPacker::WorkerThread::run(){ ...@@ -196,5 +199,6 @@ void RecallReportPacker::WorkerThread::run(){
//either from the catch a few lines above or directly from rep->execute //either from the catch a few lines above or directly from rep->execute
m_parent.logRequestReport(chrono,"tried to report endOfSession(WithError) and got an exception, cant do much more",LOG_ERR); m_parent.logRequestReport(chrono,"tried to report endOfSession(WithError) and got an exception, cant do much more",LOG_ERR);
} }
m_parent.m_lc.log(LOG_DEBUG, "Finishing RecallReportPacker thread");
} }
}}}} }}}}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "castor/tape/tapegateway/FilesToRecallList.hpp" #include "castor/tape/tapegateway/FilesToRecallList.hpp"
#include "castor/tape/tapeserver/utils/suppressUnusedVariable.hpp" #include "castor/tape/tapeserver/utils/suppressUnusedVariable.hpp"
#include "castor/tape/tapegateway/FileToRecallStruct.hpp" #include "castor/tape/tapegateway/FileToRecallStruct.hpp"
#include "log.h"
#include <stdint.h> #include <stdint.h>
using castor::log::LogContext; using castor::log::LogContext;
...@@ -105,6 +106,8 @@ bool RecallTaskInjector::synchronousInjection(uint64_t maxFiles, uint64_t byteSi ...@@ -105,6 +106,8 @@ bool RecallTaskInjector::synchronousInjection(uint64_t maxFiles, uint64_t byteSi
void RecallTaskInjector::WorkerThread::run() void RecallTaskInjector::WorkerThread::run()
{ {
using castor::log::LogContext; using castor::log::LogContext;
_this.m_lc.pushOrReplace(Param("thread", "recallTaskInjector"));
_this.m_lc.log(LOG_DEBUG, "Starting RecallTaskInjector thread");
while (1) { while (1) {
Request req = _this.m_queue.pop(); Request req = _this.m_queue.pop();
...@@ -146,6 +149,7 @@ void RecallTaskInjector::WorkerThread::run() ...@@ -146,6 +149,7 @@ void RecallTaskInjector::WorkerThread::run()
} catch (castor::tape::threading::noMore) { } catch (castor::tape::threading::noMore) {
_this.m_lc.log(LOG_INFO,"In RecallJobInjector::WorkerThread::run(): Drained the request queue. We're now empty. Finishing"); _this.m_lc.log(LOG_INFO,"In RecallJobInjector::WorkerThread::run(): Drained the request queue. We're now empty. Finishing");
} }
_this.m_lc.log(LOG_DEBUG, "Finishing RecallTaskInjector thread");
} }
} //end namespace daemon } //end namespace daemon
......
...@@ -66,6 +66,7 @@ private: ...@@ -66,6 +66,7 @@ private:
virtual void run() { virtual void run() {
// First we have to initialise the tape read session // First we have to initialise the tape read session
m_logContext.pushOrReplace(log::Param("thread", "tapeRead"));
std::auto_ptr<castor::tape::tapeFile::ReadSession> rs; std::auto_ptr<castor::tape::tapeFile::ReadSession> rs;
try { try {
rs.reset(new castor::tape::tapeFile::ReadSession(m_drive, m_vid)); rs.reset(new castor::tape::tapeFile::ReadSession(m_drive, m_vid));
......
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