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
 
struct  EventMQ
 
struct  EventStats
 
class  EventTypeMqMap
 
struct  EventTypePerConnectionStats
 
struct  SummaryStats
 

Public Types

typedef std::map< std::string,
EventStats
ConnectionStats
 
enum  ConnectionStatus { CONNECTED, CONNECTION_FAILED, DISCONNECTED, UNKNOWN }
 
typedef std::vector
< EventTypePerConnectionStats
EventTypePerConnectionStatList
 
- 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)
 
void configureAlarms (AlarmParams const &)
 
 DataRetrieverMonitorCollection (const stor::utils::Duration_t &updateInterval, stor::AlarmHandlerPtr)
 
bool getEventTypeStatsForConnection (const ConnectionID &, EventTypePerConnectionStats &)
 
void getStatsByConnection (ConnectionStats &) const
 
void getStatsByEventTypesPerConnection (EventTypePerConnectionStatList &) const
 
void getSummaryStats (SummaryStats &) const
 
bool receivedCorruptedEvent (const ConnectionID &)
 
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,
EventMQPtr
ConnectionMqMap
 
typedef boost::shared_ptr
< DataRetrieverMQ
DataRetrieverMQPtr
 
typedef boost::shared_ptr
< EventMQ
EventMQPtr
 
typedef std::map< ConnectionID,
DataRetrieverMQPtr
RetrieverMqMap
 

Private Member Functions

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

Private Attributes

stor::AlarmHandlerPtr alarmHandler_
 
AlarmParams alarmParams_
 
ConnectionMqMap connectionMqMap_
 
EventTypeMqMap eventTypeMqMap_
 
ConnectionID nextConnectionId_
 
RetrieverMqMap retrieverMqMap_
 
boost::mutex statsMutex_
 
EventMQ totals_
 
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.3
Date:
2011/05/09 11:03:25

Definition at line 35 of file DataRetrieverMonitorCollection.h.

Member Typedef Documentation

Definition at line 167 of file DataRetrieverMonitorCollection.h.

Definition at line 58 of file DataRetrieverMonitorCollection.h.

Definition at line 163 of file DataRetrieverMonitorCollection.h.

Definition at line 138 of file DataRetrieverMonitorCollection.h.

Definition at line 68 of file DataRetrieverMonitorCollection.h.

Definition at line 164 of file DataRetrieverMonitorCollection.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

smproxy::DataRetrieverMonitorCollection::DataRetrieverMonitorCollection ( const stor::utils::Duration_t updateInterval,
stor::AlarmHandlerPtr  alarmHandler 
)

Definition at line 17 of file DataRetrieverMonitorCollection.cc.

20  :
21  MonitorCollection(updateInterval),
22  updateInterval_(updateInterval),
23  alarmHandler_(alarmHandler),
24  totals_(updateInterval),
25  eventTypeMqMap_(updateInterval)
26  {}
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 30 of file DataRetrieverMonitorCollection.cc.

33  {
34  boost::mutex::scoped_lock sl(statsMutex_);
36 
37  DataRetrieverMQPtr dataRetrieverMQ( new DataRetrieverMQ(regPtr, updateInterval_) );
38  retrieverMqMap_.insert(
40  );
41 
42  eventTypeMqMap_.insert(regPtr);
43 
45  regPtr->sourceURL(),
46  EventMQPtr(new EventMQ(updateInterval_))
47  ));
48 
49  return nextConnectionId_;
50  }
boost::shared_ptr< DataRetrieverMQ > DataRetrieverMQPtr
Container::value_type value_type
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 87 of file DataRetrieverMonitorCollection.cc.

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

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

Definition at line 212 of file DataRetrieverMonitorCollection.cc.

References alarmHandler_, alarmParams_, smproxy::AlarmParams::corruptedEventRate_, smproxy::DataRetrieverMonitorCollection::EventStats::corruptedEventsStats, stor::AlarmHandler::ERROR, smproxy::DataRetrieverMonitorCollection::EventMQ::getStats(), stor::MonitoredQuantity::Stats::getValueRate(), lumiQueryAPI::msg, stor::MonitoredQuantity::RECENT, AlCaHLTBitMon_QueryRunRegistry::string, and totals_.

Referenced by sendAlarms().

