CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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

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 ()
 
- Public Member Functions inherited from stor::MonitorCollection
void appendInfoSpaceItems (InfoSpaceItems &)
 
void calculateStatistics (const utils::TimePoint_t &now)
 
 MonitorCollection (const utils::Duration_t &updateInterval)
 
void reset (const utils::TimePoint_t &now)
 
void updateInfoSpaceItems ()
 
virtual ~MonitorCollection ()
 

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_
 

Additional Inherited Members

- Public Types inherited from stor::MonitorCollection
typedef std::vector< std::pair
< std::string,
xdata::Serializable * > > 
InfoSpaceItems
 
- Protected Member Functions inherited from stor::MonitorCollection
virtual void do_appendInfoSpaceItems (InfoSpaceItems &)
 
virtual void do_updateInfoSpaceItems ()
 

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.

15  :
16  MonitorCollection(updateInterval),
17  updateInterval_(updateInterval),
18  recentDuration_(recentDuration),
19  totalQueuedMQ_(updateInterval, recentDuration),
20  totalDroppedMQ_(updateInterval, recentDuration),
21  totalServedMQ_(updateInterval, recentDuration)
22  {}
MonitorCollection(const utils::Duration_t &updateInterval)
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.

42  {
43  boost::mutex::scoped_lock l( mutex_ );
46  }
void addSample(const double &value=1)
void addEventSampleToMap(const QueueID &, const unsigned int &data_size, ConsStatMap &)
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.

67  {
68  ConsStatMap::iterator pos = map.lower_bound(qid);
69 
70  // 05-Oct-2009, KAB - added a test of whether qid appears before pos->first
71  // in the map sort order. Since lower_bound can return a non-end iterator
72  // even when qid is not in the map, we need to complete the test of whether
73  // qid is in the map. (Another way to look at this is we need to implement
74  // the full test described in the efficientAddOrUpdates pattern suggested
75  // by Item 24 of 'Effective STL' by Scott Meyers.)
76  if (pos == map.end() || (map.key_comp()(qid, pos->first)))
77  {
78  // The key does not exist in the map, add it to the map
79  // Use pos as a hint to insert, so it can avoid another lookup
80  pos = map.insert(pos,
83  new MonitoredQuantity(updateInterval_, recentDuration_)
84  )
85  )
86  );
87  }
88 
89  pos->second->addSample( data_size );
90  }
boost::shared_ptr< MonitoredQuantity > MonitoredQuantityPtr
dictionary map
Definition: Association.py:196
Container::value_type value_type
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.

30  {
31  boost::mutex::scoped_lock l( mutex_ );
32  addEventSampleToMap(qid, data_size, qmap_);
33  totalQueuedMQ_.addSample(data_size);
34  }
void addSample(const double &value=1)
void addEventSampleToMap(const QueueID &, const unsigned int &data_size, ConsStatMap &)
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.

54  {
55  boost::mutex::scoped_lock l( mutex_ );
56  addEventSampleToMap(qid, data_size, smap_);
57  totalServedMQ_.addSample(data_size);
58  }
void addSample(const double &value=1)
void addEventSampleToMap(const QueueID &, const unsigned int &data_size, ConsStatMap &)
void stor::ConsumerMonitorCollection::do_calculateStatistics ( )
privatevirtual

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_.

165  {
166  boost::mutex::scoped_lock l( mutex_ );
167  for( ConsStatMap::iterator i = qmap_.begin(); i != qmap_.end(); ++i )
168  i->second->calculateStatistics();
169  for( ConsStatMap::iterator i = smap_.begin(); i != smap_.end(); ++i )
170  i->second->calculateStatistics();
171  for( ConsStatMap::iterator i = dmap_.begin(); i != dmap_.end(); ++i )
172  i->second->calculateStatistics();
173 
177  }
int i
Definition: DBlmapReader.cc:9
void calculateStatistics(const utils::TimePoint_t &currentTime=utils::getCurrentTime())
void stor::ConsumerMonitorCollection::do_reset ( )
privatevirtual
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.

120  {
121  boost::mutex::scoped_lock l( mutex_ );
122  return getValueFromMap( qid, result, dmap_ );
123  }
tuple result
Definition: query.py:137
bool getValueFromMap(const QueueID &, MonitoredQuantity::Stats &, const ConsStatMap &) const
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.

98  {
99  boost::mutex::scoped_lock l( mutex_ );
100  return getValueFromMap( qid, result, qmap_ );
101  }
tuple result
Definition: query.py:137
bool getValueFromMap(const QueueID &, MonitoredQuantity::Stats &, const ConsStatMap &) const
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().

109  {
110  boost::mutex::scoped_lock l( mutex_ );
111  return getValueFromMap( qid, result, smap_ );
112  }
tuple result
Definition: query.py:137
bool getValueFromMap(const QueueID &, MonitoredQuantity::Stats &, const ConsStatMap &) const
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.

131  {
132  ConsStatMap::const_iterator pos = map.find(qid);
133 
134  if (pos == map.end()) return false;
135 
136  pos->second->getStats( result );
137  return true;
138  }
dictionary map
Definition: Association.py:196
tuple result
Definition: query.py:137
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_.

149  {
150  boost::mutex::scoped_lock l( mutex_ );
151  for( ConsStatMap::iterator i = qmap_.begin(); i != qmap_.end(); ++i )
152  i->second->reset();
153  for( ConsStatMap::iterator i = smap_.begin(); i != smap_.end(); ++i )
154  i->second->reset();
155  for( ConsStatMap::iterator i = dmap_.begin(); i != dmap_.end(); ++i )
156  i->second->reset();
157 
161  }
int i
Definition: DBlmapReader.cc:9

Member Data Documentation

ConsStatMap stor::ConsumerMonitorCollection::dmap_
protected

Definition at line 109 of file ConsumerMonitorCollection.h.

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

boost::mutex stor::ConsumerMonitorCollection::mutex_
mutableprotected
ConsStatMap stor::ConsumerMonitorCollection::qmap_
protected

Definition at line 108 of file ConsumerMonitorCollection.h.

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

const utils::Duration_t stor::ConsumerMonitorCollection::recentDuration_
private

Definition at line 101 of file ConsumerMonitorCollection.h.

ConsStatMap stor::ConsumerMonitorCollection::smap_
protected
MonitoredQuantity stor::ConsumerMonitorCollection::totalDroppedMQ_
private
MonitoredQuantity stor::ConsumerMonitorCollection::totalQueuedMQ_
private
MonitoredQuantity stor::ConsumerMonitorCollection::totalServedMQ_
private
const utils::Duration_t stor::ConsumerMonitorCollection::updateInterval_
private

Definition at line 100 of file ConsumerMonitorCollection.h.