CMS 3D CMS Logo

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

#include <StatisticsReporter.h>

Inheritance diagram for smproxy::StatisticsReporter:

Public Member Functions

virtual void actionPerformed (xdata::Event &)
 
stor::AlarmHandlerPtr alarmHandler ()
 
const
DataRetrieverMonitorCollection
getDataRetrieverMonitorCollection () const
 
DataRetrieverMonitorCollectiongetDataRetrieverMonitorCollection ()
 
const
stor::DQMConsumerMonitorCollection
getDQMConsumerMonitorCollection () const
 
stor::DQMConsumerMonitorCollectiongetDQMConsumerMonitorCollection ()
 
const
stor::DQMEventMonitorCollection
getDQMEventMonitorCollection () const
 
stor::DQMEventMonitorCollectiongetDQMEventMonitorCollection ()
 
const
stor::EventConsumerMonitorCollection
getEventConsumerMonitorCollection () const
 
stor::EventConsumerMonitorCollectiongetEventConsumerMonitorCollection ()
 
void reset ()
 
void startWorkLoop (std::string workloopName)
 
 StatisticsReporter (xdaq::Application *, const QueueConfigurationParams &)
 
virtual ~StatisticsReporter ()
 

Private Types

typedef std::list< std::string > InfoSpaceItemNames
 

Private Member Functions

void calculateStatistics ()
 
void collectInfoSpaceItems ()
 
void createMonitoringInfoSpace ()
 
bool monitorAction (toolbox::task::WorkLoop *)
 
StatisticsReporteroperator= (StatisticsReporter const &)
 
void putItemsIntoInfoSpace (stor::MonitorCollection::InfoSpaceItems &)
 
 StatisticsReporter (StatisticsReporter const &)
 
void updateInfoSpace ()
 

Private Attributes

stor::AlarmHandlerPtr alarmHandler_
 
xdaq::Application * app_
 
DataRetrieverMonitorCollection dataRetrieverMonCollection_
 
bool doMonitoring_
 
stor::DQMConsumerMonitorCollection dqmConsumerMonCollection_
 
stor::DQMEventMonitorCollection dqmEventMonCollection_
 
stor::EventConsumerMonitorCollection eventConsumerMonCollection_
 
xdata::InfoSpace * infoSpace_
 
InfoSpaceItemNames infoSpaceItemNames_
 
stor::utils::TimePoint_t lastMonitorAction_
 
stor::utils::Duration_t monitoringSleepSec_
 
toolbox::task::WorkLoop * monitorWL_
 

Detailed Description

Singleton to keep track of all monitoring and statistics issues

This class also starts the monitoring workloop to update the statistics for all MonitorCollections.

Author:
mommsen
Revision:
1.2
Date:
2011/03/07 15:41:54

Definition at line 42 of file StatisticsReporter.h.

Member Typedef Documentation

Definition at line 104 of file StatisticsReporter.h.

Constructor & Destructor Documentation

smproxy::StatisticsReporter::StatisticsReporter ( xdaq::Application *  app,
const QueueConfigurationParams qcp 
)
explicit

Definition at line 23 of file StatisticsReporter.cc.

References reset().

26  :
27  app_(app),
29  monitoringSleepSec_(qcp.monitoringSleepSec_),
35  {
36  reset();
39  }
double seconds()
DataRetrieverMonitorCollection dataRetrieverMonCollection_
stor::utils::Duration_t monitoringSleepSec_
stor::AlarmHandlerPtr alarmHandler_
stor::EventConsumerMonitorCollection eventConsumerMonCollection_
stor::DQMEventMonitorCollection dqmEventMonCollection_
stor::DQMConsumerMonitorCollection dqmConsumerMonCollection_
smproxy::StatisticsReporter::~StatisticsReporter ( )
virtual

Definition at line 75 of file StatisticsReporter.cc.

References doMonitoring_, and monitorWL_.

76  {
77  // Stop the monitoring activity
78  doMonitoring_ = false;
79 
80  // Cancel the workloop (will wait until the action has finished)
81  if ( monitorWL_ && monitorWL_->isActive() ) monitorWL_->cancel();
82  }
toolbox::task::WorkLoop * monitorWL_
smproxy::StatisticsReporter::StatisticsReporter ( StatisticsReporter const &  )
private

