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.15 2011/06/20 15:55:52 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  fileCount(updateInterval,timeWindowForRecentResults),
48  volume(updateInterval,timeWindowForRecentResults),
49  bandwidth(updateInterval,timeWindowForRecentResults),
50  parentCollection(coll) {}
51 
53  { fileCountPerLS.clear(); }
54 
55  void incrementFileCount(const uint32_t lumiSection);
56  void addSizeInBytes(double);
58  (
59  const uint32_t& lumiSection,
60  std::string& str
61  );
62 
63  std::string streamName; // name of the stream
64  double fractionToDisk; // fraction of events written to disk
65  MonitoredQuantity fileCount; // number of files written for this stream
66  MonitoredQuantity volume; // data in MBytes stored in this stream
67  MonitoredQuantity bandwidth; // bandwidth in MBytes for this stream
68 
70 
71  typedef std::map<uint32_t, unsigned int> FileCountPerLumiSectionMap;
73  };
74 
75  // We do not know how many streams there will be.
76  // Thus, we need a vector of them.
77  typedef boost::shared_ptr<StreamRecord> StreamRecordPtr;
78  typedef std::vector<StreamRecordPtr> StreamRecordList;
79 
80 
82  {
84 
85  void reset()
87 
89  {
91  }
92 
94  unsigned int eolsCount;
95  unsigned int lsCountWithFiles;
96  };
97  typedef boost::shared_ptr<EndOfRunReport> EndOfRunReportPtr;
98 
99 
100  explicit StreamsMonitorCollection(const utils::Duration_t& updateInterval);
101 
103 
104  void getStreamRecords(StreamRecordList&) const;
105 
106  bool streamRecordsExist() const;
107 
109  return allStreamsFileCount_;
110  }
112  return allStreamsFileCount_;
113  }
114 
116  return allStreamsVolume_;
117  }
119  return allStreamsVolume_;
120  }
121 
123  return allStreamsBandwidth_;
124  }
126  return allStreamsBandwidth_;
127  }
128 
130 
131 
132  private:
133 
134  //Prevent copying of the StreamsMonitorCollection
137 
138  typedef std::set<uint32_t> UnreportedLS;
140 
141  virtual void do_calculateStatistics();
142  virtual void do_reset();
144  virtual void do_updateInfoSpaceItems();
145 
148 
151 
155 
156  xdata::UnsignedInteger32 storedEvents_; // number of events stored in all streams
157  xdata::Double storedVolume_; // total volume in MB stored on disk
158  xdata::Double bandwidthToDisk_; // recent bandwidth in MB/s written to disk
159  xdata::Vector<xdata::String> streamNames_; // names of all streams written
160  xdata::Vector<xdata::UnsignedInteger32> eventsPerStream_; // total number of events stored per stream
161  xdata::Vector<xdata::Double> ratePerStream_; // recent event rate (Hz) per stream
162  xdata::Vector<xdata::Double> bandwidthPerStream_; // recent bandwidth (MB/s) per stream
163  };
164 
165 } // namespace stor
166 
167 #endif // EventFilter_StorageManager_StreamsMonitorCollection_h
168 
169 
std::map< uint32_t, unsigned int > FileCountPerLumiSectionMap
static boost::mutex mutex
Definition: LHEProxy.cc:11
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:65
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_