CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
stor::MonitoredQuantity Class Reference

#include <MonitoredQuantity.h>

Classes

struct  Stats
 

Public Types

enum  DataSetType { FULL = 0, RECENT = 1 }
 

Public Member Functions

void addSample (const double &value=1)
 
void addSample (const int &value=1)
 
void addSample (const unsigned int &value=1)
 
void addSample (const long &value=1)
 
void addSample (const unsigned long &value=1)
 
void addSample (const long long &value=1)
 
void addSample (const unsigned long long &value=1)
 
void addSampleIfLarger (const double &value)
 
void calculateStatistics (const utils::TimePoint_t &currentTime=utils::getCurrentTime())
 
void disable ()
 
void enable ()
 
utils::Duration_t ExpectedCalculationInterval () const
 
void getStats (Stats &stats) const
 
utils::Duration_t getTimeWindowForRecentResults () const
 
bool isEnabled () const
 
 MonitoredQuantity (utils::Duration_t expectedCalculationInterval, utils::Duration_t timeWindowForRecentResults)
 
void reset ()
 
void setNewTimeWindowForRecentResults (const utils::Duration_t &interval)
 

Private Member Functions

 MonitoredQuantity (MonitoredQuantity const &)
 
MonitoredQuantityoperator= (MonitoredQuantity const &)
 
void resetAccumulators ()
 
void resetResults ()
 

Private Attributes

boost::mutex accumulationMutex_
 
uint32_t binCount_
 
std::vector< utils::Duration_tbinDuration_
 
std::vector< uint64_t > binSampleCount_
 
std::vector< utils::TimePoint_tbinSnapshotTime_
 
std::vector< double > binValueMax_
 
std::vector< double > binValueMin_
 
std::vector< double > binValueSum_
 
std::vector< double > binValueSumOfSquares_
 
bool enabled_
 
const utils::Duration_t expectedCalculationInterval_
 
utils::Duration_t fullDuration_
 
uint64_t fullSampleCount_
 
double fullSampleRate_
 
double fullValueAverage_
 
double fullValueMax_
 
double fullValueMin_
 
double fullValueRate_
 
double fullValueRMS_
 
double fullValueSum_
 
double fullValueSumOfSquares_
 
utils::Duration_t intervalForRecentStats_
 
utils::TimePoint_t lastCalculationTime_
 
double lastLatchedSampleValue_
 
double lastLatchedValueRate_
 
utils::Duration_t recentDuration_
 
uint64_t recentSampleCount_
 
double recentSampleRate_
 
double recentValueAverage_
 
double recentValueMax_
 
double recentValueMin_
 
double recentValueRate_
 
double recentValueRMS_
 
double recentValueSum_
 
double recentValueSumOfSquares_
 
boost::mutex resultsMutex_
 
uint32_t workingBinId_
 
double workingLastSampleValue_
 
uint64_t workingSampleCount_
 
double workingValueMax_
 
double workingValueMin_
 
double workingValueSum_
 
double workingValueSumOfSquares_
 

Detailed Description

This class keeps track of statistics for a set of sample values and provides timing information on the samples.

Author:
mommsen
Revision:
1.10
Date:
2011/03/07 15:31:32

Definition at line 29 of file MonitoredQuantity.h.

Member Enumeration Documentation

Enumerator
FULL 
RECENT 

Definition at line 35 of file MonitoredQuantity.h.

35  { FULL = 0, // the full data set (all samples)
36  RECENT = 1 }; // recent data only

Constructor & Destructor Documentation

stor::MonitoredQuantity::MonitoredQuantity ( utils::Duration_t  expectedCalculationInterval,
utils::Duration_t  timeWindowForRecentResults 
)
explicit

Definition at line 13 of file MonitoredQuantity.cc.

16  :
17  enabled_(true),
18  expectedCalculationInterval_(expectedCalculationInterval)
19  {
20  setNewTimeWindowForRecentResults(timeWindowForRecentResults);
21  }
void setNewTimeWindowForRecentResults(const utils::Duration_t &interval)
const utils::Duration_t expectedCalculationInterval_
stor::MonitoredQuantity::MonitoredQuantity ( MonitoredQuantity const &  )
private

Member Function Documentation

