CMS 3D CMS Logo

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

#include <FUResourceBroker.h>

Inheritance diagram for evf::FUResourceBroker:

Public Member Functions

void actionPerformed (xdata::Event &e)
 
void customWebPage (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
 FUResourceBroker (xdaq::ApplicationStub *s)
 
xoap::MessageReference handleFSMSoapMessage (xoap::MessageReference msg) throw (xoap::exception::Exception)
 
void I2O_EVM_LUMISECTION_Callback (toolbox::mem::Reference *bufRef)
 
void I2O_FU_DATA_DISCARD_Callback (toolbox::mem::Reference *bufRef)
 
void I2O_FU_DQM_DISCARD_Callback (toolbox::mem::Reference *bufRef)
 
void I2O_FU_TAKE_Callback (toolbox::mem::Reference *bufRef)
 
unsigned int instanceNumber () const
 
void webPageRequest (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
 
 XDAQ_INSTANTIATOR ()
 
virtual ~FUResourceBroker ()
 

Static Public Attributes

static const int CRC_ERROR_SHIFT = 0x0
 
static const int DATA_ERROR_SHIFT = 0x1
 
static const int LOST_ERROR_SHIFT = 0x2
 
static const int SENT_ERREVENT_ERROR_SHIFT = 0x5
 
static const int TIMEOUT_EVENT_ERROR_SHIFT = 0x4
 
static const int TIMEOUT_NOEVENT_ERROR_SHIFT = 0x3
 

Private Member Functions

void bindStateMachineCallbacks ()
 
void exportParameters ()
 
bool waitForStateChange (std::string name, int timeoutMicroSec)
 

Private Attributes

xdata::String class_
 
rb_statemachine::SMEventSchedulereventScheduler_
 
rb_statemachine::RBStateMachinePtr fsm_
 
xdata::UnsignedInteger32 instance_
 
rb_statemachine::SharedResourcesPtr_t res_
 
xdata::String url_
 

Detailed Description

Main class of the Resource Broker XDAQ application.

Author:
aspataru

Definition at line 49 of file FUResourceBroker.h.

Constructor & Destructor Documentation

FUResourceBroker::FUResourceBroker ( xdaq::ApplicationStub *  s)

Definition at line 57 of file FUResourceBroker.cc.

References bindStateMachineCallbacks(), class_, customWebPage(), alignCSCRings::e, eventScheduler_, edm::hlt::Exception, exportParameters(), fsm_, I2O_EVM_LUMISECTION_Callback(), I2O_FU_DATA_DISCARD, I2O_FU_DATA_DISCARD_Callback(), I2O_FU_DQM_DISCARD, I2O_FU_DQM_DISCARD_Callback(), I2O_FU_TAKE_Callback(), instance_, mergeVDriftHistosByStation::name, res_, url_, and webPageRequest().

57  :
58  xdaq::Application(s),
59  res_(new SharedResources(/*this, */getApplicationLogger())) {
60 
62 
63  res_->gui_ = new IndependentWebGUI(this);
64  res_->gui_->setVersionString("Changeset: *** 05.07.2012 - V1.22 ***");
65 
66  // create state machine with shared resources
67  fsm_.reset(new RBStateMachine(this, res_));
68 
69  // initialise state machine
70  fsm_->initiate();
71 
72  // start the event scheduler
73  eventScheduler_ = new SMEventScheduler(fsm_, res_->commands_);
74 
75  // set url, class, instance, and sourceId (=class_instance)
76  url_ = getApplicationDescriptor()->getContextDescriptor()->getURL() + "/"
77  + getApplicationDescriptor()->getURN();
78  class_ = getApplicationDescriptor()->getClassName();
79  instance_ = getApplicationDescriptor()->getInstance();
80  res_->sourceId_ = class_.toString() + "_" + instance_.toString();
81 
82  // bind i2o callbacks
83  i2o::bind(this, &FUResourceBroker::I2O_FU_TAKE_Callback, I2O_FU_TAKE,
84  XDAQ_ORGANIZATION_ID);
86  I2O_FU_DATA_DISCARD, XDAQ_ORGANIZATION_ID);
88  I2O_FU_DQM_DISCARD, XDAQ_ORGANIZATION_ID);
90  I2O_EVM_LUMISECTION, XDAQ_ORGANIZATION_ID);
91 
92  // bind HyperDAQ web pages
93  xgi::bind(this, &evf::FUResourceBroker::webPageRequest, "Default");
94 
95  vector<toolbox::lang::Method*> methods = res_->gui_->getMethods();
96  vector<toolbox::lang::Method*>::iterator it;
97  for (it = methods.begin(); it != methods.end(); ++it) {
98  if ((*it)->type() == "cgi") {
99  string name = static_cast<xgi::MethodSignature*> (*it)->name();
100  xgi::bind(this, &evf::FUResourceBroker::webPageRequest, name);
101  }
102  }
103  xgi::bind(this, &evf::FUResourceBroker::customWebPage, "customWebPage");
104 
105  // allocate i2o memory pool
106  string i2oPoolName = res_->sourceId_ + "_i2oPool";
107  try {
108  toolbox::mem::HeapAllocator *allocator =
109  new toolbox::mem::HeapAllocator();
110  toolbox::net::URN urn("toolbox-mem-pool", i2oPoolName);
111  toolbox::mem::MemoryPoolFactory* poolFactory =
112  toolbox::mem::getMemoryPoolFactory();
113  res_->i2oPool_ = poolFactory->createPool(urn, allocator);
115  string s = "Failed to create pool: " + i2oPoolName;
116  LOG4CPLUS_FATAL(res_->log_, s);
117  XCEPT_RETHROW(xcept::Exception, s, e);
118  }
119 
120  // publish all parameters to app info space
122 
123  // findRcmsStateListener
124  fsm_->findRcmsStateListener(this);
125 
126  // set application icon for hyperdaq
127  getApplicationDescriptor()->setAttribute("icon", "/evf/images/rbicon.jpg");
128  //FUResource::useEvmBoard_ = useEvmBoard_;
129 
130 }
void I2O_FU_TAKE_Callback(toolbox::mem::Reference *bufRef)
void customWebPage(xgi::Input *in, xgi::Output *out)
void I2O_FU_DATA_DISCARD_Callback(toolbox::mem::Reference *bufRef)
#define I2O_FU_DQM_DISCARD
Definition: i2oEvfMsgs.h:27
void I2O_FU_DQM_DISCARD_Callback(toolbox::mem::Reference *bufRef)
rb_statemachine::SharedResourcesPtr_t res_
rb_statemachine::SMEventScheduler * eventScheduler_
rb_statemachine::RBStateMachinePtr fsm_
#define I2O_FU_DATA_DISCARD
Definition: i2oEvfMsgs.h:26
void I2O_EVM_LUMISECTION_Callback(toolbox::mem::Reference *bufRef)
xdata::UnsignedInteger32 instance_
void webPageRequest(xgi::Input *in, xgi::Output *out)
FUResourceBroker::~FUResourceBroker ( )
virtual

