CMS 3D CMS Logo

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

#include <EvFBuildingThrottle.h>

Public Types

enum  Directory { mInvalid = 0, mBase, mBU, mCOUNT }
 

Public Member Functions

 EvFBuildingThrottle (const edm::ParameterSet &pset, edm::ActivityRegistry &reg)
 
void postBeginRun (edm::GlobalContext const &gc)
 
void postEndRun (edm::GlobalContext const &gc)
 
void preBeginLumi (edm::GlobalContext const &gc)
 
void preBeginRun (edm::GlobalContext const &gc)
 
bool throttled () const
 
 ~EvFBuildingThrottle ()
 

Private Member Functions

void dowork ()
 
void start ()
 
void stop ()
 

Private Attributes

std::string baseDir_
 
double highWaterMark_
 
boost::mutex lock_
 
double lowWaterMark_
 
volatile bool m_stoprequest
 
boost::shared_ptr< boost::thread > m_thread
 
unsigned int sleep_
 
bool throttled_
 
edm::ServiceToken token_
 
Directory whatToThrottleOn_
 

Detailed Description

Definition at line 17 of file EvFBuildingThrottle.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

evf::EvFBuildingThrottle::EvFBuildingThrottle ( const edm::ParameterSet pset,
edm::ActivityRegistry reg 
)
inlineexplicit

Definition at line 21 of file EvFBuildingThrottle.h.

References postEndRun(), preBeginLumi(), preBeginRun(), edm::ActivityRegistry::watchPostGlobalEndRun(), edm::ActivityRegistry::watchPreGlobalBeginLumi(), and edm::ActivityRegistry::watchPreGlobalBeginRun().

23  : highWaterMark_(pset.getUntrackedParameter<double>("highWaterMark",0.8))
24  , lowWaterMark_(pset.getUntrackedParameter<double>("lowWaterMark",0.5))
25  , m_stoprequest(false)
27  , throttled_(false)
28  , sleep_( pset.getUntrackedParameter<unsigned int>("sleepmSecs",1000))
29  {
33  }
T getUntrackedParameter(std::string const &, T const &) const
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
void preBeginLumi(edm::GlobalContext const &gc)
void watchPreGlobalBeginRun(PreGlobalBeginRun::slot_type const &iSlot)
void watchPostGlobalEndRun(PostGlobalEndRun::slot_type const &iSlot)
void preBeginRun(edm::GlobalContext const &gc)
void postEndRun(edm::GlobalContext const &gc)
evf::EvFBuildingThrottle::~EvFBuildingThrottle ( )
inline

Definition at line 34 of file EvFBuildingThrottle.h.

34 {}

Member Function Documentation

void evf::EvFBuildingThrottle::dowork ( )
inlineprivate

Definition at line 64 of file EvFBuildingThrottle.h.

References baseDir_, gather_cfg::cout, highWaterMark_, lock_, lowWaterMark_, m_stoprequest, cmsPerfStripChart::operate(), sleep_, throttled_, and token_.

Referenced by start().

64  {
66  struct statvfs buf;
67  while(!m_stoprequest){
68  int retval = statvfs(baseDir_.c_str(),&buf);
69  if(retval != 0){
70  std::cout << " building throttle - unable to stat " << baseDir_ << std::endl;
71  m_stoprequest=true;
72  continue;
73  }
74  double fraction = 1.-float(buf.f_bfree*buf.f_bsize)/float(buf.f_blocks*buf.f_frsize);
75  bool highwater_ = fraction>highWaterMark_;
76  bool lowwater_ = fraction<lowWaterMark_;
77  if(highwater_ && !throttled_){ lock_.lock(); throttled_ = true;std::cout << ">>>>throttling on " << std::endl;}
78  if(lowwater_ && throttled_){ lock_.unlock(); throttled_ = false;}
79  std::cout << " building throttle on " << baseDir_ << " is " << fraction*100 << " %full " << std::endl;
80  //edm::Service<EvFDaqDirector>()->writeDiskAndThrottleStat(fraction,highwater_,lowwater_);
81  ::usleep(sleep_*1000);
82  }
83  }
tuple cout
Definition: gather_cfg.py:121
void evf::EvFBuildingThrottle::postBeginRun ( edm::GlobalContext const &  gc)
inline

Definition at line 52 of file EvFBuildingThrottle.h.

52  {
53  }
void evf::EvFBuildingThrottle::postEndRun ( edm::GlobalContext const &  gc)
inline

Definition at line 55 of file EvFBuildingThrottle.h.

References stop().

Referenced by EvFBuildingThrottle().

55  {
56  stop();
57  }
void evf::EvFBuildingThrottle::preBeginLumi ( edm::GlobalContext const &  gc)
inline

Definition at line 58 of file EvFBuildingThrottle.h.

References lock_.

Referenced by EvFBuildingThrottle().

58  {
59  lock_.lock();
60  lock_.unlock();
61  }
void evf::EvFBuildingThrottle::preBeginRun ( edm::GlobalContext const &  gc)
inline

Definition at line 35 of file EvFBuildingThrottle.h.

References baseDir_, mBase, mBU, mInvalid, start(), and whatToThrottleOn_.

Referenced by EvFBuildingThrottle().

35  {
36  //obtain directory to stat on
37  switch(whatToThrottleOn_){
38  case mInvalid:
39  //do nothing
40  break;
41  case mBase:
42  baseDir_ = edm::Service<EvFDaqDirector>()->baseRunDir();
43  break;
44  case mBU:
45  baseDir_ = edm::Service<EvFDaqDirector>()->buBaseRunDir();
46  break;
47  default:
48  baseDir_ = edm::Service<EvFDaqDirector>()->baseRunDir();
49  }
50  start();
51  }
void evf::EvFBuildingThrottle::start ( void  )
inlineprivate

Definition at line 84 of file EvFBuildingThrottle.h.

References gather_cfg::cout, dowork(), edm::ServiceRegistry::instance(), m_thread, edm::ServiceRegistry::presentToken(), token_, and whatToThrottleOn_.

Referenced by progressbar.ProgressBar::__next__(), Types.LuminosityBlockRange::cppID(), Types.EventRange::cppID(), and preBeginRun().

84  {
85  assert(!m_thread);
87  m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&EvFBuildingThrottle::dowork,this)));
88  std::cout << "throttle thread started - throttle on " << whatToThrottleOn_ << std::endl;
89  }
ServiceToken presentToken() const
static ServiceRegistry & instance()
boost::shared_ptr< boost::thread > m_thread
tuple cout
Definition: gather_cfg.py:121
void evf::EvFBuildingThrottle::stop ( )
inlineprivate

Definition at line 90 of file EvFBuildingThrottle.h.

References m_stoprequest, and m_thread.

Referenced by postEndRun().

90  {
91  assert(m_thread);
92  m_stoprequest=true;
93  m_thread->join();
94  }
boost::shared_ptr< boost::thread > m_thread
bool evf::EvFBuildingThrottle::throttled ( ) const
inline

Definition at line 62 of file EvFBuildingThrottle.h.

References throttled_.

Member Data Documentation

std::string evf::EvFBuildingThrottle::baseDir_
private

Definition at line 101 of file EvFBuildingThrottle.h.

Referenced by dowork(), and preBeginRun().

double evf::EvFBuildingThrottle::highWaterMark_
private

Definition at line 96 of file EvFBuildingThrottle.h.

Referenced by dowork().

boost::mutex evf::EvFBuildingThrottle::lock_
private

Definition at line 100 of file EvFBuildingThrottle.h.

Referenced by dowork(), and preBeginLumi().

double evf::EvFBuildingThrottle::lowWaterMark_
private

Definition at line 97 of file EvFBuildingThrottle.h.

Referenced by dowork().

volatile bool evf::EvFBuildingThrottle::m_stoprequest
private

Definition at line 98 of file EvFBuildingThrottle.h.

Referenced by dowork(), and stop().

boost::shared_ptr<boost::thread> evf::EvFBuildingThrottle::m_thread
private

Definition at line 99 of file EvFBuildingThrottle.h.

Referenced by start(), and stop().

unsigned int evf::EvFBuildingThrottle::sleep_
private

Definition at line 105 of file EvFBuildingThrottle.h.

Referenced by dowork().

bool evf::EvFBuildingThrottle::throttled_
private

Definition at line 104 of file EvFBuildingThrottle.h.

Referenced by dowork(), and throttled().

edm::ServiceToken evf::EvFBuildingThrottle::token_
private

Definition at line 103 of file EvFBuildingThrottle.h.

Referenced by dowork(), and start().

Directory evf::EvFBuildingThrottle::whatToThrottleOn_
private

Definition at line 102 of file EvFBuildingThrottle.h.

Referenced by preBeginRun(), and start().