CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/EventFilter/ResourceBroker/src/Enabling.cc

Go to the documentation of this file.
00001 
00006 #include "EventFilter/ResourceBroker/interface/SharedResources.h"
00007 #include "EventFilter/ResourceBroker/interface/RBStateMachine.h"
00008 
00009 #include <vector>
00010 
00011 using std::string;
00012 using std::vector;
00013 using namespace evf::rb_statemachine;
00014 
00015 // entry action, state notification, state action
00016 //______________________________________________________________________________
00017 void Enabling::do_entryActionWork() {
00018 }
00019 
00020 void Enabling::do_stateNotify() {
00021         SharedResourcesPtr_t res = outermost_context().getSharedResources();
00022         LOG4CPLUS_INFO(res->log_, "--> ResourceBroker: NEW STATE: " << stateName());
00023         outermost_context().setExternallyVisibleState(stateName());
00024         outermost_context().setInternalStateName(stateName());
00025         // RCMS notification no longer required here
00026         // this is done in FUResourceBroker in SOAP reply
00027         //outermost_context().rcmsStateChangeNotify();
00028 }
00029 
00030 void Enabling::do_stateAction() const {
00031         SharedResourcesPtr_t res = outermost_context().getSharedResources();
00032         IPCMethod* resourceStructure = res->resourceStructure_;
00033 
00034         try {
00035                 LOG4CPLUS_INFO(res->log_, "Start enabling ...");
00036 
00037                 // set current run number and reset GUI counters
00038                 // UPDATED
00039                 res->reset();
00040                 resourceStructure->setRunNumber(res->runNumber_);
00041                 res->lock();
00042 
00043                 /*
00044                  *  UPDATE:
00045                  *  releaseResources
00046                  *  resetPendingAllocates
00047                  *  resetIPC
00048                  *
00049                  *  after stopping
00050                  */
00051 
00052                 resourceStructure->resetCounters();
00053                 res->unlock();
00054 
00055                 LOG4CPLUS_INFO(res->log_, "Starting monitoring / watching workloops.");
00056                 // starting monitoring workloop
00057                 res->startMonitoringWorkLoop();
00058 
00059                 // Watching Workloop is used only for Shared Memory IPC
00060                 if (!res->useMessageQueueIPC_)
00061                         res->startWatchingWorkLoop();
00062 
00063                 // starting main workloops
00064                 // 1. Discard
00065                 res->startDiscardWorkLoop();
00066                 // 2. Send Data
00067                 res->startSendDataWorkLoop();
00068                 // 3. Send DQM
00069                 res->startSendDqmWorkLoop();
00070 
00071                 resourceStructure->sendAllocate();
00072 
00073                 res->nbTimeoutsWithEvent_ = 0;
00074                 res->nbTimeoutsWithoutEvent_ = 0;
00075                 res->dataErrorFlag_ = 0;
00076 
00077                 // make sure access is granted to the resource structure
00078                 // (re-enable access after an emergency stop)
00079                 res->allowAccessToResourceStructure_ = true;
00080 
00081                 LOG4CPLUS_INFO(res->log_, "Finished enabling!");
00082                 EventPtr enableDone(new EnableDone());
00083                 res->commands_.enqEvent(enableDone);
00084 
00085         } catch (xcept::Exception &e) {
00086                 moveToFailedState(e);
00087         }
00088 }
00089 
00090 // construction / destruction
00091 //______________________________________________________________________________
00092 Enabling::Enabling(my_context c) :
00093         my_base(c) {
00094         safeEntryAction();
00095 }
00096 
00097 Enabling::~Enabling() {
00098         safeExitAction();
00099 }
00100 
00101 // exit action, state name, move to failed state
00102 //______________________________________________________________________________
00103 void Enabling::do_exitActionWork() {
00104 }
00105 
00106 string Enabling::do_stateName() const {
00107         return string("Enabling");
00108 }
00109 
00110 void Enabling::do_moveToFailedState(xcept::Exception& exception) const {
00111         SharedResourcesPtr_t res = outermost_context().getSharedResources();
00112         res->reasonForFailed_ = exception.what();
00113         LOG4CPLUS_ERROR(res->log_,
00114                         "Moving to FAILED state! Reason: " << exception.what());
00115         EventPtr fail(new Fail());
00116         res->commands_.enqEvent(fail);
00117 }