CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/EventFilter/StorageManager/src/MonitorCollection.cc

Go to the documentation of this file.
00001 // $Id: MonitorCollection.cc,v 1.11 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #include "EventFilter/StorageManager/interface/MonitorCollection.h"
00005 #include "EventFilter/StorageManager/interface/Exception.h"
00006 
00007 
00008 namespace stor {
00009   
00010   MonitorCollection::MonitorCollection(const utils::Duration_t& updateInterval) :
00011   updateInterval_(updateInterval),
00012   lastCalculateStatistics_(boost::posix_time::not_a_date_time),
00013   infoSpaceUpdateNeeded_(false)
00014   {}
00015   
00016   
00017   void MonitorCollection::appendInfoSpaceItems(InfoSpaceItems& items)
00018   {
00019     // do any operations that are common for all child classes
00020     
00021     do_appendInfoSpaceItems(items);
00022   }
00023   
00024   
00025   void MonitorCollection::calculateStatistics(const utils::TimePoint_t& now)
00026   {
00027     if ( lastCalculateStatistics_.is_not_a_date_time() ||
00028       lastCalculateStatistics_ + updateInterval_ < now )
00029     {
00030       lastCalculateStatistics_ = now;
00031       do_calculateStatistics();
00032       infoSpaceUpdateNeeded_ = true;
00033     }
00034   }
00035   
00036   
00037   void MonitorCollection::updateInfoSpaceItems()
00038   {
00039     if (infoSpaceUpdateNeeded_)
00040     {
00041       do_updateInfoSpaceItems();
00042       infoSpaceUpdateNeeded_ = false;
00043     }
00044   }
00045   
00046   
00047   void MonitorCollection::reset(const utils::TimePoint_t& now)
00048   {
00049     do_reset();
00050     
00051     // Assure that the first update happens early.
00052     // This is important for long update intervals.
00053     lastCalculateStatistics_ = now - updateInterval_ + boost::posix_time::seconds(1);
00054     infoSpaceUpdateNeeded_ = true;
00055   }
00056   
00057 } // namespace stor
00058