CMS 3D CMS Logo

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_
 
std::mutex lock_
 
double lowWaterMark_
 
std::atomic< bool > m_stoprequest
 
std::shared_ptr< std::thread > m_thread
 
unsigned int sleep_
 
bool throttled_
 
edm::ServiceToken token_
 
Directory whatToThrottleOn_
 

Detailed Description

Definition at line 18 of file EvFBuildingThrottle.h.

Member Enumeration Documentation

◆ Directory

Enumerator
mInvalid 
mBase 
mBU 
mCOUNT 

Definition at line 20 of file EvFBuildingThrottle.h.

20 { mInvalid = 0, mBase, mBU, mCOUNT };

Constructor & Destructor Documentation

◆ EvFBuildingThrottle()

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

Definition at line 21 of file EvFBuildingThrottle.h.

22  : highWaterMark_(pset.getUntrackedParameter<double>("highWaterMark", 0.8)),
23  lowWaterMark_(pset.getUntrackedParameter<double>("lowWaterMark", 0.5)),
24  m_stoprequest(false),
25  whatToThrottleOn_(Directory(pset.getUntrackedParameter<int>("dirCode", mBase))),
26  throttled_(false),
27  sleep_(pset.getUntrackedParameter<unsigned int>("sleepmSecs", 1000)) {
31  }

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

◆ ~EvFBuildingThrottle()

evf::EvFBuildingThrottle::~EvFBuildingThrottle ( )
inline

Definition at line 32 of file EvFBuildingThrottle.h.

32 {}

Member Function Documentation

◆ dowork()

void evf::EvFBuildingThrottle::dowork ( )
inlineprivate

Definition at line 60 of file EvFBuildingThrottle.h.

60  {
62  struct statvfs buf;
63  while (!m_stoprequest) {
64  int retval = statvfs(baseDir_.c_str(), &buf);
65  if (retval != 0) {
66  std::cout << " building throttle - unable to stat " << baseDir_ << std::endl;
67  m_stoprequest = true;
68  continue;
69  }
70  double fraction = 1. - float(buf.f_bfree * buf.f_bsize) / float(buf.f_blocks * buf.f_frsize);
71  bool highwater_ = fraction > highWaterMark_;
72  bool lowwater_ = fraction < lowWaterMark_;
73  if (highwater_ && !throttled_) {
74  lock_.lock();
75  throttled_ = true;
76  std::cout << ">>>>throttling on " << std::endl;
77  }
78  if (lowwater_ && throttled_) {
79  lock_.unlock();
80  throttled_ = false;
81  }
82  std::cout << " building throttle on " << baseDir_ << " is " << fraction * 100 << " %full " << std::endl;
83  //edm::Service<EvFDaqDirector>()->writeDiskAndThrottleStat(fraction,highwater_,lowwater_);
84  ::usleep(sleep_ * 1000);
85  if (edm::shutdown_flag) {
86  std::cout << " Shutdown flag set: stop throttling" << std::endl;
87  break;
88  }
89  }
90  if (throttled_)
91  lock_.unlock();
92  }

References baseDir_, visDQMUpload::buf, gather_cfg::cout, dqmMemoryStats::float, HLT_2018_cff::fraction, highWaterMark_, lock_, lowWaterMark_, m_stoprequest, edm::shutdown_flag, sleep_, throttled_, and token_.

Referenced by start().

◆ postBeginRun()

void evf::EvFBuildingThrottle::postBeginRun ( edm::GlobalContext const &  gc)
inline

Definition at line 50 of file EvFBuildingThrottle.h.

50 {}

◆ postEndRun()

void evf::EvFBuildingThrottle::postEndRun ( edm::GlobalContext const &  gc)
inline

Definition at line 52 of file EvFBuildingThrottle.h.

52 { stop(); }

References stop().

Referenced by EvFBuildingThrottle().

◆ preBeginLumi()

void evf::EvFBuildingThrottle::preBeginLumi ( edm::GlobalContext const &  gc)
inline

Definition at line 53 of file EvFBuildingThrottle.h.

53  {
54  lock_.lock();
55  lock_.unlock();
56  }

References lock_.

Referenced by EvFBuildingThrottle().

◆ preBeginRun()

void evf::EvFBuildingThrottle::preBeginRun ( edm::GlobalContext const &  gc)
inline

Definition at line 33 of file EvFBuildingThrottle.h.

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

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

Referenced by EvFBuildingThrottle().

◆ start()

void evf::EvFBuildingThrottle::start ( )
inlineprivate

◆ stop()

void evf::EvFBuildingThrottle::stop ( )
inlineprivate

Definition at line 99 of file EvFBuildingThrottle.h.

99  {
100  assert(m_thread);
101  m_stoprequest = true;
102  m_thread->join();
103  }

References cms::cuda::assert(), m_stoprequest, and m_thread.

Referenced by postEndRun().

◆ throttled()

bool evf::EvFBuildingThrottle::throttled ( ) const
inline

Definition at line 57 of file EvFBuildingThrottle.h.

57 { return throttled_; }

References throttled_.

Member Data Documentation

◆ baseDir_

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

Definition at line 110 of file EvFBuildingThrottle.h.

Referenced by dowork(), and preBeginRun().

◆ highWaterMark_

