Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
om::Ticker Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/OnlineMonitoring/util/Ticker.h"

Public Member Functions

void Update (unsigned int run, unsigned int subrun)
 
void Subscribe (TickerSubscriber *s, unsigned int which)
 

Static Public Member Functions

static TickerInstance ()
 

Private Member Functions

void PublishRun ()
 
void PublishSubrun ()
 
void Publish30Sec ()
 
void Publish1Min ()
 
void Publish5Min ()
 
void Publish10Min ()
 
void Publish30Min ()
 
void PublishHour ()
 
void Publish24Hr ()
 
 Ticker ()
 Ticker is a singleton - constructor is private. More...
 

Private Attributes

unsigned int fLastRun
 Run number of last update. More...
 
unsigned int fLastSubrun
 Subrun number of last update. More...
 
int fLast30Sec
 Time of last 30 second update. More...
 
int fLast1Min
 Time of last 1 minute update. More...
 
int fLast5Min
 Time of last 5 minute update. More...
 
int fLast10Min
 Time of last 10 minute update. More...
 
int fLast30Min
 Time of last 30 minute update. More...
 
int fLastHour
 Time of last hour update. More...
 
int fLast24Hr
 Time of last 24 hour update. More...
 
std::list< TickerSubscriber * > f30SecSubscribers
 
std::list< TickerSubscriber * > f1MinSubscribers
 
std::list< TickerSubscriber * > f5MinSubscribers
 
std::list< TickerSubscriber * > f10MinSubscribers
 
std::list< TickerSubscriber * > f30MinSubscribers
 
std::list< TickerSubscriber * > fHourSubscribers
 
std::list< TickerSubscriber * > f24HrSubscribers
 
std::list< TickerSubscriber * > fRunSubscribers
 
std::list< TickerSubscriber * > fSubrunSubscribers
 

Static Private Attributes

static const unsigned int kUninitRun = UINT_MAX
 Define what an uninitialized run/subrun number looks like. More...
 
static const int kUninitTime = -1
 Define what an uninitialized time looks like. More...
 

Detailed Description

Definition at line 15 of file Ticker.h.

Constructor & Destructor Documentation

Ticker::Ticker ( )
private

Ticker is a singleton - constructor is private.

Definition at line 12 of file Ticker.cxx.

12  :
22 { }
static const unsigned int kUninitRun
Define what an uninitialized run/subrun number looks like.
Definition: Ticker.h:37
unsigned int fLastRun
Run number of last update.
Definition: Ticker.h:43
static const int kUninitTime
Define what an uninitialized time looks like.
Definition: Ticker.h:40
int fLast30Sec
Time of last 30 second update.
Definition: Ticker.h:45
int fLast1Min
Time of last 1 minute update.
Definition: Ticker.h:46
int fLast30Min
Time of last 30 minute update.
Definition: Ticker.h:49
unsigned int fLastSubrun
Subrun number of last update.
Definition: Ticker.h:44
int fLast5Min
Time of last 5 minute update.
Definition: Ticker.h:47
int fLast10Min
Time of last 10 minute update.
Definition: Ticker.h:48
int fLast24Hr
Time of last 24 hour update.
Definition: Ticker.h:51
int fLastHour
Time of last hour update.
Definition: Ticker.h:50

Member Function Documentation

Ticker & Ticker::Instance ( )
static

Definition at line 26 of file Ticker.cxx.

Referenced by om::OnMonProd::analyze(), and om::TickerSubscriber::TickerSubscriber().

27 {
28  static Ticker johnbonham;
29  return johnbonham;
30 }
void Ticker::Publish10Min ( )
private

Definition at line 147 of file Ticker.cxx.

References e, f10MinSubscribers, and MECModelEnuComparisons::i.

Referenced by Update().

148 {
149  std::list<TickerSubscriber*>::iterator i(f10MinSubscribers.begin());
150  std::list<TickerSubscriber*>::iterator e(f10MinSubscribers.end());
151  for (; i!=e; ++i) (*i)->TenMinTicker();
152 }
std::list< TickerSubscriber * > f10MinSubscribers
Definition: Ticker.h:55
Float_t e
Definition: plot.C:35
void Ticker::Publish1Min ( )
private

