CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StreamsMonitorCollection.h
Go to the documentation of this file.
1 // $Id: StreamsMonitorCollection.h,v 1.17 2011/11/17 17:35:41 mommsen Exp $
3 
4 #ifndef EventFilter_StorageManager_StreamsMonitorCollection_h
5 #define EventFilter_StorageManager_StreamsMonitorCollection_h
6 
7 #include <sstream>
8 #include <iomanip>
9 #include <vector>
10 #include <set>
11 
12 #include <boost/thread/mutex.hpp>
13 #include <boost/shared_ptr.hpp>
14 
15 #include "xdata/Double.h"
16 #include "xdata/String.h"
17 #include "xdata/UnsignedInteger32.h"
18 #include "xdata/Vector.h"
19 
23 
24 
25 namespace stor {
26 
36  {
37  public:
38 
39  struct StreamRecord
40  {
42  (
44  const utils::Duration_t& updateInterval,
45  const utils::Duration_t& timeWindowForRecentResults
46  ) :
47  streamName(""),
49  fractionToDisk(1),
50  fileCount(updateInterval,timeWindowForRecentResults),
51  volume(updateInterval,timeWindowForRecentResults),
52  bandwidth(updateInterval,timeWindowForRecentResults),
53  parentCollection(coll) {}
54 
56  { fileCountPerLS.clear(); }
57 
58  void incrementFileCount(const uint32_t lumiSection);
59  void addSizeInBytes(double);
61  (
62  const uint32_t& lumiSection,
63  std::string& str
64  );
65 
66  std::string streamName; // name of the stream
67  std::string outputModuleLabel;// label of the associated output module
68  double fractionToDisk; // fraction of events written to disk
69  MonitoredQuantity fileCount; // number of files written for this stream
70  MonitoredQuantity volume; // data in MBytes stored in this stream
71  MonitoredQuantity bandwidth; // bandwidth in MBytes for this stream
72 
74 
75  typedef std::map<uint32_t, unsigned int> FileCountPerLumiSectionMap;
77  };
78 
79  // We do not know how many streams there will be.
80  // Thus, we need a vector of them.
81  typedef boost::shared_ptr<StreamRecord> StreamRecordPtr;
82  typedef std::vector<StreamRecordPtr> StreamRecordList;
83 
84 
86  {
88 
89  void reset()
91 
93  {
95  }
96 
98  unsigned int eolsCount;
99  unsigned int lsCountWithFiles;
100  };
101  typedef boost::shared_ptr<EndOfRunReport> EndOfRunReportPtr;
102 
103 
104  explicit StreamsMonitorCollection(const utils::Duration_t& updateInterval);
105 
107 
108  void getStreamRecords(StreamRecordList&) const;
109 
110  bool getStreamRecordsForOutputModuleLabel(const std::string&, StreamRecordList&) const;
111 
112  bool streamRecordsExist() const;
113 
115  return allStreamsFileCount_;
116  }
118  return allStreamsFileCount_;
119  }
120 
122  return allStreamsVolume_;
123  }
125  return allStreamsVolume_;
126  }
127 
129  return allStreamsBandwidth_;
130  }
132  return allStreamsBandwidth_;
133  }
134 
136 
137 
138  private:
139 
140  //Prevent copying of the StreamsMonitorCollection
143 
144  typedef std::set<uint32_t> UnreportedLS;
146 
147  virtual void do_calculateStatistics();
148  virtual void do_reset();
150  virtual void do_updateInfoSpaceItems();
151 
154 
157 
161 
162  xdata::UnsignedInteger32 storedEvents_; // number of events stored in all streams
163  xdata::Double storedVolume_; // total volume in MB stored on disk
164  xdata::Double bandwidthToDisk_; // recent bandwidth in MB/s written to disk
165  xdata::Vector<xdata::String> streamNames_; // names of all streams written
166  xdata::Vector<xdata::UnsignedInteger32> eventsPerStream_; // total number of events stored per stream
167  xdata::Vector<xdata::Double> ratePerStream_; // recent event rate (Hz) per stream
168  xdata::Vector<xdata::Double> bandwidthPerStream_; // recent bandwidth (MB/s) per stream
169  };
170 
171 } // namespace stor
172 
173 #endif // EventFilter_StorageManager_StreamsMonitorCollection_h
174 
175 
std::map< uint32_t, unsigned int > FileCountPerLumiSectionMap
static boost::mutex mutex
Definition: LHEProxy.cc:11
bool getStreamRecordsForOutputModuleLabel(const std::string &, StreamRecordList &) const
StreamsMonitorCollection & operator=(StreamsMonitorCollection const &)
const utils::Duration_t timeWindowForRecentResults_
xdata::Vector< xdata::UnsignedInteger32 > eventsPerStream_
xdata::Vector< xdata::String > streamNames_
const MonitoredQuantity & getAllStreamsBandwidthMQ() const
boost::shared_ptr< EndOfRunReport > EndOfRunReportPtr
std::vector< StreamRecordPtr > StreamRecordList
xdata::UnsignedInteger32 storedEvents_
boost::posix_time::time_duration Duration_t
Definition: Utils.h:41
MonitoredQuantity & getAllStreamsFileCountMQ()
boost::shared_ptr< DbFileHandler > DbFileHandlerPtr
Definition: DbFileHandler.h:71
const MonitoredQuantity & getAllStreamsVolumeMQ() const
boost::shared_ptr< StreamRecord > StreamRecordPtr
void incrementFileCount(const uint32_t lumiSection)
StreamRecord(StreamsMonitorCollection *coll, const utils::Duration_t &updateInterval, const utils::Duration_t &timeWindowForRecentResults)
void reportAllLumiSectionInfos(DbFileHandlerPtr, EndOfRunReportPtr)
virtual void do_appendInfoSpaceItems(InfoSpaceItems &)
MonitoredQuantity & getAllStreamsBandwidthMQ()
xdata::Vector< xdata::Double > ratePerStream_
JetCorrectorParametersCollection coll
Definition: classes.h:14
std::vector< std::pair< std::string, xdata::Serializable * > > InfoSpaceItems
void getStreamRecords(StreamRecordList &) const
bool reportLumiSectionInfo(const uint32_t &lumiSection, std::string &str)
const MonitoredQuantity & getAllStreamsFileCountMQ() const
StreamsMonitorCollection(const utils::Duration_t &updateInterval)
xdata::Vector< xdata::Double > bandwidthPerStream_