diff --git a/RTCP/Storage/include/Storage/OutputThread.h b/RTCP/Storage/include/Storage/OutputThread.h index c116d64cd216d12c55954b3f3ed00d07835af084..7614cf7f381a8fcf6622641e2adc17ffea8ecd06 100644 --- a/RTCP/Storage/include/Storage/OutputThread.h +++ b/RTCP/Storage/include/Storage/OutputThread.h @@ -78,6 +78,7 @@ class OutputThread std::vector<unsigned> itsSequenceNumbers; FileStream *itsSequenceNumbersFile; bool itsHaveCaughtException; + unsigned itsBlocksWritten, itsBlocksDropped; }; } // namespace RTCP diff --git a/RTCP/Storage/src/InputThread.cc b/RTCP/Storage/src/InputThread.cc index bcc5de0ae7ab8bb6635a9643c1fb98875382003c..67c49582fd84aeb5a6f4811db309e293b125821e 100644 --- a/RTCP/Storage/src/InputThread.cc +++ b/RTCP/Storage/src/InputThread.cc @@ -83,7 +83,7 @@ void InputThread::mainLoop() //readTimer.stop(); //LOG_INFO_STR(itsLogPrefix << readTimer); - LOG_INFO_STR(itsLogPrefix << "Read block with seqno = " << data->sequenceNumber); + LOG_DEBUG_STR(itsLogPrefix << "Read block with seqno = " << data->sequenceNumber); if (nullInput) data.get()->sequenceNumber = count; diff --git a/RTCP/Storage/src/OutputThread.cc b/RTCP/Storage/src/OutputThread.cc index ab4e53bbba31be91bace1122e2662c7c0e50b49d..c23791774d769e7ef1bcd2b341db53f37facf23a 100644 --- a/RTCP/Storage/src/OutputThread.cc +++ b/RTCP/Storage/src/OutputThread.cc @@ -117,7 +117,9 @@ OutputThread::OutputThread(const Parset &parset, const ProcessingPlan::planlet & itsFreeQueue(freeQueue), itsReceiveQueue(receiveQueue), itsSequenceNumbersFile(0), - itsHaveCaughtException(false) + itsHaveCaughtException(false), + itsBlocksWritten(0), + itsBlocksDropped(0) { string fullfilename = dir + "/" + filename; @@ -171,6 +173,10 @@ OutputThread::~OutputThread() if (itsHaveCaughtException) LOG_WARN_STR(itsLogPrefix << "OutputThread caught non-fatal exception(s).") ; + + float dropPercent = itsBlocksWritten + itsBlocksDropped == 0 ? 0.0 : (100.0 * itsBlocksDropped) / (itsBlocksWritten + itsBlocksDropped); + + LOG_INFO_STR(itsLogPrefix << itsBlocksWritten << " blocks written, " << itsBlocksDropped << " blocks dropped: " << std::setprecision(3) << dropPercent << "% lost" ); } void OutputThread::writeLogMessage(unsigned sequenceNumber) @@ -191,11 +197,16 @@ void OutputThread::flushSequenceNumbers() void OutputThread::checkForDroppedData(StreamableData *data) { + // TODO: check for dropped data at end of observation + unsigned expectedSequenceNumber = itsNextSequenceNumber; unsigned droppedBlocks = data->sequenceNumber - expectedSequenceNumber; - if (droppedBlocks > 0) + if (droppedBlocks > 0) { + itsBlocksDropped++; + LOG_WARN_STR(itsLogPrefix << "OutputThread dropped " << droppedBlocks << (droppedBlocks == 1 ? " block" : " blocks")); + } if (itsSequenceNumbersFile != 0) { itsSequenceNumbers.push_back(data->sequenceNumber); @@ -218,14 +229,15 @@ void OutputThread::mainLoop() if (data.get() == 0) break; - checkForDroppedData(data.get()); - //writeTimer.start(); writeSemaphore.down(); try { itsWriter->write(data.get()); + itsBlocksWritten++; + + checkForDroppedData(data.get()); } catch (SystemCallException &ex) { itsHaveCaughtException = true; LOG_WARN_STR(itsLogPrefix << "OutputThread caught non-fatal exception: " << ex.what()) ; @@ -239,9 +251,6 @@ void OutputThread::mainLoop() itsFreeQueue.append(data.release()); } - - // CB -- non reachable? - flushSequenceNumbers(); } } // namespace RTCP