Definition at line 133 of file FUResourceBroker.cc.

References eventScheduler_.

133  {
134  delete eventScheduler_;
135 }
rb_statemachine::SMEventScheduler * eventScheduler_

Member Function Documentation

void FUResourceBroker::actionPerformed ( xdata::Event &  e)

xdata::ActionListener callback(s)

Definition at line 403 of file FUResourceBroker.cc.

References evf::FUResource::doFedIdCheck(), alignCSCRings::e, res_, and evf::FUResource::useEvmBoard().

403  {
404  res_->lock();
405 
406  if (0 != res_->resourceStructure_) {
407 
408  //gui_->monInfoSpace()->lock();
409 
410  if (e.type() == "urn:xdata-event:ItemGroupRetrieveEvent") {
411  res_->nbClients_ = res_->resourceStructure_->nbClients();
412  res_->clientPrcIds_
413  = res_->resourceStructure_->clientPrcIdsAsString();
414  res_->nbAllocatedEvents_ = res_->resourceStructure_->nbAllocated();
415  res_->nbPendingRequests_ = res_->resourceStructure_->nbPending();
416  res_->nbReceivedEvents_ = res_->resourceStructure_->nbCompleted();
417  res_->nbSentEvents_ = res_->resourceStructure_->nbSent();
418  res_->nbSentDqmEvents_ = res_->resourceStructure_->nbSentDqm();
419  res_->nbSentErrorEvents_ = res_->resourceStructure_->nbSentError();
420 
421  int nbPSMD = res_->resourceStructure_->nbPendingSMDiscards();
422  if (nbPSMD>=0) res_->nbPendingSMDiscards_=(unsigned int)nbPSMD;
423  else res_->nbPendingSMDiscards_=0;
424 
425  res_->nbPendingSMDqmDiscards_
426  = res_->resourceStructure_->nbPendingSMDqmDiscards();
427  res_->nbDiscardedEvents_ = res_->resourceStructure_->nbDiscarded();
428  res_->nbLostEvents_ = res_->resourceStructure_->nbLost();
429  // UPDATED
430  res_->nbEolPosted_ = res_->resourceStructure_->nbEolPosted();
431  res_->nbEolDiscarded_ = res_->resourceStructure_->nbEolDiscarded();
432  res_->nbDataErrors_ = res_->resourceStructure_->nbErrors();
433  res_->nbCrcErrors_ = res_->resourceStructure_->nbCrcErrors();
434  res_->nbAllocateSent_ = res_->resourceStructure_->nbAllocSent();
435  res_->dataErrorFlag_.value_ = (res_->nbCrcErrors_.value_ != 0u
436  + ((res_->nbDataErrors_.value_ != 0u) << 1)
437  + ((res_->nbLostEvents_.value_ != 0u) << 2)
438  + ((res_->nbTimeoutsWithEvent_.value_ != 0u) << 3)
439  + ((res_->nbTimeoutsWithoutEvent_.value_ != 0u) << 4)
440  + ((res_->nbSentErrorEvents_.value_ != 0u) << 5));
441 
442  } else if (e.type() == "ItemChangedEvent") {
443 
444  string item = dynamic_cast<xdata::ItemChangedEvent&> (e).itemName();
445 
446  if (item == "doFedIdCheck")
447  FUResource::doFedIdCheck(res_->doFedIdCheck_);
448  if (item == "useEvmBoard")
449  FUResource::useEvmBoard(res_->useEvmBoard_);
450  if (item == "doCrcCheck")
451  res_->resourceStructure_->setDoCrcCheck(res_->doCrcCheck_);
452  if (item == "doDumpEvents")
453  res_->resourceStructure_->setDoDumpEvents(res_->doDumpEvents_);
454  }
455 
456  //gui_->monInfoSpace()->unlock();
457  } else {
458  res_->nbClients_ = 0;
459  res_->clientPrcIds_ = "";
460  res_->nbAllocatedEvents_ = 0;
461  res_->nbPendingRequests_ = 0;
462  res_->nbReceivedEvents_ = 0;
463  res_->nbSentEvents_ = 0;
464  res_->nbSentDqmEvents_ = 0;
465  res_->nbSentErrorEvents_ = 0;
466  res_->nbPendingSMDiscards_ = 0;
467  res_->nbPendingSMDqmDiscards_ = 0;
468  res_->nbDiscardedEvents_ = 0;
469  res_->nbLostEvents_ = 0;
470  res_->nbDataErrors_ = 0;
471  res_->nbCrcErrors_ = 0;
472  res_->nbAllocateSent_ = 0;
473  }
474  res_->unlock();
475 }
static void useEvmBoard(bool useEvmBoard)
Definition: FUResource.h:101
rb_statemachine::SharedResourcesPtr_t res_
static void doFedIdCheck(bool doFedIdCheck)
Definition: FUResource.h:97
void FUResourceBroker::bindStateMachineCallbacks ( )
private

