CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

smproxy::StatisticsReporter Class Reference

#include <StatisticsReporter.h>

List of all members.

Public Member Functions

virtual void actionPerformed (xdata::Event &)
stor::AlarmHandlerPtr alarmHandler ()
DataRetrieverMonitorCollectiongetDataRetrieverMonitorCollection ()
const
DataRetrieverMonitorCollection
getDataRetrieverMonitorCollection () const
const
stor::DQMConsumerMonitorCollection
getDQMConsumerMonitorCollection () const
stor::DQMConsumerMonitorCollectiongetDQMConsumerMonitorCollection ()
const
stor::DQMEventMonitorCollection
getDQMEventMonitorCollection () const
stor::DQMEventMonitorCollectiongetDQMEventMonitorCollection ()
stor::EventConsumerMonitorCollectiongetEventConsumerMonitorCollection ()
const
stor::EventConsumerMonitorCollection
getEventConsumerMonitorCollection () const
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

typedef std::list<std::string> smproxy::StatisticsReporter::InfoSpaceItemNames [private]

Definition at line 104 of file StatisticsReporter.h.


Constructor & Destructor Documentation

smproxy::StatisticsReporter::StatisticsReporter ( xdaq::Application *  app,
const QueueConfigurationParams qcp 
) [explicit]
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]

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.

  {}
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]
void smproxy::StatisticsReporter::collectInfoSpaceItems ( ) [private]
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_.

DataRetrieverMonitorCollection& smproxy::StatisticsReporter::getDataRetrieverMonitorCollection ( ) [inline]

Definition at line 57 of file StatisticsReporter.h.

References dataRetrieverMonCollection_.

stor::DQMConsumerMonitorCollection& smproxy::StatisticsReporter::getDQMConsumerMonitorCollection ( ) [inline]

Definition at line 77 of file StatisticsReporter.h.

References dqmConsumerMonCollection_.

const stor::DQMConsumerMonitorCollection& smproxy::StatisticsReporter::getDQMConsumerMonitorCollection ( ) const [inline]

Definition at line 74 of file StatisticsReporter.h.

References dqmConsumerMonCollection_.

stor::DQMEventMonitorCollection& smproxy::StatisticsReporter::getDQMEventMonitorCollection ( ) [inline]

Definition at line 63 of file StatisticsReporter.h.

References dqmEventMonCollection_.

const stor::DQMEventMonitorCollection& smproxy::StatisticsReporter::getDQMEventMonitorCollection ( ) const [inline]

Definition at line 60 of file StatisticsReporter.h.

References dqmEventMonCollection_.

const stor::EventConsumerMonitorCollection& smproxy::StatisticsReporter::getEventConsumerMonitorCollection ( ) const [inline]

Definition at line 67 of file StatisticsReporter.h.

References eventConsumerMonCollection_.

stor::EventConsumerMonitorCollection& smproxy::StatisticsReporter::getEventConsumerMonitorCollection ( ) [inline]

Definition at line 70 of file StatisticsReporter.h.

References 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  )
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);
    }
  }

Member Data Documentation

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 127 of file StatisticsReporter.h.

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

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().