CMS 3D CMS Logo

XrdStatistics.h
Go to the documentation of this file.
1 #ifndef __XRD_STATISTICS_SERVICE_H_
2 #define __XRD_STATISTICS_SERVICE_H_
3 
6 
7 #include <atomic>
8 #include <chrono>
9 #include <map>
10 #include <memory>
11 #include <mutex>
12 #include <vector>
13 
14 namespace edm
15 {
16  class ParameterSet;
17  class ActivityRegistry;
19 }
20 
21 namespace XrdAdaptor
22 {
23 
24 class ClientRequest;
25 class XrdReadStatistics;
26 class XrdSiteStatistics;
27 
28 
29 /* NOTE: All member information is kept in the XrdSiteStatisticsInformation singleton,
30  * _not_ within the service itself. This is because we need to be able to use the
31  * singleton on non-CMSSW-created threads. Services are only available to threads
32  * created by CMSSW.
33  */
35 {
36 public:
37 
39 
40  void postEndJob();
41 
42  void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
43 
44 private:
45 
46 };
47 
49 {
50 friend class XrdStatisticsService;
51 
52 public:
53  static XrdSiteStatisticsInformation *getInstance();
54 
55  std::shared_ptr<XrdSiteStatistics> getStatisticsForSite(std::string const &site);
56 
57 private:
58  static void createInstance();
59 
60  static std::atomic<XrdSiteStatisticsInformation*> m_instance;
62  std::vector<edm::propagate_const<std::shared_ptr<XrdSiteStatistics>>> m_sites;
63 };
64 
66 {
67 friend class XrdReadStatistics;
68 
69 public:
70  XrdSiteStatistics(std::string const &site);
71  XrdSiteStatistics(const XrdSiteStatistics&) = delete;
72  XrdSiteStatistics &operator=(const XrdSiteStatistics&) = delete;
73 
74  std::string const &site() const {return m_site;}
75 
76  // Note that, while this function is thread-safe, the numbers are only consistent if no other
77  // thread is reading data.
78  void recomputeProperties(std::map<std::string, std::string> &props);
79 
80  static std::shared_ptr<XrdReadStatistics> startRead(std::shared_ptr<XrdSiteStatistics> parent, std::shared_ptr<ClientRequest> req);
81 
82  void finishRead(XrdReadStatistics const &);
83 
84 private:
85  const std::string m_site = "Unknown";
86 
87  std::atomic<unsigned> m_readvCount;
88  std::atomic<unsigned> m_chunkCount;
89  std::atomic<uint64_t> m_readvSize;
90  std::atomic<uint64_t> m_readvNS;
91  std::atomic<unsigned> m_readCount;
92  std::atomic<uint64_t> m_readSize;
93  std::atomic<uint64_t> m_readNS;
94 };
95 
97 {
98 friend class XrdSiteStatistics;
99 
100 public:
101  ~XrdReadStatistics() {m_parent->finishRead(*this);}
102  XrdReadStatistics(const XrdReadStatistics&) = delete;
103  XrdReadStatistics &operator=(const XrdReadStatistics&) = delete;
104 
105 private:
106  XrdReadStatistics(std::shared_ptr<XrdSiteStatistics> parent, IOSize size, size_t count);
107 
108  float elapsedNS() const;
109  int readCount() const {return m_count;}
110  int size() const {return m_size;}
111 
112  size_t m_size;
115  std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
116 };
117 
118 }
119 
120 #endif
size
Write out results.
std::string const & site() const
Definition: XrdStatistics.h:74
std::atomic< unsigned > m_readCount
Definition: XrdStatistics.h:91
static boost::mutex mutex
Definition: LHEProxy.cc:11
std::vector< edm::propagate_const< std::shared_ptr< XrdSiteStatistics > > > m_sites
Definition: XrdStatistics.h:62
static std::atomic< XrdSiteStatisticsInformation * > m_instance
Definition: XrdStatistics.h:60
std::atomic< uint64_t > m_readvSize
Definition: XrdStatistics.h:89
std::atomic< unsigned > m_readvCount
Definition: XrdStatistics.h:87
edm::propagate_const< std::shared_ptr< XrdSiteStatistics > > m_parent
std::atomic< uint64_t > m_readvNS
Definition: XrdStatistics.h:90
std::atomic< uint64_t > m_readNS
Definition: XrdStatistics.h:93
std::chrono::time_point< std::chrono::high_resolution_clock > m_start
HLT enums.
std::atomic< uint64_t > m_readSize
Definition: XrdStatistics.h:92
size_t IOSize
Definition: IOTypes.h:14
std::atomic< unsigned > m_chunkCount
Definition: XrdStatistics.h:88