void stor::MonitoredQuantity::addSample ( const double &  value = 1)

Adds the specified doubled valued sample value to the monitor instance.

Definition at line 23 of file MonitoredQuantity.cc.

References accumulationMutex_, enabled_, stor::utils::getCurrentTime(), lastCalculationTime_, relativeConstraints::value, workingLastSampleValue_, workingSampleCount_, workingValueMax_, workingValueMin_, workingValueSum_, and workingValueSumOfSquares_.

Referenced by stor::ThroughputMonitorCollection::addDiskWriterIdleSample(), stor::ThroughputMonitorCollection::addDiskWriteSample(), stor::DQMTopLevelFolder::addDQMEvent(), stor::FragmentMonitorCollection::addDQMEventFragmentSample(), stor::ThroughputMonitorCollection::addDQMEventProcessorIdleSample(), stor::FragmentMonitorCollection::addEventFragmentSample(), stor::ThroughputMonitorCollection::addFragmentProcessorIdleSample(), stor::FragmentMonitorCollection::addFragmentSample(), stor::ThroughputMonitorCollection::addPoppedDQMEventSample(), stor::ThroughputMonitorCollection::addPoppedEventSample(), stor::ThroughputMonitorCollection::addPoppedFragmentSample(), addSample(), addSampleIfLarger(), stor::StreamsMonitorCollection::StreamRecord::addSizeInBytes(), stor::RunMonitorCollection::addUnwantedEvent(), stor::ThroughputMonitorCollection::calcPoolUsage(), stor::FragmentMonitorCollection::do_calculateStatistics(), stor::StreamsMonitorCollection::do_calculateStatistics(), stor::DQMEventMonitorCollection::do_calculateStatistics(), stor::ThroughputMonitorCollection::do_calculateStatistics(), stor::DQMTopLevelFolder::getRecord(), stor::DQMTopLevelFolder::isReady(), stor::StorageManager::receiveEndOfLumiSectionMessage(), stor::StorageManager::receiveRegistryMessage(), stor::EventDistributor::tagCompleteEventForQueues(), and smproxy::DQMArchiver::writeDQMEventToFile().

24  {
25  if (! enabled_) {return;}
26 
27  boost::mutex::scoped_lock sl(accumulationMutex_);
28 
29  if ( lastCalculationTime_.is_not_a_date_time() )
30  {
32  }
33 
37 
40 
42  }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
utils::TimePoint_t lastCalculationTime_
void stor::MonitoredQuantity::addSample ( const int &  value = 1)

Adds the specified integer valued sample value to the monitor instance.

Definition at line 44 of file MonitoredQuantity.cc.

References addSample().

45  {
46  addSample(static_cast<double>(value));
47  }
void addSample(const double &value=1)
void stor::MonitoredQuantity::addSample ( const unsigned int &  value = 1)

Adds the specified unsigned integer valued sample value to the monitor instance.

Definition at line 49 of file MonitoredQuantity.cc.

References addSample().

50  {
51  addSample(static_cast<double>(value));
52  }
void addSample(const double &value=1)
void stor::MonitoredQuantity::addSample ( const long &  value = 1)

Adds the specified long valued sample value to the monitor instance.

Definition at line 54 of file MonitoredQuantity.cc.

References addSample().

55  {
56  addSample(static_cast<double>(value));
57  }
void addSample(const double &value=1)
void stor::MonitoredQuantity::addSample ( const unsigned long &  value = 1)

Adds the specified unsigned long valued sample value to the monitor instance.

Definition at line 59 of file MonitoredQuantity.cc.

References addSample().

60  {
61  addSample(static_cast<double>(value));
62  }
void addSample(const double &value=1)
void stor::MonitoredQuantity::addSample ( const long long &  value = 1)

Adds the specified long long valued sample value to the monitor instance.

Definition at line 64 of file MonitoredQuantity.cc.

References addSample().

65  {
66  addSample(static_cast<double>(value));
67  }
void addSample(const double &value=1)
void stor::MonitoredQuantity::addSample ( const unsigned long long &  value = 1)

Adds the specified unsigned long long valued sample value to the monitor instance.

Definition at line 69 of file MonitoredQuantity.cc.

References addSample().

