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 Attributes
smproxy::StateMachine Class Reference

#include <StateMachine.h>

Inheritance diagram for smproxy::StateMachine:

Public Member Functions

void clearConsumerRegistrations ()
 
void clearInitMsgCollection ()
 
void clearQueues ()
 
void disableConsumerRegistration ()
 
void enableConsumerRegistration ()
 
void failEvent (const Fail &)
 
xdaq::ApplicationDescriptor * getApplicationDescriptor () const
 
ConfigurationPtr getConfiguration () const
 
DataManagerPtr getDataManager () const
 
stor::DQMEventQueueCollectionPtr getDQMEventQueueCollection () const
 
EventQueueCollectionPtr getEventQueueCollection () const
 
std::string getExternallyVisibleStateName ()
 
stor::InitMsgCollectionPtr getInitMsgCollection () const
 
std::string getReasonForFailed ()
 
stor::RegistrationCollectionPtr getRegistrationCollection () const
 
stor::RegistrationQueuePtr getRegistrationQueue () const
 
std::string getStateName ()
 
StatisticsReporterPtr getStatisticsReporter () const
 
void moveToFailedState (xcept::Exception &e)
 
std::string processEvent (const boost::statechart::event_base &)
 
void resetStatistics ()
 
void setExternallyVisibleStateName (const std::string &stateName)
 
void setQueueSizes ()
 
 StateMachine (xdaq::Application *)
 
void unconsumed_event (const boost::statechart::event_base &)
 
void updateConfiguration ()
 

Private Attributes

xdaq::Application * app_
 
std::string appNameAndInstance_
 
ConfigurationPtr configuration_
 
DataManagerPtr dataManager_
 
stor::DQMEventQueueCollectionPtr dqmEventQueueCollection_
 
boost::mutex eventMutex_
 
EventQueueCollectionPtr eventQueueCollection_
 
stor::InitMsgCollectionPtr initMsgCollection_
 
xdaq2rc::RcmsStateNotifier rcmsStateNotifier_
 
std::string reasonForFailed_
 
stor::RegistrationCollectionPtr registrationCollection_
 
stor::RegistrationQueuePtr registrationQueue_
 
xdata::String stateName_
 
StatisticsReporterPtr statisticsReporter_
 

Detailed Description

Definition at line 68 of file StateMachine.h.

Constructor & Destructor Documentation

smproxy::StateMachine::StateMachine ( xdaq::Application *  app)

Definition at line 20 of file StateMachine.cc.

References edm::errors::Configuration.

22  :
23  app_(app),
25  (
26  app->getApplicationLogger(),
27  app->getApplicationDescriptor(),
28  app->getApplicationContext()
29  ),
30  reasonForFailed_(""),
31  stateName_("Halted")
32  {
33  std::ostringstream oss;
34  oss << app->getApplicationDescriptor()->getClassName()
35  << app->getApplicationDescriptor()->getInstance();
36  appNameAndInstance_ = oss.str();
37 
38  xdata::InfoSpace *is = app->getApplicationInfoSpace();
39  is->fireItemAvailable("rcmsStateListener",
40  rcmsStateNotifier_.getRcmsStateListenerParameter() );
41  is->fireItemAvailable("foundRcmsStateListener",
42  rcmsStateNotifier_.getFoundRcmsStateListenerParameter() );
43  rcmsStateNotifier_.findRcmsStateListener();
44  rcmsStateNotifier_.subscribeToChangesInRcmsStateListener(is);
45 
46  is->fireItemAvailable("stateName", &stateName_);
47 
48  initiate();
49 
50  configuration_.reset(new Configuration(
51  app->getApplicationInfoSpace(), app->getApplicationDescriptor()->getInstance()
52  ));
53 
55 
57  configuration_->getQueueConfigurationParams().registrationQueueSize_
58  ));
59 
61 
62  statisticsReporter_.reset(new StatisticsReporter(app,
63  configuration_->getQueueConfigurationParams()));
64 
66  statisticsReporter_->getEventConsumerMonitorCollection()));
67 
69  statisticsReporter_->getDQMConsumerMonitorCollection()));
70 
71  dataManager_.reset(new DataManager(this));
72  }
ConfigurationPtr configuration_
Definition: StateMachine.h:126
std::string appNameAndInstance_
Definition: StateMachine.h:137
xdaq::Application * app_
Definition: StateMachine.h:124
StatisticsReporterPtr statisticsReporter_
Definition: StateMachine.h:131
DataManagerPtr dataManager_
Definition: StateMachine.h:127
stor::QueueCollection< EventMsg > EventQueueCollection
stor::RegistrationQueuePtr registrationQueue_
Definition: StateMachine.h:129
std::string reasonForFailed_
Definition: StateMachine.h:138
stor::DQMEventQueueCollectionPtr dqmEventQueueCollection_
Definition: StateMachine.h:133
EventQueueCollectionPtr eventQueueCollection_
Definition: StateMachine.h:132
stor::RegistrationCollectionPtr registrationCollection_
Definition: StateMachine.h:128
xdata::String stateName_
Definition: StateMachine.h:139
stor::InitMsgCollectionPtr initMsgCollection_
Definition: StateMachine.h:130
xdaq2rc::RcmsStateNotifier rcmsStateNotifier_
Definition: StateMachine.h:125