Member Function Documentation

void smproxy::StatisticsReporter::actionPerformed ( xdata::Event &  ispaceEvent)
virtual

Update the variables put into the application info space

Definition at line 282 of file StatisticsReporter.cc.

283  {}
stor::AlarmHandlerPtr smproxy::StatisticsReporter::alarmHandler ( )
inline

Access alarm handler

Definition at line 94 of file StatisticsReporter.h.

References alarmHandler_.

94 { return alarmHandler_; }
stor::AlarmHandlerPtr alarmHandler_
void smproxy::StatisticsReporter::calculateStatistics ( )
private

Definition at line 213 of file StatisticsReporter.cc.

References stor::MonitorCollection::calculateStatistics(), dataRetrieverMonCollection_, dqmConsumerMonCollection_, dqmEventMonCollection_, eventConsumerMonCollection_, stor::utils::getCurrentTime(), and cmsPerfSuiteHarvest::now.

Referenced by monitorAction().

214  {
216 
221  }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
DataRetrieverMonitorCollection dataRetrieverMonCollection_
boost::posix_time::ptime TimePoint_t
Definition: Utils.h:35
void calculateStatistics(const utils::TimePoint_t &now)
stor::EventConsumerMonitorCollection eventConsumerMonCollection_
stor::DQMEventMonitorCollection dqmEventMonCollection_
stor::DQMConsumerMonitorCollection dqmConsumerMonCollection_
void smproxy::StatisticsReporter::collectInfoSpaceItems ( )
private

Definition at line 118 of file StatisticsReporter.cc.

References stor::MonitorCollection::appendInfoSpaceItems(), dataRetrieverMonCollection_, dqmConsumerMonCollection_, dqmEventMonCollection_, eventConsumerMonCollection_, infoSpaceItemNames_, and putItemsIntoInfoSpace().

119  {
121  infoSpaceItemNames_.clear();
122 
127 
128  putItemsIntoInfoSpace(infoSpaceItems);
129  }
DataRetrieverMonitorCollection dataRetrieverMonCollection_
void putItemsIntoInfoSpace(stor::MonitorCollection::InfoSpaceItems &)
void appendInfoSpaceItems(InfoSpaceItems &)
std::vector< std::pair< std::string, xdata::Serializable * > > InfoSpaceItems
stor::EventConsumerMonitorCollection eventConsumerMonCollection_
stor::DQMEventMonitorCollection dqmEventMonCollection_
stor::DQMConsumerMonitorCollection dqmConsumerMonCollection_
InfoSpaceItemNames infoSpaceItemNames_
void smproxy::StatisticsReporter::createMonitoringInfoSpace ( )
private

Definition at line 85 of file StatisticsReporter.cc.

References app_, alignCSCRings::e, edm::hlt::Exception, infoSpace_, and AlCaHLTBitMon_QueryRunRegistry::string.

86  {
87  // Create an infospace which can be monitored.
88 
89  std::ostringstream oss;
90  oss << "urn:xdaq-monitorable-" << app_->getApplicationDescriptor()->getClassName();
91 
92  std::string errorMsg =
93  "Failed to create monitoring info space " + oss.str();
94 
95  try
96  {
97  toolbox::net::URN urn = app_->createQualifiedInfoSpace(oss.str());
98  xdata::getInfoSpaceFactory()->lock();
99  infoSpace_ = xdata::getInfoSpaceFactory()->get(urn.toString());
100  xdata::getInfoSpaceFactory()->unlock();
101  }
103  {
104  xdata::getInfoSpaceFactory()->unlock();
105 
106  XCEPT_RETHROW(exception::Infospace, errorMsg, e);
107  }
108  catch (...)
109  {
110  xdata::getInfoSpaceFactory()->unlock();
111 
112  errorMsg += " : unknown exception";
113  XCEPT_RAISE(exception::Infospace, errorMsg);
114  }
115  }
const DataRetrieverMonitorCollection& smproxy::StatisticsReporter::getDataRetrieverMonitorCollection ( ) const
inline

Definition at line 54 of file StatisticsReporter.h.

