diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp index 29808cab220bfb01cbc1e1561651d7e69f453c16..b8bdea4ec273ac06ae28957ced7b92f880b874f5 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSession.cpp @@ -337,11 +337,11 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction } catch (cta::exception::Exception & e) { cta::log::LogContext::ScopedParam sp1(lc, cta::log::Param("errorMessage", e.getMessage().str())); lc.log(cta::log::INFO, "Aborting the session after problem with mount details. Notifying the client."); - mrp.synchronousReportEndWithErrors(e.getMessageValue(), 666); + mrp.synchronousReportEndWithErrors(e.getMessageValue(), 666, lc); return MARK_DRIVE_AS_UP; } catch (...) { lc.log(cta::log::INFO, "Aborting the session after problem with mount details (unknown exception). Notifying the client."); - mrp.synchronousReportEndWithErrors("Unknown exception while checking session parameters with VMGR", 666); + mrp.synchronousReportEndWithErrors("Unknown exception while checking session parameters with VMGR", 666, lc); return MARK_DRIVE_AS_UP; } diff --git a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.cpp b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.cpp index c38890d342ec00e761e2d7c3b361a0a3138a84fa..eff8fe45d42645b1b32bf185c2ac7b46efe5722c 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.cpp @@ -59,8 +59,11 @@ MigrationReportPacker::~MigrationReportPacker(){ //reportCompletedJob //------------------------------------------------------------------------------ void MigrationReportPacker::reportCompletedJob( -std::unique_ptr<cta::ArchiveJob> successfulArchiveJob) { +std::unique_ptr<cta::ArchiveJob> successfulArchiveJob, cta::log::LogContext & lc) { std::unique_ptr<Report> rep(new ReportSuccessful(std::move(successfulArchiveJob))); + cta::log::ScopedParamContainer params(lc); + params.add("type", "ReportSuccessful"); + lc.log(cta::log::DEBUG, "In MigrationReportPacker::reportCompletedJob(), pushing a report."); cta::threading::MutexLocker ml(m_producterProtection); m_fifo.push(rep.release()); } @@ -68,36 +71,51 @@ std::unique_ptr<cta::ArchiveJob> successfulArchiveJob) { //reportFailedJob //------------------------------------------------------------------------------ void MigrationReportPacker::reportFailedJob(std::unique_ptr<cta::ArchiveJob> failedArchiveJob, - const cta::exception::Exception &ex){ + const cta::exception::Exception &ex, cta::log::LogContext & lc){ std::unique_ptr<Report> rep(new ReportError(std::move(failedArchiveJob),ex)); + cta::log::ScopedParamContainer params(lc); + params.add("type", "ReportError"); + lc.log(cta::log::DEBUG, "In MigrationReportPacker::reportFailedJob(), pushing a report."); cta::threading::MutexLocker ml(m_producterProtection); m_fifo.push(rep.release()); } //------------------------------------------------------------------------------ //reportFlush //------------------------------------------------------------------------------ -void MigrationReportPacker::reportFlush(drive::compressionStats compressStats){ +void MigrationReportPacker::reportFlush(drive::compressionStats compressStats, cta::log::LogContext & lc){ + cta::log::ScopedParamContainer params(lc); + params.add("type", "ReportFlush"); + lc.log(cta::log::DEBUG, "In MigrationReportPacker::reportFlush(), pushing a report."); cta::threading::MutexLocker ml(m_producterProtection); m_fifo.push(new ReportFlush(compressStats)); } //------------------------------------------------------------------------------ //reportTapeFull //------------------------------------------------------------------------------ -void MigrationReportPacker::reportTapeFull(){ +void MigrationReportPacker::reportTapeFull(cta::log::LogContext & lc){ + cta::log::ScopedParamContainer params(lc); + params.add("type", "ReportTapeFull"); + lc.log(cta::log::DEBUG, "In MigrationReportPacker::reportTapeFull(), pushing a report."); cta::threading::MutexLocker ml(m_producterProtection); m_fifo.push(new ReportTapeFull()); } //------------------------------------------------------------------------------ //reportEndOfSession //------------------------------------------------------------------------------ -void MigrationReportPacker::reportEndOfSession() { +void MigrationReportPacker::reportEndOfSession(cta::log::LogContext & lc) { + cta::log::ScopedParamContainer params(lc); + params.add("type", "ReportEndofSession"); + lc.log(cta::log::DEBUG, "In MigrationReportPacker::reportEndOfSession(), pushing a report."); cta::threading::MutexLocker ml(m_producterProtection); m_fifo.push(new ReportEndofSession()); } //------------------------------------------------------------------------------ //reportEndOfSessionWithErrors //------------------------------------------------------------------------------ -void MigrationReportPacker::reportEndOfSessionWithErrors(std::string msg,int errorCode){ +void MigrationReportPacker::reportEndOfSessionWithErrors(std::string msg,int errorCode, cta::log::LogContext & lc){ + cta::log::ScopedParamContainer params(lc); + params.add("type", "ReportEndofSessionWithErrors"); + lc.log(cta::log::DEBUG, "In MigrationReportPacker::reportEndOfSessionWithErrors(), pushing a report."); cta::threading::MutexLocker ml(m_producterProtection); m_fifo.push(new ReportEndofSessionWithErrors(msg,errorCode)); } @@ -105,7 +123,10 @@ void MigrationReportPacker::reportEndOfSessionWithErrors(std::string msg,int err //------------------------------------------------------------------------------ //reportTestGoingToEnd //------------------------------------------------------------------------------ -void MigrationReportPacker::reportTestGoingToEnd(){ +void MigrationReportPacker::reportTestGoingToEnd(cta::log::LogContext & lc){ + cta::log::ScopedParamContainer params(lc); + params.add("type", "ReportTestGoingToEnd"); + lc.log(cta::log::DEBUG, "In MigrationReportPacker::reportTestGoingToEnd(), pushing a report."); cta::threading::MutexLocker ml(m_producterProtection); m_fifo.push(new ReportTestGoingToEnd()); } @@ -113,11 +134,34 @@ void MigrationReportPacker::reportTestGoingToEnd(){ //------------------------------------------------------------------------------ //synchronousReportEndWithErrors //------------------------------------------------------------------------------ -void MigrationReportPacker::synchronousReportEndWithErrors(const std::string msg, int errorCode){ - // We create the report task here and excute it immediately instead of posting - // it to a queue. - ReportEndofSessionWithErrors rep(msg,errorCode); - rep.execute(*this); +void MigrationReportPacker::synchronousReportEndWithErrors(const std::string msg, int errorCode, cta::log::LogContext & lc){ + cta::log::ScopedParamContainer params(lc); + params.add("type", "ReportEndofSessionWithErrors"); + lc.log(cta::log::DEBUG, "In MigrationReportPacker::synchronousReportEndWithErrors(), reporting asynchronously."); + m_continue=false; + m_archiveMount->complete(); + if(m_errorHappened) { + cta::log::ScopedParamContainer sp(lc); + sp.add("errorMessage", msg) + .add("errorCode", errorCode); + lc.log(cta::log::INFO,"Reported end of session with error to client after sending file errors"); + } else{ + const std::string& msg ="Reported end of session with error to client"; + // As a measure of safety we censor any session error which is not ENOSPC into + // Meaningless 666 (used to be SEINTERNAL in CASTOR). ENOSPC is the only one interpreted by the tape gateway. + if (ENOSPC != errorCode) { + errorCode = 666; + } + lc.log(cta::log::INFO,msg); + } + if(m_watchdog) { + m_watchdog->addParameter(cta::log::Param("status", + ENOSPC == errorCode?"success":"failure")); + // We have a race condition here between the processing of this message by + // the initial process and the printing of the end-of-session log, triggered + // by the end our process. To delay the latter, we sleep half a second here. + usleep(500*1000); + } } //------------------------------------------------------------------------------ @@ -130,7 +174,10 @@ void MigrationReportPacker::ReportSuccessful::execute(MigrationReportPacker& rep //------------------------------------------------------------------------------ //reportDriveStatus //------------------------------------------------------------------------------ -void MigrationReportPacker::reportDriveStatus(cta::common::dataStructures::DriveStatus status) { +void MigrationReportPacker::reportDriveStatus(cta::common::dataStructures::DriveStatus status, cta::log::LogContext & lc) { + cta::log::ScopedParamContainer params(lc); + params.add("type", "ReportDriveStatus"); + lc.log(cta::log::DEBUG, "In MigrationReportPacker::reportDriveStatus(), pushing a report."); cta::threading::MutexLocker ml(m_producterProtection); m_fifo.push(new ReportDriveStatus(status)); } @@ -280,8 +327,20 @@ void MigrationReportPacker::ReportEndofSessionWithErrors::execute(MigrationRepor //------------------------------------------------------------------------------ void MigrationReportPacker::ReportError::execute(MigrationReportPacker& reportPacker){ reportPacker.m_errorHappened=true; - reportPacker.m_lc.log(cta::log::ERR,m_ex.getMessageValue()); - m_failedArchiveJob->failed(cta::exception::Exception(m_ex.getMessageValue())); + { + cta::log::ScopedParamContainer params(reportPacker.m_lc); + params.add("ExceptionMSG", m_ex.getMessageValue()) + .add("fileId", m_failedArchiveJob->archiveFile.archiveFileID); + reportPacker.m_lc.log(cta::log::ERR,"In MigrationReportPacker::ReportError::execute(): failing archive job after exception."); + } + try { + m_failedArchiveJob->failed(cta::exception::Exception(m_ex.getMessageValue())); + } catch (cta::exception::Exception & ex) { + cta::log::ScopedParamContainer params(reportPacker.m_lc); + params.add("ExceptionMSG", ex.getMessageValue()) + .add("fileId", m_failedArchiveJob->archiveFile.archiveFileID); + reportPacker.m_lc.log(cta::log::ERR,"In MigrationReportPacker::ReportError::execute(): call to m_failedArchiveJob->failed() threw an exception."); + } } //------------------------------------------------------------------------------ diff --git a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.hpp b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.hpp index 2eaded1cbf5413fa3f849540fdbfd9388000fd79..66ae7de1ed025e85da6ac80136addb30516254f0 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPacker.hpp @@ -54,59 +54,68 @@ public: * @param blockId The tape logical object ID of the first block of the header * of the file. This is 0 (instead of 1) for the first file on the tape (aka * fseq = 1). + * @param lc log context provided by the calling thread. */ - virtual void reportCompletedJob(std::unique_ptr<cta::ArchiveJob> successfulArchiveJob); + virtual void reportCompletedJob(std::unique_ptr<cta::ArchiveJob> successfulArchiveJob, cta::log::LogContext & lc); /** * Create into the MigrationReportPacker a report for the failled migration * of migratedFile * @param migratedFile the file which failled - * @param ex the reason for the failure + * @param ex the reason for the failure + * @param lc log context provided by the calling thread. */ - virtual void reportFailedJob(std::unique_ptr<cta::ArchiveJob> failedArchiveJob, const cta::exception::Exception& ex); + virtual void reportFailedJob(std::unique_ptr<cta::ArchiveJob> failedArchiveJob, const cta::exception::Exception& ex, cta::log::LogContext & lc); /** * Create into the MigrationReportPacker a report for the signaling a flusing on tape * @param compressStats - * + * @param lc log context provided by the calling thread. + * */ - virtual void reportFlush(drive::compressionStats compressStats); + virtual void reportFlush(drive::compressionStats compressStats, cta::log::LogContext & lc); /** * Create into the MigrationReportPacker a report of reaching the end of the tape. + * @param lc log context provided by the calling thread. */ - virtual void reportTapeFull(); + virtual void reportTapeFull(cta::log::LogContext & lc); /** * Report the drive state and set it in the central drive register. This * function is to be used by the tape thread when running. * @param state the new drive state. + * @param lc log context provided by the calling thread. */ - virtual void reportDriveStatus(cta::common::dataStructures::DriveStatus status); + virtual void reportDriveStatus(cta::common::dataStructures::DriveStatus status, cta::log::LogContext & lc); /** * Create into the MigrationReportPacker a report for the nominal end of session + * @param lc log context provided by the calling thread. */ - virtual void reportEndOfSession(); + virtual void reportEndOfSession(cta::log::LogContext & lc); /** * Function for testing purposes. It is used to tell the report packer that this is the last report + * @param lc log context provided by the calling thread. */ - virtual void reportTestGoingToEnd(); + virtual void reportTestGoingToEnd(cta::log::LogContext & lc); /** * Create into the MigrationReportPacker a report for an erroneous end of session * @param msg The error message * @param error_code The error code given by the drive + * @param lc log context provided by the calling thread. */ - virtual void reportEndOfSessionWithErrors(const std::string msg,int error_code); + virtual void reportEndOfSessionWithErrors(const std::string msg,int error_code, cta::log::LogContext & lc); /** * Immediately report the end of session to the client. * @param msg The error message * @param error_code The error code given by the drive + * @param lc log context provided by the calling thread. */ - virtual void synchronousReportEndWithErrors(const std::string msg,int error_code); + virtual void synchronousReportEndWithErrors(const std::string msg,int error_code, cta::log::LogContext & lc); void startThreads() { m_workerThread.start(); } void waitThread() { m_workerThread.wait(); } @@ -125,19 +134,21 @@ private: public: ReportSuccessful(std::unique_ptr<cta::ArchiveJob> successfulArchiveJob): m_successfulArchiveJob(std::move(successfulArchiveJob)) {} - virtual void execute(MigrationReportPacker& reportPacker); + void execute(MigrationReportPacker& reportPacker) override; }; class ReportTestGoingToEnd : public Report { public: ReportTestGoingToEnd() {} - virtual void execute(MigrationReportPacker& reportPacker) {reportPacker.m_continue=false;reportPacker.m_archiveMount->complete();} + virtual void execute(MigrationReportPacker& reportPacker) override { + reportPacker.m_continue=false;reportPacker.m_archiveMount->complete(); + } }; class ReportDriveStatus : public Report { cta::common::dataStructures::DriveStatus m_status; public: ReportDriveStatus(cta::common::dataStructures::DriveStatus status): m_status(status) {} - virtual void execute(MigrationReportPacker& reportPacker); + void execute(MigrationReportPacker& reportPacker) override; }; class ReportFlush : public Report { @@ -151,12 +162,12 @@ private: * */ ReportFlush(drive::compressionStats compressStats):m_compressStats(compressStats){} - void execute(MigrationReportPacker& reportPacker); + void execute(MigrationReportPacker& reportPacker) override; }; class ReportTapeFull: public Report { public: ReportTapeFull() {} - void execute(MigrationReportPacker& reportPacker); + void execute(MigrationReportPacker& reportPacker) override; }; class ReportError : public Report { const cta::exception::Exception m_ex; @@ -169,11 +180,11 @@ private: ReportError(std::unique_ptr<cta::ArchiveJob> failedArchiveJob, const cta::exception::Exception &ex): m_ex(ex), m_failedArchiveJob(std::move(failedArchiveJob)){} - virtual void execute(MigrationReportPacker& reportPacker); + void execute(MigrationReportPacker& reportPacker) override; }; class ReportEndofSession : public Report { public: - virtual void execute(MigrationReportPacker& reportPacker); + virtual void execute(MigrationReportPacker& reportPacker) override; }; class ReportEndofSessionWithErrors : public Report { std::string m_message; @@ -182,7 +193,7 @@ private: ReportEndofSessionWithErrors(std::string msg,int errorCode): m_message(msg),m_errorCode(errorCode){} - virtual void execute(MigrationReportPacker& reportPacker); + void execute(MigrationReportPacker& reportPacker) override; }; class WorkerThread: public cta::threading::Thread { diff --git a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPackerTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPackerTest.cpp index 4f74a94426d517a1a773cc403701e9fc008ef333..02ca43cd2aa01fceea365c48d05b2b8bddd4b053 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPackerTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/MigrationReportPackerTest.cpp @@ -100,13 +100,13 @@ namespace unitTests { tapeserver::daemon::MigrationReportPacker mrp(&tam,lc); mrp.startThreads(); - mrp.reportCompletedJob(std::move(job1)); - mrp.reportCompletedJob(std::move(job2)); + mrp.reportCompletedJob(std::move(job1), lc); + mrp.reportCompletedJob(std::move(job2), lc); const tapeserver::drive::compressionStats statsCompress; - mrp.reportFlush(statsCompress); - mrp.reportEndOfSession(); - mrp.reportTestGoingToEnd(); + mrp.reportFlush(statsCompress, lc); + mrp.reportEndOfSession(lc); + mrp.reportTestGoingToEnd(lc); mrp.waitThread(); //here std::string temp = log.getLog(); @@ -143,17 +143,17 @@ namespace unitTests { tapeserver::daemon::MigrationReportPacker mrp(&tam,lc); mrp.startThreads(); - mrp.reportCompletedJob(std::move(job1)); - mrp.reportCompletedJob(std::move(job2)); + mrp.reportCompletedJob(std::move(job1), lc); + mrp.reportCompletedJob(std::move(job2), lc); const std::string error_msg = "ERROR_TEST_MSG"; const cta::exception::Exception ex(error_msg); - mrp.reportFailedJob(std::move(job3),ex); + mrp.reportFailedJob(std::move(job3),ex, lc); const tapeserver::drive::compressionStats statsCompress; - mrp.reportFlush(statsCompress); - mrp.reportEndOfSession(); - mrp.reportTestGoingToEnd(); + mrp.reportFlush(statsCompress, lc); + mrp.reportEndOfSession(lc); + mrp.reportTestGoingToEnd(lc); mrp.waitThread(); std::string temp = log.getLog(); @@ -197,14 +197,14 @@ namespace unitTests { tapeserver::daemon::MigrationReportPacker mrp(&tam,lc); mrp.startThreads(); - mrp.reportCompletedJob(std::move(migratedBigFile)); - mrp.reportCompletedJob(std::move(migratedFileSmall)); - mrp.reportCompletedJob(std::move(migratedNullFile)); + mrp.reportCompletedJob(std::move(migratedBigFile), lc); + mrp.reportCompletedJob(std::move(migratedFileSmall), lc); + mrp.reportCompletedJob(std::move(migratedNullFile), lc); tapeserver::drive::compressionStats stats; stats.toTape=(100000+1)/3; - mrp.reportFlush(stats); - mrp.reportEndOfSession(); - mrp.reportTestGoingToEnd(); + mrp.reportFlush(stats, lc); + mrp.reportEndOfSession(lc); + mrp.reportTestGoingToEnd(lc); mrp.waitThread(); std::string temp = log.getLog(); diff --git a/tapeserver/castor/tape/tapeserver/daemon/ReportPackerInterface.hpp b/tapeserver/castor/tape/tapeserver/daemon/ReportPackerInterface.hpp index 5265cb2b2e8a850bffd16212fc5952b61a2b00b5..9af8e7f48d98a0a4c0b57de6804c31f3cc602630 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/ReportPackerInterface.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/ReportPackerInterface.hpp @@ -108,7 +108,7 @@ template <class PlaceHolder> class ReportPackerInterface{ } /** - * The log context, copied du to threads + * The log context, copied due to threads */ cta::log::LogContext m_lc; diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp index f9c5f1814b1f0b48a9506bd4954b17e679b23d49..2985569d91247c94f316be0ff7764920d2d1479c 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteSingleThread.cpp @@ -63,7 +63,7 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeCleaning::~TapeClea m_this.m_logContext.log(cta::log::ERR, "Failed to turn off encryption before unmounting"); } m_this.m_stats.encryptionControlTime += m_timer.secs(cta::utils::Timer::resetCounter); - m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::CleaningUp); + m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::CleaningUp, m_this.m_logContext); // This out-of-try-catch variables allows us to record the stage of the // process we're in, and to count the error if it occurs. // We will not record errors for an empty string. This will allow us to @@ -90,7 +90,7 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeCleaning::~TapeClea } // in the special case of a "manual" mode tape, we should skip the unload too. if (cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.librarySlot().getLibraryType()) { - m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Unloading); + m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Unloading, m_this.m_logContext); m_this.m_drive.unloadTape(); m_this.m_logContext.log(cta::log::INFO, "TapeWriteSingleThread: Tape unloaded"); } else { @@ -101,10 +101,10 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeCleaning::~TapeClea // In case of manual mode, this will be filtered by the rmc daemon // (which will do nothing) currentErrorToCount = "Error_tapeDismount"; - m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Unmounting); + m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Unmounting, m_this.m_logContext); m_this.m_mc.dismountTape(m_this.m_volInfo.vid, m_this.m_drive.config.librarySlot()); m_this.m_drive.disableLogicalBlockProtection(); - m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Up); + m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Up, m_this.m_logContext); m_this.m_stats.unmountTime += m_timer.secs(cta::utils::Timer::resetCounter); m_this.m_logContext.log(cta::log::INFO, cta::mediachanger::TAPE_LIBRARY_TYPE_MANUAL != m_this.m_drive.config.librarySlot().getLibraryType() ? "TapeWriteSingleThread : tape unmounted":"TapeWriteSingleThread : tape NOT unmounted (manual mode)"); @@ -115,7 +115,7 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeCleaning::~TapeClea catch(const cta::exception::Exception& ex){ // Notify something failed during the cleaning m_this.m_hardwareStatus = Session::MARK_DRIVE_AS_DOWN; - m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Down); + m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Down, m_this.m_logContext); cta::log::ScopedParamContainer scoped(m_this.m_logContext); scoped.add("exception_message", ex.getMessageValue()); m_this.m_logContext.log(cta::log::ERR, "Exception in TapeWriteSingleThread-TapeCleaning"); @@ -129,7 +129,7 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeCleaning::~TapeClea } catch (...) { // Notify something failed during the cleaning m_this.m_hardwareStatus = Session::MARK_DRIVE_AS_DOWN; - m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Down); + m_this.m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Down, m_this.m_logContext); m_this.m_logContext.log(cta::log::ERR, "Non-Castor exception in TapeWriteSingleThread-TapeCleaning when unmounting the tape"); try { if (currentErrorToCount.size()) { @@ -199,7 +199,7 @@ tapeFlush(const std::string& message,uint64_t bytes,uint64_t files, m_stats.flushTime += flushTime; - m_reportPacker.reportFlush(m_drive.getCompression()); + m_reportPacker.reportFlush(m_drive.getCompression(), m_logContext); m_drive.clearCompressionStats(); } @@ -299,7 +299,7 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() { // TapeCleaning cleaner(*this, timer); currentErrorToCount = "Error_tapeMountForWrite"; - m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Mounting); + m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Mounting, m_logContext); // Before anything, the tape should be mounted // This call does the logging of the mount mountTapeReadWrite(); @@ -387,7 +387,7 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() { // Tasks handle their error logging themselves. currentErrorToCount = ""; std::unique_ptr<TapeWriteTask> task; - m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Transfering); + m_reportPacker.reportDriveStatus(cta::common::dataStructures::DriveStatus::Transfering, m_logContext); while(1) { //get a task task.reset(m_tasks.pop()); @@ -398,7 +398,7 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() { tapeFlush("No more data to write on tape, unconditional flushing to the client",bytes,files,timer); m_stats.flushTime += timer.secs(cta::utils::Timer::resetCounter); //end of session + log - m_reportPacker.reportEndOfSession(); + m_reportPacker.reportEndOfSession(m_logContext); cta::log::LogContext::ScopedParam sp0(m_logContext, cta::log::Param("tapeThreadDuration", totalTimer.secs())); m_logContext.log(cta::log::DEBUG, "writing data to tape has finished"); break; @@ -460,7 +460,7 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() { } // This is indeed the end of the tape. Not an error. m_watchdog.setErrorCount("Info_tapeFilledUp",1); - m_reportPacker.reportTapeFull(); + m_reportPacker.reportTapeFull(m_logContext); } catch (...) { // The error is not an ENOSPC, so it is, indeed, an error. // If we got here with a new error, currentErrorToCount will be non-empty, @@ -498,7 +498,7 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() { m_stats.totalTime = totalTimer.secs(); logWithStats(cta::log::INFO, "Tape thread complete", params); - m_reportPacker.reportEndOfSessionWithErrors(errorMessage,errorCode); + m_reportPacker.reportEndOfSessionWithErrors(errorMessage,errorCode, m_logContext); } } diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp index 03a956efdd02d9346e3e3c59e0cd2ac0e438bc77..a5d651a193fcc33cd9ac0c9e2fbab1dab7ac09e4 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp @@ -135,7 +135,7 @@ namespace daemon { } m_archiveJob->tapeFile.compressedSize = m_taskStats.dataVolume; m_archiveJob->tapeFile.blockId = output->getBlockId(); - reportPacker.reportCompletedJob(std::move(m_archiveJob)); + reportPacker.reportCompletedJob(std::move(m_archiveJob), lc); m_taskStats.waitReportingTime += timer.secs(cta::utils::Timer::resetCounter); m_taskStats.totalTime = localTime.secs(); // Log the successful transfer @@ -173,7 +173,7 @@ namespace daemon { } // This is indeed the end of the tape. Not an error. watchdog.setErrorCount("Info_tapeFilledUp",1); - reportPacker.reportTapeFull(); + reportPacker.reportTapeFull(lc); } catch (...) { // The error is not an ENOSPC, so it is, indeed, an error. // If we got here with a new error, currentErrorToCount will be non-empty, @@ -203,7 +203,7 @@ namespace daemon { LogContext::ScopedParam sp1(lc, Param("exceptionMessage", e.getMessageValue())); lc.log(errorLevel,"An error occurred for this file. End of migrations."); circulateMemBlocks(); - reportPacker.reportFailedJob(std::move(m_archiveJob),e); + reportPacker.reportFailedJob(std::move(m_archiveJob),e, lc); //we throw again because we want TWST to stop all tasks from execution //and go into a degraded mode operation.