CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
smproxy::DataRetrieverMonitorCollection Class Reference

#include <DataRetrieverMonitorCollection.h>

Inheritance diagram for smproxy::DataRetrieverMonitorCollection:
stor::MonitorCollection

Classes

struct  DataRetrieverMQ
 
class  EventTypeMqMap
 
struct  EventTypeStats
 
struct  SummaryStats
 

Public Types

typedef std::map< std::string,
stor::MonitoredQuantity::Stats
ConnectionStats
 
enum  ConnectionStatus { CONNECTED, CONNECTION_FAILED, DISCONNECTED, UNKNOWN }
 
typedef std::vector
< EventTypeStats
EventTypeStatList
 
- Public Types inherited from stor::MonitorCollection
typedef std::vector< std::pair
< std::string,
xdata::Serializable * > > 
InfoSpaceItems
 

Public Member Functions

ConnectionID addNewConnection (const stor::RegPtr)
 
bool addRetrievedSample (const ConnectionID &, const unsigned int &size)
 
 DataRetrieverMonitorCollection (const stor::utils::Duration_t &updateInterval)
 
bool getEventTypeStatsForConnection (const ConnectionID &, EventTypeStats &)
 
void getStatsByConnection (ConnectionStats &) const
 
void getStatsByEventTypes (EventTypeStatList &) const
 
void getSummaryStats (SummaryStats &) const
 
bool setConnectionStatus (const ConnectionID &, const ConnectionStatus &)
 
- 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 ()
 

Private Types

typedef std::map< std::string,
stor::MonitoredQuantityPtr
ConnectionMqMap
 
typedef boost::shared_ptr
< DataRetrieverMQ
DataRetrieverMQPtr
 
typedef std::map< ConnectionID,
DataRetrieverMQPtr
RetrieverMqMap
 

Private Member Functions

 DataRetrieverMonitorCollection (DataRetrieverMonitorCollection const &)
 
virtual void do_calculateStatistics ()
 
virtual void do_reset ()
 
DataRetrieverMonitorCollectionoperator= (DataRetrieverMonitorCollection const &)
 

Private Attributes

ConnectionMqMap connectionMqMap_
 
EventTypeMqMap eventTypeMqMap_
 
ConnectionID nextConnectionId_
 
RetrieverMqMap retrieverMqMap_
 
boost::mutex statsMutex_
 
stor::MonitoredQuantity totalSize_
 
const stor::utils::Duration_t updateInterval_
 

Additional Inherited Members

- Protected Member Functions inherited from stor::MonitorCollection
virtual void do_appendInfoSpaceItems (InfoSpaceItems &)
 
virtual void do_updateInfoSpaceItems ()
 

Detailed Description

A collection of MonitoredQuantities related to data retrieval

Author:
mommsen
Revision:
1.1.2.8
Date:
2011/03/01 08:32:14

Definition at line 33 of file DataRetrieverMonitorCollection.h.

Member Typedef Documentation

Definition at line 130 of file DataRetrieverMonitorCollection.h.

Definition at line 50 of file DataRetrieverMonitorCollection.h.

Definition at line 126 of file DataRetrieverMonitorCollection.h.

Definition at line 60 of file DataRetrieverMonitorCollection.h.

Definition at line 127 of file DataRetrieverMonitorCollection.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

smproxy::DataRetrieverMonitorCollection::DataRetrieverMonitorCollection ( const stor::utils::Duration_t updateInterval)
explicit

Definition at line 17 of file DataRetrieverMonitorCollection.cc.

19  :
20  MonitorCollection(updateInterval),
21  totalSize_(updateInterval, boost::posix_time::seconds(60)),
22  updateInterval_(updateInterval),
23  eventTypeMqMap_(updateInterval)
24  {}
double seconds()
MonitorCollection(const utils::Duration_t &updateInterval)
smproxy::DataRetrieverMonitorCollection::DataRetrieverMonitorCollection ( DataRetrieverMonitorCollection const &  )
private

Member Function Documentation

ConnectionID smproxy::DataRetrieverMonitorCollection::addNewConnection ( const stor::RegPtr  regPtr)

Add a new server connection. Returns an unique connection ID.

Definition at line 28 of file DataRetrieverMonitorCollection.cc.

References seconds().