Member Function Documentation

void smproxy::StateMachine::clearConsumerRegistrations ( )

Definition at line 169 of file StateMachine.cc.

References dqmEventQueueCollection_, eventQueueCollection_, and registrationCollection_.

170  {
171  registrationCollection_->clearRegistrations();
172  eventQueueCollection_->removeQueues();
173  dqmEventQueueCollection_->removeQueues();
174  }
stor::DQMEventQueueCollectionPtr dqmEventQueueCollection_
Definition: StateMachine.h:133
EventQueueCollectionPtr eventQueueCollection_
Definition: StateMachine.h:132
stor::RegistrationCollectionPtr registrationCollection_
Definition: StateMachine.h:128
void smproxy::StateMachine::clearInitMsgCollection ( )

Definition at line 157 of file StateMachine.cc.

References initMsgCollection_.

158  {
159  initMsgCollection_->clear();
160  }
stor::InitMsgCollectionPtr initMsgCollection_
Definition: StateMachine.h:130
void smproxy::StateMachine::clearQueues ( )

Definition at line 191 of file StateMachine.cc.

References dqmEventQueueCollection_, eventQueueCollection_, and registrationQueue_.

192  {
193  registrationQueue_->clear();
194  eventQueueCollection_->clearQueues();
195  dqmEventQueueCollection_->clearQueues();
196  }
stor::RegistrationQueuePtr registrationQueue_
Definition: StateMachine.h:129
stor::DQMEventQueueCollectionPtr dqmEventQueueCollection_
Definition: StateMachine.h:133
EventQueueCollectionPtr eventQueueCollection_
Definition: StateMachine.h:132
void smproxy::StateMachine::disableConsumerRegistration ( )

Definition at line 184 of file StateMachine.cc.

References dataManager_, and registrationCollection_.

185  {
186  registrationCollection_->disableConsumerRegistration();
187  dataManager_->stop();
188  }
DataManagerPtr dataManager_
Definition: StateMachine.h:127
stor::RegistrationCollectionPtr registrationCollection_
Definition: StateMachine.h:128
void smproxy::StateMachine::enableConsumerRegistration ( )

Definition at line 177 of file StateMachine.cc.

References configuration_, dataManager_, and registrationCollection_.

178  {
179  registrationCollection_->enableConsumerRegistration();
180  dataManager_->start(configuration_->getDataRetrieverParams());
181  }
ConfigurationPtr configuration_
Definition: StateMachine.h:126
DataManagerPtr dataManager_
Definition: StateMachine.h:127
stor::RegistrationCollectionPtr registrationCollection_
Definition: StateMachine.h:128
void smproxy::StateMachine::failEvent ( const Fail evt)

Definition at line 92 of file StateMachine.cc.

References app_, smproxy::Fail::getException(), smproxy::Fail::getReason(), smproxy::Fail::getTraceback(), rcmsStateNotifier_, reasonForFailed_, and stateName_.

93  {
94  stateName_ = "Failed";
95  reasonForFailed_ = evt.getTraceback();
96 
97  LOG4CPLUS_FATAL(app_->getApplicationLogger(),
98  "Failed: " << evt.getReason() << ". " << reasonForFailed_);
99 
100  rcmsStateNotifier_.stateChanged(stateName_, evt.getReason());
101 
102  app_->notifyQualified("fatal", evt.getException());
103  }
xdaq::Application * app_
Definition: StateMachine.h:124
std::string reasonForFailed_
Definition: StateMachine.h:138
xdata::String stateName_
Definition: StateMachine.h:139
xdaq2rc::RcmsStateNotifier rcmsStateNotifier_
Definition: StateMachine.h:125
xdaq::ApplicationDescriptor* smproxy::StateMachine::getApplicationDescriptor ( ) const
inline

Definition at line 109 of file StateMachine.h.

References app_.

110  { return app_->getApplicationDescriptor(); }
xdaq::Application * app_
Definition: StateMachine.h:124
ConfigurationPtr smproxy::StateMachine::getConfiguration ( ) const
inline