References dataRetrieverMonCollection_.

55  { return dataRetrieverMonCollection_; }
DataRetrieverMonitorCollection dataRetrieverMonCollection_
DataRetrieverMonitorCollection& smproxy::StatisticsReporter::getDataRetrieverMonitorCollection ( )
inline

Definition at line 57 of file StatisticsReporter.h.

References dataRetrieverMonCollection_.

58  { return dataRetrieverMonCollection_; }
DataRetrieverMonitorCollection dataRetrieverMonCollection_
const stor::DQMConsumerMonitorCollection& smproxy::StatisticsReporter::getDQMConsumerMonitorCollection ( ) const
inline

Definition at line 74 of file StatisticsReporter.h.

References dqmConsumerMonCollection_.

75  { return dqmConsumerMonCollection_; }
stor::DQMConsumerMonitorCollection dqmConsumerMonCollection_
stor::DQMConsumerMonitorCollection& smproxy::StatisticsReporter::getDQMConsumerMonitorCollection ( )
inline

Definition at line 77 of file StatisticsReporter.h.

References dqmConsumerMonCollection_.

78  { return dqmConsumerMonCollection_; }
stor::DQMConsumerMonitorCollection dqmConsumerMonCollection_
const stor::DQMEventMonitorCollection& smproxy::StatisticsReporter::getDQMEventMonitorCollection ( ) const
inline

Definition at line 60 of file StatisticsReporter.h.

References dqmEventMonCollection_.

61  { return dqmEventMonCollection_; }
stor::DQMEventMonitorCollection dqmEventMonCollection_
stor::DQMEventMonitorCollection& smproxy::StatisticsReporter::getDQMEventMonitorCollection ( )
inline

Definition at line 63 of file StatisticsReporter.h.

References dqmEventMonCollection_.

64  { return dqmEventMonCollection_; }
stor::DQMEventMonitorCollection dqmEventMonCollection_
const stor::EventConsumerMonitorCollection& smproxy::StatisticsReporter::getEventConsumerMonitorCollection ( ) const
inline

Definition at line 67 of file StatisticsReporter.h.

References eventConsumerMonCollection_.

68  { return eventConsumerMonCollection_; }
stor::EventConsumerMonitorCollection eventConsumerMonCollection_
stor::EventConsumerMonitorCollection& smproxy::StatisticsReporter::getEventConsumerMonitorCollection ( )
inline

Definition at line 70 of file StatisticsReporter.h.

References eventConsumerMonCollection_.

71  { return eventConsumerMonCollection_; }
stor::EventConsumerMonitorCollection eventConsumerMonCollection_
bool smproxy::StatisticsReporter::monitorAction ( toolbox::task::WorkLoop *  wl)
private

Definition at line 164 of file StatisticsReporter.cc.

References app_, calculateStatistics(), doMonitoring_, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, stor::utils::getCurrentTime(), lastMonitorAction_, monitoringSleepSec_, stor::utils::sleepUntil(), AlCaHLTBitMon_QueryRunRegistry::string, and updateInfoSpace().

Referenced by startWorkLoop().

165  {
168 
169  std::string errorMsg = "Failed to update the monitoring information";
170 
171  try
172  {
174  updateInfoSpace();
175  }
176  catch(xcept::Exception &e)
177  {
178  LOG4CPLUS_ERROR(app_->getApplicationLogger(),
179  errorMsg << xcept::stdformat_exception_history(e));
180 
181  XCEPT_DECLARE_NESTED(exception::Monitoring,
182  sentinelException, errorMsg, e);
183  app_->notifyQualified("error", sentinelException);
184  }
185  catch(std::exception &e)
186  {
187  errorMsg += ": ";
188  errorMsg += e.what();
189 
190  LOG4CPLUS_ERROR(app_->getApplicationLogger(),
191  errorMsg);
192 
193  XCEPT_DECLARE(exception::Monitoring,
194  sentinelException, errorMsg);
195  app_->notifyQualified("error", sentinelException);
196  }
197  catch(...)
198  {
199  errorMsg += ": Unknown exception";
200 
201  LOG4CPLUS_ERROR(app_->getApplicationLogger(),
202  errorMsg);
203 
204  XCEPT_DECLARE(exception::Monitoring,
205  sentinelException, errorMsg);
206  app_->notifyQualified("error", sentinelException);
207  }
208 
209  return doMonitoring_;
210  }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
void sleepUntil(TimePoint_t)
Definition: Utils.h:168
stor::utils::TimePoint_t lastMonitorAction_
stor::utils::Duration_t monitoringSleepSec_
StatisticsReporter& smproxy::StatisticsReporter::operator= ( StatisticsReporter const &  )
private
void smproxy::StatisticsReporter::putItemsIntoInfoSpace ( stor::MonitorCollection::InfoSpaceItems items)
private