Definition at line 142 of file FUResourceBroker.cc.

References handleFSMSoapMessage().

Referenced by FUResourceBroker().

142  {
143  xoap::bind(this, &FUResourceBroker::handleFSMSoapMessage, "Configure",
144  XDAQ_NS_URI);
145  xoap::bind(this, &FUResourceBroker::handleFSMSoapMessage, "Enable",
146  XDAQ_NS_URI);
147  xoap::bind(this, &FUResourceBroker::handleFSMSoapMessage, "Stop",
148  XDAQ_NS_URI);
149  xoap::bind(this, &FUResourceBroker::handleFSMSoapMessage, "Halt",
150  XDAQ_NS_URI);
151 }
xoap::MessageReference handleFSMSoapMessage(xoap::MessageReference msg)
void FUResourceBroker::customWebPage ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)

Definition at line 585 of file FUResourceBroker.cc.

References gather_cfg::cout, asciidump::els, i, recoMuon::in, dbtoconf::out, evf::utils::pid, runtimedef::set(), evf::utils::state, ntuplemaker::status, asciidump::table, and cond::rpcobgas::time.

Referenced by FUResourceBroker().

586  {
587  using namespace cgicc;
588  Cgicc cgi(in);
589  std::vector < FormEntry > els = cgi.getElements();
590  for (std::vector<FormEntry>::iterator it = els.begin(); it != els.end(); it++)
591  cout << "form entry " << (*it).getValue() << endl;
592 
593  std::vector < FormEntry > el1;
594  cgi.getElement("crcError", el1);
595  *out << "<html>" << endl;
596  res_->gui_->htmlHead(in, out, res_->sourceId_);
597  *out << "<body>" << endl;
598  res_->gui_->htmlHeadline(in, out);
599 
600  res_->lock();
601 
602  if (0 != res_->resourceStructure_) {
603  if (el1.size() != 0) {
604  res_->resourceStructure_->injectCRCError();
605  }
606  *out << "<form method=\"GET\" action=\"customWebPage\" >";
607  *out
608  << "<button name=\"crcError\" type=\"submit\" value=\"injCRC\">Inject CRC</button>"
609  << endl;
610  *out << "</form>" << endl;
611  *out << "<hr/>" << endl;
612  vector < pid_t > client_prc_ids
613  = res_->resourceStructure_->clientPrcIds();
614  *out << table().set("frame", "void").set("rules", "rows") .set("class",
615  "modules").set("width", "250") << endl << tr() << th(
616  "Client Processes").set("colspan", "3") << tr() << endl << tr()
617  << th("client").set("align", "left") << th("process id").set(
618  "align", "center") << th("status").set("align", "center")
619  << tr() << endl;
620  for (UInt_t i = 0; i < client_prc_ids.size(); i++) {
621 
622  pid_t pid = client_prc_ids[i];
623  int status = kill(pid, 0);
624 
625  stringstream ssi;
626  ssi << i + 1;
627  stringstream sspid;
628  sspid << pid;
629  stringstream ssstatus;
630  ssstatus << status;
631 
632  string bg_status = (status == 0) ? "#00ff00" : "ff0000";
633  *out << tr() << td(ssi.str()).set("align", "left") << td(
634  sspid.str()).set("align", "center")
635  << td(ssstatus.str()).set("align", "center").set("bgcolor",
636  bg_status) << tr() << endl;
637  }
638  *out << table() << endl;
639  *out << "<br><br>" << endl;
640 
641  vector < string > states = res_->resourceStructure_->cellStates();
642  vector < UInt_t > evt_numbers
643  = res_->resourceStructure_->cellEvtNumbers();
644  vector < pid_t > prc_ids = res_->resourceStructure_->cellPrcIds();
645  vector < time_t > time_stamps
646  = res_->resourceStructure_->cellTimeStamps();
647 
648  *out << table().set("frame", "void").set("rules", "rows") .set("class",
649  "modules").set("width", "500") << endl << tr() << th(
650  "Shared Memory Cells").set("colspan", "6") << tr() << endl
651  << tr() << th("cell").set("align", "left") << th("state").set(
652  "align", "center") << th("event").set("align", "center") << th(
653  "process id").set("align", "center") << th("timestamp").set(
654  "align", "center") << th("time").set("align", "center") << tr()
655  << endl;
656  for (UInt_t i = 0; i < states.size(); i++) {
657  string state = states[i];
658  UInt_t evt = evt_numbers[i];
659  pid_t pid = prc_ids[i];
660  time_t tstamp = time_stamps[i];
661  double tdiff = difftime(time(0), tstamp);
662 
663  stringstream ssi;
664  ssi << i;
665  stringstream ssevt;
666  if (evt != 0xffffffff)
667  ssevt << evt;
668  else
669  ssevt << " - ";
670  stringstream sspid;
671  if (pid != 0)
672  sspid << pid;
673  else
674  sspid << " - ";
675  stringstream sststamp;
676  if (tstamp != 0)
677  sststamp << tstamp;
678  else
679  sststamp << " - ";
680  stringstream sstdiff;
681  if (tstamp != 0)
682  sstdiff << tdiff;
683  else
684  sstdiff << " - ";
685 
686  string bg_state = "#ffffff";
687  if (state == "RAWWRITING" || state == "RAWWRITTEN" || state
688  == "RAWREADING" || state == "RAWREAD")
689  bg_state = "#99CCff";
690  else if (state == "PROCESSING")
691  bg_state = "#ff0000";
692  else if (state == "PROCESSED" || state == "RECOWRITING" || state
693  == "RECOWRITTEN")
694  bg_state = "#CCff99";
695  else if (state == "SENDING")
696  bg_state = "#00FF33";
697  else if (state == "SENT")
698  bg_state = "#006633";
699  else if (state == "DISCARDING")
700  bg_state = "#FFFF00";
701  else if (state == "LUMISECTION")
702  bg_state = "#0000FF";
703 
704  *out << tr() << td(ssi.str()).set("align", "left")
705  << td(state).set("align", "center").set("bgcolor", bg_state)
706  << td(ssevt.str()).set("align", "center")
707  << td(sspid.str()).set("align", "center") << td(
708  sststamp.str()).set("align", "center")
709  << td(sstdiff.str()).set("align", "center") << tr() << endl;
710  }
711  *out << table() << endl;
712  *out << "<br><br>" << endl;
713 
714  vector < string > dqmstates = res_->resourceStructure_->dqmCellStates();
715 
716  *out << table().set("frame", "void").set("rules", "rows") .set("class",
717  "modules").set("width", "500") << endl << tr() << th(
718  "Shared Memory DQM Cells").set("colspan", "6") << tr() << endl
719  << tr() << th("cell").set("align", "left") << th("state").set(
720  "align", "center") << tr() << endl;
721  for (UInt_t i = 0; i < dqmstates.size(); i++) {
722  string state = dqmstates[i];
723 
724  string bg_state = "#ffffff";
725  if (state == "WRITING" || state == "WRITTEN")
726  bg_state = "#99CCff";
727  else if (state == "SENDING")
728  bg_state = "#00FF33";
729  else if (state == "SENT")
730  bg_state = "#006633";
731  else if (state == "DISCARDING")
732  bg_state = "#FFFF00";
733 
734  *out << tr() << "<td>" << i << "</td>" << td(state).set("align",
735  "center").set("bgcolor", bg_state) << tr() << endl;
736  }
737  *out << table() << endl;
738 
739  }
740  *out << "</body>" << endl << "</html>" << endl;
741 
742  res_->unlock();
743 }
list table
Definition: asciidump.py:386
int i
Definition: DBlmapReader.cc:9
tuple els
Definition: asciidump.py:420
rb_statemachine::SharedResourcesPtr_t res_
tuple out
Definition: dbtoconf.py:99
unsigned int UInt_t
Definition: FUTypes.h:12
char state
Definition: procUtils.cc:75
tuple cout
Definition: gather_cfg.py:121
tuple status
Definition: ntuplemaker.py:245
void set(const std::string &name, int value)
set the flag, with a run-time name
void FUResourceBroker::exportParameters ( )
private

