CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes

stor::StreamsMonitorCollection Class Reference

#include <StreamsMonitorCollection.h>

Inheritance diagram for stor::StreamsMonitorCollection:
stor::MonitorCollection

List of all members.

Classes

struct  EndOfRunReport
struct  StreamRecord

Public Types

typedef boost::shared_ptr
< EndOfRunReport
EndOfRunReportPtr
typedef std::vector
< StreamRecordPtr
StreamRecordList
typedef boost::shared_ptr
< StreamRecord
StreamRecordPtr

Public Member Functions

const MonitoredQuantitygetAllStreamsBandwidthMQ () const
MonitoredQuantitygetAllStreamsBandwidthMQ ()
const MonitoredQuantitygetAllStreamsFileCountMQ () const
MonitoredQuantitygetAllStreamsFileCountMQ ()
MonitoredQuantitygetAllStreamsVolumeMQ ()
const MonitoredQuantitygetAllStreamsVolumeMQ () const
StreamRecordPtr getNewStreamRecord ()
void getStreamRecords (StreamRecordList &) const
void reportAllLumiSectionInfos (DbFileHandlerPtr, EndOfRunReportPtr)
bool streamRecordsExist () const
 StreamsMonitorCollection (const utils::Duration_t &updateInterval)

Private Types

typedef std::set< uint32_t > UnreportedLS

Private Member Functions

virtual void do_appendInfoSpaceItems (InfoSpaceItems &)
virtual void do_calculateStatistics ()
virtual void do_reset ()
virtual void do_updateInfoSpaceItems ()
void getListOfAllUnreportedLS (UnreportedLS &)
StreamsMonitorCollectionoperator= (StreamsMonitorCollection const &)
 StreamsMonitorCollection (StreamsMonitorCollection const &)

Private Attributes

MonitoredQuantity allStreamsBandwidth_
MonitoredQuantity allStreamsFileCount_
MonitoredQuantity allStreamsVolume_
xdata::Vector< xdata::Double > bandwidthPerStream_
xdata::Double bandwidthToDisk_
xdata::Vector
< xdata::UnsignedInteger32 > 
eventsPerStream_
xdata::Vector< xdata::Double > ratePerStream_
xdata::UnsignedInteger32 storedEvents_
xdata::Double storedVolume_
xdata::Vector< xdata::String > streamNames_
StreamRecordList streamRecords_
boost::mutex streamRecordsMutex_
const utils::Duration_t timeWindowForRecentResults_
const utils::Duration_t updateInterval_

Detailed Description

A collection of MonitoredQuantities of output streams

Author:
mommsen
Revision:
1.16
Date:
2011/06/20 16:38:51

Definition at line 35 of file StreamsMonitorCollection.h.


Member Typedef Documentation

Definition at line 97 of file StreamsMonitorCollection.h.

Definition at line 78 of file StreamsMonitorCollection.h.

Definition at line 77 of file StreamsMonitorCollection.h.

typedef std::set<uint32_t> stor::StreamsMonitorCollection::UnreportedLS [private]

Definition at line 138 of file StreamsMonitorCollection.h.


Constructor & Destructor Documentation

stor::StreamsMonitorCollection::StreamsMonitorCollection ( const utils::Duration_t updateInterval) [explicit]
stor::StreamsMonitorCollection::StreamsMonitorCollection ( StreamsMonitorCollection const &  ) [private]

Member Function Documentation

void stor::StreamsMonitorCollection::do_appendInfoSpaceItems ( InfoSpaceItems infoSpaceItems) [private, virtual]

Reimplemented from stor::MonitorCollection.

Definition at line 203 of file StreamsMonitorCollection.cc.