Definition at line 129 of file Ticker.cxx.

References e, f1MinSubscribers, and MECModelEnuComparisons::i.

Referenced by Update().

130 {
131  std::list<TickerSubscriber*>::iterator i(f1MinSubscribers.begin());
132  std::list<TickerSubscriber*>::iterator e(f1MinSubscribers.end());
133  for (; i!=e; ++i) (*i)->OneMinTicker();
134 }
std::list< TickerSubscriber * > f1MinSubscribers
Definition: Ticker.h:53
Float_t e
Definition: plot.C:35
void Ticker::Publish24Hr ( )
private

Definition at line 174 of file Ticker.cxx.

References e, f24HrSubscribers, and MECModelEnuComparisons::i.

Referenced by Update().

175 {
176  std::list<TickerSubscriber*>::iterator i(f24HrSubscribers.begin());
177  std::list<TickerSubscriber*>::iterator e(f24HrSubscribers.end());
178  for (; i!=e; ++i) (*i)->TwentyFourHrTicker();
179 }
Float_t e
Definition: plot.C:35
std::list< TickerSubscriber * > f24HrSubscribers
Definition: Ticker.h:58
void Ticker::Publish30Min ( )
private

Definition at line 156 of file Ticker.cxx.

References e, f30MinSubscribers, and MECModelEnuComparisons::i.

Referenced by Update().

157 {
158  std::list<TickerSubscriber*>::iterator i(f30MinSubscribers.begin());
159  std::list<TickerSubscriber*>::iterator e(f30MinSubscribers.end());
160  for (; i!=e; ++i) (*i)->ThirtyMinTicker();
161 }
std::list< TickerSubscriber * > f30MinSubscribers
Definition: Ticker.h:56
Float_t e
Definition: plot.C:35
void Ticker::Publish30Sec ( )
private

Definition at line 120 of file Ticker.cxx.

References e, f30SecSubscribers, and MECModelEnuComparisons::i.

Referenced by Update().

121 {
122  std::list<TickerSubscriber*>::iterator i(f30SecSubscribers.begin());
123  std::list<TickerSubscriber*>::iterator e(f30SecSubscribers.end());
124  for (; i!=e; ++i) (*i)->ThirtySecTicker();
125 }
std::list< TickerSubscriber * > f30SecSubscribers
Definition: Ticker.h:52
Float_t e
Definition: plot.C:35
void Ticker::Publish5Min ( )
private

Definition at line 138 of file Ticker.cxx.

References e, f5MinSubscribers, and MECModelEnuComparisons::i.

Referenced by Update().

139 {
140  std::list<TickerSubscriber*>::iterator i(f5MinSubscribers.begin());
141  std::list<TickerSubscriber*>::iterator e(f5MinSubscribers.end());
142  for (; i!=e; ++i) (*i)->FiveMinTicker();
143 }
std::list< TickerSubscriber * > f5MinSubscribers
Definition: Ticker.h:54
Float_t e
Definition: plot.C:35
void Ticker::PublishHour ( )
private

Definition at line 165 of file Ticker.cxx.

References e, fHourSubscribers, and MECModelEnuComparisons::i.

Referenced by Update().

166 {
167  std::list<TickerSubscriber*>::iterator i(fHourSubscribers.begin());
168  std::list<TickerSubscriber*>::iterator e(fHourSubscribers.end());
169  for (; i!=e; ++i) (*i)->HourTicker();
170 }
std::list< TickerSubscriber * > fHourSubscribers
Definition: Ticker.h:57
Float_t e
Definition: plot.C:35
void Ticker::PublishRun ( )
private

Definition at line 102 of file Ticker.cxx.

References e, fRunSubscribers, and MECModelEnuComparisons::i.

Referenced by Update().

103 {
104  std::list<TickerSubscriber*>::iterator i(fRunSubscribers.begin());
105  std::list<TickerSubscriber*>::iterator e(fRunSubscribers.end());
106  for (; i!=e; ++i) (*i)->RunTicker();
107 }
std::list< TickerSubscriber * > fRunSubscribers
Definition: Ticker.h:59
Float_t e
Definition: plot.C:35
void Ticker::PublishSubrun ( )
private