Definition at line 93 of file StateMachine.h.

References configuration_.

Referenced by smproxy::DQMArchiver::createRegistration().

94  { return configuration_; }
ConfigurationPtr configuration_
Definition: StateMachine.h:126
DataManagerPtr smproxy::StateMachine::getDataManager ( ) const
inline

Definition at line 95 of file StateMachine.h.

References dataManager_.

96  { return dataManager_; }
DataManagerPtr dataManager_
Definition: StateMachine.h:127
stor::DQMEventQueueCollectionPtr smproxy::StateMachine::getDQMEventQueueCollection ( ) const
inline

Definition at line 105 of file StateMachine.h.

References dqmEventQueueCollection_.

Referenced by smproxy::DataManager::checkForStaleConsumers().

106  { return dqmEventQueueCollection_; }
stor::DQMEventQueueCollectionPtr dqmEventQueueCollection_
Definition: StateMachine.h:133
EventQueueCollectionPtr smproxy::StateMachine::getEventQueueCollection ( ) const
inline

Definition at line 103 of file StateMachine.h.

References eventQueueCollection_.

Referenced by smproxy::DataManager::checkForStaleConsumers().

104  { return eventQueueCollection_; }
EventQueueCollectionPtr eventQueueCollection_
Definition: StateMachine.h:132
std::string smproxy::StateMachine::getExternallyVisibleStateName ( )
inline

Definition at line 90 of file StateMachine.h.

References stateName_.

91  { return stateName_.toString(); }
xdata::String stateName_
Definition: StateMachine.h:139
stor::InitMsgCollectionPtr smproxy::StateMachine::getInitMsgCollection ( ) const
inline

Definition at line 101 of file StateMachine.h.

References initMsgCollection_.

102  { return initMsgCollection_; }
stor::InitMsgCollectionPtr initMsgCollection_
Definition: StateMachine.h:130
std::string smproxy::StateMachine::getReasonForFailed ( )
inline

Definition at line 86 of file StateMachine.h.

References reasonForFailed_.

87  { return reasonForFailed_; }
std::string reasonForFailed_
Definition: StateMachine.h:138
stor::RegistrationCollectionPtr smproxy::StateMachine::getRegistrationCollection ( ) const
inline

Definition at line 97 of file StateMachine.h.

References registrationCollection_.

Referenced by smproxy::DQMArchiver::createRegistration(), and smproxy::DQMArchiver::doIt().

98  { return registrationCollection_; }
stor::RegistrationCollectionPtr registrationCollection_
Definition: StateMachine.h:128
stor::RegistrationQueuePtr smproxy::StateMachine::getRegistrationQueue ( ) const
inline

Definition at line 99 of file StateMachine.h.

References registrationQueue_.

100  { return registrationQueue_; }
stor::RegistrationQueuePtr registrationQueue_
Definition: StateMachine.h:129
std::string smproxy::StateMachine::getStateName ( )
inline

Definition at line 88 of file StateMachine.h.

89  { return state_cast<const StateName&>().stateName(); }
StatisticsReporterPtr smproxy::StateMachine::getStatisticsReporter ( ) const
inline

Definition at line 107 of file StateMachine.h.

References statisticsReporter_.

108  { return statisticsReporter_; }
StatisticsReporterPtr statisticsReporter_
Definition: StateMachine.h:131
void smproxy::StateMachine::moveToFailedState ( xcept::Exception &  e)
inline
std::string smproxy::StateMachine::processEvent ( const boost::statechart::event_base &  event)

Definition at line 75 of file StateMachine.cc.

References eventMutex_.

Referenced by moveToFailedState().

76  {
77  boost::mutex::scoped_lock sl(eventMutex_);
78  process_event(event);
79  return state_cast<const StateName&>().stateName();
80  }
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
boost::mutex eventMutex_
Definition: StateMachine.h:135
void smproxy::StateMachine::resetStatistics ( )

Definition at line 163 of file StateMachine.cc.

References statisticsReporter_.

164  {
165  statisticsReporter_->reset();
166  }
StatisticsReporterPtr statisticsReporter_
Definition: StateMachine.h:131
void smproxy::StateMachine::setExternallyVisibleStateName ( const std::string &  stateName)

Definition at line 83 of file StateMachine.cc.

References appNameAndInstance_, rcmsStateNotifier_, and stateName_.

84  {
85  stateName_ = stateName;
86  rcmsStateNotifier_.stateChanged(stateName,
87  appNameAndInstance_ + " has reached target state " +
88  stateName);
89  }
std::string appNameAndInstance_
Definition: StateMachine.h:137
xdata::String stateName_
Definition: StateMachine.h:139
xdaq2rc::RcmsStateNotifier rcmsStateNotifier_
Definition: StateMachine.h:125
void smproxy::StateMachine::setQueueSizes ( )