Definition at line 478 of file FUResourceBroker.cc.

References class_, fsm_, instance_, res_, and url_.

Referenced by FUResourceBroker().

478  {
479  assert(0 != res_->gui_);
480 
481  res_->gui_->addMonitorParam("url", &url_);
482  res_->gui_->addMonitorParam("class", &class_);
483  res_->gui_->addMonitorParam("instance", &instance_);
484  res_->gui_->addMonitorParam("runNumber", &res_->runNumber_);
485  res_->gui_->addMonitorParam("stateName",
486  fsm_->getExternallyVisibleStatePtr());
487 
488  res_->gui_->addMonitorParam("deltaT", &res_->deltaT_);
489  res_->gui_->addMonitorParam("deltaN", &res_->deltaN_);
490  res_->gui_->addMonitorParam("deltaSumOfSquares", &res_->deltaSumOfSquares_);
491  res_->gui_->addMonitorParam("deltaSumOfSizes", &res_->deltaSumOfSizes_);
492 
493  res_->gui_->addMonitorParam("throughput", &res_->throughput_);
494  res_->gui_->addMonitorParam("rate", &res_->rate_);
495  res_->gui_->addMonitorParam("average", &res_->average_);
496  res_->gui_->addMonitorParam("rms", &res_->rms_);
497  res_->gui_->addMonitorParam("dataErrorFlag", &res_->dataErrorFlag_);
498 
499  res_->gui_->addMonitorCounter("nbAllocatedEvents",
500  &res_->nbAllocatedEvents_);
501  res_->gui_->addMonitorCounter("nbPendingRequests",
502  &res_->nbPendingRequests_);
503  res_->gui_->addMonitorCounter("nbReceivedEvents", &res_->nbReceivedEvents_);
504  res_->gui_->addMonitorCounter("nbSentEvents", &res_->nbSentEvents_);
505  res_->gui_->addMonitorCounter("nbSentErrorEvents",
506  &res_->nbSentErrorEvents_);
507  res_->gui_->addMonitorCounter("nbDiscardedEvents",
508  &res_->nbDiscardedEvents_);
509  // UPDATED
510  res_->gui_->addMonitorCounter("nbReceivedEol", &res_->nbReceivedEol_);
511  res_->gui_->addMonitorCounter("highestEolReceived",
512  &res_->highestEolReceived_);
513  res_->gui_->addMonitorCounter("nbEolPosted", &res_->nbEolPosted_);
514  res_->gui_->addMonitorCounter("nbEolDiscarded", &res_->nbEolDiscarded_);
515 
516  res_->gui_->addMonitorCounter("nbPendingSMDiscards",
517  &res_->nbPendingSMDiscards_);
518 
519  res_->gui_->addMonitorCounter("nbSentDqmEvents", &res_->nbSentDqmEvents_);
520  res_->gui_->addMonitorCounter("nbDqmDiscardReceived",
521  &res_->nbDqmDiscardReceived_);
522  res_->gui_->addMonitorCounter("nbPendingSMDqmDiscards",
523  &res_->nbPendingSMDqmDiscards_);
524 
525  res_->gui_->addMonitorCounter("nbLostEvents", &res_->nbLostEvents_);
526  res_->gui_->addMonitorCounter("nbDataErrors", &res_->nbDataErrors_);
527  res_->gui_->addMonitorCounter("nbCrcErrors", &res_->nbCrcErrors_);
528  res_->gui_->addMonitorCounter("nbTimeoutsWithEvent",
529  &res_->nbTimeoutsWithEvent_);
530  res_->gui_->addMonitorCounter("nbTimeoutsWithoutEvent",
531  &res_->nbTimeoutsWithoutEvent_);
532 
533  res_->gui_->addStandardParam("segmentationMode", &res_->segmentationMode_);
534  res_->gui_->addStandardParam("useMessageQueueIPC",
535  &res_->useMessageQueueIPC_);
536  res_->gui_->addStandardParam("nbClients", &res_->nbClients_);
537  res_->gui_->addStandardParam("clientPrcIds", &res_->clientPrcIds_);
538  res_->gui_->addStandardParam("nbRawCells", &res_->nbRawCells_);
539  res_->gui_->addStandardParam("nbRecoCells", &res_->nbRecoCells_);
540  res_->gui_->addStandardParam("nbDqmCells", &res_->nbDqmCells_);
541  res_->gui_->addStandardParam("rawCellSize", &res_->rawCellSize_);
542  res_->gui_->addStandardParam("recoCellSize", &res_->recoCellSize_);
543  res_->gui_->addStandardParam("dqmCellSize", &res_->dqmCellSize_);
544  res_->gui_->addStandardParam("nbFreeResRequiredForAllocate",
545  &res_->freeResRequiredForAllocate_);
546 
547  res_->gui_->addStandardParam("doDropEvents", &res_->doDropEvents_);
548  res_->gui_->addStandardParam("doFedIdCheck", &res_->doFedIdCheck_);
549  res_->gui_->addStandardParam("doCrcCheck", &res_->doCrcCheck_);
550  res_->gui_->addStandardParam("doDumpEvents", &res_->doDumpEvents_);
551  res_->gui_->addStandardParam("buClassName", &res_->buClassName_);
552  res_->gui_->addStandardParam("buInstance", &res_->buInstance_);
553  res_->gui_->addStandardParam("smClassName", &res_->smClassName_);
554  res_->gui_->addStandardParam("smInstance", &res_->smInstance_);
555  res_->gui_->addStandardParam("resourceStructureTimeout_",
556  &res_->resourceStructureTimeout_);
557  res_->gui_->addStandardParam("monSleepSec", &res_->monSleepSec_);
558  res_->gui_->addStandardParam("watchSleepSec", &res_->watchSleepSec_);
559  res_->gui_->addStandardParam("timeOutSec", &res_->timeOutSec_);
560  res_->gui_->addStandardParam("processKillerEnabled",
561  &res_->processKillerEnabled_);
562  res_->gui_->addStandardParam("useEvmBoard", &res_->useEvmBoard_);
563  res_->gui_->addStandardParam("rcmsStateListener", fsm_->rcmsStateListener());
564 
565  res_->gui_->addStandardParam("foundRcmsStateListener",
566  fsm_->foundRcmsStateListener());
567 
568  res_->gui_->addStandardParam("reasonForFailed", &res_->reasonForFailed_);
569 
570  res_->gui_->addDebugCounter("nbAllocateSent", &res_->nbAllocateSent_);
571  res_->gui_->addDebugCounter("nbTakeReceived", &res_->nbTakeReceived_);
572  res_->gui_->addDebugCounter("nbDataDiscardReceived",
573  &res_->nbDataDiscardReceived_);
574 
575  res_->gui_->exportParameters();
576 
577  res_->gui_->addItemChangedListener("doFedIdCheck", this);
578  res_->gui_->addItemChangedListener("useEvmBoard", this);
579  res_->gui_->addItemChangedListener("doCrcCheck", this);
580  res_->gui_->addItemChangedListener("doDumpEvents", this);
581 
582 }
rb_statemachine::SharedResourcesPtr_t res_
rb_statemachine::RBStateMachinePtr fsm_
xdata::UnsignedInteger32 instance_
xoap::MessageReference FUResourceBroker::handleFSMSoapMessage ( xoap::MessageReference  msg)
throw (xoap::exception::Exception
)