70  {
71  addSample(static_cast<double>(value));
72  }
void addSample(const double &value=1)
void stor::MonitoredQuantity::addSampleIfLarger ( const double &  value)

Adds the specified double valued sample value to the monitor instance if it is larger than the previously added value.

Definition at line 74 of file MonitoredQuantity.cc.

References addSample(), and workingLastSampleValue_.

Referenced by stor::EventDistributor::tagCompleteEventForQueues().

75  {
78  }
void addSample(const double &value=1)
void stor::MonitoredQuantity::calculateStatistics ( const utils::TimePoint_t currentTime = utils::getCurrentTime())

Forces a calculation of the statistics for the monitored quantity. The frequency of the updates to the statistics is driven by how often this method is called. It is expected that this method will be called once per interval specified by expectedCalculationInterval

Definition at line 80 of file MonitoredQuantity.cc.

References accumulationMutex_, binCount_, binDuration_, binSampleCount_, binSnapshotTime_, binValueMax_, binValueMin_, binValueSum_, binValueSumOfSquares_, stor::utils::durationToSeconds(), enabled_, expectedCalculationInterval_, fullDuration_, fullSampleCount_, fullSampleRate_, fullValueAverage_, fullValueMax_, fullValueMin_, fullValueRate_, fullValueRMS_, fullValueSum_, fullValueSumOfSquares_, lastCalculationTime_, lastLatchedSampleValue_, lastLatchedValueRate_, recentDuration_, recentSampleCount_, recentSampleRate_, recentValueAverage_, recentValueMax_, recentValueMin_, recentValueRate_, recentValueRMS_, recentValueSum_, recentValueSumOfSquares_, resultsMutex_, seconds(), mathSSE::sqrt(), workingBinId_, workingLastSampleValue_, workingSampleCount_, workingValueMax_, workingValueMin_, workingValueSum_, and workingValueSumOfSquares_.

Referenced by stor::ThroughputMonitorCollection::calcPoolUsage(), stor::ConsumerMonitorCollection::do_calculateStatistics(), stor::RunMonitorCollection::do_calculateStatistics(), stor::FragmentMonitorCollection::do_calculateStatistics(), stor::StreamsMonitorCollection::do_calculateStatistics(), stor::DQMEventMonitorCollection::do_calculateStatistics(), and stor::ThroughputMonitorCollection::do_calculateStatistics().

81  {
82  if (! enabled_) {return;}
83 
84  // create local copies of the working values to minimize the
85  // time that we could block a thread trying to add a sample.
86  // Also, reset the working values.
87  long long latestSampleCount;
88  double latestValueSum;
89  double latestValueSumOfSquares;
90  double latestValueMin;
91  double latestValueMax;
92  utils::Duration_t latestDuration;
93  utils::TimePoint_t latestSnapshotTime;
94  double latestLastLatchedSampleValue;
95  {
96  boost::mutex::scoped_lock sl(accumulationMutex_);
97 
98  if (lastCalculationTime_.is_not_a_date_time()) {return;}
99  if (currentTime - lastCalculationTime_ < expectedCalculationInterval_) {return;}
100 
101  latestSampleCount = workingSampleCount_;
102  latestValueSum = workingValueSum_;
103  latestValueSumOfSquares = workingValueSumOfSquares_;
104  latestValueMin = workingValueMin_;
105  latestValueMax = workingValueMax_;
106  latestDuration = currentTime - lastCalculationTime_;
107  latestSnapshotTime = currentTime;
108  latestLastLatchedSampleValue = workingLastSampleValue_;
109 
110  lastCalculationTime_ = currentTime;
112  workingValueSum_ = 0.0;
114  workingValueMin_ = INFINITY;
115  workingValueMax_ = -INFINITY;
116  }
117 
118  // lock out any interaction with the results while we update them
119  {
120  boost::mutex::scoped_lock sl(resultsMutex_);
121  lastLatchedSampleValue_ = latestLastLatchedSampleValue;
122 
123  // we simply add the latest results to the full set
124  fullSampleCount_ += latestSampleCount;
125  fullValueSum_ += latestValueSum;
126  fullValueSumOfSquares_ += latestValueSumOfSquares;
127  if (latestValueMin < fullValueMin_) {fullValueMin_ = latestValueMin;}
128  if (latestValueMax > fullValueMax_) {fullValueMax_ = latestValueMax;}
129  fullDuration_ += latestDuration;
130 
131  // for the recent results, we need to replace the contents of
132  // the working bin and re-calculate the recent values
133  binSampleCount_[workingBinId_] = latestSampleCount;
134  binValueSum_[workingBinId_] = latestValueSum;
135  binValueSumOfSquares_[workingBinId_] = latestValueSumOfSquares;
136  binValueMin_[workingBinId_] = latestValueMin;
137  binValueMax_[workingBinId_] = latestValueMax;
138  binDuration_[workingBinId_] = latestDuration;
139  binSnapshotTime_[workingBinId_] = latestSnapshotTime;
140 
141  lastLatchedValueRate_ = latestValueSum / utils::durationToSeconds(latestDuration);
142 
143  recentSampleCount_ = 0;
144  recentValueSum_ = 0.0;
146  recentValueMin_ = INFINITY;
147  recentValueMax_ = -INFINITY;
149 
150  for (unsigned int idx = 0; idx < binCount_; ++idx) {
154  if (binValueMin_[idx] < recentValueMin_) {
156  }
157  if (binValueMax_[idx] > recentValueMax_) {
159  }
161  }
162 
163  // update the working bin ID here so that we are ready for
164  // the next calculation request
165  ++workingBinId_;
166  if (workingBinId_ >= binCount_) {workingBinId_ = 0;}
167 
168  // calculate the derived full values
169  const double fullDuration = utils::durationToSeconds(fullDuration_);
170  fullSampleRate_ = fullSampleCount_ / fullDuration;
171  fullValueRate_ = fullValueSum_ / fullDuration;
172 
173  if (fullSampleCount_ > 0) {
174  fullValueAverage_ = fullValueSum_ / static_cast<double>(fullSampleCount_);
175 
176  double squareAvg = fullValueSumOfSquares_ / static_cast<double>(fullSampleCount_);
177  double avg = fullValueSum_ / static_cast<double>(fullSampleCount_);
178  double sigSquared = squareAvg - avg*avg;
179  if(sigSquared > 0.0) {
180  fullValueRMS_ = sqrt(sigSquared);
181  }
182  else {
183  fullValueRMS_ = 0.0;
184  }
185  }
186  else {
187  fullValueAverage_ = 0.0;
188  fullValueRMS_ = 0.0;
189  }
190 
191  // calculate the derived recent values
192  const double recentDuration = utils::durationToSeconds(recentDuration_);
193  if (recentDuration > 0) {
194  recentSampleRate_ = recentSampleCount_ / recentDuration;
195  recentValueRate_ = recentValueSum_ / recentDuration;
196  }
197  else {
198  recentSampleRate_ = 0.0;
199  recentValueRate_ = 0.0;
200  }
201 
202  if (recentSampleCount_ > 0) {
203  recentValueAverage_ = recentValueSum_ / static_cast<double>(recentSampleCount_);
204 
205  double squareAvg = recentValueSumOfSquares_ /
206  static_cast<double>(recentSampleCount_);
207  double avg = recentValueSum_ / static_cast<double>(recentSampleCount_);
208  double sigSquared = squareAvg - avg*avg;
209  if(sigSquared > 0.0) {
210  recentValueRMS_ = sqrt(sigSquared);
211  }
212  else {
213  recentValueRMS_ = 0.0;
214  }
215  }
216  else {
217  recentValueAverage_ = 0.0;
218  recentValueRMS_ = 0.0;
219  }
220  }
221  }
utils::Duration_t recentDuration_
std::vector< utils::TimePoint_t > binSnapshotTime_
double seconds()
std::vector< uint64_t > binSampleCount_
std::vector< double > binValueSum_
const utils::Duration_t expectedCalculationInterval_
std::vector< utils::Duration_t > binDuration_
std::vector< double > binValueMax_
utils::Duration_t fullDuration_
boost::posix_time::time_duration Duration_t
Definition: Utils.h:41
T sqrt(T t)
Definition: SSEVec.h:46
boost::posix_time::ptime TimePoint_t
Definition: Utils.h:35
utils::TimePoint_t lastCalculationTime_
double durationToSeconds(Duration_t const &)
Definition: Utils.h:147
std::vector< double > binValueMin_
std::vector< double > binValueSumOfSquares_
void stor::MonitoredQuantity::disable ( )