Definition at line 111 of file Ticker.cxx.

References e, fSubrunSubscribers, and MECModelEnuComparisons::i.

Referenced by Update().

112 {
113  std::list<TickerSubscriber*>::iterator i(fSubrunSubscribers.begin());
114  std::list<TickerSubscriber*>::iterator e(fSubrunSubscribers.end());
115  for (; i!=e; ++i) (*i)->SubrunTicker();
116 }
std::list< TickerSubscriber * > fSubrunSubscribers
Definition: Ticker.h:60
Float_t e
Definition: plot.C:35
void Ticker::Subscribe ( TickerSubscriber s,
unsigned int  which 
)

Definition at line 183 of file Ticker.cxx.

References f10MinSubscribers, f1MinSubscribers, f24HrSubscribers, f30MinSubscribers, f30SecSubscribers, f5MinSubscribers, fHourSubscribers, fRunSubscribers, fSubrunSubscribers, om::TickerSubscriber::k10min, om::TickerSubscriber::k1min, om::TickerSubscriber::k24hr, om::TickerSubscriber::k30min, om::TickerSubscriber::k30sec, om::TickerSubscriber::k5min, om::TickerSubscriber::kHour, om::TickerSubscriber::kRun, and om::TickerSubscriber::kSubrun.

Referenced by om::TickerSubscriber::TickerSubscriber().

184 {
185  if ((which&TickerSubscriber::kRun)!=0) {
186  fRunSubscribers.push_back(s);
187  }
188  if ((which&TickerSubscriber::kSubrun)!=0) {
189  fSubrunSubscribers.push_back(s);
190  }
191  if ((which&TickerSubscriber::k30sec)!=0) {
192  f30SecSubscribers.push_back(s);
193  }
194  if ((which&TickerSubscriber::k1min)!=0) {
195  f1MinSubscribers.push_back(s);
196  }
197  if ((which&TickerSubscriber::k5min)!=0) {
198  f5MinSubscribers.push_back(s);
199  }
200  if ((which&TickerSubscriber::k10min)!=0) {
201  f10MinSubscribers.push_back(s);
202  }
203  if ((which&TickerSubscriber::k30min)!=0) {
204  f30MinSubscribers.push_back(s);
205  }
206  if ((which&TickerSubscriber::kHour)!=0) {
207  fHourSubscribers.push_back(s);
208  }
209  if ((which&TickerSubscriber::k24hr)!=0) {
210  f24HrSubscribers.push_back(s);
211  }
212 }
std::list< TickerSubscriber * > fSubrunSubscribers
Definition: Ticker.h:60
std::list< TickerSubscriber * > fHourSubscribers
Definition: Ticker.h:57
std::list< TickerSubscriber * > f10MinSubscribers
Definition: Ticker.h:55
std::list< TickerSubscriber * > f30MinSubscribers
Definition: Ticker.h:56
std::list< TickerSubscriber * > f30SecSubscribers
Definition: Ticker.h:52
std::list< TickerSubscriber * > fRunSubscribers
Definition: Ticker.h:59
std::list< TickerSubscriber * > f1MinSubscribers
Definition: Ticker.h:53
std::list< TickerSubscriber * > f5MinSubscribers
Definition: Ticker.h:54
std::list< TickerSubscriber * > f24HrSubscribers
Definition: Ticker.h:58
void Ticker::Update ( unsigned int  run,
unsigned int  subrun 
)

Definition at line 34 of file Ticker.cxx.

References fLast10Min, fLast1Min, fLast24Hr, fLast30Min, fLast30Sec, fLast5Min, fLastHour, fLastRun, fLastSubrun, kUninitRun, kUninitTime, Publish10Min(), Publish1Min(), Publish24Hr(), Publish30Min(), Publish30Sec(), Publish5Min(), PublishHour(), PublishRun(), PublishSubrun(), updateRunHistoryTables::run, and getGoodRuns4SAM::subrun.

Referenced by om::OnMonProd::analyze(), progbar.ProgressBar::Finish(), and progbar.ProgressBar::Start().