FSM SOAP command callback

Definition at line 175 of file FUResourceBroker.cc.

References edmPickEvents::command, evf::soaputils::createFsmSoapResponseMsg(), alignCSCRings::e, edm::hlt::Exception, evf::soaputils::extractParameters(), edm::hlt::Fail, lumiQueryAPI::msg, and alignCSCRings::s.

Referenced by bindStateMachineCallbacks().

176  {
177 
178  string errorMsg;
179  xoap::MessageReference returnMsg;
180 
181  // register the state of the FSM before processing SOAP command
182  string initialState = fsm_->getExternallyVisibleState();
183 
184  try {
185  errorMsg
186  = "Failed to extract FSM event and parameters from SOAP message: ";
187  string command = soaputils::extractParameters(msg, this);
188 
189  errorMsg = "Failed to put a '" + command
190  + "' state machine event into command queue: ";
191 
192  if (command == "Configure") {
193 
194  EventPtr stMachEvent(new Configure());
195  res_->commands_.enqEvent(stMachEvent);
196 
197  } else if (command == "Enable") {
198 
199  EventPtr stMachEvent(new Enable());
200  res_->commands_.enqEvent(stMachEvent);
201 
202  } else if (command == "Stop") {
203 
204  EventPtr stMachEvent(new Stop());
205  res_->commands_.enqEvent(stMachEvent);
206 
207  } else if (command == "Halt") {
208 
209  EventPtr stMachEvent(new Halt());
210  res_->commands_.enqEvent(stMachEvent);
211  }
212 
213  else {
214  XCEPT_RAISE(
216  "Received an unknown state machine event '" + command
217  + "'.");
218  // send fail event to FSM
219  EventPtr stMachEvent(new Fail());
220  res_->commands_.enqEvent(stMachEvent);
221  }
222 
223  errorMsg = "Failed to create FSM SOAP reply message: ";
224 
225  // wait until 'initialState' is changed
226  // the SOAP response will be issued only when the state has changed
227  if (waitForStateChange(initialState, 2000000)) {
228  returnMsg = soaputils::createFsmSoapResponseMsg(command,
229  fsm_->getExternallyVisibleState());
230  } else {
231  XCEPT_RAISE(xcept::Exception,
232  "FAILED TO REACH TARGET STATE FROM SOAP COMMAND WITHIN TIMEOUT!");
233  // send fail event to FSM
234  EventPtr stMachEvent(new Fail());
235  res_->commands_.enqEvent(stMachEvent);
236  }
237 
238  } catch (xcept::Exception& e) {
239  string s = "Exception on FSM Callback!";
240  LOG4CPLUS_FATAL(res_->log_, s);
241  XCEPT_RETHROW(xcept::Exception, s, e);
242  }
243 
244  return returnMsg;
245 }
std::string extractParameters(xoap::MessageReference, xdaq::Application *)
Definition: SoapUtils.cc:28
reject
Definition: HLTenums.h:23
bool waitForStateChange(std::string name, int timeoutMicroSec)
boost::shared_ptr< boost::statechart::event_base > EventPtr
Definition: CommandQueue.h:23
rb_statemachine::SharedResourcesPtr_t res_
rb_statemachine::RBStateMachinePtr fsm_
xoap::MessageReference createFsmSoapResponseMsg(const std::string commandName, const std::string currentState)
Definition: SoapUtils.cc:38
void FUResourceBroker::I2O_EVM_LUMISECTION_Callback ( toolbox::mem::Reference *  bufRef)