213  {
214  const std::string alarmName = "CorruptedEvents";
215 
216  EventStats eventStats;
217  totals_.getStats(eventStats);
218  const double corruptedEventRate =
219  eventStats.corruptedEventsStats.getValueRate(stor::MonitoredQuantity::RECENT);
220  if ( corruptedEventRate > alarmParams_.corruptedEventRate_ )
221  {
222  std::ostringstream msg;
223  msg << "Received " << corruptedEventRate << " Hz of corrupted events from StorageManagers.";
224  XCEPT_DECLARE(exception::CorruptedEvents, ex, msg.str());
225  alarmHandler_->raiseAlarm(alarmName, stor::AlarmHandler::ERROR, ex);
226  }
227  else if ( corruptedEventRate < (alarmParams_.corruptedEventRate_ * 0.9) )
228  // avoid revoking the alarm if we're close to the limit
229  {
230  alarmHandler_->revokeAlarm(alarmName);
231  }
232  }
void smproxy::DataRetrieverMonitorCollection::configureAlarms ( AlarmParams const &  alarmParams)

Configure the alarm settings

Definition at line 198 of file DataRetrieverMonitorCollection.cc.

References alarmParams_.

199  {
200  alarmParams_ = alarmParams;
201  }
void smproxy::DataRetrieverMonitorCollection::do_calculateStatistics ( )
privatevirtual

Implements stor::MonitorCollection.

Definition at line 235 of file DataRetrieverMonitorCollection.cc.

References smproxy::DataRetrieverMonitorCollection::EventMQ::calculateStatistics(), smproxy::DataRetrieverMonitorCollection::EventTypeMqMap::calculateStatistics(), connectionMqMap_, eventTypeMqMap_, retrieverMqMap_, sendAlarms(), statsMutex_, and totals_.

236  {
237  boost::mutex::scoped_lock sl(statsMutex_);
238 
240 
241  for (RetrieverMqMap::const_iterator it = retrieverMqMap_.begin(),
242  itEnd = retrieverMqMap_.end(); it != itEnd; ++it)
243  {
244  it->second->eventMQ_->calculateStatistics();
245  }
246 
247  for (ConnectionMqMap::const_iterator it = connectionMqMap_.begin(),
248  itEnd = connectionMqMap_.end(); it != itEnd; ++it)
249  {
250  it->second->calculateStatistics();
251  }
252 
254 
255  sendAlarms();
256  }
void smproxy::DataRetrieverMonitorCollection::do_reset ( )
privatevirtual
bool smproxy::DataRetrieverMonitorCollection::getEventTypeStatsForConnection ( const ConnectionID connectionId,
EventTypePerConnectionStats stats 
)

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

Definition at line 68 of file DataRetrieverMonitorCollection.cc.

References smproxy::DataRetrieverMonitorCollection::EventTypePerConnectionStats::connectionStatus, smproxy::DataRetrieverMonitorCollection::EventTypePerConnectionStats::eventStats, pos, and smproxy::DataRetrieverMonitorCollection::EventTypePerConnectionStats::regPtr.

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

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

Definition at line 161 of file DataRetrieverMonitorCollection.cc.

References connectionMqMap_, and statsMutex_.

162  {
163  boost::mutex::scoped_lock sl(statsMutex_);
164  cs.clear();
165 
166  for (ConnectionMqMap::const_iterator it = connectionMqMap_.begin(),
167  itEnd = connectionMqMap_.end(); it != itEnd; ++it)
168  {
169  EventStats stats;
170  it->second->getStats(stats);
171  cs.insert(ConnectionStats::value_type(it->first, stats));
172  }
173  }
auto_ptr< ClusterSequence > cs
Container::value_type value_type
void smproxy::DataRetrieverMonitorCollection::getStatsByEventTypesPerConnection ( EventTypePerConnectionStatList etsl) const

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

Definition at line 177 of file DataRetrieverMonitorCollection.cc.

References smproxy::DataRetrieverMonitorCollection::EventTypePerConnectionStats::connectionStatus, smproxy::DataRetrieverMonitorCollection::EventTypePerConnectionStats::eventStats, smproxy::DataRetrieverMonitorCollection::EventTypePerConnectionStats::regPtr, and python.multivaluedict::sort().