Disables the monitor.

Definition at line 293 of file MonitoredQuantity.cc.

References enabled_.

294  {
295  // It is faster to just set enabled_ to false than to test and set
296  // it conditionally.
297  enabled_ = false;
298  }
void stor::MonitoredQuantity::enable ( )

Enables the monitor (and resets the statistics to provide a fresh start).

Definition at line 285 of file MonitoredQuantity.cc.

References enabled_, and reset().

286  {
287  if (! enabled_) {
288  reset();
289  enabled_ = true;
290  }
291  }
utils::Duration_t stor::MonitoredQuantity::ExpectedCalculationInterval ( ) const
inline

Definition at line 136 of file MonitoredQuantity.h.

References expectedCalculationInterval_.

137  {
139  }
const utils::Duration_t expectedCalculationInterval_
void stor::MonitoredQuantity::getStats ( Stats stats) const

Write all our collected statistics into the given Stats struct.

Definition at line 343 of file MonitoredQuantity.cc.

References binCount_, binDuration_, binSampleCount_, binSnapshotTime_, binValueSum_, stor::MonitoredQuantity::Stats::enabled, enabled_, stor::MonitoredQuantity::Stats::fullDuration, fullDuration_, stor::MonitoredQuantity::Stats::fullSampleCount, fullSampleCount_, stor::MonitoredQuantity::Stats::fullSampleRate, fullSampleRate_, stor::MonitoredQuantity::Stats::fullValueAverage, fullValueAverage_, stor::MonitoredQuantity::Stats::fullValueMax, fullValueMax_, stor::MonitoredQuantity::Stats::fullValueMin, fullValueMin_, stor::MonitoredQuantity::Stats::fullValueRate, fullValueRate_, stor::MonitoredQuantity::Stats::fullValueRMS, fullValueRMS_, stor::MonitoredQuantity::Stats::fullValueSum, fullValueSum_, stor::MonitoredQuantity::Stats::fullValueSumOfSquares, fullValueSumOfSquares_, lastLatchedSampleValue_, lastLatchedValueRate_, stor::MonitoredQuantity::Stats::lastSampleValue, stor::MonitoredQuantity::Stats::lastValueRate, stor::MonitoredQuantity::Stats::recentBinnedDurations, stor::MonitoredQuantity::Stats::recentBinnedSampleCounts, stor::MonitoredQuantity::Stats::recentBinnedSnapshotTimes, stor::MonitoredQuantity::Stats::recentBinnedValueSums, stor::MonitoredQuantity::Stats::recentDuration, recentDuration_, stor::MonitoredQuantity::Stats::recentSampleCount, recentSampleCount_, stor::MonitoredQuantity::Stats::recentSampleRate, recentSampleRate_, stor::MonitoredQuantity::Stats::recentValueAverage, recentValueAverage_, stor::MonitoredQuantity::Stats::recentValueMax, recentValueMax_, stor::MonitoredQuantity::Stats::recentValueMin, recentValueMin_, stor::MonitoredQuantity::Stats::recentValueRate, recentValueRate_, stor::MonitoredQuantity::Stats::recentValueRMS, recentValueRMS_, stor::MonitoredQuantity::Stats::recentValueSum, recentValueSum_, stor::MonitoredQuantity::Stats::recentValueSumOfSquares, recentValueSumOfSquares_, python.entryComment::results, resultsMutex_, and workingBinId_.

Referenced by stor::SMWebPageHelper::addDOMforRunMonitor(), stor::SMWebPageHelper::addDOMforStoredData(), stor::RunMonitorCollection::alarmErrorEvents(), stor::FragmentMonitorCollection::do_calculateStatistics(), stor::StreamsMonitorCollection::do_calculateStatistics(), stor::DQMEventMonitorCollection::do_calculateStatistics(), stor::ThroughputMonitorCollection::do_getStats(), stor::RunMonitorCollection::do_updateInfoSpaceItems(), stor::FragmentMonitorCollection::do_updateInfoSpaceItems(), stor::StreamsMonitorCollection::do_updateInfoSpaceItems(), stor::FragmentMonitorCollection::getStats(), stor::DQMEventMonitorCollection::getStats(), stor::ConsumerMonitorCollection::getTotalStats(), and stor::SMWebPageHelper::listStreamRecordsStats().

