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 #include <boost/utility.hpp>
11 
14 
15 namespace XrdAdaptor {
16 
17  class QualityMetric;
18  class QualityMetricSource;
20 
21  class QualityMetricWatch : boost::noncopyable {
22  friend class QualityMetricSource;
23 
24  public:
25  QualityMetricWatch() : m_parent1(nullptr), m_parent2(nullptr) {}
28 
29  void swap(QualityMetricWatch &);
30 
31  private:
33  timespec m_start;
36  };
37 
38  class QualityMetric : boost::noncopyable {
39  friend class QualityMetricWatch;
40 
41  public:
42  QualityMetric(timespec now, int default_value = 260);
43  unsigned get();
44 
45  private:
46  void finishWatch(timespec now, int ms);
47 
48  static const unsigned interval_length = 60;
49 
50  int m_value;
58 
60  };
61 
63  friend class Source;
64 
65  private:
66  static std::unique_ptr<QualityMetricSource> get(timespec now, const std::string &id);
67 
69 
70  typedef tbb::concurrent_unordered_map<std::string, QualityMetricUniqueSource *> MetricMap;
72  };
73 
78  class QualityMetricSource final : public QualityMetric {
80 
81  public:
83 
84  private:
85  QualityMetricSource(QualityMetricUniqueSource &parent, timespec now, int default_value);
86 
88  };
89 
90  /*
91  * This quality metric tracks all accesses to a given source ID.
92  */
94  friend class QualityMetricFactory;
95 
96  private:
98  std::unique_ptr<QualityMetricSource> newSource(timespec now);
99  };
100 
101 } // namespace XrdAdaptor
102 
103 #endif // Utilities_XrdAdaptor_QualityMetric_h
XrdAdaptor::QualityMetric::m_interval3_val
int m_interval3_val
Definition: QualityMetric.h:56
propagate_const.h
XrdAdaptor::QualityMetricWatch::QualityMetricWatch
QualityMetricWatch()
Definition: QualityMetric.h:25
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::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:78
XrdAdaptor::QualityMetricUniqueSource
Definition: QualityMetric.h:93
XrdAdaptor::QualityMetricSource::startWatch
void startWatch(QualityMetricWatch &)
Definition: QualityMetric.cc:151
XrdAdaptor::QualityMetric::interval_length
static const unsigned interval_length
Definition: QualityMetric.h:48
fileCollector.now
now
Definition: fileCollector.py:207
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:21
XrdAdaptor::QualityMetricSource::m_parent
QualityMetricUniqueSource & m_parent
Definition: QualityMetric.h:87
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:34
XrdAdaptor::QualityMetricUniqueSource::QualityMetricUniqueSource
QualityMetricUniqueSource(timespec now)
Definition: QualityMetric.cc:156
CMS_THREAD_SAFE
#define CMS_THREAD_SAFE
Definition: thread_safety_macros.h:4
mutex
static boost::mutex mutex
Definition: Proxy.cc:9
XrdAdaptor::QualityMetric::finishWatch
void finishWatch(timespec now, int ms)
Definition: QualityMetric.cc:79
XrdAdaptor::QualityMetricWatch::m_start
timespec m_start
Definition: QualityMetric.h:33
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
XrdAdaptor::QualityMetric::m_interval4_val
int m_interval4_val
Definition: QualityMetric.h:57
thread_safety_macros.h
XrdAdaptor::QualityMetric::m_interval0_n
int m_interval0_n
Definition: QualityMetric.h:51
XrdAdaptor::QualityMetricFactory::m_sources
MetricMap m_sources
Definition: QualityMetric.h:71
XrdAdaptor::QualityMetric::m_value
int m_value
Definition: QualityMetric.h:50
XrdAdaptor::Source
Definition: XrdSource.h:25
XrdAdaptor::QualityMetricWatch::swap
void swap(QualityMetricWatch &)
Definition: QualityMetric.cc:55
XrdAdaptor::QualityMetricWatch::~QualityMetricWatch
~QualityMetricWatch()
Definition: QualityMetric.cc:34
XrdAdaptor::QualityMetricFactory
Definition: QualityMetric.h:62
XrdAdaptor::QualityMetricFactory::MetricMap
tbb::concurrent_unordered_map< std::string, QualityMetricUniqueSource * > MetricMap
Definition: QualityMetric.h:70
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:35
XrdAdaptor::QualityMetric::m_interval2_val
int m_interval2_val
Definition: QualityMetric.h:55
XrdAdaptor::QualityMetric
Definition: QualityMetric.h:38
XrdAdaptor::QualityMetric::m_mutex
std::mutex m_mutex
Definition: QualityMetric.h:59
class-composition.parent
parent
Definition: class-composition.py:88
XrdAdaptor
Definition: QualityMetric.h:15
XrdAdaptor::QualityMetric::m_interval0_start
time_t m_interval0_start
Definition: QualityMetric.h:53
XrdAdaptor::QualityMetricFactory::m_instance
static QualityMetricFactory m_instance
Definition: QualityMetric.h:68