Go to the documentation of this file.00001
00003
00004 #ifndef EventFilter_StorageManager_ConsumerMonitorCollection_h
00005 #define EventFilter_StorageManager_ConsumerMonitorCollection_h
00006
00007 #include "EventFilter/StorageManager/interface/MonitorCollection.h"
00008 #include "EventFilter/StorageManager/interface/QueueID.h"
00009
00010 #include <boost/thread/mutex.hpp>
00011 #include <boost/shared_ptr.hpp>
00012
00013 #include <map>
00014
00015 namespace stor {
00016
00017 class MonitoredQuantity;
00018
00019
00028 class ConsumerMonitorCollection: public MonitorCollection
00029 {
00030
00031 public:
00032
00033 struct TotalStats
00034 {
00035 MonitoredQuantity::Stats queuedStats;
00036 MonitoredQuantity::Stats droppedStats;
00037 MonitoredQuantity::Stats servedStats;
00038 };
00039
00040 explicit ConsumerMonitorCollection
00041 (
00042 const utils::Duration_t& updateInterval,
00043 const utils::Duration_t& recentDuration
00044 );
00045
00049 void addQueuedEventSample( const QueueID&, const unsigned int& data_size );
00050
00054 void addDroppedEvents( const QueueID&, const size_t& count );
00055
00059 void addServedEventSample( const QueueID&, const unsigned int& data_size );
00060
00064 bool getQueued( const QueueID& qid, MonitoredQuantity::Stats& result ) const;
00065
00069 bool getServed( const QueueID& qid, MonitoredQuantity::Stats& result ) const;
00070
00074 bool getDropped( const QueueID& qid, MonitoredQuantity::Stats& result ) const;
00075
00079 void getTotalStats( TotalStats& ) const;
00080
00084 void resetCounters();
00085
00086 private:
00087
00088
00089 ConsumerMonitorCollection( const ConsumerMonitorCollection& );
00090 ConsumerMonitorCollection& operator = ( const ConsumerMonitorCollection& );
00091
00092 typedef std::map<QueueID, MonitoredQuantityPtr> ConsStatMap;
00093
00094 void addEventSampleToMap( const QueueID&, const unsigned int& data_size, ConsStatMap& );
00095 bool getValueFromMap( const QueueID&, MonitoredQuantity::Stats&, const ConsStatMap& ) const;
00096
00097 virtual void do_calculateStatistics();
00098 virtual void do_reset();
00099
00100 const utils::Duration_t updateInterval_;
00101 const utils::Duration_t recentDuration_;
00102 MonitoredQuantity totalQueuedMQ_;
00103 MonitoredQuantity totalDroppedMQ_;
00104 MonitoredQuantity totalServedMQ_;
00105
00106 protected:
00107
00108 ConsStatMap qmap_;
00109 ConsStatMap dmap_;
00110 ConsStatMap smap_;
00111
00112 mutable boost::mutex mutex_;
00113
00114 };
00115
00116 }
00117
00118 #endif // EventFilter_StorageManager_ConsumerMonitorCollection_h
00119
00120