I2O End Of Lumisection callback, received from EVM

Definition at line 288 of file FUResourceBroker.cc.

References alignCSCRings::e, edm::hlt::Fail, cmsPerfPublish::fail(), fsm_, lumiQueryAPI::msg, res_, evf::rb_statemachine::RUNNING, and summarizeEdmComparisonLogfiles::success.

Referenced by FUResourceBroker().

289  {
290 
291  int currentStateID = -1;
292  fsm_->transitionReadLock();
293  currentStateID = fsm_->getCurrentState().stateID();
294  fsm_->transitionUnlock();
295 
296  bool success = true;
297  if (currentStateID==rb_statemachine::RUNNING) {
298 
299  I2O_EVM_END_OF_LUMISECTION_MESSAGE_FRAME *msg =
300  (I2O_EVM_END_OF_LUMISECTION_MESSAGE_FRAME *) bufRef->getDataLocation();
301  if (msg->lumiSection == 0) {
302  LOG4CPLUS_ERROR(res_->log_, "EOL message received for ls=0!!! ");
303  EventPtr fail(new Fail());
304  res_->commands_.enqEvent(fail);
305  success=false;
306  }
307  if (success) {
308  res_->nbReceivedEol_++;
309  if (res_->highestEolReceived_.value_ + 100 < msg->lumiSection) {
310  LOG4CPLUS_ERROR( res_->log_, "EOL message not in sequence, expected "
311  << res_->highestEolReceived_.value_ + 1 << " received "
312  << msg->lumiSection);
313 
314  EventPtr fail(new Fail());
315  res_->commands_.enqEvent(fail);
316  success=false;
317  }
318  }
319  if (success) {
320  if (res_->highestEolReceived_.value_ + 1 != msg->lumiSection)
321  LOG4CPLUS_WARN( res_->log_, "EOL message not in sequence, expected "
322  << res_->highestEolReceived_.value_ + 1 << " received "
323  << msg->lumiSection);
324 
325  if (res_->highestEolReceived_.value_ < msg->lumiSection)
326  res_->highestEolReceived_.value_ = msg->lumiSection;
327 
328  try {
329  res_->resourceStructure_->postEndOfLumiSection(bufRef);
330  } catch (evf::Exception& e) {
331  fsm_->getCurrentState().moveToFailedState(e);
332  }
333  }
334  }
335  else success=false;
336 
337  if (!success) LOG4CPLUS_ERROR(res_->log_,"EOL i2o frame received in state "
338  << fsm_->getExternallyVisibleState() << " is being lost");
339  bufRef->release();
340 }
reject
Definition: HLTenums.h:23
boost::shared_ptr< boost::statechart::event_base > EventPtr
Definition: CommandQueue.h:23
rb_statemachine::SharedResourcesPtr_t res_
rb_statemachine::RBStateMachinePtr fsm_
void FUResourceBroker::I2O_FU_DATA_DISCARD_Callback ( toolbox::mem::Reference *  bufRef)