31  {
32  boost::mutex::scoped_lock sl(statsMutex_);
34 
35  DataRetrieverMQPtr dataRetrieverMQ( new DataRetrieverMQ(regPtr, updateInterval_) );
36  retrieverMqMap_.insert(
38  );
39 
40  eventTypeMqMap_.insert(regPtr);
41 
42  connectionMqMap_.insert(ConnectionMqMap::value_type(regPtr->sourceURL(),
45  )
46  ));
47 
48  return nextConnectionId_;
49  }
double seconds()
boost::shared_ptr< MonitoredQuantity > MonitoredQuantityPtr
Container::value_type value_type
boost::shared_ptr< DataRetrieverMQ > DataRetrieverMQPtr
bool smproxy::DataRetrieverMonitorCollection::addRetrievedSample ( const ConnectionID connectionId,
const unsigned int &  size 
)

Add a retrieved sample in Bytes from the given connection. Returns false if the ConnectionID is unknown.

Definition at line 86 of file DataRetrieverMonitorCollection.cc.

References findQualityFiles::size, and reco_skim_cfg_mod::sourceURL.

90  {
91  boost::mutex::scoped_lock sl(statsMutex_);
92 
93  RetrieverMqMap::const_iterator retrieverPos = retrieverMqMap_.find(connectionId);
94  if ( retrieverPos == retrieverMqMap_.end() ) return false;
95 
96  const double sizeKB = static_cast<double>(size) / 1024;
97  retrieverPos->second->size_.addSample(sizeKB);
98 
99  const stor::RegPtr regPtr = retrieverPos->second->regPtr_;
100 
101  eventTypeMqMap_.addSample(regPtr, sizeKB);
102 
103  const std::string sourceURL = regPtr->sourceURL();
104  ConnectionMqMap::const_iterator connectionPos = connectionMqMap_.find(sourceURL);
105  connectionPos->second->addSample(sizeKB);
106 
107  totalSize_.addSample(sizeKB);
108 
109  return true;
110  }
boost::shared_ptr< RegistrationInfoBase > RegPtr
void addSample(const double &value=1)
tuple size
Write out results.
void smproxy::DataRetrieverMonitorCollection::do_calculateStatistics ( )
privatevirtual

Implements stor::MonitorCollection.

Definition at line 168 of file DataRetrieverMonitorCollection.cc.

References stor::MonitoredQuantity::calculateStatistics(), smproxy::DataRetrieverMonitorCollection::EventTypeMqMap::calculateStatistics(), connectionMqMap_, eventTypeMqMap_, retrieverMqMap_, statsMutex_, and totalSize_.

169  {
170  boost::mutex::scoped_lock sl(statsMutex_);
171 
173 
174  for (RetrieverMqMap::const_iterator it = retrieverMqMap_.begin(),
175  itEnd = retrieverMqMap_.end(); it != itEnd; ++it)
176  {
177  it->second->size_.calculateStatistics();
178  }
179 
180  for (ConnectionMqMap::const_iterator it = connectionMqMap_.begin(),
181  itEnd = connectionMqMap_.end(); it != itEnd; ++it)
182  {
183  it->second->calculateStatistics();
184  }
185 
187  }
void calculateStatistics(const utils::TimePoint_t &currentTime=utils::getCurrentTime())
void smproxy::DataRetrieverMonitorCollection::do_reset ( )
privatevirtual
bool smproxy::DataRetrieverMonitorCollection::getEventTypeStatsForConnection ( const ConnectionID connectionId,
EventTypeStats stats 
)

Put the event type statistics for the given consumer ID into the passed EventTypeStats. Return false if the connection ID is not found.

Definition at line 67 of file DataRetrieverMonitorCollection.cc.

References smproxy::DataRetrieverMonitorCollection::EventTypeStats::connectionStatus, pos, smproxy::DataRetrieverMonitorCollection::EventTypeStats::regPtr, and smproxy::DataRetrieverMonitorCollection::EventTypeStats::sizeStats.

71  {
72  boost::mutex::scoped_lock sl(statsMutex_);
73  RetrieverMqMap::const_iterator pos = retrieverMqMap_.find(connectionId);
74 
75  if ( pos == retrieverMqMap_.end() ) return false;
76 
77  stats.regPtr = pos->second->regPtr_;
78  stats.connectionStatus = pos->second->connectionStatus_;
79  pos->second->size_.getStats(stats.sizeStats);
80 
81  return true;
82  }
void smproxy::DataRetrieverMonitorCollection::getStatsByConnection ( ConnectionStats cs) const

Write the data retrieval statistics for each connection into the given struct.

Definition at line 134 of file DataRetrieverMonitorCollection.cc.

References connectionMqMap_, and statsMutex_.

135  {
136  boost::mutex::scoped_lock sl(statsMutex_);
137  cs.clear();
138 
139  for (ConnectionMqMap::const_iterator it = connectionMqMap_.begin(),
140  itEnd = connectionMqMap_.end(); it != itEnd; ++it)
141  {
143  it->second->getStats(stats);
144  cs.insert(ConnectionStats::value_type(it->first, stats));
145  }
146  }
Container::value_type value_type
void smproxy::DataRetrieverMonitorCollection::getStatsByEventTypes ( EventTypeStatList etsl) const

Write the data retrieval statistics for each event type request into the given struct.

Definition at line 149 of file DataRetrieverMonitorCollection.cc.

References smproxy::DataRetrieverMonitorCollection::EventTypeStats::connectionStatus, smproxy::DataRetrieverMonitorCollection::EventTypeStats::regPtr, retrieverMqMap_, smproxy::DataRetrieverMonitorCollection::EventTypeStats::sizeStats, python.multivaluedict::sort(), and statsMutex_.

150  {
151  boost::mutex::scoped_lock sl(statsMutex_);
152  etsl.clear();
153 
154  for (RetrieverMqMap::const_iterator it = retrieverMqMap_.begin(),
155  itEnd = retrieverMqMap_.end(); it != itEnd; ++it)
156  {
157  const DataRetrieverMQPtr mq = it->second;
158  EventTypeStats stats;
159  stats.regPtr = mq->regPtr_;
160  stats.connectionStatus = mq->connectionStatus_;
161  mq->size_.getStats(stats.sizeStats);
162  etsl.push_back(stats);
163  }
164  std::sort(etsl.begin(), etsl.end());
165  }
boost::shared_ptr< DataRetrieverMQ > DataRetrieverMQPtr
void smproxy::DataRetrieverMonitorCollection::getSummaryStats ( SummaryStats stats) const

Write the data retrieval summary statistics into the given struct.

Definition at line 113 of file DataRetrieverMonitorCollection.cc.

References smproxy::DataRetrieverMonitorCollection::SummaryStats::activeSMs, CONNECTED, eventTypeMqMap_, smproxy::DataRetrieverMonitorCollection::SummaryStats::eventTypeStats, stor::MonitoredQuantity::getStats(), smproxy::DataRetrieverMonitorCollection::EventTypeMqMap::getStats(), smproxy::DataRetrieverMonitorCollection::SummaryStats::registeredSMs, retrieverMqMap_, smproxy::DataRetrieverMonitorCollection::SummaryStats::sizeStats, statsMutex_, and totalSize_.

114  {
115  boost::mutex::scoped_lock sl(statsMutex_);
116 
117  stats.registeredSMs = 0;
118  stats.activeSMs = 0;
119 
120  for (RetrieverMqMap::const_iterator it = retrieverMqMap_.begin(),
121  itEnd = retrieverMqMap_.end(); it != itEnd; ++it)
122  {
123  ++stats.registeredSMs;
124  if ( it->second->connectionStatus_ == CONNECTED )
125  ++stats.activeSMs;
126  }
127 
128  eventTypeMqMap_.getStats(stats.eventTypeStats);
129 
130  totalSize_.getStats(stats.sizeStats);
131  }
void getStats(Stats &stats) const
DataRetrieverMonitorCollection& smproxy::DataRetrieverMonitorCollection::operator= ( DataRetrieverMonitorCollection const &  )
private
bool smproxy::DataRetrieverMonitorCollection::setConnectionStatus ( const ConnectionID connectionId,
const ConnectionStatus status 
)

Set status of given connection. Returns false if the ConnectionID is unknown.

Definition at line 53 of file DataRetrieverMonitorCollection.cc.

References pos, and ntuplemaker::status.

57  {
58  boost::mutex::scoped_lock sl(statsMutex_);
59  RetrieverMqMap::const_iterator pos = retrieverMqMap_.find(connectionId);
60  if ( pos == retrieverMqMap_.end() ) return false;
61  pos->second->connectionStatus_ = status;
62  return true;
63  }
tuple status
Definition: ntuplemaker.py:245

Member Data Documentation

ConnectionMqMap smproxy::DataRetrieverMonitorCollection::connectionMqMap_
private
EventTypeMqMap smproxy::DataRetrieverMonitorCollection::eventTypeMqMap_
private
ConnectionID smproxy::DataRetrieverMonitorCollection::nextConnectionId_
private

Definition at line 134 of file DataRetrieverMonitorCollection.h.

RetrieverMqMap smproxy::DataRetrieverMonitorCollection::retrieverMqMap_
private
boost::mutex smproxy::DataRetrieverMonitorCollection::statsMutex_
mutableprivate
stor::MonitoredQuantity smproxy::DataRetrieverMonitorCollection::totalSize_
private
const stor::utils::Duration_t smproxy::DataRetrieverMonitorCollection::updateInterval_
private