CMS 3D CMS Logo

QualityMetric.h
Go to the documentation of this file.
1 #ifndef Utilities_XrdAdaptor_QualityMetric_h
2 #define Utilities_XrdAdaptor_QualityMetric_h
3 
4 #include <ctime>
5 
6 #include <mutex>
7 #include <memory>
8 
9 #include "tbb/concurrent_unordered_map.h"
10 
13 
14 namespace XrdAdaptor {
15 
16  class QualityMetric;
17  class QualityMetricSource;
19 
21  friend class QualityMetricSource;
22 
23  public:
24  QualityMetricWatch() : m_parent1(nullptr), m_parent2(nullptr) {}
27 
28  QualityMetricWatch(const QualityMetricWatch &) = delete;
30 
31  void swap(QualityMetricWatch &);
32 
33  private:
35  timespec m_start;
38  };
39 
40  class QualityMetric {
41  friend class QualityMetricWatch;
42 
43  public:
44  QualityMetric(timespec now, int default_value = 260);
45  unsigned get();
46 
47  QualityMetric(const QualityMetric &) = delete;
48  QualityMetric &operator=(const QualityMetric &) = delete;
49 
50  private:
51  void finishWatch(timespec now, int ms);
52 
53  static const unsigned interval_length = 60;
54 
55  int m_value;
63 
65  };
66 
68  friend class Source;
69 
70  private:
71  static std::unique_ptr<QualityMetricSource> get(timespec now, const std::string &id);
72 
74 
75  typedef tbb::concurrent_unordered_map<std::string, QualityMetricUniqueSource *> MetricMap;
77  };
78 
83  class QualityMetricSource final : public QualityMetric {
85 
86  public:
88 
89  private:
90  QualityMetricSource(QualityMetricUniqueSource &parent, timespec now, int default_value);
91 
93  };
94 
95  /*
96  * This quality metric tracks all accesses to a given source ID.
97  */
99  friend class QualityMetricFactory;
100 
101  private:
102  QualityMetricUniqueSource(timespec now);
103  std::unique_ptr<QualityMetricSource> newSource(timespec now);
104  };
105 
106 } // namespace XrdAdaptor
107 
108 #endif // Utilities_XrdAdaptor_QualityMetric_h
XrdAdaptor::QualityMetric::m_interval3_val
int m_interval3_val
Definition: QualityMetric.h:61
propagate_const.h
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
XrdAdaptor::QualityMetricWatch::QualityMetricWatch
QualityMetricWatch()
Definition: QualityMetric.h:24
XrdAdaptor::QualityMetric::m_interval1_val
int m_interval1_val
Definition: QualityMetric.h:59
XrdAdaptor::QualityMetric::m_interval0_val
int m_interval0_val
Definition: QualityMetric.h:57
XrdAdaptor::QualityMetric::get
unsigned get()
Definition: QualityMetric.cc:98
XrdAdaptor::QualityMetricUniqueSource::newSource
std::unique_ptr< QualityMetricSource > newSource(timespec now)
Definition: QualityMetric.cc:158
XrdAdaptor::QualityMetricSource
Definition: QualityMetric.h:83
XrdAdaptor::QualityMetricUniqueSource
Definition: QualityMetric.h:98
XrdAdaptor::QualityMetricSource::startWatch
void startWatch(QualityMetricWatch &)
Definition: QualityMetric.cc:151
XrdAdaptor::QualityMetric::interval_length
static const unsigned interval_length
Definition: QualityMetric.h:53
edm::propagate_const
Definition: propagate_const.h:32
XrdAdaptor::QualityMetricSource::QualityMetricSource
QualityMetricSource(QualityMetricUniqueSource &parent, timespec now, int default_value)
Definition: QualityMetric.cc:148
XrdAdaptor::QualityMetricWatch
Definition: QualityMetric.h:20
XrdAdaptor::QualityMetricSource::m_parent
QualityMetricUniqueSource & m_parent
Definition: QualityMetric.h:92
XrdAdaptor::QualityMetric::QualityMetric
QualityMetric(timespec now, int default_value=260)
Definition: QualityMetric.cc:69
XrdAdaptor::QualityMetricWatch::m_parent1
edm::propagate_const< QualityMetric * > m_parent1
Definition: QualityMetric.h:36
XrdAdaptor::QualityMetricUniqueSource::QualityMetricUniqueSource
QualityMetricUniqueSource(timespec now)
Definition: QualityMetric.cc:156
CMS_THREAD_SAFE
#define CMS_THREAD_SAFE
Definition: thread_safety_macros.h:4
XrdAdaptor::QualityMetric::finishWatch
void finishWatch(timespec now, int ms)
Definition: QualityMetric.cc:79
XrdAdaptor::QualityMetricWatch::m_start
timespec m_start
Definition: QualityMetric.h:35
XrdAdaptor::QualityMetric::m_interval4_val
int m_interval4_val
Definition: QualityMetric.h:62
thread_safety_macros.h
XrdAdaptor::QualityMetric::m_interval0_n
int m_interval0_n
Definition: QualityMetric.h:56
mutex
static std::mutex mutex
Definition: Proxy.cc:8
XrdAdaptor::QualityMetricFactory::m_sources
MetricMap m_sources
Definition: QualityMetric.h:76
XrdAdaptor::QualityMetric::m_value
int m_value
Definition: QualityMetric.h:55
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
XrdAdaptor::Source
Definition: XrdSource.h:23
XrdAdaptor::QualityMetricWatch::swap
void swap(QualityMetricWatch &)
Definition: QualityMetric.cc:55
XrdAdaptor::QualityMetricWatch::~QualityMetricWatch
~QualityMetricWatch()
Definition: QualityMetric.cc:34
XrdAdaptor::QualityMetricFactory
Definition: QualityMetric.h:67
XrdAdaptor::QualityMetricFactory::MetricMap
tbb::concurrent_unordered_map< std::string, QualityMetricUniqueSource * > MetricMap
Definition: QualityMetric.h:75
XrdAdaptor::QualityMetricFactory::get
static std::unique_ptr< QualityMetricSource > get(timespec now, const std::string &id)
Definition: QualityMetric.cc:134
XrdAdaptor::QualityMetricWatch::m_parent2
edm::propagate_const< QualityMetric * > m_parent2
Definition: QualityMetric.h:37
XrdAdaptor::QualityMetric::m_interval2_val
int m_interval2_val
Definition: QualityMetric.h:60
XrdAdaptor::QualityMetric
Definition: QualityMetric.h:40
XrdAdaptor::QualityMetric::operator=
QualityMetric & operator=(const QualityMetric &)=delete
XrdAdaptor::QualityMetric::m_mutex
std::mutex m_mutex
Definition: QualityMetric.h:64
class-composition.parent
parent
Definition: class-composition.py:98
XrdAdaptor
Definition: QualityMetric.h:14
XrdAdaptor::QualityMetric::m_interval0_start
time_t m_interval0_start
Definition: QualityMetric.h:58
XrdAdaptor::QualityMetricFactory::m_instance
static QualityMetricFactory m_instance
Definition: QualityMetric.h:73
XrdAdaptor::QualityMetricWatch::operator=
QualityMetricWatch & operator=(const QualityMetricWatch &)=delete