Definition at line 133 of file StatisticsReporter.cc.

References alignCSCRings::e, and edm::hlt::Exception.

Referenced by collectInfoSpaceItems().

136  {
137 
138  for ( stor::MonitorCollection::InfoSpaceItems::const_iterator it = items.begin(),
139  itEnd = items.end();
140  it != itEnd;
141  ++it )
142  {
143  try
144  {
145  // fireItemAvailable locks the infospace internally
146  infoSpace_->fireItemAvailable(it->first, it->second);
147  }
149  {
150  std::stringstream oss;
151 
152  oss << "Failed to put " << it->first;
153  oss << " into info space " << infoSpace_->name();
154 
155  XCEPT_RETHROW(exception::Monitoring, oss.str(), e);
156  }
157 
158  // keep a list of info space names for the fireItemGroupChanged
159  infoSpaceItemNames_.push_back(it->first);
160  }
161  }
InfoSpaceItemNames infoSpaceItemNames_
void smproxy::StatisticsReporter::reset ( void  )

Reset all monitored quantities

Definition at line 269 of file StatisticsReporter.cc.

References alarmHandler_, dataRetrieverMonCollection_, dqmConsumerMonCollection_, dqmEventMonCollection_, eventConsumerMonCollection_, stor::utils::getCurrentTime(), cmsPerfSuiteHarvest::now, and stor::MonitorCollection::reset().

270  {
272 
277 
278  alarmHandler_->clearAllAlarms();
279  }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
DataRetrieverMonitorCollection dataRetrieverMonCollection_
boost::posix_time::ptime TimePoint_t
Definition: Utils.h:35
void reset(const utils::TimePoint_t &now)
stor::AlarmHandlerPtr alarmHandler_
stor::EventConsumerMonitorCollection eventConsumerMonCollection_
stor::DQMEventMonitorCollection dqmEventMonCollection_
stor::DQMConsumerMonitorCollection dqmConsumerMonCollection_
void smproxy::StatisticsReporter::startWorkLoop ( std::string  workloopName)

Create and start the monitoring workloop

Definition at line 42 of file StatisticsReporter.cc.

References app_, doMonitoring_, alignCSCRings::e, edm::hlt::Exception, stor::utils::getCurrentTime(), stor::utils::getIdentifier(), lastMonitorAction_, monitorAction(), monitorWL_, lumiQueryAPI::msg, and AlCaHLTBitMon_QueryRunRegistry::string.

43  {
44  if ( !doMonitoring_ ) return;
45 
46  try
47  {
48  std::string identifier =
49  stor::utils::getIdentifier(app_->getApplicationDescriptor());
50 
51  monitorWL_=
52  toolbox::task::getWorkLoopFactory()->getWorkLoop(
53  identifier + workloopName, "waiting");
54 
55  if ( ! monitorWL_->isActive() )
56  {
57  toolbox::task::ActionSignature* monitorAction =
58  toolbox::task::bind(this, &StatisticsReporter::monitorAction,
59  identifier + "MonitorAction");
60  monitorWL_->submit(monitorAction);
61 
63  monitorWL_->activate();
64  }
65  }
66  catch (xcept::Exception& e)
67  {
69  "Failed to start workloop 'StatisticsReporter' with 'MonitorAction'.";
70  XCEPT_RETHROW(exception::Monitoring, msg, e);
71  }
72  }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
toolbox::task::WorkLoop * monitorWL_
stor::utils::TimePoint_t lastMonitorAction_
bool monitorAction(toolbox::task::WorkLoop *)
std::string getIdentifier(xdaq::ApplicationDescriptor *)
Definition: Utils.cc:72
void smproxy::StatisticsReporter::updateInfoSpace ( )
private