180  {
181  boost::mutex::scoped_lock sl(statsMutex_);
182  etsl.clear();
183 
184  for (RetrieverMqMap::const_iterator it = retrieverMqMap_.begin(),
185  itEnd = retrieverMqMap_.end(); it != itEnd; ++it)
186  {
187  const DataRetrieverMQPtr mq = it->second;
188  EventTypePerConnectionStats stats;
189  stats.regPtr = mq->regPtr_;
190  stats.connectionStatus = mq->connectionStatus_;
191  mq->eventMQ_->getStats(stats.eventStats);
192  etsl.push_back(stats);
193  }
194  std::sort(etsl.begin(), etsl.end());
195  }
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 140 of file DataRetrieverMonitorCollection.cc.

References smproxy::DataRetrieverMonitorCollection::SummaryStats::activeSMs, CONNECTED, eventTypeMqMap_, smproxy::DataRetrieverMonitorCollection::SummaryStats::eventTypeStats, smproxy::DataRetrieverMonitorCollection::EventMQ::getStats(), smproxy::DataRetrieverMonitorCollection::EventTypeMqMap::getStats(), smproxy::DataRetrieverMonitorCollection::SummaryStats::registeredSMs, retrieverMqMap_, statsMutex_, smproxy::DataRetrieverMonitorCollection::SummaryStats::totals, and totals_.

141  {
142  boost::mutex::scoped_lock sl(statsMutex_);
143 
144  stats.registeredSMs = 0;
145  stats.activeSMs = 0;
146 
147  for (RetrieverMqMap::const_iterator it = retrieverMqMap_.begin(),
148  itEnd = retrieverMqMap_.end(); it != itEnd; ++it)
149  {
150  ++stats.registeredSMs;
151  if ( it->second->connectionStatus_ == CONNECTED )
152  ++stats.activeSMs;
153  }
154 
155  eventTypeMqMap_.getStats(stats.eventTypeStats);
156 
157  totals_.getStats(stats.totals);
158  }
DataRetrieverMonitorCollection& smproxy::DataRetrieverMonitorCollection::operator= ( DataRetrieverMonitorCollection const &  )
private
bool smproxy::DataRetrieverMonitorCollection::receivedCorruptedEvent ( const ConnectionID connectionId)

Increment number of corrupted events received from the given connection. Returns false if the ConnectionID is unknown.

Definition at line 115 of file DataRetrieverMonitorCollection.cc.

References reco_skim_cfg_mod::sourceURL, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by smproxy::DataRetrieverMonitorCollection::EventTypeMqMap::receivedCorruptedEvent().

118  {
119  boost::mutex::scoped_lock sl(statsMutex_);
120 
121  RetrieverMqMap::const_iterator retrieverPos = retrieverMqMap_.find(connectionId);
122  if ( retrieverPos == retrieverMqMap_.end() ) return false;
123 
124  retrieverPos->second->eventMQ_->corruptedEvents_.addSample(1);
125 
126  const stor::RegPtr regPtr = retrieverPos->second->regPtr_;
127 
129 
130  const std::string sourceURL = regPtr->sourceURL();
131  ConnectionMqMap::const_iterator connectionPos = connectionMqMap_.find(sourceURL);
132  connectionPos->second->corruptedEvents_.addSample(1);
133 
135 
136  return true;
137  }
boost::shared_ptr< RegistrationInfoBase > RegPtr
void addSample(const double &value=1)
void smproxy::DataRetrieverMonitorCollection::sendAlarms ( )
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 54 of file DataRetrieverMonitorCollection.cc.

References pos, and ntuplemaker::status.

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

Member Data Documentation

stor::AlarmHandlerPtr smproxy::DataRetrieverMonitorCollection::alarmHandler_
private

Definition at line 158 of file DataRetrieverMonitorCollection.h.

Referenced by checkForCorruptedEvents().

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

Definition at line 171 of file DataRetrieverMonitorCollection.h.

RetrieverMqMap smproxy::DataRetrieverMonitorCollection::retrieverMqMap_
private
boost::mutex smproxy::DataRetrieverMonitorCollection::statsMutex_
mutableprivate
EventMQ smproxy::DataRetrieverMonitorCollection::totals_
private
const stor::utils::Duration_t smproxy::DataRetrieverMonitorCollection::updateInterval_
private