CMS 3D CMS Logo

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

stor::ConsumerMonitorCollection Class Reference

#include <ConsumerMonitorCollection.h>

Inheritance diagram for stor::ConsumerMonitorCollection:
stor::MonitorCollection stor::DQMConsumerMonitorCollection stor::EventConsumerMonitorCollection

List of all members.

Classes

struct  TotalStats

Public Member Functions

void addDroppedEvents (const QueueID &, const size_t &count)
void addQueuedEventSample (const QueueID &, const unsigned int &data_size)
void addServedEventSample (const QueueID &, const unsigned int &data_size)
 ConsumerMonitorCollection (const utils::Duration_t &updateInterval, const utils::Duration_t &recentDuration)
bool getDropped (const QueueID &qid, MonitoredQuantity::Stats &result) const
bool getQueued (const QueueID &qid, MonitoredQuantity::Stats &result) const
bool getServed (const QueueID &qid, MonitoredQuantity::Stats &result) const
void getTotalStats (TotalStats &) const
void resetCounters ()

Protected Attributes

ConsStatMap dmap_
boost::mutex mutex_
ConsStatMap qmap_
ConsStatMap smap_

Private Types

typedef std::map< QueueID,
MonitoredQuantityPtr
ConsStatMap

Private Member Functions

void addEventSampleToMap (const QueueID &, const unsigned int &data_size, ConsStatMap &)
 ConsumerMonitorCollection (const ConsumerMonitorCollection &)
virtual void do_calculateStatistics ()
virtual void do_reset ()
bool getValueFromMap (const QueueID &, MonitoredQuantity::Stats &, const ConsStatMap &) const
ConsumerMonitorCollectionoperator= (const ConsumerMonitorCollection &)

Private Attributes

const utils::Duration_t recentDuration_
MonitoredQuantity totalDroppedMQ_
MonitoredQuantity totalQueuedMQ_
MonitoredQuantity totalServedMQ_
const utils::Duration_t updateInterval_

Detailed Description

A collection of MonitoredQuantities to track consumer activity.

Author:
mommsen
Revision:
1.12
Date:
2011/03/07 15:31:31

Definition at line 28 of file ConsumerMonitorCollection.h.


Member Typedef Documentation

Definition at line 92 of file ConsumerMonitorCollection.h.


Constructor & Destructor Documentation

stor::ConsumerMonitorCollection::ConsumerMonitorCollection ( const utils::Duration_t updateInterval,
const utils::Duration_t recentDuration 
) [explicit]

Definition at line 12 of file ConsumerMonitorCollection.cc.

   :
  MonitorCollection(updateInterval),
  updateInterval_(updateInterval),
  recentDuration_(recentDuration),
  totalQueuedMQ_(updateInterval, recentDuration),
  totalDroppedMQ_(updateInterval, recentDuration),
  totalServedMQ_(updateInterval, recentDuration)
  {}
stor::ConsumerMonitorCollection::ConsumerMonitorCollection ( const ConsumerMonitorCollection ) [private]

Member Function Documentation

void stor::ConsumerMonitorCollection::addDroppedEvents ( const QueueID qid,
const size_t &  count 
)

Add number of dropped events

Definition at line 38 of file ConsumerMonitorCollection.cc.

References prof2calltree::l.

  {
    boost::mutex::scoped_lock l( mutex_ );
    addEventSampleToMap(qid, count, dmap_);
    totalDroppedMQ_.addSample(count);
  }
void stor::ConsumerMonitorCollection::addEventSampleToMap ( const QueueID qid,
const unsigned int &  data_size,
ConsStatMap map 
) [private]

Definition at line 62 of file ConsumerMonitorCollection.cc.

References pos.

  {
    ConsStatMap::iterator pos = map.lower_bound(qid);
    
    // 05-Oct-2009, KAB - added a test of whether qid appears before pos->first
    // in the map sort order.  Since lower_bound can return a non-end iterator
    // even when qid is not in the map, we need to complete the test of whether
    // qid is in the map.  (Another way to look at this is we need to implement
    // the full test described in the efficientAddOrUpdates pattern suggested
    // by Item 24 of 'Effective STL' by Scott Meyers.)
    if (pos == map.end() || (map.key_comp()(qid, pos->first)))
    {
      // The key does not exist in the map, add it to the map
      // Use pos as a hint to insert, so it can avoid another lookup
      pos = map.insert(pos,
        ConsStatMap::value_type(qid, 
          MonitoredQuantityPtr(
            new MonitoredQuantity(updateInterval_, recentDuration_)
          )
        )
      );
    }
    
    pos->second->addSample( data_size );
  }
void stor::ConsumerMonitorCollection::addQueuedEventSample ( const QueueID qid,
const unsigned int &  data_size 
)

Add queued sample

Definition at line 26 of file ConsumerMonitorCollection.cc.

References prof2calltree::l.

  {
    boost::mutex::scoped_lock l( mutex_ );
    addEventSampleToMap(qid, data_size, qmap_);
    totalQueuedMQ_.addSample(data_size);
  }
void stor::ConsumerMonitorCollection::addServedEventSample ( const QueueID qid,
const unsigned int &  data_size 
)

Add served sample

Definition at line 50 of file ConsumerMonitorCollection.cc.

