CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends
XrdAdaptor::QualityMetric Class Reference

#include <QualityMetric.h>

Inheritance diagram for XrdAdaptor::QualityMetric:
XrdAdaptor::QualityMetricSource XrdAdaptor::QualityMetricUniqueSource

Public Member Functions

unsigned get ()
 
 QualityMetric (timespec now, int default_value=260)
 

Private Member Functions

void finishWatch (timespec now, int ms)
 

Private Attributes

int m_interval0_n
 
time_t m_interval0_start
 
int m_interval0_val
 
int m_interval1_val
 
int m_interval2_val
 
int m_interval3_val
 
int m_interval4_val
 
std::mutex m_mutex
 
int m_value
 

Static Private Attributes

static const unsigned interval_length = 60
 

Friends

class QualityMetricWatch
 

Detailed Description

Definition at line 38 of file QualityMetric.h.

Constructor & Destructor Documentation

◆ QualityMetric()

QualityMetric::QualityMetric ( timespec  now,
int  default_value = 260 
)

Definition at line 69 of file QualityMetric.cc.

70  : m_value(default_value),
71  m_interval0_n(0),
72  m_interval0_val(-1),
73  m_interval0_start(now.tv_sec),
74  m_interval1_val(-1),
75  m_interval2_val(-1),
76  m_interval3_val(-1),
77  m_interval4_val(-1) {}

Member Function Documentation

◆ finishWatch()

void QualityMetric::finishWatch ( timespec  now,
int  ms 
)
private

Definition at line 79 of file QualityMetric.cc.

79  {
80  std::unique_lock<std::mutex> sentry(m_mutex);
81 
82  m_value = -1;
83  if (stop.tv_sec > m_interval0_start + interval_length) {
88  m_interval0_n = 1;
89  m_interval0_val = ms;
90  m_interval0_start = stop.tv_sec;
91  } else {
92  int num = m_interval0_val * m_interval0_n + ms;
93  m_interval0_n++;
95  }
96 }

References interval_length, m_interval0_n, m_interval0_start, m_interval0_val, m_interval1_val, m_interval2_val, m_interval3_val, m_interval4_val, m_mutex, m_value, and EgammaValidation_cff::num.

◆ get()

unsigned QualityMetric::get ( void  )

Definition at line 98 of file QualityMetric.cc.

98  {
99  std::unique_lock<std::mutex> sentry(m_mutex);
100 
101  if (m_value == -1) {
102  unsigned den = 0;
103  m_value = 0;
104  if (m_interval0_val >= 0) {
105  den += 16;
106  m_value = 16 * m_interval0_val;
107  }
108  if (m_interval1_val >= 0) {
109  den += 8;
110  m_value += 8 * m_interval1_val;
111  }
112  if (m_interval2_val >= 0) {
113  den += 4;
114  m_value += 4 * m_interval2_val;
115  }
116  if (m_interval3_val >= 0) {
117  den += 2;
118  m_value += 2 * m_interval3_val;
119  }
120  if (m_interval4_val >= 0) {
121  den += 1;
123  }
124  if (den)
125  m_value /= den;
126  else
127  m_value = 260;
128  }
129  return m_value;
130 }

References m_interval0_val, m_interval1_val, m_interval2_val, m_interval3_val, m_interval4_val, m_mutex, and m_value.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), and XrdAdaptor::QualityMetricUniqueSource::newSource().

Friends And Related Function Documentation

◆ QualityMetricWatch

friend class QualityMetricWatch
friend

Definition at line 39 of file QualityMetric.h.

Member Data Documentation

◆ interval_length

const unsigned XrdAdaptor::QualityMetric::interval_length = 60
staticprivate

Definition at line 48 of file QualityMetric.h.

Referenced by finishWatch().

◆ m_interval0_n

int XrdAdaptor::QualityMetric::m_interval0_n
private

Definition at line 51 of file QualityMetric.h.

Referenced by finishWatch().

◆ m_interval0_start

time_t XrdAdaptor::QualityMetric::m_interval0_start
private

Definition at line 53 of file QualityMetric.h.

Referenced by finishWatch().

◆ m_interval0_val

int XrdAdaptor::QualityMetric::m_interval0_val
private

Definition at line 52 of file QualityMetric.h.

Referenced by finishWatch(), and get().

◆ m_interval1_val

int XrdAdaptor::QualityMetric::m_interval1_val
private

Definition at line 54 of file QualityMetric.h.

Referenced by finishWatch(), and get().

◆ m_interval2_val

int XrdAdaptor::QualityMetric::m_interval2_val
private

Definition at line 55 of file QualityMetric.h.

Referenced by finishWatch(), and get().

◆ m_interval3_val

int XrdAdaptor::QualityMetric::m_interval3_val
private

Definition at line 56 of file QualityMetric.h.

Referenced by finishWatch(), and get().

◆ m_interval4_val

int XrdAdaptor::QualityMetric::m_interval4_val
private

Definition at line 57 of file QualityMetric.h.

Referenced by finishWatch(), and get().

◆ m_mutex

std::mutex XrdAdaptor::QualityMetric::m_mutex
private

Definition at line 59 of file QualityMetric.h.

Referenced by finishWatch(), and get().

◆ m_value

int XrdAdaptor::QualityMetric::m_value
private

Definition at line 50 of file QualityMetric.h.

Referenced by finishWatch(), and get().

XrdAdaptor::QualityMetric::m_interval3_val
int m_interval3_val
Definition: QualityMetric.h:56
XrdAdaptor::QualityMetric::m_interval1_val
int m_interval1_val
Definition: QualityMetric.h:54
XrdAdaptor::QualityMetric::m_interval0_val
int m_interval0_val
Definition: QualityMetric.h:52
XrdAdaptor::QualityMetric::interval_length
static const unsigned interval_length
Definition: QualityMetric.h:48
fileCollector.now
now
Definition: fileCollector.py:207
XrdAdaptor::QualityMetric::m_interval4_val
int m_interval4_val
Definition: QualityMetric.h:57
XrdAdaptor::QualityMetric::m_interval0_n
int m_interval0_n
Definition: QualityMetric.h:51
XrdAdaptor::QualityMetric::m_value
int m_value
Definition: QualityMetric.h:50
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
XrdAdaptor::QualityMetric::m_interval2_val
int m_interval2_val
Definition: QualityMetric.h:55
XrdAdaptor::QualityMetric::m_mutex
std::mutex m_mutex
Definition: QualityMetric.h:59
XrdAdaptor::QualityMetric::m_interval0_start
time_t m_interval0_start
Definition: QualityMetric.h:53