XRootD
Loading...
Searching...
No Matches
XrdPfcStats.hh
Go to the documentation of this file.
1#ifndef __XRDPFC_STATS_HH__
2#define __XRDPFC_STATS_HH__
3
4//----------------------------------------------------------------------------------
5// Copyright (c) 2014 by Board of Trustees of the Leland Stanford, Jr., University
6// Author: Alja Mrak-Tadel, Matevz Tadel, Brian Bockelman
7//----------------------------------------------------------------------------------
8// XRootD is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Lesser General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12//
13// XRootD is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public License
19// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
20//----------------------------------------------------------------------------------
21
22namespace XrdPfc
23{
24
25//----------------------------------------------------------------------------
27// Used both as aggregation of usage by a single file as well as for
28// collecting per-directory statistics on time-interval basis. In this second
29// case they are used as "deltas" ... differences in respect to a previous
30// reference value.
31// For running averages / deltas, one might need a version with doubles, so
32// it might make sense to template this. And add some timestamp.
33//----------------------------------------------------------------------------
34class Stats
35{
36public:
37 int m_NumIos = 0;
38 int m_Duration = 0;
39 long long m_BytesHit = 0;
40 long long m_BytesMissed = 0;
41 long long m_BytesBypassed = 0;
42 long long m_BytesWritten = 0;
43 long long m_StBlocksAdded = 0;
45
46 //----------------------------------------------------------------------
47
48 Stats() = default;
49
50 Stats(const Stats& s) = default;
51
52 Stats& operator=(const Stats&) = default;
53
64
65 //----------------------------------------------------------------------
66
73
74 void AddBytesHit(long long bh)
75 {
76 m_BytesHit += bh;
77 }
78
79 void AddWriteStats(long long bytes_written, int n_cks_errs)
80 {
81 m_BytesWritten += bytes_written;
82 m_NCksumErrors += n_cks_errs;
83 }
84
85 void IoAttach()
86 {
87 ++m_NumIos;
88 }
89
90 void IoDetach(int duration)
91 {
92 m_Duration += duration;
93 }
94
95 //----------------------------------------------------------------------
96
97 long long BytesRead() const
98 {
100 }
101
102 long long BytesReadAndWritten() const
103 {
104 return BytesRead() + m_BytesWritten;
105 }
106
118
130
131 void Reset()
132 {
133 m_NumIos = 0;
134 m_Duration = 0;
135 m_BytesHit = 0;
136 m_BytesMissed = 0;
137 m_BytesBypassed = 0;
138 m_BytesWritten = 0;
139 m_StBlocksAdded = 0;
140 m_NCksumErrors = 0;
141 }
142};
143
144//==============================================================================
145
146class DirStats : public Stats
147{
148public:
149 long long m_StBlocksRemoved = 0; // number of 512-byte blocks removed from the directory
153 int m_NFilesRemoved = 0; // purged or otherwise (error, direct requests)
156
157 //----------------------------------------------------------------------
158
159 DirStats() = default;
160
161 DirStats(const DirStats& s) = default;
162
163 DirStats& operator=(const DirStats&) = default;
164
175
176 //----------------------------------------------------------------------
177
178 using Stats::DeltaToReference; // activate overload based on arg
190
191 using Stats::AddUp; // activate overload based on arg
203
204 using Stats::Reset; // activate overload based on arg
205 void Reset()
206 {
207 Stats::Reset();
209 m_NFilesOpened = 0;
210 m_NFilesClosed = 0;
211 m_NFilesCreated = 0;
212 m_NFilesRemoved = 0;
215 }
216};
217
218}
219
220#endif
DirStats(const DirStats &s)=default
DirStats & operator=(const DirStats &)=default
void DeltaToReference(const DirStats &ref)
void AddUp(const DirStats &s)
DirStats(const DirStats &a, const DirStats &b)
DirStats()=default
long long m_StBlocksRemoved
long long m_BytesMissed
number of bytes served from remote and cached
void AddReadStats(const Stats &s)
long long m_StBlocksAdded
number of 512-byte blocks the file has grown by
long long m_BytesBypassed
number of bytes served directly through XrdCl
void AddUp(const Stats &s)
void AddWriteStats(long long bytes_written, int n_cks_errs)
int m_NCksumErrors
number of checksum errors while getting data from remote
long long BytesReadAndWritten() const
Stats & operator=(const Stats &)=default
Stats()=default
int m_Duration
total duration of all IOs attached
void AddBytesHit(long long bh)
long long BytesRead() const
int m_NumIos
number of IO objects attached during this access
long long m_BytesHit
number of bytes served from disk
long long m_BytesWritten
number of bytes written to disk
void IoDetach(int duration)
void DeltaToReference(const Stats &ref)
Stats(const Stats &s)=default
Stats(const Stats &a, const Stats &b)