I2O DATA DISCARD callback, received from SM

Definition at line 343 of file FUResourceBroker.cc.

References evf::rb_statemachine::BaseState::discardDataEvent(), fsm_, and res_.

Referenced by FUResourceBroker().

344  {
345 
346  // obtain lock on Resource Structure for discard
347  res_->lockRSAccess();
348 
349  fsm_->transitionReadLock();
350  const BaseState& currentState = fsm_->getCurrentState();
351 
352  if (res_->allowI2ODiscards_)
353  /*bool success = */
354  currentState.discardDataEvent(bufRef);
355  else {
356  LOG4CPLUS_WARN(
357  res_->log_,
358  "Data Discard I2O message received from SM is being ignored! ShmBuffer was reinitialized!");
359  bufRef->release();
360  }
361  fsm_->transitionUnlock();
362  res_->unlockRSAccess();
363 
364  res_->nbDataDiscardReceived_.value_++;
365 }
virtual bool discardDataEvent(MemRef_t *bufRef) const
rb_statemachine::SharedResourcesPtr_t res_
rb_statemachine::RBStateMachinePtr fsm_
void FUResourceBroker::I2O_FU_DQM_DISCARD_Callback ( toolbox::mem::Reference *  bufRef)

I2O DQM DISCARD callback, received from SM

Definition at line 368 of file FUResourceBroker.cc.

References evf::rb_statemachine::BaseState::discardDqmEvent(), fsm_, and res_.

Referenced by FUResourceBroker().

369  {
370 
371  // obtain lock on Resource Structure for discard
372  res_->lockRSAccess();
373 
374  fsm_->transitionReadLock();
375  const BaseState& currentState = fsm_->getCurrentState();
376 
377  if (res_->allowI2ODiscards_)
378  /*bool success = */
379  currentState.discardDqmEvent(bufRef);
380  else {
381  LOG4CPLUS_WARN(
382  res_->log_,
383  "DQM Discard I2O message received from SM is being ignored! ShmBuffer was reinitialized!");
384  bufRef->release();
385  }
386  fsm_->transitionUnlock();
387  res_->unlockRSAccess();
388 
389  res_->nbDqmDiscardReceived_.value_++;
390 }
rb_statemachine::SharedResourcesPtr_t res_
rb_statemachine::RBStateMachinePtr fsm_
virtual bool discardDqmEvent(MemRef_t *bufRef) const
void FUResourceBroker::I2O_FU_TAKE_Callback ( toolbox::mem::Reference *  bufRef)

I2O TAKE callback, received from BU

Definition at line 248 of file FUResourceBroker.cc.

