CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastMonitor.h
Go to the documentation of this file.
1 /*
2  * FastMonitor.h
3  *
4  * Created on: Nov 27, 2012
5  * Author: aspataru
6  */
7 
8 #ifndef FASTMONITOR_H_
9 #define FASTMONITOR_H_
10 
14 
15 #include <unordered_set>
16 
17 namespace jsoncollector {
18 
19 class FastMonitor {
20 
21 public:
22 
23  FastMonitor(std::string const& defPath, std::string const defGroup, bool strictChecking, bool useSource=true, bool useDefinition=true);
24  FastMonitor(DataPointDefinition * dpd, bool strictChecking, bool useSource=true, bool useDefinition=true);
25 
26  virtual ~FastMonitor();
27 
28  void addFastPathDefinition(std::string const& defPathFast, std::string const defGroupFast, bool strict);
29 
30  void setDefPath(std::string const& dpath) {defPath_=dpath;for (auto dp : dataPoints_) dp->updateDefinition(dpath);}
31 
32  void setNStreams(unsigned int nStreams) {nStreams_=nStreams;}
33 
34  //register global monitorable
35  void registerGlobalMonitorable(JsonMonitorable *newMonitorable, bool NAifZeroUpdates, unsigned int *nBins=nullptr);
36 
37  //register fastPath global monitorable
38  void registerFastGlobalMonitorable(JsonMonitorable *newMonitorable);
39 
40  //register per-stream monitores vector (unsigned int)
42  std::vector<unsigned int> *inputs, bool NAifZeroUpdates, unsigned int *nBins=nullptr);
43 
44  //NOT implemented yet
45  //void registerStreamMonitorableIntVec(std::string &name, std::vector<unsigned int>,true,0);
46  //void registerStreamMonitorableDoubleVec(std::string &name, std::vector<unsigned int>,true,0);
47  //void registerStreamMonitorableStringVec(std::string &name, std::vector<std::string>,true,0);
48 
50  std::vector<AtomicMonUInt*> *inputs, bool NAifZeroUpdates, unsigned int *nBins=nullptr);
51 
52  //take vector used to track stream lumis and finish initialization
53  void commit(std::vector<unsigned int> *streamLumisPtr);
54 
55  // fetches new snapshot and outputs one-line CSV if set (timer based)
56  void snap(unsigned int ls);
57 
58  //only update global variables (invoked at global EOL)
59  void snapGlobal(unsigned int ls);
60 
61  //only updates atomic vectors (for certain stream - at stream EOL)
62  void snapStreamAtomic(unsigned int ls, unsigned int streamID);
63 
64  //fastpath CSV string
66 
67  //fastpath file output
68  void outputCSV(std::string const& path, std::string const& csvString);
69 
70  //provide merged variable back to user
71  JsonMonitorable* getMergedIntJForLumi(std::string const& name,unsigned int forLumi);
72 
73  // merges and outputs everything collected for the given stream to JSON file
74  bool outputFullJSON(std::string const& path, unsigned int lumi, bool log=true);
75 
76  //discard what was collected for a lumisection
77  void discardCollected(unsigned int forLumi);
78 
79  //this is added to the JSON file
80  void getHostAndPID(std::string& sHPid);
81 
82 private:
83 
88  bool useSource_;
90  bool haveFastPath_=false;
91 
92  unsigned int nStreams_;
93 
97  bool deleteDef_=false;
98  bool deleteDefFast_=false;
99 
100  std::vector<DataPoint*> dataPoints_;
101  std::vector<DataPoint*> dataPointsFastOnly_;
102  std::vector<unsigned int> jsonDpIndex_;
103  std::vector<DataPoint*> jsonDpIndexFast_;
104  std::vector<DataPoint*> orphanedDps_;
105  std::map<std::string,unsigned int> dpNameMap_;
106 
107  unsigned int recentSnaps_ = 0;
108  unsigned int recentSnapsTimer_ = 0;
109  unsigned int regDpCount_ = 0;
110  unsigned int fregDpCount_ = 0;
111 
112  std::unordered_set<std::string> uids_;
113 
114 };
115 
116 }
117 
118 #endif /* FASTMONITOR_H_ */
void registerFastGlobalMonitorable(JsonMonitorable *newMonitorable)
Definition: FastMonitor.cc:75
void addFastPathDefinition(std::string const &defPathFast, std::string const defGroupFast, bool strict)
Definition: FastMonitor.cc:51
void setDefPath(std::string const &dpath)
Definition: FastMonitor.h:30
DataPointDefinition * dpdFast_
Definition: FastMonitor.h:96
bool outputFullJSON(std::string const &path, unsigned int lumi, bool log=true)
Definition: FastMonitor.cc:249
void snapStreamAtomic(unsigned int ls, unsigned int streamID)
Definition: FastMonitor.cc:209
tuple lumi
Definition: fjr2json.py:35
void registerStreamMonitorableUIntVecAtomic(std::string const &name, std::vector< AtomicMonUInt * > *inputs, bool NAifZeroUpdates, unsigned int *nBins=nullptr)
Definition: FastMonitor.cc:95
def ls
Definition: eostools.py:346
std::vector< DataPoint * > dataPointsFastOnly_
Definition: FastMonitor.h:101
std::map< std::string, unsigned int > dpNameMap_
Definition: FastMonitor.h:105
std::vector< DataPoint * > orphanedDps_
Definition: FastMonitor.h:104
FastMonitor(std::string const &defPath, std::string const defGroup, bool strictChecking, bool useSource=true, bool useDefinition=true)
Definition: FastMonitor.cc:22
void registerGlobalMonitorable(JsonMonitorable *newMonitorable, bool NAifZeroUpdates, unsigned int *nBins=nullptr)
Definition: FastMonitor.cc:62
std::vector< unsigned int > jsonDpIndex_
Definition: FastMonitor.h:102
tuple path
else: Piece not in the list, fine.
std::vector< DataPoint * > dataPoints_
Definition: FastMonitor.h:100
void registerStreamMonitorableUIntVec(std::string const &name, std::vector< unsigned int > *inputs, bool NAifZeroUpdates, unsigned int *nBins=nullptr)
Definition: FastMonitor.cc:83
std::unordered_set< std::string > uids_
Definition: FastMonitor.h:112
void commit(std::vector< unsigned int > *streamLumisPtr)
Definition: FastMonitor.cc:109
std::vector< DataPoint * > jsonDpIndexFast_
Definition: FastMonitor.h:103
void outputCSV(std::string const &path, std::string const &csvString)
Definition: FastMonitor.cc:231
void snap(unsigned int ls)
Definition: FastMonitor.cc:190
DataPointDefinition * dpd_
Definition: FastMonitor.h:95
JsonMonitorable * getMergedIntJForLumi(std::string const &name, unsigned int forLumi)
Definition: FastMonitor.cc:242
unsigned int recentSnapsTimer_
Definition: FastMonitor.h:108
void getHostAndPID(std::string &sHPid)
Definition: FastMonitor.cc:273
void setNStreams(unsigned int nStreams)
Definition: FastMonitor.h:32
void discardCollected(unsigned int forLumi)
Definition: FastMonitor.cc:268
void snapGlobal(unsigned int ls)
Definition: FastMonitor.cc:200
tuple log
Definition: cmsBatch.py:347