CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FUResourceTable.h
Go to the documentation of this file.
1 //
3 // FUResourceTable
4 // ---------------
5 //
6 // 12/10/2006 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
7 // 20/01/2012 Andrei Spataru <aspataru@cern.ch>
9 
10 #ifndef FURESOURCETABLE_H
11 #define FURESOURCETABLE_H 1
12 
18 
19 #include "log4cplus/logger.h"
20 #include "toolbox/lang/Class.h"
21 #include "toolbox/task/Action.h"
22 #include "toolbox/task/WorkLoop.h"
23 
24 #include <sys/types.h>
25 #include <string>
26 #include <vector>
27 #include <queue>
28 
29 #include "IPCMethod.h"
30 
31 namespace evf {
32 
40 class FUResourceTable: public IPCMethod {
41 public:
42  //
43  // construction/destruction
44  //
45  FUResourceTable(bool segmentationMode, UInt_t nbRawCells,
46  UInt_t nbRecoCells, UInt_t nbDqmCells, UInt_t rawCellSize,
47  UInt_t recoCellSize, UInt_t dqmCellSize, int freeResReq, BUProxy* bu, SMProxy* sm,
48  log4cplus::Logger logger, unsigned int, EvffedFillerRB* frb,
49  xdaq::Application*) throw (evf::Exception);
50  virtual ~FUResourceTable();
51 
52  //
53  // member functions
54  //
55 
59  void initialize(bool segmentationMode, UInt_t nbRawCells,
60  UInt_t nbRecoCells, UInt_t nbDqmCells, UInt_t rawCellSize,
61  UInt_t recoCellSize, UInt_t dqmCellSize) throw (evf::Exception);
62 
66  bool sendData();
70  bool sendDataWhileHalting();
71 
75  bool sendDqm();
79  bool sendDqmWhileHalting();
80 
84  bool discard();
88  bool discardWhileHalting(bool sendDiscards);
89 
93  bool buildResource(MemRef_t* bufRef);
94 
98  bool discardDataEvent(MemRef_t* bufRef);
99 
104 
108  bool discardDqmEvent(MemRef_t* bufRef);
113 
117  void postEndOfLumiSection(MemRef_t* bufRef);
118 
122  void dropEvent();
123 
128  bool handleCrashedEP(UInt_t runNumber, pid_t pid);
129 
133  void shutDownClients();
134 
138  void clear();
139 
143  void resetCounters();
144 
145  UInt_t nbResources() const {
146  return resources_.size();
147  }
148 
149  // information about (raw) shared memory cells
150  UInt_t nbClients() const;
151  std::vector<pid_t> clientPrcIds() const;
152  std::string clientPrcIdsAsString() const;
153  std::vector<std::string> cellStates() const;
154  std::vector<std::string> dqmCellStates() const;
155  std::vector<UInt_t> cellEvtNumbers() const;
156  std::vector<pid_t> cellPrcIds() const;
157  std::vector<time_t> cellTimeStamps() const;
158 
159  //
160  // helpers
161  //
162  unsigned int nbResources() {
163  return resources_.size();
164  }
165  void lastResort();
167  void resetIPC();
168 
169  //debugging
170  std::string printStatus();
171 
172 private:
173 
178  void discardNoReschedule();
179 
183  void rethrowShmBufferException(evf::Exception& e, std::string where) const throw (evf::Exception);
184 
188  void shutdownWatchdog(unsigned int timeout);
189 
190 
192 
193  //workloop termination status
196 
197  std::atomic_bool watchDogEnd_;
198  std::atomic_bool watchDogSetFailed_;
199 
200 
201 };
202 
203 } // namespace evf
204 
205 
206 #endif
bool discardDataEvent(MemRef_t *bufRef)
std::vector< UInt_t > cellEvtNumbers() const
std::vector< std::string > cellStates() const
FUResourceTable(bool segmentationMode, UInt_t nbRawCells, UInt_t nbRecoCells, UInt_t nbDqmCells, UInt_t rawCellSize, UInt_t recoCellSize, UInt_t dqmCellSize, int freeResReq, BUProxy *bu, SMProxy *sm, log4cplus::Logger logger, unsigned int, EvffedFillerRB *frb, xdaq::Application *)
bool handleCrashedEP(UInt_t runNumber, pid_t pid)
std::ostream & logger()
Definition: fwLog.cc:41
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
std::atomic_bool watchDogEnd_
bool buildResource(MemRef_t *bufRef)
unsigned int nbResources()
UInt_t nbClients() const
FUShmBuffer * shmBuffer_
bool discardWhileHalting(bool sendDiscards)
void shutdownWatchdog(unsigned int timeout)
std::vector< time_t > cellTimeStamps() const
bool discardDqmEventWhileHalting(MemRef_t *bufRef)
std::vector< pid_t > clientPrcIds() const
FUResourceVec_t resources_
Definition: IPCMethod.h:393
UInt_t nbResources() const
unsigned int UInt_t
Definition: FUTypes.h:12
std::string clientPrcIdsAsString() const
std::vector< pid_t > cellPrcIds() const
void postEndOfLumiSection(MemRef_t *bufRef)
std::atomic_bool watchDogSetFailed_
std::vector< std::string > dqmCellStates() const
void rethrowShmBufferException(evf::Exception &e, std::string where) const
bool discardDqmEvent(MemRef_t *bufRef)
bool discardDataEventWhileHalting(MemRef_t *bufRef)
void resetIPC()
reset the ShmBuffer to the initial state
void initialize(bool segmentationMode, UInt_t nbRawCells, UInt_t nbRecoCells, UInt_t nbDqmCells, UInt_t rawCellSize, UInt_t recoCellSize, UInt_t dqmCellSize)