References gather_cfg::cout, alignCSCRings::e, fsm_, res_, and evf::rb_statemachine::RUNNING.

Referenced by FUResourceBroker().

248  {
249 
250  int currentStateID = -1;
251  fsm_->transitionReadLock();
252  currentStateID = fsm_->getCurrentState().stateID();
253  fsm_->transitionUnlock();
254 
255  if (currentStateID==rb_statemachine::RUNNING) {
256  try {
257  bool eventComplete = res_->resourceStructure_->buildResource(bufRef);
258  if (eventComplete && res_->doDropEvents_)
259  {
260  cout << "dropping event" << endl;
261  res_->resourceStructure_->dropEvent();
262  }
263  }
264  catch (evf::Exception& e) {
265  fsm_->getCurrentState().moveToFailedState(e);
266  }
267  }
268  else {
269 
270  stringstream details;
271  details << " More details -> allocated events: "
272  << res_->nbAllocatedEvents_ << ", pending requests to BU: "
273  << res_->nbPendingRequests_ << ", received events: "
274  << res_->nbReceivedEvents_;
275  LOG4CPLUS_ERROR(
276  res_->log_,
277  "TAKE i2o frame received in state "
278  << fsm_->getExternallyVisibleState()
279  << " is being lost! THIS MEANS LOST EVENT DATA!"
280  << details.str());
281 
282  bufRef->release();
283  }
284  res_->nbTakeReceived_.value_++;
285 }
rb_statemachine::SharedResourcesPtr_t res_
rb_statemachine::RBStateMachinePtr fsm_
tuple cout
Definition: gather_cfg.py:121
unsigned int evf::FUResourceBroker::instanceNumber ( ) const
inline

Definition at line 104 of file FUResourceBroker.h.

References instance_.

Referenced by evf::EvffedFillerRB::EvffedFillerRB().

104  {
105  return instance_.value_;
106  }
xdata::UnsignedInteger32 instance_
bool FUResourceBroker::waitForStateChange ( std::string  name,
int  timeoutMicroSec 
)
private

Definition at line 154 of file FUResourceBroker.cc.

References fsm_, cmsPerfSuiteHarvest::now, and errorMatrix2Lands_multiChannel::start.

155  {
156  timeval start;
157  timeval now;
158 
159  gettimeofday(&start, 0);
160 
161  while (fsm_->getExternallyVisibleState().compare(initialState) == 0) {
162  gettimeofday(&now, 0);
163  if (now.tv_usec <= start.tv_usec + timeoutMicroSec)
164  ::usleep(50000);
165  else
166  return false;
167  }
168  return true;
169 }
rb_statemachine::RBStateMachinePtr fsm_
void FUResourceBroker::webPageRequest ( xgi::Input in,
xgi::Output out 
)
throw (xgi::exception::Exception
)

Definition at line 393 of file FUResourceBroker.cc.

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

Referenced by FUResourceBroker().

394  {
395  string name = in->getenv("PATH_INFO");
396  if (name.empty())
397  name = "defaultWebPage";
398  static_cast<xgi::MethodSignature*> (res_->gui_->getMethod(name))->invoke(
399  in, out);
400 }
rb_statemachine::SharedResourcesPtr_t res_
tuple out
Definition: dbtoconf.py:99
evf::FUResourceBroker::XDAQ_INSTANTIATOR ( )

Member Data Documentation

xdata::String evf::FUResourceBroker::class_
private

Definition at line 139 of file FUResourceBroker.h.

Referenced by exportParameters(), and FUResourceBroker().

const int evf::FUResourceBroker::CRC_ERROR_SHIFT = 0x0
static

Definition at line 109 of file FUResourceBroker.h.

const int evf::FUResourceBroker::DATA_ERROR_SHIFT = 0x1
static

Definition at line 110 of file FUResourceBroker.h.

rb_statemachine::SMEventScheduler* evf::FUResourceBroker::eventScheduler_
private

Definition at line 129 of file FUResourceBroker.h.

Referenced by FUResourceBroker(), and ~FUResourceBroker().

rb_statemachine::RBStateMachinePtr evf::FUResourceBroker::fsm_
private
xdata::UnsignedInteger32 evf::FUResourceBroker::instance_
private

Definition at line 140 of file FUResourceBroker.h.

Referenced by exportParameters(), FUResourceBroker(), and instanceNumber().

const int evf::FUResourceBroker::LOST_ERROR_SHIFT = 0x2
static

Definition at line 111 of file FUResourceBroker.h.

rb_statemachine::SharedResourcesPtr_t evf::FUResourceBroker::res_
private
const int evf::FUResourceBroker::SENT_ERREVENT_ERROR_SHIFT = 0x5
static

Definition at line 114 of file FUResourceBroker.h.

const int evf::FUResourceBroker::TIMEOUT_EVENT_ERROR_SHIFT = 0x4
static

Definition at line 113 of file FUResourceBroker.h.

const int evf::FUResourceBroker::TIMEOUT_NOEVENT_ERROR_SHIFT = 0x3
static

Definition at line 112 of file FUResourceBroker.h.

xdata::String evf::FUResourceBroker::url_
private

Definition at line 138 of file FUResourceBroker.h.

Referenced by exportParameters(), and FUResourceBroker().