CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Halting.cc
Go to the documentation of this file.
1 
7 #include "EvffedFillerRB.h"
8 
9 #include <iostream>
10 
11 using std::string;
12 using std::cout;
13 using std::endl;
14 using namespace evf::rb_statemachine;
15 
16 // entry action, state notification, state action
17 //______________________________________________________________________________
19 }
20 
22  SharedResourcesPtr_t res = outermost_context().getSharedResources();
23  LOG4CPLUS_INFO(res->log_, "--> ResourceBroker: NEW STATE: " << stateName());
24  outermost_context().setExternallyVisibleState(stateName());
25  outermost_context().setInternalStateName(stateName());
26  // RCMS notification no longer required here
27  // this is done in FUResourceBroker in SOAP reply
28  //outermost_context().rcmsStateChangeNotify();
29 }
30 
32  SharedResourcesPtr_t res = outermost_context().getSharedResources();
33  try {
34  LOG4CPLUS_INFO(res->log_, "Start halting ...");
35  if (res->resourceStructure_->isActive()) {
36  res->resourceStructure_->shutDownClients();
37  UInt_t count = 0;
38  while (count < 10) {
39  if (res->resourceStructure_->isReadyToShutDown()) {
40  res->lock();
41 
42  delete res->resourceStructure_;
43  res->resourceStructure_ = 0;
44 
45  res->unlock();
46  LOG4CPLUS_INFO(
47  res->log_,
48  count + 1
49  << ". try to destroy resource table succeeded!");
50  break;
51  } else {
52  count++;
53 
54  LOG4CPLUS_DEBUG(
55  res->log_,
56  count
57  << ". try to destroy resource table failed ...");
58 
59  ::sleep(1);
60  }
61  }
62  } else {
63  res->lock();
64 
65  delete res->resourceStructure_;
66  res->resourceStructure_ = 0;
67 
68  res->unlock();
69  }
70 
71  if (0 == res->resourceStructure_) {
72  LOG4CPLUS_INFO(res->log_, "Finished halting!");
73  EventPtr haltDone(new HaltDone());
74  res->commands_.enqEvent(haltDone);
75  } else {
76  res->reasonForFailed_
77  = "halting FAILED: ResourceTable shutdown timed out.";
78  LOG4CPLUS_FATAL(res->log_,
79  "Moving to FAILED state! Reason: " << res->reasonForFailed_.value_);
80  EventPtr failTimeOut(new Fail());
81  res->commands_.enqEvent(failTimeOut);
82  }
83  } catch (xcept::Exception &e) {
85  }
86 
87  if (res->frb_)
88  delete res->frb_;
89 }
90 
91 /*
92  * I2O capability
93  */
94 bool Halting::discardDataEvent(MemRef_t* bufRef) const {
95  SharedResourcesPtr_t res = outermost_context().getSharedResources();
96  bool returnValue = false;
97  try {
98  returnValue = res->resourceStructure_->discardDataEventWhileHalting(
99  bufRef);
100  } catch (evf::Exception& e) {
102  }
103  return returnValue;
104 }
105 bool Halting::discardDqmEvent(MemRef_t* bufRef) const {
106  SharedResourcesPtr_t res = outermost_context().getSharedResources();
107  bool returnValue = false;
108  try {
109  returnValue = res->resourceStructure_->discardDqmEvent(bufRef);
110  //returnValue = res->resourceStructure_->discardDqmEventWhileHalting(bufRef);
111  } catch (evf::Exception& e) {
113  }
114  return returnValue;
115 }
116 
117 // construction / destruction
118 //______________________________________________________________________________
119 Halting::Halting(my_context c) :
120  my_base(c) {
121  safeEntryAction();
122 }
123 
125  safeExitAction();
126 }
127 
128 // exit action, state name, move to failed state
129 //______________________________________________________________________________
131 }
132 
133 string Halting::do_stateName() const {
134  return string("Halting");
135 }
136 
138  SharedResourcesPtr_t res = outermost_context().getSharedResources();
139  res->reasonForFailed_ = exception.what();
140  LOG4CPLUS_FATAL(res->log_,
141  "Moving to FAILED state! Reason: " << exception.what());
142  EventPtr fail(new Fail());
143  res->commands_.enqEvent(fail);
144 }
virtual void do_entryActionWork()
Definition: Halting.cc:18
virtual void do_stateNotify()
Definition: Halting.cc:21
virtual void do_moveToFailedState(xcept::Exception &exception) const
Definition: Halting.cc:137
virtual bool discardDqmEvent(MemRef_t *bufRef) const
Definition: Halting.cc:105
boost::shared_ptr< SharedResources > SharedResourcesPtr_t
virtual void do_stateAction() const
Definition: Halting.cc:31
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
reject
Definition: HLTenums.h:23
virtual std::string do_stateName() const
Definition: Halting.cc:133
boost::shared_ptr< boost::statechart::event_base > EventPtr
Definition: CommandQueue.h:23
void sleep(Duration_t)
Definition: Utils.h:163
void moveToFailedState(xcept::Exception &exception) const
Definition: BaseState.cc:35
unsigned int UInt_t
Definition: FUTypes.h:12
virtual void do_exitActionWork()
Definition: Halting.cc:130
virtual bool discardDataEvent(MemRef_t *bufRef) const
Definition: Halting.cc:94
tuple cout
Definition: gather_cfg.py:121
std::string stateName() const
Definition: BaseState.cc:31