344  {
345  boost::mutex::scoped_lock results(resultsMutex_);
346 
347  s.fullSampleCount = fullSampleCount_;
348  s.fullSampleRate = fullSampleRate_;
349  s.fullValueSum = fullValueSum_;
350  s.fullValueSumOfSquares = fullValueSumOfSquares_;
351  s.fullValueAverage = fullValueAverage_;
352  s.fullValueRMS = fullValueRMS_;
353  s.fullValueMin = fullValueMin_;
354  s.fullValueMax = fullValueMax_;
355  s.fullValueRate = fullValueRate_;
356  s.fullDuration = fullDuration_;
357 
358  s.recentSampleCount = recentSampleCount_;
359  s.recentSampleRate = recentSampleRate_;
360  s.recentValueSum = recentValueSum_;
361  s.recentValueSumOfSquares = recentValueSumOfSquares_;
362  s.recentValueAverage = recentValueAverage_;
363  s.recentValueRMS = recentValueRMS_;
364  s.recentValueMin = recentValueMin_;
365  s.recentValueMax = recentValueMax_;
366  s.recentValueRate = recentValueRate_;
367  s.recentDuration = recentDuration_;
368 
369  s.recentBinnedSampleCounts.resize(binCount_);
370  s.recentBinnedValueSums.resize(binCount_);
371  s.recentBinnedDurations.resize(binCount_);
372  s.recentBinnedSnapshotTimes.resize(binCount_);
373  uint32_t sourceBinId = workingBinId_;
374  for (uint32_t idx = 0; idx < binCount_; ++idx) {
375  if (sourceBinId >= binCount_) {sourceBinId = 0;}
376  s.recentBinnedSampleCounts[idx] = binSampleCount_[sourceBinId];
377  s.recentBinnedValueSums[idx] = binValueSum_[sourceBinId];
378  s.recentBinnedDurations[idx] = binDuration_[sourceBinId];
379  s.recentBinnedSnapshotTimes[idx] = binSnapshotTime_[sourceBinId];
380  ++sourceBinId;
381  }
382 
383  s.lastSampleValue = lastLatchedSampleValue_;
384  s.lastValueRate = lastLatchedValueRate_;
385  s.enabled = enabled_;
386  }
utils::Duration_t recentDuration_
std::vector< utils::TimePoint_t > binSnapshotTime_
std::vector< uint64_t > binSampleCount_
std::vector< double > binValueSum_
std::vector< utils::Duration_t > binDuration_
utils::Duration_t fullDuration_
utils::Duration_t stor::MonitoredQuantity::getTimeWindowForRecentResults ( ) const
inline

Returns the length of the time window that has been specified for recent results. (This may be different than the actual length of the recent time window which is affected by the interval of calls to the calculateStatistics() method. Use a getDuration(RECENT) call to determine the actual recent time window.)

Definition at line 131 of file MonitoredQuantity.h.

References intervalForRecentStats_.

132  {
134  }
utils::Duration_t intervalForRecentStats_
bool stor::MonitoredQuantity::isEnabled ( ) const
inline

Tests whether the monitor is currently enabled.

Definition at line 115 of file MonitoredQuantity.h.

References enabled_.

115 {return enabled_;}
MonitoredQuantity& stor::MonitoredQuantity::operator= ( MonitoredQuantity const &  )
private
void stor::MonitoredQuantity::reset ( void  )
void stor::MonitoredQuantity::resetAccumulators ( )
private
void stor::MonitoredQuantity::resetResults ( )
private

Definition at line 234 of file MonitoredQuantity.cc.

References binCount_, binDuration_, binSampleCount_, binSnapshotTime_, binValueMax_, binValueMin_, binValueSum_, binValueSumOfSquares_, fullDuration_, fullSampleCount_, fullSampleRate_, fullValueAverage_, fullValueMax_, fullValueMin_, fullValueRate_, fullValueRMS_, fullValueSum_, fullValueSumOfSquares_, lastLatchedSampleValue_, lastLatchedValueRate_, recentDuration_, recentSampleCount_, recentSampleRate_, recentValueAverage_, recentValueMax_, recentValueMin_, recentValueRate_, recentValueRMS_, recentValueSum_, recentValueSumOfSquares_, seconds(), and workingBinId_.

Referenced by reset(), and setNewTimeWindowForRecentResults().

235  {
236  workingBinId_ = 0;
237  for (unsigned int idx = 0; idx < binCount_; ++idx) {
238  binSampleCount_[idx] = 0;
239  binValueSum_[idx] = 0.0;
240  binValueSumOfSquares_[idx] = 0.0;
241  binValueMin_[idx] = INFINITY;
242  binValueMax_[idx] = -INFINITY;
244  binSnapshotTime_[idx] = boost::posix_time::not_a_date_time;
245  }
246 
247  fullSampleCount_ = 0;
248  fullSampleRate_ = 0.0;
249  fullValueSum_ = 0.0;
251  fullValueAverage_ = 0.0;
252  fullValueRMS_ = 0.0;
253  fullValueMin_ = INFINITY;
254  fullValueMax_ = -INFINITY;
255  fullValueRate_ = 0.0;
257 
258  recentSampleCount_ = 0;
259  recentSampleRate_ = 0.0;
260  recentValueSum_ = 0.0;
262  recentValueAverage_ = 0.0;
263  recentValueRMS_ = 0.0;
264  recentValueMin_ = INFINITY;
265  recentValueMax_ = -INFINITY;
266  recentValueRate_ = 0.0;
269  lastLatchedValueRate_ = 0.0;
270  }
utils::Duration_t recentDuration_
std::vector< utils::TimePoint_t > binSnapshotTime_
double seconds()
std::vector< uint64_t > binSampleCount_
std::vector< double > binValueSum_
std::vector< utils::Duration_t > binDuration_
std::vector< double > binValueMax_
utils::Duration_t fullDuration_
std::vector< double > binValueMin_
std::vector< double > binValueSumOfSquares_
void stor::MonitoredQuantity::setNewTimeWindowForRecentResults ( const utils::Duration_t interval)

Specifies a new time interval to be used when calculating "recent" statistics.

Definition at line 300 of file MonitoredQuantity.cc.

References accumulationMutex_, binCount_, binDuration_, binSampleCount_, binSnapshotTime_, binValueMax_, binValueMin_, binValueSum_, binValueSumOfSquares_, expectedCalculationInterval_, MergeJob_cfg::interval, intervalForRecentStats_, max(), resetAccumulators(), resetResults(), and resultsMutex_.

301  {
302  // lock the results objects since we're dramatically changing the
303  // bins used for the recent results
304  {
305  boost::mutex::scoped_lock sl(resultsMutex_);
306 
308 
309  // determine how many bins we should use in our sliding window
310  // by dividing the input time window by the expected calculation
311  // interval and rounding to the nearest integer.
312  // In case that the calculation interval is larger then the
313  // interval for recent stats, keep the last one.
314  binCount_ = std::max(1U,
315  static_cast<unsigned int>(
316  (intervalForRecentStats_.total_nanoseconds() / expectedCalculationInterval_.total_nanoseconds()) + 0.5
317  )
318  );
319 
320  // create the vectors for the binned quantities
321  binSampleCount_.reserve(binCount_);
322  binValueSum_.reserve(binCount_);
324  binValueMin_.reserve(binCount_);
325  binValueMax_.reserve(binCount_);
326  binDuration_.reserve(binCount_);
327  binSnapshotTime_.reserve(binCount_);
328 
329  resetResults();
330  }
331 
332  {
333  boost::mutex::scoped_lock sl(accumulationMutex_);
335  }
336 
337  // call the reset method to populate the correct initial values
338  // for the internal sample data
339  //reset();
340  }
utils::Duration_t intervalForRecentStats_
std::vector< utils::TimePoint_t > binSnapshotTime_
tuple interval
Definition: MergeJob_cfg.py:20
std::vector< uint64_t > binSampleCount_
std::vector< double > binValueSum_
const utils::Duration_t expectedCalculationInterval_
std::vector< utils::Duration_t > binDuration_
std::vector< double > binValueMax_
const T & max(const T &a, const T &b)
std::vector< double > binValueMin_
std::vector< double > binValueSumOfSquares_

