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::SMProxyServer Class Reference

#include <SMProxyServer.h>

Inheritance diagram for smproxy::SMProxyServer:

Public Member Functions

 SMProxyServer (xdaq::ApplicationStub *s)
 

Private Types

typedef stor::ConsumerUtils
< Configuration,
EventQueueCollection
ConsumerUtils_t
 

Private Member Functions

void bindConsumerCallbacks ()
 
void bindStateMachineCallbacks ()
 
void bindWebInterfaceCallbacks ()
 
void consumerStatisticsWebPage (xgi::Input *in, xgi::Output *out) throw ( xgi::exception::Exception )
 
void css (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
void dataRetrieverWebPage (xgi::Input *in, xgi::Output *out) throw ( xgi::exception::Exception )
 
void defaultWebPage (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
void dqmEventStatisticsWebPage (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
xoap::MessageReference handleFSMSoapMessage (xoap::MessageReference) throw ( xoap::exception::Exception )
 
void initializeSharedResources ()
 
SMProxyServeroperator= (SMProxyServer const &)
 
void processConsumerEventRequest (xgi::Input *in, xgi::Output *out) throw ( xgi::exception::Exception )
 
void processConsumerHeaderRequest (xgi::Input *in, xgi::Output *out) throw ( xgi::exception::Exception )
 
void processConsumerRegistrationRequest (xgi::Input *in, xgi::Output *out) throw ( xgi::exception::Exception )
 
void processDQMConsumerEventRequest (xgi::Input *in, xgi::Output *out) throw ( xgi::exception::Exception )
 
void processDQMConsumerRegistrationRequest (xgi::Input *in, xgi::Output *out) throw ( xgi::exception::Exception )
 
 SMProxyServer (SMProxyServer const &)
 
void startWorkerThreads ()
 

Private Attributes

boost::scoped_ptr
< ConsumerUtils_t
consumerUtils_
 
boost::scoped_ptr
< SMPSWebPageHelper
smpsWebPageHelper_
 
StateMachinePtr stateMachine_
 

Detailed Description

Main class of the SMProxyServer XDAQ application

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

Definition at line 31 of file SMProxyServer.h.

Member Typedef Documentation

Definition at line 140 of file SMProxyServer.h.

Constructor & Destructor Documentation

SMProxyServer::SMProxyServer ( xdaq::ApplicationStub *  s)

Definition at line 24 of file SMProxyServer.cc.

References bindConsumerCallbacks(), bindStateMachineCallbacks(), bindWebInterfaceCallbacks(), alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, initializeSharedResources(), and startWorkerThreads().

24  :
25  xdaq::Application(s)
26 {
27  LOG4CPLUS_INFO(this->getApplicationLogger(),"Making SMProxyServer");
28 
29  // bind all callback functions
33 
34  std::string errorMsg = "Exception in SMProxyServer constructor: ";
35  try
36  {
38  }
39  catch(std::exception &e)
40  {
41  errorMsg += e.what();
42  LOG4CPLUS_FATAL( getApplicationLogger(), e.what() );
43  XCEPT_RAISE( exception::Exception, e.what() );
44  }
45  catch(...)
46  {
47  errorMsg += "unknown exception";
48  LOG4CPLUS_FATAL( getApplicationLogger(), errorMsg );
49  XCEPT_RAISE( exception::Exception, errorMsg );
50  }
51 
53 }
smproxy::SMProxyServer::SMProxyServer ( SMProxyServer const &  )
private

Member Function Documentation

void SMProxyServer::bindConsumerCallbacks ( )
private

Bind callbacks for consumers

Definition at line 87 of file SMProxyServer.cc.

References processConsumerEventRequest(), processConsumerHeaderRequest(), processConsumerRegistrationRequest(), processDQMConsumerEventRequest(), and processDQMConsumerRegistrationRequest().

Referenced by SMProxyServer().

88 {
89  // event consumers
90  xgi::bind( this, &SMProxyServer::processConsumerRegistrationRequest, "registerConsumer" );
91  xgi::bind( this, &SMProxyServer::processConsumerHeaderRequest, "getregdata" );
92  xgi::bind( this, &SMProxyServer::processConsumerEventRequest, "geteventdata" );
93 
94  // dqm event consumers
95  xgi::bind(this,&SMProxyServer::processDQMConsumerRegistrationRequest, "registerDQMConsumer");
96  xgi::bind(this,&SMProxyServer::processDQMConsumerEventRequest, "getDQMeventdata");
97 }
void processDQMConsumerEventRequest(xgi::Input *in, xgi::Output *out)
void processConsumerRegistrationRequest(xgi::Input *in, xgi::Output *out)
void processConsumerHeaderRequest(xgi::Input *in, xgi::Output *out)
void processConsumerEventRequest(xgi::Input *in, xgi::Output *out)
void processDQMConsumerRegistrationRequest(xgi::Input *in, xgi::Output *out)
void SMProxyServer::bindStateMachineCallbacks ( )
private

Bind callbacks for state machine SOAP messages

Definition at line 56 of file SMProxyServer.cc.

References handleFSMSoapMessage().

Referenced by SMProxyServer().

57 {
58  xoap::bind( this,
60  "Configure",
61  XDAQ_NS_URI );
62  xoap::bind( this,
64  "Enable",
65  XDAQ_NS_URI );
66  xoap::bind( this,
68  "Stop",
69  XDAQ_NS_URI );
70  xoap::bind( this,
72  "Halt",
73  XDAQ_NS_URI );
74 }
xoap::MessageReference handleFSMSoapMessage(xoap::MessageReference)
void SMProxyServer::bindWebInterfaceCallbacks ( )
private

Bind callbacks for web interface

Definition at line 77 of file SMProxyServer.cc.

References consumerStatisticsWebPage(), css(), dataRetrieverWebPage(), defaultWebPage(), and dqmEventStatisticsWebPage().

Referenced by SMProxyServer().

78 {
79  xgi::bind(this,&SMProxyServer::css, "styles.css");
80  xgi::bind(this,&SMProxyServer::defaultWebPage, "Default");
81  xgi::bind(this,&SMProxyServer::dataRetrieverWebPage, "dataRetriever");
82  xgi::bind(this,&SMProxyServer::dqmEventStatisticsWebPage,"dqmEventStatistics");
83  xgi::bind(this,&SMProxyServer::consumerStatisticsWebPage,"consumerStatistics" );
84 }
void dataRetrieverWebPage(xgi::Input *in, xgi::Output *out)
void css(xgi::Input *in, xgi::Output *out)
void consumerStatisticsWebPage(xgi::Input *in, xgi::Output *out)
void defaultWebPage(xgi::Input *in, xgi::Output *out)
void dqmEventStatisticsWebPage(xgi::Input *in, xgi::Output *out)
void SMProxyServer::consumerStatisticsWebPage ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Webinterface callback creating web page showing the connected consumers

Definition at line 211 of file SMProxyServer.cc.

References alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, and dbtoconf::out.

Referenced by bindWebInterfaceCallbacks().

213 {
214 
215  std::string err_msg =
216  "Failed to create consumer web page";
217 
218  try
219  {
220  smpsWebPageHelper_->consumerStatisticsWebPage(out);
221  }
222  catch( std::exception &e )
223  {
224  err_msg += ": ";
225  err_msg += e.what();
226  LOG4CPLUS_ERROR( getApplicationLogger(), err_msg );
227  XCEPT_RAISE( xgi::exception::Exception, err_msg );
228  }
229  catch(...)
230  {
231  err_msg += ": Unknown exception";
232  LOG4CPLUS_ERROR( getApplicationLogger(), err_msg );
233  XCEPT_RAISE( xgi::exception::Exception, err_msg );
234  }
235 }
tuple out
Definition: dbtoconf.py:99
boost::scoped_ptr< SMPSWebPageHelper > smpsWebPageHelper_
void SMProxyServer::css ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Webinterface callback for style sheet

Definition at line 150 of file SMProxyServer.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by bindWebInterfaceCallbacks().

152 {
153  smpsWebPageHelper_->css(in,out);
154 }
tuple out
Definition: dbtoconf.py:99
boost::scoped_ptr< SMPSWebPageHelper > smpsWebPageHelper_
void SMProxyServer::dataRetrieverWebPage ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Webinterface callback creating web page showing the data retrieval

Definition at line 184 of file SMProxyServer.cc.

References alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, and dbtoconf::out.

Referenced by bindWebInterfaceCallbacks().

186 {
187 
188  std::string err_msg =
189  "Failed to create data retriever web page";
190 
191  try
192  {
193  smpsWebPageHelper_->dataRetrieverWebPage(out);
194  }
195  catch( std::exception &e )
196  {
197  err_msg += ": ";
198  err_msg += e.what();
199  LOG4CPLUS_ERROR( getApplicationLogger(), err_msg );
200  XCEPT_RAISE( xgi::exception::Exception, err_msg );
201  }
202  catch(...)
203  {
204  err_msg += ": Unknown exception";
205  LOG4CPLUS_ERROR( getApplicationLogger(), err_msg );
206  XCEPT_RAISE( xgi::exception::Exception, err_msg );
207  }
208 }
tuple out
Definition: dbtoconf.py:99
boost::scoped_ptr< SMPSWebPageHelper > smpsWebPageHelper_
void SMProxyServer::defaultWebPage ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Webinterface callback creating default web page

Definition at line 157 of file SMProxyServer.cc.

References alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, and dbtoconf::out.

Referenced by bindWebInterfaceCallbacks().

159 {
160  std::string errorMsg = "Failed to create the default webpage";
161 
162  try
163  {
164  smpsWebPageHelper_->defaultWebPage(out);
165  }
166  catch(std::exception &e)
167  {
168  errorMsg += ": ";
169  errorMsg += e.what();
170 
171  LOG4CPLUS_ERROR(getApplicationLogger(), errorMsg);
172  XCEPT_RAISE(xgi::exception::Exception, errorMsg);
173  }
174  catch(...)
175  {
176  errorMsg += ": Unknown exception";
177 
178  LOG4CPLUS_ERROR(getApplicationLogger(), errorMsg);
179  XCEPT_RAISE(xgi::exception::Exception, errorMsg);
180  }
181 }
tuple out
Definition: dbtoconf.py:99
boost::scoped_ptr< SMPSWebPageHelper > smpsWebPageHelper_
void SMProxyServer::dqmEventStatisticsWebPage ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Webinterface callback creating web page showing statistics about the processed DQM events.

Definition at line 238 of file SMProxyServer.cc.

References alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, and dbtoconf::out.

Referenced by bindWebInterfaceCallbacks().

240 {
241  std::string errorMsg = "Failed to create the DQM event statistics webpage";
242 
243  try
244  {
245  smpsWebPageHelper_->dqmEventStatisticsWebPage(out);
246  }
247  catch(std::exception &e)
248  {
249  errorMsg += ": ";
250  errorMsg += e.what();
251 
252  LOG4CPLUS_ERROR(getApplicationLogger(), errorMsg);
253  XCEPT_RAISE(xgi::exception::Exception, errorMsg);
254  }
255  catch(...)
256  {
257  errorMsg += ": Unknown exception";
258 
259  LOG4CPLUS_ERROR(getApplicationLogger(), errorMsg);
260  XCEPT_RAISE(xgi::exception::Exception, errorMsg);
261  }
262 }
tuple out
Definition: dbtoconf.py:99
boost::scoped_ptr< SMPSWebPageHelper > smpsWebPageHelper_
xoap::MessageReference SMProxyServer::handleFSMSoapMessage ( xoap::MessageReference  msg)
throw (xoap::exception::Exception
)
private

Callback for SOAP message containint a state machine event, possibly including new configuration values

Definition at line 269 of file SMProxyServer.cc.

References edmPickEvents::command, stor::soaputils::createFsmSoapResponseMsg(), alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, cms::Exception::explainSelf(), stor::soaputils::extractParameters(), and lumiQueryAPI::msg.

Referenced by bindStateMachineCallbacks().

271 {
272  std::string errorMsg;
273  xoap::MessageReference returnMsg;
274 
275  try {
276  errorMsg = "Failed to extract FSM event and parameters from SOAP message: ";
277  std::string command = stor::soaputils::extractParameters(msg, this);
278  std::string newState = "unknown";
279 
280  errorMsg = "Failed to process '" + command + "' state machine event: ";
281  if (command == "Configure")
282  {
283  newState = stateMachine_->processEvent( Configure() );
284  }
285  else if (command == "Enable")
286  {
287  newState = stateMachine_->processEvent( Enable() );
288  }
289  else if (command == "Stop")
290  {
291  newState = stateMachine_->processEvent( Stop() );
292  }
293  else if (command == "Halt")
294  {
295  newState = stateMachine_->processEvent( Halt() );
296  }
297  else
298  {
299  XCEPT_RAISE(exception::StateMachine,
300  "Received an unknown state machine event '" + command + "'.");
301  }
302 
303  errorMsg = "Failed to create FSM SOAP reply message: ";
304  returnMsg = stor::soaputils::createFsmSoapResponseMsg(command, newState);
305  }
306  catch (cms::Exception& e) {
307  errorMsg += e.explainSelf();
308  XCEPT_DECLARE(xoap::exception::Exception,
309  sentinelException, errorMsg);
310  stateMachine_->moveToFailedState(sentinelException);
311  }
312  catch (xcept::Exception &e) {
313  XCEPT_DECLARE_NESTED(xoap::exception::Exception,
314  sentinelException, errorMsg, e);
315  stateMachine_->moveToFailedState(sentinelException);
316  }
317  catch (std::exception& e) {
318  errorMsg += e.what();
319  XCEPT_DECLARE(xoap::exception::Exception,
320  sentinelException, errorMsg);
321  stateMachine_->moveToFailedState(sentinelException);
322  }
323  catch (...) {
324  errorMsg += "Unknown exception";
325  XCEPT_DECLARE(xoap::exception::Exception,
326  sentinelException, errorMsg);
327  stateMachine_->moveToFailedState(sentinelException);
328  }
329 
330  return returnMsg;
331 }
StateMachinePtr stateMachine_
virtual std::string explainSelf() const
Definition: Exception.cc:146
xoap::MessageReference createFsmSoapResponseMsg(const std::string commandName, const std::string currentState)
Definition: SoapUtils.cc:38
std::string extractParameters(xoap::MessageReference, xdaq::Application *)
Definition: SoapUtils.cc:25
void SMProxyServer::initializeSharedResources ( )
private

Initialize the shared resources

Definition at line 100 of file SMProxyServer.cc.

References consumerUtils_, smpsWebPageHelper_, and stateMachine_.

Referenced by SMProxyServer().

101 {
102  stateMachine_.reset( new StateMachine(this) );
103 
104  consumerUtils_.reset( new ConsumerUtils_t (
105  stateMachine_->getConfiguration(),
106  stateMachine_->getRegistrationCollection(),
107  stateMachine_->getRegistrationQueue(),
108  stateMachine_->getInitMsgCollection(),
109  stateMachine_->getEventQueueCollection(),
110  stateMachine_->getDQMEventQueueCollection(),
111  stateMachine_->getStatisticsReporter()->alarmHandler()
112  ) );
113 
115  getApplicationDescriptor(), stateMachine_));
116 }
stor::ConsumerUtils< Configuration, EventQueueCollection > ConsumerUtils_t
StateMachinePtr stateMachine_
boost::scoped_ptr< ConsumerUtils_t > consumerUtils_
boost::scoped_ptr< SMPSWebPageHelper > smpsWebPageHelper_
SMProxyServer& smproxy::SMProxyServer::operator= ( SMProxyServer const &  )
private
void SMProxyServer::processConsumerEventRequest ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Callback handling event consumer event request

Definition at line 355 of file SMProxyServer.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by bindConsumerCallbacks().

357 {
358  consumerUtils_->processConsumerEventRequest(in,out);
359 }
boost::scoped_ptr< ConsumerUtils_t > consumerUtils_
tuple out
Definition: dbtoconf.py:99
void SMProxyServer::processConsumerHeaderRequest ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Callback handling event consumer init message request

Definition at line 347 of file SMProxyServer.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by bindConsumerCallbacks().

349 {
350  consumerUtils_->processConsumerHeaderRequest(in,out);
351 }
boost::scoped_ptr< ConsumerUtils_t > consumerUtils_
tuple out
Definition: dbtoconf.py:99
void SMProxyServer::processConsumerRegistrationRequest ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Callback handling event consumer registration request

Definition at line 339 of file SMProxyServer.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by bindConsumerCallbacks().

341 {
342  consumerUtils_->processConsumerRegistrationRequest(in,out);
343 }
boost::scoped_ptr< ConsumerUtils_t > consumerUtils_
tuple out
Definition: dbtoconf.py:99
void SMProxyServer::processDQMConsumerEventRequest ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Callback handling DQM event consumer DQM event request

Definition at line 371 of file SMProxyServer.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by bindConsumerCallbacks().

373 {
374  consumerUtils_->processDQMConsumerEventRequest(in,out);
375 }
boost::scoped_ptr< ConsumerUtils_t > consumerUtils_
tuple out
Definition: dbtoconf.py:99
void SMProxyServer::processDQMConsumerRegistrationRequest ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)
private

