00001 #ifndef __XRDXROOTDFILESTATS__ 00002 #define __XRDXROOTDFILESTATS__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d X r o o t d F i l e S t a t s . h h */ 00006 /* */ 00007 /* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include "XrdXrootd/XrdXrootdMonData.hh" 00034 00035 class XrdXrootdFileStats 00036 { 00037 public: 00038 00039 kXR_unt32 FileID; // Unique file id used for monitoring 00040 short MonEnt; // Set by mon: entry in reporting table or -1 00041 char monLvl; // Set by mon: level of data collection needed 00042 char xfrXeq; // Transfer has occurred 00043 long long fSize; // Size of file when opened 00044 XrdXrootdMonStatXFR xfr; 00045 XrdXrootdMonStatOPS ops; 00046 struct {double read; // sum(read_size[i] **2) i = 1 to Ops.read 00047 double readv; // sum(readv_size[i]**2) i = 1 to Ops.readv 00048 double rsegs; // sum(readv_segs[i]**2) i = 1 to Ops.readv 00049 double write; // sum(write_size[i]**2) i = 1 to Ops.write 00050 } ssq; 00051 00052 enum monLevel {monOff = 0, monOn = 1, monOps = 2, monSsq = 3}; 00053 00054 void Init() 00055 {FileID = 0; MonEnt = -1; monLvl = xfrXeq = 0; 00056 memset(&xfr, 0, sizeof(xfr)); 00057 memset(&ops, 0, sizeof(ops)); 00058 ops.rsMin = 0x7fff; 00059 ops.rdMin = ops.rvMin = ops.wrMin = 0x7fffffff; 00060 ssq.read = ssq.readv = ssq.write = ssq.rsegs = 0.0; 00061 }; 00062 00063 inline void rdOps(int rsz) 00064 {if (monLvl) 00065 {xfr.read += rsz; ops.read++; xfrXeq = 1; 00066 if (monLvl > 1) 00067 {if (rsz < ops.rdMin) ops.rdMin = rsz; 00068 if (rsz > ops.rdMax) ops.rdMax = rsz; 00069 if (monLvl > 2) 00070 ssq.read += static_cast<double>(rsz) 00071 * static_cast<double>(rsz); 00072 } 00073 } 00074 } 00075 00076 inline void rvOps(int rsz, int ssz) 00077 {if (monLvl) 00078 {xfr.readv += rsz; ops.readv++; ops.rsegs += ssz; xfrXeq=1; 00079 if (monLvl > 1) 00080 {if (rsz < ops.rvMin) ops.rvMin = rsz; 00081 if (rsz > ops.rvMax) ops.rvMax = rsz; 00082 if (ssz < ops.rsMin) ops.rsMin = ssz; 00083 if (ssz > ops.rsMax) ops.rsMax = ssz; 00084 if (monLvl > 2) 00085 {ssq.readv += static_cast<double>(rsz) 00086 * static_cast<double>(rsz); 00087 ssq.rsegs += static_cast<double>(ssz) 00088 * static_cast<double>(ssz); 00089 } 00090 } 00091 } 00092 } 00093 00094 inline void wrOps(int wsz) 00095 {if (monLvl) 00096 {xfr.write += wsz; ops.write++; xfrXeq = 1; 00097 if (monLvl > 1) 00098 {if (wsz < ops.wrMin) ops.wrMin = wsz; 00099 if (wsz > ops.wrMax) ops.wrMax = wsz; 00100 if (monLvl > 2) 00101 ssq.write += static_cast<double>(wsz) 00102 * static_cast<double>(wsz); 00103 } 00104 } 00105 } 00106 00107 inline void wvOps(int wsz, int ssz) {} 00108 /* When we start reporting detail of writev's we will uncomment this 00109 {if (monLvl) 00110 {xfr.writev += wsz; ops.writev++; ops.wsegs += ssz; xfrXeq=1; 00111 if (monLvl > 1) 00112 {if (wsz < ops.wvMin) ops.wvMin = wsz; 00113 if (wsz > ops.wvMax) ops.wvMax = wsz; 00114 if (ssz < ops.wsMin) ops.wsMin = ssz; 00115 if (ssz > ops.wsMax) ops.wsMax = ssz; 00116 if (monLvl > 2) 00117 {ssq.writev+= static_cast<double>(wsz) 00118 * static_cast<double>(wsz); 00119 ssq.wsegs += static_cast<double>(ssz) 00120 * static_cast<double>(ssz); 00121 } 00122 } 00123 } 00124 } 00125 */ 00126 XrdXrootdFileStats() {Init();} 00127 ~XrdXrootdFileStats() {} 00128 }; 00129 #endif