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
22#include "XrdOuc/XrdOucCache.hh"
24
25namespace XrdPfc
26{
27//----------------------------------------------------------------------------
29//----------------------------------------------------------------------------
30class Stats
31{
32public:
35 long long m_BytesHit;
36 long long m_BytesMissed;
37 long long m_BytesBypassed;
38 long long m_BytesWritten;
40
41 //----------------------------------------------------------------------
42
48
54
55 Stats& operator=(const Stats&) = default;
56
57 //----------------------------------------------------------------------
58
67
68 void AddBytesHit(long long bh)
69 {
71
72 m_BytesHit += bh;
73 }
74
75 void AddWriteStats(long long bytes_written, int n_cks_errs)
76 {
78
79 m_BytesWritten += bytes_written;
80 m_NCksumErrors += n_cks_errs;
81 }
82
83 void IoAttach()
84 {
86
87 ++m_NumIos;
88 }
89
90 void IoDetach(int duration)
91 {
93
94 m_Duration += duration;
95 }
96
98 {
100
101 return Stats(*this);
102 }
103
104 //----------------------------------------------------------------------
105
106 void DeltaToReference(const Stats& ref)
107 {
108 // Not locked, only used from Cache / Purge thread.
109 m_NumIos = ref.m_NumIos - m_NumIos;
116 }
117
118 void AddUp(const Stats& s)
119 {
120 // Not locked, only used from Cache / Purge thread.
121 m_NumIos += s.m_NumIos;
128 }
129
130 void Reset()
131 {
132 // Not locked, only used from Cache / Purge thread.
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_NCksumErrors = 0;
140 }
141
142private:
144};
145}
146
147#endif
148
Statistics of cache utilisation by a File object.
Definition XrdPfcStats.hh:31
void IoAttach()
Definition XrdPfcStats.hh:83
Stats Clone()
Definition XrdPfcStats.hh:97
long long m_BytesMissed
number of bytes served from remote and cached
Definition XrdPfcStats.hh:36
void AddReadStats(const Stats &s)
Definition XrdPfcStats.hh:59
long long m_BytesBypassed
number of bytes served directly through XrdCl
Definition XrdPfcStats.hh:37
void Reset()
Definition XrdPfcStats.hh:130
void AddUp(const Stats &s)
Definition XrdPfcStats.hh:118
Stats(const Stats &s)
Definition XrdPfcStats.hh:49
void AddWriteStats(long long bytes_written, int n_cks_errs)
Definition XrdPfcStats.hh:75
int m_NCksumErrors
number of checksum errors while getting data from remote
Definition XrdPfcStats.hh:39
Stats()
Definition XrdPfcStats.hh:43
Stats & operator=(const Stats &)=default
int m_Duration
total duration of all IOs attached
Definition XrdPfcStats.hh:34
void AddBytesHit(long long bh)
Definition XrdPfcStats.hh:68
XrdSysMutex m_Mutex
Definition XrdPfcStats.hh:143
int m_NumIos
number of IO objects attached during this access
Definition XrdPfcStats.hh:33
long long m_BytesHit
number of bytes served from disk
Definition XrdPfcStats.hh:35
long long m_BytesWritten
number of bytes written to disk
Definition XrdPfcStats.hh:38
void IoDetach(int duration)
Definition XrdPfcStats.hh:90
void DeltaToReference(const Stats &ref)
Definition XrdPfcStats.hh:106
Definition XrdSysPthread.hh:263
Definition XrdSysPthread.hh:165
Definition XrdPfc.hh:41