References bandwidthPerStream_, bandwidthToDisk_, eventsPerStream_, ratePerStream_, storedEvents_, storedVolume_, and streamNames_.

  {
    infoSpaceItems.push_back(std::make_pair("storedEvents",  &storedEvents_));
    infoSpaceItems.push_back(std::make_pair("storedVolume",  &storedVolume_));
    infoSpaceItems.push_back(std::make_pair("bandwidthToDisk",  &bandwidthToDisk_));
    infoSpaceItems.push_back(std::make_pair("streamNames",  &streamNames_));
    infoSpaceItems.push_back(std::make_pair("eventsPerStream",  &eventsPerStream_));
    infoSpaceItems.push_back(std::make_pair("ratePerStream",  &ratePerStream_));
    infoSpaceItems.push_back(std::make_pair("bandwidthPerStream",  &bandwidthPerStream_));
  }
void stor::StreamsMonitorCollection::do_calculateStatistics ( ) [private, virtual]

Implements stor::MonitorCollection.

Definition at line 168 of file StreamsMonitorCollection.cc.

References stor::MonitoredQuantity::addSample(), allStreamsBandwidth_, allStreamsFileCount_, allStreamsVolume_, stor::MonitoredQuantity::calculateStatistics(), stor::MonitoredQuantity::Stats::getLastValueRate(), stor::MonitoredQuantity::Stats::getSampleCount(), stor::MonitoredQuantity::getStats(), streamRecords_, and streamRecordsMutex_.

  {
    MonitoredQuantity::Stats stats;
    
    allStreamsFileCount_.calculateStatistics();
    allStreamsVolume_.calculateStatistics();
    allStreamsVolume_.getStats(stats);
    bool samplingHasStarted = (stats.getSampleCount() > 0);
    if (samplingHasStarted) {
      allStreamsBandwidth_.addSample(stats.getLastValueRate());
    }
    allStreamsBandwidth_.calculateStatistics();
    
    
    boost::mutex::scoped_lock sl(streamRecordsMutex_);
    
    for (
      StreamRecordList::const_iterator 
        it = streamRecords_.begin(), itEnd = streamRecords_.end();
      it != itEnd;
      ++it
    ) 
    {
      (*it)->fileCount.calculateStatistics();
      (*it)->volume.calculateStatistics();
      (*it)->volume.getStats(stats);
      if (samplingHasStarted) {
        (*it)->bandwidth.addSample(stats.getLastValueRate());
      }
      (*it)->bandwidth.calculateStatistics();
    }
  }
void stor::StreamsMonitorCollection::do_reset ( ) [private, virtual]
void stor::StreamsMonitorCollection::do_updateInfoSpaceItems ( ) [private, virtual]

Reimplemented from stor::MonitorCollection.

Definition at line 228 of file StreamsMonitorCollection.cc.

References allStreamsVolume_, bandwidthPerStream_, bandwidthToDisk_, eventsPerStream_, stor::MonitoredQuantity::FULL, stor::MonitoredQuantity::Stats::getSampleCount(), stor::MonitoredQuantity::Stats::getSampleRate(), stor::MonitoredQuantity::getStats(), stor::MonitoredQuantity::Stats::getValueRate(), stor::MonitoredQuantity::Stats::getValueSum(), ratePerStream_, stor::MonitoredQuantity::RECENT, storedEvents_, storedVolume_, streamNames_, streamRecords_, and streamRecordsMutex_.

  {
    MonitoredQuantity::Stats allStreamsVolumeStats;
    allStreamsVolume_.getStats(allStreamsVolumeStats);
    
    storedEvents_ = static_cast<xdata::UnsignedInteger32>(
      allStreamsVolumeStats.getSampleCount()
    );
    storedVolume_ = static_cast<xdata::Double>(
      allStreamsVolumeStats.getValueSum()
    );
    bandwidthToDisk_ = static_cast<xdata::Double>(
      allStreamsVolumeStats.getValueRate(MonitoredQuantity::RECENT)
    );
    
    boost::mutex::scoped_lock sl(streamRecordsMutex_);
    
    streamNames_.clear();
    eventsPerStream_.clear();
    ratePerStream_.clear();
    bandwidthPerStream_.clear();
    
    streamNames_.reserve(streamRecords_.size());
    eventsPerStream_.reserve(streamRecords_.size());
    ratePerStream_.reserve(streamRecords_.size());
    bandwidthPerStream_.reserve(streamRecords_.size());
    
    for (
      StreamRecordList::const_iterator
        it = streamRecords_.begin(), itEnd = streamRecords_.end();
      it != itEnd;
      ++it
    )
    {
      MonitoredQuantity::Stats streamVolumeStats;
      (*it)->volume.getStats(streamVolumeStats);
      MonitoredQuantity::Stats streamBandwidthStats;
      (*it)->bandwidth.getStats(streamBandwidthStats);
      
      streamNames_.push_back(
        static_cast<xdata::String>( (*it)->streamName )
      );
      
      eventsPerStream_.push_back(
        static_cast<xdata::UnsignedInteger32>(
          streamVolumeStats.getSampleCount(MonitoredQuantity::FULL)
        )
      );
      
      ratePerStream_.push_back(
        static_cast<xdata::Double>(
          streamVolumeStats.getSampleRate(MonitoredQuantity::RECENT)
        )
      );
      
      bandwidthPerStream_.push_back(
        static_cast<xdata::Double>(
          streamBandwidthStats.getValueRate(MonitoredQuantity::RECENT)
        )
      );
    }
  }