35 {
36  // Get current UNIX time in seconds
37  time_t tt = time(0);
38  struct tm t;
39  gmtime_r(&tt, &t);
40 
41  //
42  // Initialize the counters if we have to.
43  //
46  if (fLast30Sec ==kUninitTime) fLast30Sec = t.tm_sec;
47  if (fLast1Min ==kUninitTime) fLast1Min = t.tm_min;
48  if (fLast5Min ==kUninitTime) fLast5Min = t.tm_min;
49  if (fLast10Min ==kUninitTime) fLast10Min = t.tm_min;
50  if (fLast30Min ==kUninitTime) fLast30Min = t.tm_min;
51  if (fLastHour ==kUninitTime) fLastHour = t.tm_hour;
52  if (fLast24Hr ==kUninitTime) fLast24Hr = t.tm_yday;
53 
54  bool do30sec = (t.tm_sec !=fLast30Sec && (t.tm_sec%30==0));
55  bool do1min = (t.tm_min !=fLast1Min);
56  bool do5min = (t.tm_min !=fLast5Min && (t.tm_min%5==0));
57  bool do10min = (t.tm_min !=fLast10Min && (t.tm_min%10==0));
58  bool do30min = (t.tm_min !=fLast30Min && (t.tm_min%30==0));
59  bool dohour = (t.tm_hour!=fLastHour);
60  bool do24hr = (t.tm_yday!=fLast24Hr);
61 
62  /*
63  std::cout << "**" << std::endl;
64  std::cout << "30s:\t"<<t.tm_sec<<"\t"<<fLast30Sec<<"\t"<<do30sec<<std::endl;
65  std::cout << "1m:\t" <<t.tm_min<<"\t"<<fLast1Min <<"\t"<<do1min <<std::endl;
66  std::cout << "5m:\t" <<t.tm_min<<"\t"<<fLast5Min <<"\t"<<do5min <<std::endl;
67  std::cout << "10m:\t"<<t.tm_min<<"\t"<<fLast10Min<<"\t"<<do10min<<std::endl;
68  std::cout << "30m:\t"<<t.tm_min<<"\t"<<fLast30Min<<"\t"<<do30min<<std::endl;
69  std::cout << "1h:\t" <<t.tm_hour<<"\t"<<fLastHour<<"\t"<<dohour<<std::endl;
70  std::cout << "24h:\t"<<t.tm_yday<<"\t"<<fLast24Hr<<"\t"<<do24hr<<std::endl;
71  */
72 
73  if (do30sec) { fLast30Sec = t.tm_sec; this->Publish30Sec(); }
74  if (do1min) { fLast1Min = t.tm_min; this->Publish1Min(); }
75  if (do5min) { fLast5Min = t.tm_min; this->Publish5Min(); }
76  if (do10min) { fLast10Min = t.tm_min; this->Publish10Min(); }
77  if (do30min) { fLast30Min = t.tm_min; this->Publish30Min(); }
78  if (dohour) { fLastHour = t.tm_hour; this->PublishHour(); }
79  if (do24hr) { fLast24Hr = t.tm_yday; this->Publish24Hr(); }
80 
81  //
82  // Check the run/subrun tickers and publish if we need to. Note that
83  // the "run update" should also trigger a "subrun update" since
84  // logically the last subrun of a run ends just prior to the end of
85  // the run (try saying that ten times fast!). When publishing, be
86  // sure to update the run and subrun numbers of the last update.
87  //
88  if (fLastRun!=run) {
89  fLastRun = run;
91  this->PublishSubrun();
92  this->PublishRun();
93  }
94  if (fLastSubrun!=subrun) {
96  this->PublishSubrun();
97  }
98 }
static const unsigned int kUninitRun
Define what an uninitialized run/subrun number looks like.
Definition: Ticker.h:37
void Publish10Min()
Definition: Ticker.cxx:147
unsigned int fLastRun
Run number of last update.
Definition: Ticker.h:43
void Publish5Min()
Definition: Ticker.cxx:138
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
static const int kUninitTime
Define what an uninitialized time looks like.
Definition: Ticker.h:40
int fLast30Sec
Time of last 30 second update.
Definition: Ticker.h:45
Definition: type_traits.h:56
void PublishRun()
Definition: Ticker.cxx:102
void Publish1Min()
Definition: Ticker.cxx:129
int fLast1Min
Time of last 1 minute update.
Definition: Ticker.h:46
Definition: run.py:1
int fLast30Min
Time of last 30 minute update.
Definition: Ticker.h:49
void Publish30Min()
Definition: Ticker.cxx:156
unsigned int fLastSubrun
Subrun number of last update.
Definition: Ticker.h:44
void Publish24Hr()
Definition: Ticker.cxx:174
void Publish30Sec()
Definition: Ticker.cxx:120
int fLast5Min
Time of last 5 minute update.
Definition: Ticker.h:47
int fLast10Min
Time of last 10 minute update.
Definition: Ticker.h:48
int fLast24Hr
Time of last 24 hour update.
Definition: Ticker.h:51
void PublishSubrun()
Definition: Ticker.cxx:111
int fLastHour
Time of last hour update.
Definition: Ticker.h:50
void PublishHour()
Definition: Ticker.cxx:165