Member Data Documentation

boost::mutex stor::MonitoredQuantity::accumulationMutex_
mutableprivate
uint32_t stor::MonitoredQuantity::binCount_
private
std::vector<utils::Duration_t> stor::MonitoredQuantity::binDuration_
private
std::vector<uint64_t> stor::MonitoredQuantity::binSampleCount_
private
std::vector<utils::TimePoint_t> stor::MonitoredQuantity::binSnapshotTime_
private
std::vector<double> stor::MonitoredQuantity::binValueMax_
private
std::vector<double> stor::MonitoredQuantity::binValueMin_
private
std::vector<double> stor::MonitoredQuantity::binValueSum_
private
std::vector<double> stor::MonitoredQuantity::binValueSumOfSquares_
private
bool stor::MonitoredQuantity::enabled_
private
const utils::Duration_t stor::MonitoredQuantity::expectedCalculationInterval_
private
utils::Duration_t stor::MonitoredQuantity::fullDuration_
private

Definition at line 185 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

uint64_t stor::MonitoredQuantity::fullSampleCount_
private

Definition at line 176 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::fullSampleRate_
private

Definition at line 177 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::fullValueAverage_
private

Definition at line 180 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::fullValueMax_
private

Definition at line 183 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::fullValueMin_
private

Definition at line 182 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::fullValueRate_
private

Definition at line 184 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::fullValueRMS_
private

Definition at line 181 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::fullValueSum_
private

Definition at line 178 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::fullValueSumOfSquares_
private

Definition at line 179 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

utils::Duration_t stor::MonitoredQuantity::intervalForRecentStats_
private
utils::TimePoint_t stor::MonitoredQuantity::lastCalculationTime_
private

Definition at line 156 of file MonitoredQuantity.h.

Referenced by addSample(), calculateStatistics(), and resetAccumulators().

double stor::MonitoredQuantity::lastLatchedSampleValue_
private

Definition at line 197 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::lastLatchedValueRate_
private

Definition at line 198 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

utils::Duration_t stor::MonitoredQuantity::recentDuration_
private

Definition at line 196 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

uint64_t stor::MonitoredQuantity::recentSampleCount_
private

Definition at line 187 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::recentSampleRate_
private

Definition at line 188 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::recentValueAverage_
private

Definition at line 191 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::recentValueMax_
private

Definition at line 194 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::recentValueMin_
private

Definition at line 193 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::recentValueRate_
private

Definition at line 195 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::recentValueRMS_
private

Definition at line 192 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::recentValueSum_
private

Definition at line 189 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::recentValueSumOfSquares_
private

Definition at line 190 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

boost::mutex stor::MonitoredQuantity::resultsMutex_
mutableprivate
uint32_t stor::MonitoredQuantity::workingBinId_
private

Definition at line 167 of file MonitoredQuantity.h.

Referenced by calculateStatistics(), getStats(), and resetResults().

double stor::MonitoredQuantity::workingLastSampleValue_
private
uint64_t stor::MonitoredQuantity::workingSampleCount_
private

Definition at line 157 of file MonitoredQuantity.h.

Referenced by addSample(), calculateStatistics(), and resetAccumulators().

double stor::MonitoredQuantity::workingValueMax_
private

Definition at line 161 of file MonitoredQuantity.h.

Referenced by addSample(), calculateStatistics(), and resetAccumulators().

double stor::MonitoredQuantity::workingValueMin_
private

Definition at line 160 of file MonitoredQuantity.h.

Referenced by addSample(), calculateStatistics(), and resetAccumulators().

double stor::MonitoredQuantity::workingValueSum_
private

Definition at line 158 of file MonitoredQuantity.h.

Referenced by addSample(), calculateStatistics(), and resetAccumulators().

double stor::MonitoredQuantity::workingValueSumOfSquares_
private

Definition at line 159 of file MonitoredQuantity.h.

Referenced by addSample(), calculateStatistics(), and resetAccumulators().