CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/EventFilter/ResourceBroker/interface/FUResourceQueue.h

Go to the documentation of this file.
00001 
00002 //
00003 // FUResourceQueue
00004 // ---------------
00005 //
00006 //            28/10/2011 Andrei Spataru <aspataru@cern.ch>
00008 
00009 #ifndef FURESOURCEQUEUE_H
00010 #define FURESOURCEQUEUE_H 1
00011 
00012 #include "EventFilter/ResourceBroker/interface/RawCache.h"
00013 #include "EventFilter/ResourceBroker/interface/FUTypes.h"
00014 #include "EventFilter/Utilities/interface/MasterQueue.h"
00015 #include "EventFilter/Utilities/interface/Exception.h"
00016 
00017 #include "log4cplus/logger.h"
00018 #include "toolbox/lang/Class.h"
00019 #include "toolbox/task/Action.h"
00020 #include "toolbox/task/WorkLoop.h"
00021 
00022 #include <sys/types.h>
00023 #include <string>
00024 #include <vector>
00025 #include <queue>
00026 
00027 #include "IPCMethod.h"
00028 
00029 namespace evf {
00030 
00031 class FUResourceQueue: public IPCMethod {
00032 public:
00033         //
00034         // construction/destruction
00035         //
00036         FUResourceQueue(bool segmentationMode, UInt_t nbRawCells,
00037                         UInt_t nbRecoCells, UInt_t nbDqmCells, UInt_t rawCellSize,
00038                         UInt_t recoCellSize, UInt_t dqmCellSize, int freeResReq,
00039                         BUProxy* bu, SMProxy* sm, log4cplus::Logger logger, unsigned int,
00040                         EvffedFillerRB*frb, xdaq::Application*) throw (evf::Exception);
00041         virtual ~FUResourceQueue();
00042 
00043         //
00044         // member functions
00045         //
00046         // initialization of the resource queue
00047         void initialize(bool segmentationMode, UInt_t nbRawCells,
00048                         UInt_t nbRecoCells, UInt_t nbDqmCells, UInt_t rawCellSize,
00049                         UInt_t recoCellSize, UInt_t dqmCellSize) throw (evf::Exception);
00050 
00051         // work loop to send data events to storage manager
00052         bool sendData();
00053         //improvement: make simpler
00054         bool sendDataWhileHalting();
00055 
00056         // work loop to send dqm events to storage manager
00057         bool sendDqm();
00058         bool sendDqmWhileHalting();
00059 
00060         // work loop to discard events to builder unit
00061         bool discard();
00062         bool discardWhileHalting(bool sendDiscards);
00063 
00064         // process buffer received via I2O_FU_TAKE message
00065         bool buildResource(MemRef_t* bufRef);
00066 
00067         // process buffer received via I2O_SM_DATA_DISCARD message
00068         bool discardDataEvent(MemRef_t* bufRef);
00069         bool discardDataEventWhileHalting(MemRef_t* bufRef);
00070 
00071         // process buffer received via I2O_SM_DQM_DISCARD message
00072         bool discardDqmEvent(MemRef_t* bufRef);
00073         bool discardDqmEventWhileHalting(MemRef_t* bufRef);
00074 
00075         // post end-of-ls event to shmem
00076         void postEndOfLumiSection(MemRef_t* bufRef);
00077 
00078         // drop next available event
00079         void dropEvent();
00080 
00081         // send event belonging to crashed process to error stream (return false
00082         // if no event is found)
00083         bool handleCrashedEP(UInt_t runNumber, pid_t pid);
00084 
00085         // dump event to ascii file
00086         void dumpEvent(evf::FUShmRawCell* cell);
00087 
00088         // send empty events to notify clients to shutdown
00089         void shutDownClients();
00090 
00091         void clear();
00092 
00093         // reset event & error counters
00094         void resetCounters();
00095 
00096         UInt_t nbResources() const {
00097                 return resources_.size();
00098         }
00099 
00100         // information about (raw) shared memory cells
00101         UInt_t nbClients() const;
00102         std::vector<pid_t> clientPrcIds() const;
00103         std::string clientPrcIdsAsString() const;
00104         std::vector<std::string> cellStates() const;
00105         std::vector<std::string> dqmCellStates() const;
00106         std::vector<UInt_t> cellEvtNumbers() const;
00107         std::vector<pid_t> cellPrcIds() const;
00108         std::vector<time_t> cellTimeStamps() const;
00109 
00110         //
00111         // helpers
00112         //
00113         void lastResort();
00114         void resetIPC() {
00115                 // nothing here
00116         }
00117 
00118 private:
00119         //
00120         // member data
00121         //
00122 
00123         MasterQueue msq_;
00124         RawCache* cache_;
00125 
00126         // XXX move?
00127         UInt_t rawCellSize_, recoCellSize_, dqmCellSize_;
00128 
00129 };
00130 
00131 } // namespace evf
00132 
00133 
00134 #endif // FURESOURCEQUEUE_H