CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  public:
21  FastMonitor(std::string const& defPath,
22  std::string const defGroup,
23  bool strictChecking,
24  bool useSource = true,
25  bool useDefinition = true);
26  FastMonitor(DataPointDefinition const* dpd, bool strictChecking, bool useSource = true, bool useDefinition = true);
27 
28  virtual ~FastMonitor();
29 
30  void addFastPathDefinition(std::string const& defPathFast, std::string const defGroupFast, bool strict);
31 
32  void setDefPath(std::string const& dpath) {
33  defPath_ = dpath;
34  for (auto dp : dataPoints_)
35  dp->updateDefinition(dpath);
36  }
37 
38  void setNStreams(unsigned int nStreams) { nStreams_ = nStreams; }
39 
40  //register global monitorable
41  void registerGlobalMonitorable(JsonMonitorable* newMonitorable,
42  bool NAifZeroUpdates,
43  unsigned int* nBins = nullptr);
44 
45  //register fastPath global monitorable
46  void registerFastGlobalMonitorable(JsonMonitorable* newMonitorable);
47 
48  //register per-stream monitores vector (unsigned int)
50  std::vector<unsigned int>* inputs,
51  bool NAifZeroUpdates,
52  unsigned int* nBins = nullptr);
53 
54  //NOT implemented yet
55  //void registerStreamMonitorableIntVec(std::string &name, std::vector<unsigned int>,true,0);
56  //void registerStreamMonitorableDoubleVec(std::string &name, std::vector<unsigned int>,true,0);
57  //void registerStreamMonitorableStringVec(std::string &name, std::vector<std::string>,true,0);
58 
60  std::vector<AtomicMonUInt*>* inputs,
61  bool NAifZeroUpdates,
62  unsigned int* nBins = nullptr);
63 
64  //take vector used to track stream lumis and finish initialization
65  void commit(std::vector<unsigned int>* streamLumisPtr);
66 
67  // fetches new snapshot and outputs one-line CSV if set (timer based)
68  void snap(unsigned int ls);
69 
70  //only update global variables (invoked at global EOL)
71  void snapGlobal(unsigned int ls);
72 
73  //only updates atomic vectors (for certain stream - at stream EOL)
74  void snapStreamAtomic(unsigned int ls, unsigned int streamID);
75 
76  //fastpath CSV string
77  std::string getCSVString(int sid = -1);
78 
79  //fastpath file output
80  void outputCSV(std::string const& path, std::string const& csvString);
81 
82  //provide merged variable back to user
83  JsonMonitorable* getMergedIntJForLumi(std::string const& name, unsigned int forLumi);
84 
85  // merges and outputs everything collected for the given stream to JSON file
86  bool outputFullJSONs(std::string const& pathstem, std::string const& ext, unsigned int lumi, bool output = true);
87  bool outputFullJSON(std::string const& path, unsigned int lumi, bool output = true);
88 
89  //discard what was collected for a lumisection
90  void discardCollected(unsigned int forLumi);
91 
92  //this is added to the JSON file
93  void getHostAndPID(std::string& sHPid);
94 
95  private:
102  bool haveFastPath_ = false;
103 
104  unsigned int nStreams_;
105 
109  bool deleteDef_ = false;
110  bool deleteDefFast_ = false;
111 
112  std::vector<DataPoint*> dataPoints_;
113  std::vector<DataPoint*> dataPointsFastOnly_;
114  std::vector<unsigned int> jsonDpIndex_;
115  std::vector<DataPoint*> jsonDpIndexFast_;
116  std::vector<DataPoint*> orphanedDps_;
117  std::map<std::string, unsigned int> dpNameMap_;
118 
119  unsigned int recentSnaps_ = 0;
120  unsigned int recentSnapsTimer_ = 0;
121  unsigned int regDpCount_ = 0;
122  unsigned int fregDpCount_ = 0;
123 
124  std::unordered_set<std::string> uids_;
125  };
126 
127 } // namespace jsoncollector
128 
129 #endif /* FASTMONITOR_H_ */
void registerFastGlobalMonitorable(JsonMonitorable *newMonitorable)
Definition: FastMonitor.cc:81
void addFastPathDefinition(std::string const &defPathFast, std::string const defGroupFast, bool strict)
Definition: FastMonitor.cc:56
void setDefPath(std::string const &dpath)
Definition: FastMonitor.h:32
DataPointDefinition const * dpd_
Definition: FastMonitor.h:107
void snapStreamAtomic(unsigned int ls, unsigned int streamID)
Definition: FastMonitor.cc:207
void registerStreamMonitorableUIntVecAtomic(std::string const &name, std::vector< AtomicMonUInt * > *inputs, bool NAifZeroUpdates, unsigned int *nBins=nullptr)
Definition: FastMonitor.cc:101
def ls
Definition: eostools.py:349
std::vector< DataPoint * > dataPointsFastOnly_
Definition: FastMonitor.h:113
std::vector< DataPoint * > orphanedDps_
Definition: FastMonitor.h:116
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:67
std::vector< unsigned int > jsonDpIndex_
Definition: FastMonitor.h:114
std::vector< DataPoint * > dataPoints_
Definition: FastMonitor.h:112
void registerStreamMonitorableUIntVec(std::string const &name, std::vector< unsigned int > *inputs, bool NAifZeroUpdates, unsigned int *nBins=nullptr)
Definition: FastMonitor.cc:88
std::map< std::string, unsigned int > dpNameMap_
Definition: FastMonitor.h:117
std::unordered_set< std::string > uids_
Definition: FastMonitor.h:124
list lumi
Definition: dqmdumpme.py:53
void commit(std::vector< unsigned int > *streamLumisPtr)
Definition: FastMonitor.cc:116
std::string getCSVString(int sid=-1)
Definition: FastMonitor.cc:214
bool outputFullJSON(std::string const &path, unsigned int lumi, bool output=true)
Definition: FastMonitor.cc:268
std::vector< DataPoint * > jsonDpIndexFast_
Definition: FastMonitor.h:115
DataPointDefinition const * dpdFast_
Definition: FastMonitor.h:108
void outputCSV(std::string const &path, std::string const &csvString)
Definition: FastMonitor.cc:228
void snap(unsigned int ls)
Definition: FastMonitor.cc:190
JsonMonitorable * getMergedIntJForLumi(std::string const &name, unsigned int forLumi)
Definition: FastMonitor.cc:237
unsigned int recentSnapsTimer_
Definition: FastMonitor.h:120
void getHostAndPID(std::string &sHPid)
Definition: FastMonitor.cc:291
void setNStreams(unsigned int nStreams)
Definition: FastMonitor.h:38
void discardCollected(unsigned int forLumi)
Definition: FastMonitor.cc:286
bool outputFullJSONs(std::string const &pathstem, std::string const &ext, unsigned int lumi, bool output=true)
Definition: FastMonitor.cc:243
void snapGlobal(unsigned int ls)
Definition: FastMonitor.cc:199