test
CMS 3D CMS Logo

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