MonitoredQuantity& stor::StreamsMonitorCollection::getAllStreamsBandwidthMQ ( ) [inline]

Definition at line 125 of file StreamsMonitorCollection.h.

References allStreamsBandwidth_.

                                                  {
      return allStreamsBandwidth_;
    }
const MonitoredQuantity& stor::StreamsMonitorCollection::getAllStreamsBandwidthMQ ( ) const [inline]
const MonitoredQuantity& stor::StreamsMonitorCollection::getAllStreamsFileCountMQ ( ) const [inline]
MonitoredQuantity& stor::StreamsMonitorCollection::getAllStreamsFileCountMQ ( ) [inline]

Definition at line 111 of file StreamsMonitorCollection.h.

References allStreamsFileCount_.

                                                  {
      return allStreamsFileCount_;
    }
const MonitoredQuantity& stor::StreamsMonitorCollection::getAllStreamsVolumeMQ ( ) const [inline]
MonitoredQuantity& stor::StreamsMonitorCollection::getAllStreamsVolumeMQ ( ) [inline]

Definition at line 118 of file StreamsMonitorCollection.h.

References allStreamsVolume_.

                                               {
      return allStreamsVolume_;
    }
void stor::StreamsMonitorCollection::getListOfAllUnreportedLS ( UnreportedLS unreportedLS) [private]

Definition at line 147 of file StreamsMonitorCollection.cc.

References streamRecords_.

Referenced by reportAllLumiSectionInfos().

  {
    // Have to loop over all streams as not every stream
    // might have got an event for a given lumi section
    for (StreamRecordList::const_iterator 
           stream = streamRecords_.begin(),
           streamEnd = streamRecords_.end();
         stream != streamEnd;
         ++stream)
    {
      for (StreamRecord::FileCountPerLumiSectionMap::const_iterator
             lscount = (*stream)->fileCountPerLS.begin(),
             lscountEnd = (*stream)->fileCountPerLS.end();
           lscount != lscountEnd; ++lscount)
      {
        unreportedLS.insert(lscount->first);
      }
    }
  }
StreamsMonitorCollection::StreamRecordPtr stor::StreamsMonitorCollection::getNewStreamRecord ( )

Definition at line 28 of file StreamsMonitorCollection.cc.

References streamRecords_, streamRecordsMutex_, timeWindowForRecentResults_, and updateInterval_.

  {
    boost::mutex::scoped_lock sl(streamRecordsMutex_);
    
    StreamRecordPtr streamRecord(
      new StreamRecord(this,updateInterval_,timeWindowForRecentResults_)
    );
    streamRecords_.push_back(streamRecord);
    return streamRecord;
  }
