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
unsigned int kXR_unt32
Definition: XPtypes.hh:90
ssize_t readv(int fildes, const struct iovec *iov, int iovcnt)
ssize_t write(int fildes, const void *buf, size_t nbyte)
ssize_t read(int fildes, void *buf, size_t nbyte)
void rvOps(int rsz, int ssz)
struct XrdXrootdFileStats::@167 ssq
XrdXrootdMonStatPRW prw
void pgrOps(int rsz, bool isRetry=false)
void pgwOps(int wsz, bool isRetry=false)
void wvOps(int wsz, int ssz)
void pgUpdt(int wErrs, int wFixd, int wUnc)
XrdXrootdMonStatXFR xfr
XrdXrootdMonStatOPS ops