Member Data Documentation

std::list<TickerSubscriber*> om::Ticker::f10MinSubscribers
private

Definition at line 55 of file Ticker.h.

Referenced by Publish10Min(), and Subscribe().

std::list<TickerSubscriber*> om::Ticker::f1MinSubscribers
private

Definition at line 53 of file Ticker.h.

Referenced by Publish1Min(), and Subscribe().

std::list<TickerSubscriber*> om::Ticker::f24HrSubscribers
private

Definition at line 58 of file Ticker.h.

Referenced by Publish24Hr(), and Subscribe().

std::list<TickerSubscriber*> om::Ticker::f30MinSubscribers
private

Definition at line 56 of file Ticker.h.

Referenced by Publish30Min(), and Subscribe().

std::list<TickerSubscriber*> om::Ticker::f30SecSubscribers
private

Definition at line 52 of file Ticker.h.

Referenced by Publish30Sec(), and Subscribe().

std::list<TickerSubscriber*> om::Ticker::f5MinSubscribers
private

Definition at line 54 of file Ticker.h.

Referenced by Publish5Min(), and Subscribe().

std::list<TickerSubscriber*> om::Ticker::fHourSubscribers
private

Definition at line 57 of file Ticker.h.

Referenced by PublishHour(), and Subscribe().

int om::Ticker::fLast10Min
private

Time of last 10 minute update.

Definition at line 48 of file Ticker.h.

Referenced by Update().

int om::Ticker::fLast1Min
private

Time of last 1 minute update.

Definition at line 46 of file Ticker.h.

Referenced by Update().

int om::Ticker::fLast24Hr
private

Time of last 24 hour update.

Definition at line 51 of file Ticker.h.

Referenced by Update().

int om::Ticker::fLast30Min
private

Time of last 30 minute update.

Definition at line 49 of file Ticker.h.

Referenced by Update().

int om::Ticker::fLast30Sec
private

Time of last 30 second update.

Definition at line 45 of file Ticker.h.

Referenced by Update().

int om::Ticker::fLast5Min
private

Time of last 5 minute update.

Definition at line 47 of file Ticker.h.

Referenced by Update().

int om::Ticker::fLastHour
private

Time of last hour update.

Definition at line 50 of file Ticker.h.

Referenced by Update().

unsigned int om::Ticker::fLastRun
private

Run number of last update.

Definition at line 43 of file Ticker.h.

Referenced by Update().

unsigned int om::Ticker::fLastSubrun
private

Subrun number of last update.

Definition at line 44 of file Ticker.h.

Referenced by Update().

std::list<TickerSubscriber*> om::Ticker::fRunSubscribers
private

Definition at line 59 of file Ticker.h.

Referenced by PublishRun(), and Subscribe().

std::list<TickerSubscriber*> om::Ticker::fSubrunSubscribers
private

Definition at line 60 of file Ticker.h.

Referenced by PublishSubrun(), and Subscribe().

const unsigned int om::Ticker::kUninitRun = UINT_MAX
staticprivate

Define what an uninitialized run/subrun number looks like.

Definition at line 37 of file Ticker.h.

Referenced by Update().

const int om::Ticker::kUninitTime = -1
staticprivate

Define what an uninitialized time looks like.

Definition at line 40 of file Ticker.h.

Referenced by Update().


The documentation for this class was generated from the following files: