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, mSM,
  mMon, mWhat, mCOUNT
}
 

Public Member Functions

 EvFBuildingThrottle (const edm::ParameterSet &pset, edm::ActivityRegistry &reg)
 
void postBeginRun (edm::RunID const &id, edm::Timestamp const &ts)
 
void postEndRun (edm::Run const &run, edm::EventSetup const &es)
 
void preBeginLumi (edm::LuminosityBlockID const &iID, edm::Timestamp const &iTime)
 
void preBeginRun (edm::RunID const &id, edm::Timestamp const &ts)
 
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 22 of file EvFBuildingThrottle.h.

References postEndRun(), preBeginLumi(), preBeginRun(), edm::ActivityRegistry::watchPostEndRun(), edm::ActivityRegistry::watchPreBeginLumi(), and edm::ActivityRegistry::watchPreBeginRun().

24  : highWaterMark_(pset.getUntrackedParameter<double>("highWaterMark",0.8))
25  , lowWaterMark_(pset.getUntrackedParameter<double>("lowWaterMark",0.5))
26  , m_stoprequest(false)
28  , throttled_(false)
29  , sleep_( pset.getUntrackedParameter<unsigned int>("sleepmSecs",1000))
30  {
34  }
T getUntrackedParameter(std::string const &, T const &) const
void preBeginLumi(edm::LuminosityBlockID const &iID, edm::Timestamp const &iTime)
void postEndRun(edm::Run const &run, edm::EventSetup const &es)
void watchPreBeginLumi(PreBeginLumi::slot_type const &iSlot)
void watchPostEndRun(PostEndRun::slot_type const &iSlot)
void preBeginRun(edm::RunID const &id, edm::Timestamp const &ts)
void watchPreBeginRun(PreBeginRun::slot_type const &iSlot)
evf::EvFBuildingThrottle::~EvFBuildingThrottle ( )
inline

Definition at line 35 of file EvFBuildingThrottle.h.

35 {}

Member Function Documentation

void evf::EvFBuildingThrottle::dowork ( )
inlineprivate

Definition at line 72 of file EvFBuildingThrottle.h.

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

Referenced by start().

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

Definition at line 59 of file EvFBuildingThrottle.h.

59  {
60 
61  }
void evf::EvFBuildingThrottle::postEndRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
inline

Definition at line 63 of file EvFBuildingThrottle.h.

References stop().

Referenced by EvFBuildingThrottle().

63  {
64  stop();
65  }
void evf::EvFBuildingThrottle::preBeginLumi ( edm::LuminosityBlockID const &  iID,
edm::Timestamp const &  iTime 
)
inline

Definition at line 66 of file EvFBuildingThrottle.h.

References lock_.

Referenced by EvFBuildingThrottle().

66  {
67  lock_.lock();
68  lock_.unlock();
69  }
void evf::EvFBuildingThrottle::preBeginRun ( edm::RunID const &  id,
edm::Timestamp const &  ts 
)
inline

Definition at line 36 of file EvFBuildingThrottle.h.

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

Referenced by EvFBuildingThrottle().

36  {
37  //obtain directory to stat on
38  switch(whatToThrottleOn_){
39  case mInvalid:
40  //do nothing
41  break;
42  case mBase:
44  break;
45  case mBU:
46  baseDir_ = edm::Service<EvFDaqDirector>()->buBaseDir();
47  break;
48  case mSM:
49  baseDir_ = edm::Service<EvFDaqDirector>()->smBaseDir();
50  break;
51  case mMon:
52  baseDir_ = edm::Service<EvFDaqDirector>()->monitorBaseDir();
53  break;
54  default:
56  }
57  start();
58  }
void evf::EvFBuildingThrottle::start ( void  )
inlineprivate

Definition at line 92 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().

92  {
93  assert(!m_thread);
95  m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&EvFBuildingThrottle::dowork,this)));
96  std::cout << "throttle thread started - throttle on " << whatToThrottleOn_ << std::endl;
97  }
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 98 of file EvFBuildingThrottle.h.

References m_stoprequest, and m_thread.

Referenced by postEndRun().

98  {
99  assert(m_thread);
100  m_stoprequest=true;
101  m_thread->join();
102  }
boost::shared_ptr< boost::thread > m_thread
bool evf::EvFBuildingThrottle::throttled ( ) const
inline

Definition at line 70 of file EvFBuildingThrottle.h.

References throttled_.

Member Data Documentation

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

Definition at line 109 of file EvFBuildingThrottle.h.

Referenced by dowork(), and preBeginRun().

double evf::EvFBuildingThrottle::highWaterMark_
private

Definition at line 104 of file EvFBuildingThrottle.h.

Referenced by dowork().

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

Definition at line 108 of file EvFBuildingThrottle.h.

Referenced by dowork(), and preBeginLumi().

double evf::EvFBuildingThrottle::lowWaterMark_
private

Definition at line 105 of file EvFBuildingThrottle.h.

Referenced by dowork().

volatile bool evf::EvFBuildingThrottle::m_stoprequest
private

Definition at line 106 of file EvFBuildingThrottle.h.

Referenced by dowork(), and stop().

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

Definition at line 107 of file EvFBuildingThrottle.h.

Referenced by start(), and stop().

unsigned int evf::EvFBuildingThrottle::sleep_
private

Definition at line 113 of file EvFBuildingThrottle.h.

Referenced by dowork().

bool evf::EvFBuildingThrottle::throttled_
private

Definition at line 112 of file EvFBuildingThrottle.h.

Referenced by dowork(), and throttled().

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

Definition at line 111 of file EvFBuildingThrottle.h.

Referenced by dowork(), and start().

Directory evf::EvFBuildingThrottle::whatToThrottleOn_
private

Definition at line 110 of file EvFBuildingThrottle.h.

Referenced by preBeginRun(), and start().