CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FUResourceQueue.h
Go to the documentation of this file.
1 //
3 // FUResourceQueue
4 // ---------------
5 //
6 // 28/10/2011 Andrei Spataru <aspataru@cern.ch>
8 
9 #ifndef FURESOURCEQUEUE_H
10 #define FURESOURCEQUEUE_H 1
11 
16 
17 #include "log4cplus/logger.h"
18 #include "toolbox/lang/Class.h"
19 #include "toolbox/task/Action.h"
20 #include "toolbox/task/WorkLoop.h"
21 
22 #include <sys/types.h>
23 #include <string>
24 #include <vector>
25 #include <queue>
26 
27 #include "IPCMethod.h"
28 
29 namespace evf {
30 
31 class FUResourceQueue: public IPCMethod {
32 public:
33  //
34  // construction/destruction
35  //
36  FUResourceQueue(bool segmentationMode, UInt_t nbRawCells,
37  UInt_t nbRecoCells, UInt_t nbDqmCells, UInt_t rawCellSize,
38  UInt_t recoCellSize, UInt_t dqmCellSize, int freeResReq,
39  BUProxy* bu, SMProxy* sm, log4cplus::Logger logger, unsigned int,
40  EvffedFillerRB*frb, xdaq::Application*) throw (evf::Exception);
41  virtual ~FUResourceQueue();
42 
43  //
44  // member functions
45  //
46  // initialization of the resource queue
47  void initialize(bool segmentationMode, UInt_t nbRawCells,
48  UInt_t nbRecoCells, UInt_t nbDqmCells, UInt_t rawCellSize,
49  UInt_t recoCellSize, UInt_t dqmCellSize) throw (evf::Exception);
50 
51  // work loop to send data events to storage manager
52  bool sendData();
53  //improvement: make simpler
54  bool sendDataWhileHalting();
55 
56  // work loop to send dqm events to storage manager
57  bool sendDqm();
58  bool sendDqmWhileHalting();
59 
60  // work loop to discard events to builder unit
61  bool discard();
62  bool discardWhileHalting(bool sendDiscards);
63 
64  // process buffer received via I2O_FU_TAKE message
65  bool buildResource(MemRef_t* bufRef);
66 
67  // process buffer received via I2O_SM_DATA_DISCARD message
68  bool discardDataEvent(MemRef_t* bufRef);
70 
71  // process buffer received via I2O_SM_DQM_DISCARD message
72  bool discardDqmEvent(MemRef_t* bufRef);
74 
75  // post end-of-ls event to shmem
76  void postEndOfLumiSection(MemRef_t* bufRef);
77 
78  // drop next available event
79  void dropEvent();
80 
81  // send event belonging to crashed process to error stream (return false
82  // if no event is found)
83  bool handleCrashedEP(UInt_t runNumber, pid_t pid);
84 
85  // dump event to ascii file
86  void dumpEvent(evf::FUShmRawCell* cell);
87 
88  // send empty events to notify clients to shutdown
89  void shutDownClients();
90 
91  void clear();
92 
93  // reset event & error counters
94  void resetCounters();
95 
96  UInt_t nbResources() const {
97  return resources_.size();
98  }
99 
100  // information about (raw) shared memory cells
101  UInt_t nbClients() const;
102  std::vector<pid_t> clientPrcIds() const;
103  std::string clientPrcIdsAsString() const;
104  std::vector<std::string> cellStates() const;
105  std::vector<std::string> dqmCellStates() const;
106  std::vector<UInt_t> cellEvtNumbers() const;
107  std::vector<pid_t> cellPrcIds() const;
108  std::vector<time_t> cellTimeStamps() const;
109 
110  //
111  // helpers
112  //
113  void lastResort();
114  void resetIPC() {
115  // nothing here
116  }
117 
118 private:
119  //
120  // member data
121  //
122 
125 
126  // XXX move?
128 
129 };
130 
131 } // namespace evf
132 
133 
134 #endif // FURESOURCEQUEUE_H
bool handleCrashedEP(UInt_t runNumber, pid_t pid)
void initialize(bool segmentationMode, UInt_t nbRawCells, UInt_t nbRecoCells, UInt_t nbDqmCells, UInt_t rawCellSize, UInt_t recoCellSize, UInt_t dqmCellSize)
std::vector< pid_t > clientPrcIds() const
std::ostream & logger()
Definition: fwLog.cc:41
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
std::vector< std::string > cellStates() const
UInt_t nbResources() const
UInt_t nbClients() const
std::vector< time_t > cellTimeStamps() const
FUResourceQueue(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 *)
void postEndOfLumiSection(MemRef_t *bufRef)
bool discardDqmEventWhileHalting(MemRef_t *bufRef)
FUResourceVec_t resources_
Definition: IPCMethod.h:393
unsigned int UInt_t
Definition: FUTypes.h:12
void dumpEvent(evf::FUShmRawCell *cell)
bool buildResource(MemRef_t *bufRef)
std::string clientPrcIdsAsString() const
bool discardDataEvent(MemRef_t *bufRef)
bool discardDqmEvent(MemRef_t *bufRef)
bool discardDataEventWhileHalting(MemRef_t *bufRef)
std::vector< std::string > dqmCellStates() const
void resetIPC()
resets the underlying IPC method to the initial state
std::vector< UInt_t > cellEvtNumbers() const
std::vector< pid_t > cellPrcIds() const
bool discardWhileHalting(bool sendDiscards)