Definition at line 224 of file StatisticsReporter.cc.

References dataRetrieverMonCollection_, dqmConsumerMonCollection_, dqmEventMonCollection_, alignCSCRings::e, eventConsumerMonCollection_, cppFunctionSkipper::exception, edm::hlt::Exception, infoSpace_, infoSpaceItemNames_, AlCaHLTBitMon_QueryRunRegistry::string, and stor::MonitorCollection::updateInfoSpaceItems().

Referenced by monitorAction().

225  {
226  std::string errorMsg =
227  "Failed to update values of items in info space " + infoSpace_->name();
228 
229  // Lock the infospace to assure that all items are consistent
230  try
231  {
232  infoSpace_->lock();
233 
238 
239  infoSpace_->unlock();
240  }
241  catch(std::exception &e)
242  {
243  infoSpace_->unlock();
244 
245  errorMsg += ": ";
246  errorMsg += e.what();
247  XCEPT_RAISE(exception::Monitoring, errorMsg);
248  }
249  catch (...)
250  {
251  infoSpace_->unlock();
252 
253  errorMsg += " : unknown exception";
254  XCEPT_RAISE(exception::Monitoring, errorMsg);
255  }
256 
257  try
258  {
259  // The fireItemGroupChanged locks the infospace
260  infoSpace_->fireItemGroupChanged(infoSpaceItemNames_, this);
261  }
262  catch (xdata::exception::Exception &e)
263  {
264  XCEPT_RETHROW(exception::Monitoring, errorMsg, e);
265  }
266  }
DataRetrieverMonitorCollection dataRetrieverMonCollection_
stor::EventConsumerMonitorCollection eventConsumerMonCollection_
stor::DQMEventMonitorCollection dqmEventMonCollection_
stor::DQMConsumerMonitorCollection dqmConsumerMonCollection_
InfoSpaceItemNames infoSpaceItemNames_

Member Data Documentation

stor::AlarmHandlerPtr smproxy::StatisticsReporter::alarmHandler_
private

Definition at line 118 of file StatisticsReporter.h.

Referenced by alarmHandler(), and reset().

xdaq::Application* smproxy::StatisticsReporter::app_
private

Definition at line 117 of file StatisticsReporter.h.

Referenced by createMonitoringInfoSpace(), monitorAction(), and startWorkLoop().

DataRetrieverMonitorCollection smproxy::StatisticsReporter::dataRetrieverMonCollection_
private
bool smproxy::StatisticsReporter::doMonitoring_
private

Definition at line 127 of file StatisticsReporter.h.

Referenced by monitorAction(), startWorkLoop(), and ~StatisticsReporter().

stor::DQMConsumerMonitorCollection smproxy::StatisticsReporter::dqmConsumerMonCollection_
private
stor::DQMEventMonitorCollection smproxy::StatisticsReporter::dqmEventMonCollection_
private
stor::EventConsumerMonitorCollection smproxy::StatisticsReporter::eventConsumerMonCollection_
private
xdata::InfoSpace* smproxy::StatisticsReporter::infoSpace_
private

Definition at line 130 of file StatisticsReporter.h.

Referenced by createMonitoringInfoSpace(), and updateInfoSpace().

InfoSpaceItemNames smproxy::StatisticsReporter::infoSpaceItemNames_
private

Definition at line 131 of file StatisticsReporter.h.

Referenced by collectInfoSpaceItems(), and updateInfoSpace().

stor::utils::TimePoint_t smproxy::StatisticsReporter::lastMonitorAction_
private

Definition at line 120 of file StatisticsReporter.h.

Referenced by monitorAction(), and startWorkLoop().

stor::utils::Duration_t smproxy::StatisticsReporter::monitoringSleepSec_
private

Definition at line 119 of file StatisticsReporter.h.

Referenced by monitorAction().

toolbox::task::WorkLoop* smproxy::StatisticsReporter::monitorWL_
private

Definition at line 126 of file StatisticsReporter.h.

Referenced by startWorkLoop(), and ~StatisticsReporter().