References prof2calltree::l.

  {
    boost::mutex::scoped_lock l( mutex_ );
    addEventSampleToMap(qid, data_size, smap_);
    totalServedMQ_.addSample(data_size);
  }
void stor::ConsumerMonitorCollection::do_calculateStatistics ( ) [private, virtual]

Implements stor::MonitorCollection.

Definition at line 164 of file ConsumerMonitorCollection.cc.

References stor::MonitoredQuantity::calculateStatistics(), dmap_, i, prof2calltree::l, mutex_, qmap_, smap_, totalDroppedMQ_, totalQueuedMQ_, and totalServedMQ_.

  {
    boost::mutex::scoped_lock l( mutex_ );
    for( ConsStatMap::iterator i = qmap_.begin(); i != qmap_.end(); ++i )
      i->second->calculateStatistics();
    for( ConsStatMap::iterator i = smap_.begin(); i != smap_.end(); ++i )
      i->second->calculateStatistics();
    for( ConsStatMap::iterator i = dmap_.begin(); i != dmap_.end(); ++i )
      i->second->calculateStatistics();
    
    totalQueuedMQ_.calculateStatistics();
    totalDroppedMQ_.calculateStatistics();
    totalServedMQ_.calculateStatistics();
  }
void stor::ConsumerMonitorCollection::do_reset ( ) [private, virtual]

Implements stor::MonitorCollection.

Definition at line 180 of file ConsumerMonitorCollection.cc.

References dmap_, prof2calltree::l, mutex_, qmap_, stor::MonitoredQuantity::reset(), smap_, totalDroppedMQ_, totalQueuedMQ_, and totalServedMQ_.

  {
    boost::mutex::scoped_lock l( mutex_ );
    qmap_.clear();
    smap_.clear();
    dmap_.clear();
    
    totalQueuedMQ_.reset();
    totalDroppedMQ_.reset();
    totalServedMQ_.reset();
  }
bool stor::ConsumerMonitorCollection::getDropped ( const QueueID qid,
MonitoredQuantity::Stats result 
) const

Get number of dropped events. Return false if consumer ID not found.

Definition at line 116 of file ConsumerMonitorCollection.cc.

References prof2calltree::l.

  {
    boost::mutex::scoped_lock l( mutex_ );
    return getValueFromMap( qid, result, dmap_ );
  }
bool stor::ConsumerMonitorCollection::getQueued ( const QueueID qid,
MonitoredQuantity::Stats result 
) const

Get queued data size. Return false if consumer ID not found.

Definition at line 94 of file ConsumerMonitorCollection.cc.

References prof2calltree::l.

  {
    boost::mutex::scoped_lock l( mutex_ );
    return getValueFromMap( qid, result, qmap_ );
  }
bool stor::ConsumerMonitorCollection::getServed ( const QueueID qid,
MonitoredQuantity::Stats result 
) const

Get served data size. Return false if consumer ID not found.

Definition at line 105 of file ConsumerMonitorCollection.cc.

References prof2calltree::l.

Referenced by smproxy::SMPSWebPageHelper::addRowForEventType(), and stor::SMWebPageHelper::getServedConsumerBandwidth().

  {
    boost::mutex::scoped_lock l( mutex_ );
    return getValueFromMap( qid, result, smap_ );
  }
void stor::ConsumerMonitorCollection::getTotalStats ( TotalStats totalStats) const
bool stor::ConsumerMonitorCollection::getValueFromMap ( const QueueID qid,
MonitoredQuantity::Stats result,
const ConsStatMap map 
) const [private]

Definition at line 126 of file ConsumerMonitorCollection.cc.

References pos.

  {
    ConsStatMap::const_iterator pos = map.find(qid);
    
    if (pos == map.end()) return false;
    
    pos->second->getStats( result );
    return true;
  }
ConsumerMonitorCollection& stor::ConsumerMonitorCollection::operator= ( const ConsumerMonitorCollection ) [private]
void stor::ConsumerMonitorCollection::resetCounters ( )

Reset sizes to zero leaving consumers in

Definition at line 148 of file ConsumerMonitorCollection.cc.

References dmap_, i, prof2calltree::l, mutex_, qmap_, stor::MonitoredQuantity::reset(), smap_, totalDroppedMQ_, totalQueuedMQ_, and totalServedMQ_.

  {
    boost::mutex::scoped_lock l( mutex_ );
    for( ConsStatMap::iterator i = qmap_.begin(); i != qmap_.end(); ++i )
      i->second->reset();
    for( ConsStatMap::iterator i = smap_.begin(); i != smap_.end(); ++i )
      i->second->reset();
    for( ConsStatMap::iterator i = dmap_.begin(); i != dmap_.end(); ++i )
      i->second->reset();
    
    totalQueuedMQ_.reset();
    totalDroppedMQ_.reset();
    totalServedMQ_.reset();
  }

Member Data Documentation

Definition at line 109 of file ConsumerMonitorCollection.h.

Referenced by do_calculateStatistics(), do_reset(), and resetCounters().

Definition at line 108 of file ConsumerMonitorCollection.h.

Referenced by do_calculateStatistics(), do_reset(), and resetCounters().

Definition at line 101 of file ConsumerMonitorCollection.h.

Reimplemented from stor::MonitorCollection.

Definition at line 100 of file ConsumerMonitorCollection.h.