void stor::StreamsMonitorCollection::getStreamRecords ( StreamRecordList list) const

Definition at line 40 of file StreamsMonitorCollection.cc.

References streamRecords_, and streamRecordsMutex_.

Referenced by stor::SMWebPageHelper::listStreamRecordsStats().

  {
    boost::mutex::scoped_lock sl(streamRecordsMutex_);

    list.clear();
    list.reserve(streamRecords_.size());
    
    for (
      StreamRecordList::const_iterator 
        it = streamRecords_.begin(), itEnd = streamRecords_.end();
      it != itEnd;
      ++it
    )
    {
      list.push_back(*it);
    }
  }
StreamsMonitorCollection& stor::StreamsMonitorCollection::operator= ( StreamsMonitorCollection const &  ) [private]
void stor::StreamsMonitorCollection::reportAllLumiSectionInfos ( DbFileHandlerPtr  dbFileHandler,
EndOfRunReportPtr  endOfRunReport 
)

Definition at line 113 of file StreamsMonitorCollection.cc.

References getListOfAllUnreportedLS(), streamRecords_, and streamRecordsMutex_.

Referenced by stor::DiskWriter::reportRemainingLumiSections().

  {
    boost::mutex::scoped_lock sl(streamRecordsMutex_);

    UnreportedLS unreportedLS;
    getListOfAllUnreportedLS(unreportedLS);
    
    for (UnreportedLS::const_iterator it = unreportedLS.begin(),
           itEnd = unreportedLS.end(); it != itEnd; ++it)
    {
      std::string lsEntry;
      bool filesWritten = false;

      for (StreamRecordList::const_iterator 
             stream = streamRecords_.begin(),
             streamEnd = streamRecords_.end();
           stream != streamEnd;
           ++stream)
      {
        if ( (*stream)->reportLumiSectionInfo((*it), lsEntry) )
          filesWritten = true;
      }
      lsEntry += "\tEoLS:0";
      dbFileHandler->write(lsEntry);

      if (filesWritten) ++(endOfRunReport->lsCountWithFiles);
      endOfRunReport->updateLatestWrittenLumiSection(*it);
    }
  }
bool stor::StreamsMonitorCollection::streamRecordsExist ( ) const

Definition at line 59 of file StreamsMonitorCollection.cc.

References streamRecords_, and streamRecordsMutex_.

Referenced by stor::SMWebPageHelper::addDOMforStoredData().

  {
    boost::mutex::scoped_lock sl(streamRecordsMutex_);

    return ( ! streamRecords_.empty() );
  }

Member Data Documentation

Definition at line 162 of file StreamsMonitorCollection.h.

Referenced by do_appendInfoSpaceItems(), and do_updateInfoSpaceItems().

Definition at line 158 of file StreamsMonitorCollection.h.

Referenced by do_appendInfoSpaceItems(), and do_updateInfoSpaceItems().

Definition at line 160 of file StreamsMonitorCollection.h.

Referenced by do_appendInfoSpaceItems(), and do_updateInfoSpaceItems().

Definition at line 161 of file StreamsMonitorCollection.h.

Referenced by do_appendInfoSpaceItems(), and do_updateInfoSpaceItems().

xdata::UnsignedInteger32 stor::StreamsMonitorCollection::storedEvents_ [private]

Definition at line 156 of file StreamsMonitorCollection.h.

Referenced by do_appendInfoSpaceItems(), and do_updateInfoSpaceItems().

Definition at line 157 of file StreamsMonitorCollection.h.

Referenced by do_appendInfoSpaceItems(), and do_updateInfoSpaceItems().

Definition at line 159 of file StreamsMonitorCollection.h.

Referenced by do_appendInfoSpaceItems(), and do_updateInfoSpaceItems().

Definition at line 150 of file StreamsMonitorCollection.h.

Referenced by getNewStreamRecord().

Reimplemented from stor::MonitorCollection.

Definition at line 149 of file StreamsMonitorCollection.h.

Referenced by getNewStreamRecord().