Callback handling DQM event consumer registration request

Definition at line 363 of file SMProxyServer.cc.

References recoMuon::in, and dbtoconf::out.

Referenced by bindConsumerCallbacks().

365 {
366  consumerUtils_->processDQMConsumerRegistrationRequest(in,out);
367 }
boost::scoped_ptr< ConsumerUtils_t > consumerUtils_
tuple out
Definition: dbtoconf.py:99
void SMProxyServer::startWorkerThreads ( )
private

Create and start all worker threads

Definition at line 119 of file SMProxyServer.cc.

References alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, and stateMachine_.

Referenced by SMProxyServer().

120 {
121  // Start the workloops
122  try
123  {
124  stateMachine_->getStatisticsReporter()->startWorkLoop("theStatisticsReporter");
125  }
126  catch(xcept::Exception &e)
127  {
128  stateMachine_->moveToFailedState(e);
129  }
130  catch(std::exception &e)
131  {
132  XCEPT_DECLARE(exception::Exception,
133  sentinelException, e.what());
134  stateMachine_->moveToFailedState(sentinelException);
135  }
136  catch(...)
137  {
138  std::string errorMsg = "Unknown exception when starting the workloops";
139  XCEPT_DECLARE(exception::Exception,
140  sentinelException, errorMsg);
141  stateMachine_->moveToFailedState(sentinelException);
142  }
143 }
StateMachinePtr stateMachine_

Member Data Documentation

boost::scoped_ptr<ConsumerUtils_t> smproxy::SMProxyServer::consumerUtils_
private

Definition at line 141 of file SMProxyServer.h.

Referenced by initializeSharedResources().

boost::scoped_ptr<SMPSWebPageHelper> smproxy::SMProxyServer::smpsWebPageHelper_
private

Definition at line 144 of file SMProxyServer.h.

Referenced by initializeSharedResources().

StateMachinePtr smproxy::SMProxyServer::stateMachine_
private

Definition at line 138 of file SMProxyServer.h.

Referenced by initializeSharedResources(), and startWorkerThreads().