Definition at line 148 of file StateMachine.cc.

References configuration_, registrationQueue_, and smproxy::QueueConfigurationParams::registrationQueueSize_.

149  {
150  QueueConfigurationParams queueParams =
151  configuration_->getQueueConfigurationParams();
153  setCapacity(queueParams.registrationQueueSize_);
154  }
ConfigurationPtr configuration_
Definition: StateMachine.h:126
stor::RegistrationQueuePtr registrationQueue_
Definition: StateMachine.h:129
void smproxy::StateMachine::unconsumed_event ( const boost::statechart::event_base &  evt)

Definition at line 106 of file StateMachine.cc.

References app_, AlCaRecoCosmics_cfg::name, and stateName_.

107  {
108  LOG4CPLUS_ERROR(app_->getApplicationLogger(),
109  "The " << typeid(evt).name()
110  << " event is not supported from the "
111  << stateName_.toString() << " state!");
112  }
xdaq::Application * app_
Definition: StateMachine.h:124
xdata::String stateName_
Definition: StateMachine.h:139
void smproxy::StateMachine::updateConfiguration ( )

Definition at line 115 of file StateMachine.cc.

References edm::errors::Configuration, configuration_, ExpressReco_HICollisions_FallBack::e, cmsCodeRules.cppFunctionSkipper::exception, edm::hlt::Exception, and moveToFailedState().

116  {
117  std::string errorMsg = "Failed to update configuration parameters";
118  try
119  {
120  configuration_->updateAllParams();
121  }
122  catch(xcept::Exception &e)
123  {
124  XCEPT_DECLARE_NESTED(exception::Configuration,
125  sentinelException, errorMsg, e);
126  moveToFailedState(sentinelException);
127  }
128  catch( std::exception &e )
129  {
130  errorMsg.append(": ");
131  errorMsg.append( e.what() );
132 
133  XCEPT_DECLARE(exception::Configuration,
134  sentinelException, errorMsg);
135  moveToFailedState(sentinelException);
136  }
137  catch(...)
138  {
139  errorMsg.append(": unknown exception");
140 
141  XCEPT_DECLARE(exception::Configuration,
142  sentinelException, errorMsg);
143  moveToFailedState(sentinelException);
144  }
145  }
ConfigurationPtr configuration_
Definition: StateMachine.h:126
void moveToFailedState(xcept::Exception &e)
Definition: StateMachine.h:79

Member Data Documentation

xdaq::Application* smproxy::StateMachine::app_
private

Definition at line 124 of file StateMachine.h.

Referenced by failEvent(), getApplicationDescriptor(), and unconsumed_event().

std::string smproxy::StateMachine::appNameAndInstance_
private

Definition at line 137 of file StateMachine.h.

Referenced by setExternallyVisibleStateName().

ConfigurationPtr smproxy::StateMachine::configuration_
private
DataManagerPtr smproxy::StateMachine::dataManager_
private
stor::DQMEventQueueCollectionPtr smproxy::StateMachine::dqmEventQueueCollection_
private
boost::mutex smproxy::StateMachine::eventMutex_
mutableprivate

Definition at line 135 of file StateMachine.h.

Referenced by processEvent().

EventQueueCollectionPtr smproxy::StateMachine::eventQueueCollection_
private
stor::InitMsgCollectionPtr smproxy::StateMachine::initMsgCollection_
private

Definition at line 130 of file StateMachine.h.

Referenced by clearInitMsgCollection(), and getInitMsgCollection().

xdaq2rc::RcmsStateNotifier smproxy::StateMachine::rcmsStateNotifier_
private

Definition at line 125 of file StateMachine.h.

Referenced by failEvent(), and setExternallyVisibleStateName().

std::string smproxy::StateMachine::reasonForFailed_
private

Definition at line 138 of file StateMachine.h.

Referenced by failEvent(), and getReasonForFailed().

stor::RegistrationCollectionPtr smproxy::StateMachine::registrationCollection_
private
stor::RegistrationQueuePtr smproxy::StateMachine::registrationQueue_
private

Definition at line 129 of file StateMachine.h.

Referenced by clearQueues(), getRegistrationQueue(), and setQueueSizes().

xdata::String smproxy::StateMachine::stateName_
private
StatisticsReporterPtr smproxy::StateMachine::statisticsReporter_
private

Definition at line 131 of file StateMachine.h.

Referenced by getStatisticsReporter(), and resetStatistics().