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
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
00026
00027
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
00038
00039 res->reset();
00040 resourceStructure->setRunNumber(res->runNumber_);
00041 res->lock();
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 resourceStructure->resetCounters();
00053 res->unlock();
00054
00055 LOG4CPLUS_INFO(res->log_, "Starting monitoring / watching workloops.");
00056
00057 res->startMonitoringWorkLoop();
00058
00059
00060 if (!res->useMessageQueueIPC_)
00061 res->startWatchingWorkLoop();
00062
00063
00064
00065 res->startDiscardWorkLoop();
00066
00067 res->startSendDataWorkLoop();
00068
00069 res->startSendDqmWorkLoop();
00070
00071 resourceStructure->sendAllocate();
00072
00073 res->nbTimeoutsWithEvent_ = 0;
00074 res->nbTimeoutsWithoutEvent_ = 0;
00075 res->dataErrorFlag_ = 0;
00076
00077
00078
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
00091
00092 Enabling::Enabling(my_context c) :
00093 my_base(c) {
00094 safeEntryAction();
00095 }
00096
00097 Enabling::~Enabling() {
00098 safeExitAction();
00099 }
00100
00101
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 }