xrootd
XrdXrootdFileStats.hh
Go to the documentation of this file.
1 #ifndef __XRDXROOTDFILESTATS__
2 #define __XRDXROOTDFILESTATS__
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d F i l e S t a t s . h h */
6 /* */
7 /* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
34 
36 {
37 public:
38 
39 kXR_unt32 FileID; // Unique file id used for monitoring
40 short MonEnt; // Set by mon: entry in reporting table or -1
41 char monLvl; // Set by mon: level of data collection needed
42 char xfrXeq; // Transfer has occurred
43 long long fSize; // Size of file when opened
47 struct {double read; // sum(read_size[i] **2) i = 1 to Ops.read
48  double readv; // sum(readv_size[i]**2) i = 1 to Ops.readv
49  double rsegs; // sum(readv_segs[i]**2) i = 1 to Ops.readv
50  double write; // sum(write_size[i]**2) i = 1 to Ops.write
51  } ssq;
52 
53 enum monLevel {monOff = 0, monOn = 1, monOps = 2, monSsq = 3};
54 
55  void Init()
56  {FileID = 0; MonEnt = -1; monLvl = xfrXeq = 0;
57  memset(&xfr, 0, sizeof(xfr));
58  memset(&ops, 0, sizeof(ops));
59  memset(&prw, 0, sizeof(prw));
60  ops.rsMin = 0x7fff;
61  ops.rdMin = ops.rvMin = ops.wrMin = 0x7fffffff;
62  ssq.read = ssq.readv = ssq.write = ssq.rsegs = 0.0;
63  };
64 
65 inline void pgrOps(int rsz, bool isRetry=false)
66  {if (monLvl)
67  {prw.rBytes += rsz;
68  prw.rCount++;
69  if(isRetry) prw.rRetry++;
70  }
71  }
72 
73 inline void pgwOps(int wsz, bool isRetry=false)
74  {if (monLvl)
75  {prw.wBytes += wsz;
76  prw.wCount++;
77  if(isRetry) prw.wRetry++;
78  }
79  }
80 
81 inline void pgUpdt(int wErrs, int wFixd, int wUnc)
82  {if (monLvl)
83  {prw.wcsErr = wErrs;
84  prw.wRetry = wFixd;
85  prw.wcsUnc = wUnc;
86  }
87  }
88 
89 inline void rdOps(int rsz)
90  {if (monLvl)
91  {xfr.read += rsz; ops.read++; xfrXeq = 1;
92  if (monLvl > 1)
93  {if (rsz < ops.rdMin) ops.rdMin = rsz;
94  if (rsz > ops.rdMax) ops.rdMax = rsz;
95  if (monLvl > 2)
96  ssq.read += static_cast<double>(rsz)
97  * static_cast<double>(rsz);
98  }
99  }
100  }
101 
102 inline void rvOps(int rsz, int ssz)
103  {if (monLvl)
104  {xfr.readv += rsz; ops.readv++; ops.rsegs += ssz; xfrXeq=1;
105  if (monLvl > 1)
106  {if (rsz < ops.rvMin) ops.rvMin = rsz;
107  if (rsz > ops.rvMax) ops.rvMax = rsz;
108  if (ssz < ops.rsMin) ops.rsMin = ssz;
109  if (ssz > ops.rsMax) ops.rsMax = ssz;
110  if (monLvl > 2)
111  {ssq.readv += static_cast<double>(rsz)
112  * static_cast<double>(rsz);
113  ssq.rsegs += static_cast<double>(ssz)
114  * static_cast<double>(ssz);
115  }
116  }
117  }
118  }
119 
120 inline void wrOps(int wsz)
121  {if (monLvl)
122  {xfr.write += wsz; ops.write++; xfrXeq = 1;
123  if (monLvl > 1)
124  {if (wsz < ops.wrMin) ops.wrMin = wsz;
125  if (wsz > ops.wrMax) ops.wrMax = wsz;
126  if (monLvl > 2)
127  ssq.write += static_cast<double>(wsz)
128  * static_cast<double>(wsz);
129  }
130  }
131  }
132 
133 inline void wvOps(int wsz, int ssz) {wrOps(wsz);}
134 /* !!! When we start reporting detail of writev's we will uncomment this
135  !!! For now writev's are treated as single write, not correct but at least
136  !!! the data gets counted.
137  {if (monLvl)
138  {xfr.writev += wsz; ops.writev++; ops.wsegs += ssz; xfrXeq=1;
139  if (monLvl > 1)
140  {if (wsz < ops.wvMin) ops.wvMin = wsz;
141  if (wsz > ops.wvMax) ops.wvMax = wsz;
142  if (ssz < ops.wsMin) ops.wsMin = ssz;
143  if (ssz > ops.wsMax) ops.wsMax = ssz;
144  if (monLvl > 2)
145  {ssq.writev+= static_cast<double>(wsz)
146  * static_cast<double>(wsz);
147  ssq.wsegs += static_cast<double>(ssz)
148  * static_cast<double>(ssz);
149  }
150  }
151  }
152  }
153 */
156 };
157 #endif
XrdXrootdFileStats::pgUpdt
void pgUpdt(int wErrs, int wFixd, int wUnc)
Definition: XrdXrootdFileStats.hh:81
XrdXrootdFileStats::fSize
long long fSize
Definition: XrdXrootdFileStats.hh:43
XrdXrootdMonStatPRW::rCount
int rCount
Definition: XrdXrootdMonData.hh:236
XrdXrootdFileStats::rsegs
double rsegs
Definition: XrdXrootdFileStats.hh:49
XrdXrootdFileStats::MonEnt
short MonEnt
Definition: XrdXrootdFileStats.hh:40
XrdXrootdFileStats::prw
XrdXrootdMonStatPRW prw
Definition: XrdXrootdFileStats.hh:46
XrdXrootdMonStatOPS::write
int write
Definition: XrdXrootdMonData.hh:249
XrdXrootdMonStatOPS::rvMin
int rvMin
Definition: XrdXrootdMonData.hh:255
XrdXrootdFileStats::FileID
kXR_unt32 FileID
Definition: XrdXrootdFileStats.hh:39
XrdXrootdFileStats::write
double write
Definition: XrdXrootdFileStats.hh:50
XrdXrootdFileStats::monSsq
@ monSsq
Definition: XrdXrootdFileStats.hh:53
XrdXrootdMonStatOPS::rdMin
int rdMin
Definition: XrdXrootdMonData.hh:253
XrdXrootdMonStatXFR::write
long long write
Definition: XrdXrootdMonData.hh:281
XrdXrootdMonStatXFR
Definition: XrdXrootdMonData.hh:278
XrdXrootdFileStats::readv
double readv
Definition: XrdXrootdFileStats.hh:48
XrdXrootdMonStatPRW::wcsErr
int wcsErr
Definition: XrdXrootdMonData.hh:241
XrdXrootdFileStats::monOff
@ monOff
Definition: XrdXrootdFileStats.hh:53
kXR_unt32
unsigned int kXR_unt32
Definition: XPtypes.hh:90
XrdXrootdMonStatOPS::wrMin
int wrMin
Definition: XrdXrootdMonData.hh:257
XrdXrootdMonStatPRW::wcsUnc
int wcsUnc
Definition: XrdXrootdMonData.hh:242
XrdXrootdFileStats::xfr
XrdXrootdMonStatXFR xfr
Definition: XrdXrootdFileStats.hh:44
XrdXrootdMonStatXFR::read
long long read
Definition: XrdXrootdMonData.hh:279
XrdXrootdFileStats::monOps
@ monOps
Definition: XrdXrootdFileStats.hh:53
XrdXrootdMonStatPRW::rBytes
long long rBytes
Definition: XrdXrootdMonData.hh:235
XrdXrootdMonStatPRW::wBytes
long long wBytes
Definition: XrdXrootdMonData.hh:238
XrdXrootdMonStatXFR::readv
long long readv
Definition: XrdXrootdMonData.hh:280
XrdXrootdMonStatOPS::readv
int readv
Definition: XrdXrootdMonData.hh:248
XrdXrootdMonStatOPS
Definition: XrdXrootdMonData.hh:246
XrdXrootdFileStats::wvOps
void wvOps(int wsz, int ssz)
Definition: XrdXrootdFileStats.hh:133
XrdXrootdFileStats::wrOps
void wrOps(int wsz)
Definition: XrdXrootdFileStats.hh:120
XrdXrootdMonStatPRW
Definition: XrdXrootdMonData.hh:234
XrdXrootdMonStatOPS::read
int read
Definition: XrdXrootdMonData.hh:247
XrdXrootdFileStats::read
double read
Definition: XrdXrootdFileStats.hh:47
XrdXrootdMonStatOPS::rsMax
short rsMax
Definition: XrdXrootdMonData.hh:251
XrdXrootdMonStatOPS::rdMax
int rdMax
Definition: XrdXrootdMonData.hh:254
XrdXrootdFileStats::ops
XrdXrootdMonStatOPS ops
Definition: XrdXrootdFileStats.hh:45
XrdXrootdFileStats::rvOps
void rvOps(int rsz, int ssz)
Definition: XrdXrootdFileStats.hh:102
XrdXrootdFileStats::rdOps
void rdOps(int rsz)
Definition: XrdXrootdFileStats.hh:89
XrdXrootdMonStatOPS::rsMin
short rsMin
Definition: XrdXrootdMonData.hh:250
XrdXrootdMonStatPRW::wCount
int wCount
Definition: XrdXrootdMonData.hh:239
XrdXrootdFileStats::monLvl
char monLvl
Definition: XrdXrootdFileStats.hh:41
XrdXrootdFileStats
Definition: XrdXrootdFileStats.hh:36
XrdXrootdFileStats::~XrdXrootdFileStats
~XrdXrootdFileStats()
Definition: XrdXrootdFileStats.hh:155
XrdXrootdMonStatOPS::rvMax
int rvMax
Definition: XrdXrootdMonData.hh:256
XrdXrootdMonStatPRW::wRetry
int wRetry
Definition: XrdXrootdMonData.hh:240
XrdXrootdMonStatOPS::rsegs
long long rsegs
Definition: XrdXrootdMonData.hh:252
XrdXrootdFileStats::XrdXrootdFileStats
XrdXrootdFileStats()
Definition: XrdXrootdFileStats.hh:154
XrdXrootdMonStatOPS::wrMax
int wrMax
Definition: XrdXrootdMonData.hh:258
XrdXrootdFileStats::ssq
struct XrdXrootdFileStats::@152 ssq
XrdXrootdFileStats::pgrOps
void pgrOps(int rsz, bool isRetry=false)
Definition: XrdXrootdFileStats.hh:65
XrdXrootdMonData.hh
XrdXrootdMonStatPRW::rRetry
int rRetry
Definition: XrdXrootdMonData.hh:237
XrdXrootdFileStats::pgwOps
void pgwOps(int wsz, bool isRetry=false)
Definition: XrdXrootdFileStats.hh:73
XrdXrootdFileStats::Init
void Init()
Definition: XrdXrootdFileStats.hh:55
XrdXrootdFileStats::xfrXeq
char xfrXeq
Definition: XrdXrootdFileStats.hh:42
XrdXrootdFileStats::monOn
@ monOn
Definition: XrdXrootdFileStats.hh:53
XrdXrootdFileStats::monLevel
monLevel
Definition: XrdXrootdFileStats.hh:53