#include <StatisticsReporter.h>
Singleton to keep track of all monitoring and statistics issues
This class also starts the monitoring workloop to update the statistics for all MonitorCollections.
Definition at line 42 of file StatisticsReporter.h.
typedef std::list<std::string> smproxy::StatisticsReporter::InfoSpaceItemNames [private] |
Definition at line 104 of file StatisticsReporter.h.
smproxy::StatisticsReporter::StatisticsReporter | ( | xdaq::Application * | app, |
const QueueConfigurationParams & | qcp | ||
) | [explicit] |
Definition at line 23 of file StatisticsReporter.cc.
References reset().
: app_(app), alarmHandler_(new stor::AlarmHandler(app)), monitoringSleepSec_(qcp.monitoringSleepSec_), dataRetrieverMonCollection_(monitoringSleepSec_, alarmHandler_), dqmEventMonCollection_(monitoringSleepSec_*5), eventConsumerMonCollection_(monitoringSleepSec_), dqmConsumerMonCollection_(monitoringSleepSec_), doMonitoring_(monitoringSleepSec_>boost::posix_time::seconds(0)) { reset(); createMonitoringInfoSpace(); collectInfoSpaceItems(); }
smproxy::StatisticsReporter::~StatisticsReporter | ( | ) | [virtual] |
Definition at line 75 of file StatisticsReporter.cc.
References doMonitoring_, and monitorWL_.
{ // Stop the monitoring activity doMonitoring_ = false; // Cancel the workloop (will wait until the action has finished) if ( monitorWL_ && monitorWL_->isActive() ) monitorWL_->cancel(); }
smproxy::StatisticsReporter::StatisticsReporter | ( | StatisticsReporter const & | ) | [private] |
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.
{}
stor::AlarmHandlerPtr smproxy::StatisticsReporter::alarmHandler | ( | ) | [inline] |
Access alarm handler
Definition at line 94 of file StatisticsReporter.h.
References alarmHandler_.
{ return 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().
{ const stor::utils::TimePoint_t now = stor::utils::getCurrentTime(); dataRetrieverMonCollection_.calculateStatistics(now); dqmEventMonCollection_.calculateStatistics(now); eventConsumerMonCollection_.calculateStatistics(now); dqmConsumerMonCollection_.calculateStatistics(now); }
void smproxy::StatisticsReporter::collectInfoSpaceItems | ( | ) | [private] |
Definition at line 118 of file StatisticsReporter.cc.
References stor::MonitorCollection::appendInfoSpaceItems(), dataRetrieverMonCollection_, dqmConsumerMonCollection_, dqmEventMonCollection_, eventConsumerMonCollection_, infoSpaceItemNames_, and putItemsIntoInfoSpace().
{ stor::MonitorCollection::InfoSpaceItems infoSpaceItems; infoSpaceItemNames_.clear(); dataRetrieverMonCollection_.appendInfoSpaceItems(infoSpaceItems); dqmEventMonCollection_.appendInfoSpaceItems(infoSpaceItems); eventConsumerMonCollection_.appendInfoSpaceItems(infoSpaceItems); dqmConsumerMonCollection_.appendInfoSpaceItems(infoSpaceItems); putItemsIntoInfoSpace(infoSpaceItems); }
void smproxy::StatisticsReporter::createMonitoringInfoSpace | ( | ) | [private] |
Definition at line 85 of file StatisticsReporter.cc.
References app_, alignCSCRings::e, Exception, and infoSpace_.
{ // Create an infospace which can be monitored. std::ostringstream oss; oss << "urn:xdaq-monitorable-" << app_->getApplicationDescriptor()->getClassName(); std::string errorMsg = "Failed to create monitoring info space " + oss.str(); try { toolbox::net::URN urn = app_->createQualifiedInfoSpace(oss.str()); xdata::getInfoSpaceFactory()->lock(); infoSpace_ = xdata::getInfoSpaceFactory()->get(urn.toString()); xdata::getInfoSpaceFactory()->unlock(); } catch(xdata::exception::Exception &e) { xdata::getInfoSpaceFactory()->unlock(); XCEPT_RETHROW(exception::Infospace, errorMsg, e); } catch (...) { xdata::getInfoSpaceFactory()->unlock(); errorMsg += " : unknown exception"; XCEPT_RAISE(exception::Infospace, errorMsg); } }
const DataRetrieverMonitorCollection& smproxy::StatisticsReporter::getDataRetrieverMonitorCollection | ( | ) | const [inline] |
Definition at line 54 of file StatisticsReporter.h.
References dataRetrieverMonCollection_.
{ return dataRetrieverMonCollection_; }
DataRetrieverMonitorCollection& smproxy::StatisticsReporter::getDataRetrieverMonitorCollection | ( | ) | [inline] |
Definition at line 57 of file StatisticsReporter.h.
References dataRetrieverMonCollection_.
{ return dataRetrieverMonCollection_; }
stor::DQMConsumerMonitorCollection& smproxy::StatisticsReporter::getDQMConsumerMonitorCollection | ( | ) | [inline] |
Definition at line 77 of file StatisticsReporter.h.
References dqmConsumerMonCollection_.
{ return dqmConsumerMonCollection_; }
const stor::DQMConsumerMonitorCollection& smproxy::StatisticsReporter::getDQMConsumerMonitorCollection | ( | ) | const [inline] |
Definition at line 74 of file StatisticsReporter.h.
References dqmConsumerMonCollection_.
{ return dqmConsumerMonCollection_; }
stor::DQMEventMonitorCollection& smproxy::StatisticsReporter::getDQMEventMonitorCollection | ( | ) | [inline] |
Definition at line 63 of file StatisticsReporter.h.
References dqmEventMonCollection_.
{ return dqmEventMonCollection_; }
const stor::DQMEventMonitorCollection& smproxy::StatisticsReporter::getDQMEventMonitorCollection | ( | ) | const [inline] |
Definition at line 60 of file StatisticsReporter.h.
References dqmEventMonCollection_.
{ return dqmEventMonCollection_; }
const stor::EventConsumerMonitorCollection& smproxy::StatisticsReporter::getEventConsumerMonitorCollection | ( | ) | const [inline] |
Definition at line 67 of file StatisticsReporter.h.
References eventConsumerMonCollection_.
{ return eventConsumerMonCollection_; }
stor::EventConsumerMonitorCollection& smproxy::StatisticsReporter::getEventConsumerMonitorCollection | ( | ) | [inline] |
Definition at line 70 of file StatisticsReporter.h.
References eventConsumerMonCollection_.
{ return eventConsumerMonCollection_; }
bool smproxy::StatisticsReporter::monitorAction | ( | toolbox::task::WorkLoop * | wl | ) | [private] |
Definition at line 164 of file StatisticsReporter.cc.
References app_, calculateStatistics(), doMonitoring_, alignCSCRings::e, exception, Exception, stor::utils::getCurrentTime(), lastMonitorAction_, monitoringSleepSec_, stor::utils::sleepUntil(), and updateInfoSpace().
Referenced by startWorkLoop().
{ stor::utils::sleepUntil(lastMonitorAction_ + monitoringSleepSec_); lastMonitorAction_ = stor::utils::getCurrentTime(); std::string errorMsg = "Failed to update the monitoring information"; try { calculateStatistics(); updateInfoSpace(); } catch(xcept::Exception &e) { LOG4CPLUS_ERROR(app_->getApplicationLogger(), errorMsg << xcept::stdformat_exception_history(e)); XCEPT_DECLARE_NESTED(exception::Monitoring, sentinelException, errorMsg, e); app_->notifyQualified("error", sentinelException); } catch(std::exception &e) { errorMsg += ": "; errorMsg += e.what(); LOG4CPLUS_ERROR(app_->getApplicationLogger(), errorMsg); XCEPT_DECLARE(exception::Monitoring, sentinelException, errorMsg); app_->notifyQualified("error", sentinelException); } catch(...) { errorMsg += ": Unknown exception"; LOG4CPLUS_ERROR(app_->getApplicationLogger(), errorMsg); XCEPT_DECLARE(exception::Monitoring, sentinelException, errorMsg); app_->notifyQualified("error", sentinelException); } return doMonitoring_; }
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 Exception.
Referenced by collectInfoSpaceItems().
{ for ( stor::MonitorCollection::InfoSpaceItems::const_iterator it = items.begin(), itEnd = items.end(); it != itEnd; ++it ) { try { // fireItemAvailable locks the infospace internally infoSpace_->fireItemAvailable(it->first, it->second); } catch(xdata::exception::Exception &e) { std::stringstream oss; oss << "Failed to put " << it->first; oss << " into info space " << infoSpace_->name(); XCEPT_RETHROW(exception::Monitoring, oss.str(), e); } // keep a list of info space names for the fireItemGroupChanged infoSpaceItemNames_.push_back(it->first); } }
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().
{ const stor::utils::TimePoint_t now = stor::utils::getCurrentTime(); dataRetrieverMonCollection_.reset(now); dqmEventMonCollection_.reset(now); eventConsumerMonCollection_.reset(now); dqmConsumerMonCollection_.reset(now); alarmHandler_->clearAllAlarms(); }
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, Exception, stor::utils::getCurrentTime(), stor::utils::getIdentifier(), lastMonitorAction_, monitorAction(), monitorWL_, and lumiQueryAPI::msg.
{ if ( !doMonitoring_ ) return; try { std::string identifier = stor::utils::getIdentifier(app_->getApplicationDescriptor()); monitorWL_= toolbox::task::getWorkLoopFactory()->getWorkLoop( identifier + workloopName, "waiting"); if ( ! monitorWL_->isActive() ) { toolbox::task::ActionSignature* monitorAction = toolbox::task::bind(this, &StatisticsReporter::monitorAction, identifier + "MonitorAction"); monitorWL_->submit(monitorAction); lastMonitorAction_ = stor::utils::getCurrentTime(); monitorWL_->activate(); } } catch (xcept::Exception& e) { std::string msg = "Failed to start workloop 'StatisticsReporter' with 'MonitorAction'."; XCEPT_RETHROW(exception::Monitoring, msg, e); } }
void smproxy::StatisticsReporter::updateInfoSpace | ( | ) | [private] |
Definition at line 224 of file StatisticsReporter.cc.
References dataRetrieverMonCollection_, dqmConsumerMonCollection_, dqmEventMonCollection_, alignCSCRings::e, eventConsumerMonCollection_, exception, Exception, infoSpace_, infoSpaceItemNames_, and stor::MonitorCollection::updateInfoSpaceItems().
Referenced by monitorAction().
{ std::string errorMsg = "Failed to update values of items in info space " + infoSpace_->name(); // Lock the infospace to assure that all items are consistent try { infoSpace_->lock(); dataRetrieverMonCollection_.updateInfoSpaceItems(); dqmEventMonCollection_.updateInfoSpaceItems(); eventConsumerMonCollection_.updateInfoSpaceItems(); dqmConsumerMonCollection_.updateInfoSpaceItems(); infoSpace_->unlock(); } catch(std::exception &e) { infoSpace_->unlock(); errorMsg += ": "; errorMsg += e.what(); XCEPT_RAISE(exception::Monitoring, errorMsg); } catch (...) { infoSpace_->unlock(); errorMsg += " : unknown exception"; XCEPT_RAISE(exception::Monitoring, errorMsg); } try { // The fireItemGroupChanged locks the infospace infoSpace_->fireItemGroupChanged(infoSpaceItemNames_, this); } catch (xdata::exception::Exception &e) { XCEPT_RETHROW(exception::Monitoring, errorMsg, e); } }
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().
Definition at line 122 of file StatisticsReporter.h.
Referenced by calculateStatistics(), collectInfoSpaceItems(), getDataRetrieverMonitorCollection(), reset(), and updateInfoSpace().
bool smproxy::StatisticsReporter::doMonitoring_ [private] |
Definition at line 127 of file StatisticsReporter.h.
Referenced by monitorAction(), startWorkLoop(), and ~StatisticsReporter().
Definition at line 125 of file StatisticsReporter.h.
Referenced by calculateStatistics(), collectInfoSpaceItems(), getDQMConsumerMonitorCollection(), reset(), and updateInfoSpace().
Definition at line 123 of file StatisticsReporter.h.
Referenced by calculateStatistics(), collectInfoSpaceItems(), getDQMEventMonitorCollection(), reset(), and updateInfoSpace().
stor::EventConsumerMonitorCollection smproxy::StatisticsReporter::eventConsumerMonCollection_ [private] |
Definition at line 124 of file StatisticsReporter.h.
Referenced by calculateStatistics(), collectInfoSpaceItems(), getEventConsumerMonitorCollection(), reset(), and updateInfoSpace().
xdata::InfoSpace* smproxy::StatisticsReporter::infoSpace_ [private] |
Definition at line 130 of file StatisticsReporter.h.
Referenced by createMonitoringInfoSpace(), and updateInfoSpace().
Definition at line 131 of file StatisticsReporter.h.
Referenced by collectInfoSpaceItems(), and updateInfoSpace().
Definition at line 120 of file StatisticsReporter.h.
Referenced by monitorAction(), and startWorkLoop().
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().