double evf::EvFBuildingThrottle::highWaterMark_
private

Definition at line 105 of file EvFBuildingThrottle.h.

Referenced by dowork().

◆ lock_

std::mutex evf::EvFBuildingThrottle::lock_
private

Definition at line 109 of file EvFBuildingThrottle.h.

Referenced by dowork(), and preBeginLumi().

◆ lowWaterMark_

double evf::EvFBuildingThrottle::lowWaterMark_
private

Definition at line 106 of file EvFBuildingThrottle.h.

Referenced by dowork().

◆ m_stoprequest

std::atomic<bool> evf::EvFBuildingThrottle::m_stoprequest
private

Definition at line 107 of file EvFBuildingThrottle.h.

Referenced by dowork(), and stop().

◆ m_thread

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

Definition at line 108 of file EvFBuildingThrottle.h.

Referenced by start(), and stop().

◆ sleep_

unsigned int evf::EvFBuildingThrottle::sleep_
private

Definition at line 114 of file EvFBuildingThrottle.h.

Referenced by dowork().

◆ throttled_

bool evf::EvFBuildingThrottle::throttled_
private

Definition at line 113 of file EvFBuildingThrottle.h.

Referenced by dowork(), and throttled().

◆ token_

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

Definition at line 112 of file EvFBuildingThrottle.h.

Referenced by dowork(), and start().

◆ whatToThrottleOn_

Directory evf::EvFBuildingThrottle::whatToThrottleOn_
private

Definition at line 111 of file EvFBuildingThrottle.h.

Referenced by preBeginRun(), and start().

evf::EvFBuildingThrottle::preBeginLumi
void preBeginLumi(edm::GlobalContext const &gc)
Definition: EvFBuildingThrottle.h:53
evf::EvFBuildingThrottle::postEndRun
void postEndRun(edm::GlobalContext const &gc)
Definition: EvFBuildingThrottle.h:52
evf::EvFBuildingThrottle::throttled_
bool throttled_
Definition: EvFBuildingThrottle.h:113
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
evf::EvFBuildingThrottle::m_stoprequest
std::atomic< bool > m_stoprequest
Definition: EvFBuildingThrottle.h:107
evf::EvFBuildingThrottle::mBU
Definition: EvFBuildingThrottle.h:20
edm::ActivityRegistry::watchPostGlobalEndRun
void watchPostGlobalEndRun(PostGlobalEndRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:290
evf::EvFBuildingThrottle::highWaterMark_
double highWaterMark_
Definition: EvFBuildingThrottle.h:105
gather_cfg.cout
cout
Definition: gather_cfg.py:144
evf::EvFBuildingThrottle::m_thread
std::shared_ptr< std::thread > m_thread
Definition: EvFBuildingThrottle.h:108
evf::EvFBuildingThrottle::lowWaterMark_
double lowWaterMark_
Definition: EvFBuildingThrottle.h:106
cms::cuda::assert
assert(be >=bs)
evf::EvFBuildingThrottle::token_
edm::ServiceToken token_
Definition: EvFBuildingThrottle.h:112
evf::EvFBuildingThrottle::baseDir_
std::string baseDir_
Definition: EvFBuildingThrottle.h:110
evf::EvFBuildingThrottle::dowork
void dowork()
Definition: EvFBuildingThrottle.h:60
evf::EvFBuildingThrottle::mInvalid
Definition: EvFBuildingThrottle.h:20
edm::ServiceRegistry::presentToken
ServiceToken presentToken() const
Definition: ServiceRegistry.cc:63
edm::shutdown_flag
volatile std::atomic< bool > shutdown_flag
Definition: UnixSignalHandlers.cc:22
evf::EvFBuildingThrottle::lock_
std::mutex lock_
Definition: EvFBuildingThrottle.h:109
edm::Service
Definition: Service.h:30
edm::ServiceRegistry::instance
static ServiceRegistry & instance()
Definition: ServiceRegistry.cc:90
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
edm::ActivityRegistry::watchPreGlobalBeginLumi
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:333
evf::EvFBuildingThrottle::mCOUNT
Definition: EvFBuildingThrottle.h:20
evf::EvFBuildingThrottle::preBeginRun
void preBeginRun(edm::GlobalContext const &gc)
Definition: EvFBuildingThrottle.h:33
evf::EvFBuildingThrottle::Directory
Directory
Definition: EvFBuildingThrottle.h:20
evf::EvFBuildingThrottle::mBase
Definition: EvFBuildingThrottle.h:20
evf::EvFBuildingThrottle::start
void start()
Definition: EvFBuildingThrottle.h:93
evf::EvFBuildingThrottle::whatToThrottleOn_
Directory whatToThrottleOn_
Definition: EvFBuildingThrottle.h:111
evf::EvFBuildingThrottle::stop
void stop()
Definition: EvFBuildingThrottle.h:99
edm::ActivityRegistry::watchPreGlobalBeginRun
void watchPreGlobalBeginRun(PreGlobalBeginRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:273
evf::EvFBuildingThrottle::sleep_
unsigned int sleep_
Definition: EvFBuildingThrottle.h:114
edm::ServiceRegistry::Operate
Definition: ServiceRegistry.h:40
HLT_2018_cff.fraction
fraction
Definition: HLT_2018_cff.py:51317
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27