XRootD
Loading...
Searching...
No Matches
XrdXrootdMonFile Class Reference

#include <XrdXrootdMonFile.hh>

+ Inheritance diagram for XrdXrootdMonFile:
+ Collaboration diagram for XrdXrootdMonFile:

Public Member Functions

 XrdXrootdMonFile ()
 
 ~XrdXrootdMonFile ()
 
void DoIt ()
 

Static Public Member Functions

static void Close (XrdXrootdFileStats *fsP, bool isDisc=false)
 
static void Defaults (int intv, int opts, int iocnt, int fbsz)
 
static void Disc (unsigned int usrID)
 
static bool Init ()
 
static void Open (XrdXrootdFileStats *fsP, const char *Path, unsigned int uDID, bool isRW)
 

Detailed Description

Definition at line 42 of file XrdXrootdMonFile.hh.

Constructor & Destructor Documentation

◆ XrdXrootdMonFile()

XrdXrootdMonFile::XrdXrootdMonFile ( )
inline

Definition at line 59 of file XrdXrootdMonFile.hh.

59: XrdJob("monitor fstat") {}
XrdJob(const char *desc="")
Definition XrdJob.hh:51

Referenced by Init().

+ Here is the caller graph for this function:

◆ ~XrdXrootdMonFile()

XrdXrootdMonFile::~XrdXrootdMonFile ( )
inline

Definition at line 60 of file XrdXrootdMonFile.hh.

60{}

Member Function Documentation

◆ Close()

void XrdXrootdMonFile::Close ( XrdXrootdFileStats * fsP,
bool isDisc = false )
static

Definition at line 90 of file XrdXrootdMonFile.cc.

91{
93 char *cP;
94 int iEnt, iMap, iSlot;
95
96// If this object was registered for I/O reporting, deregister it.
97//
98 if (fsP->MonEnt != -1)
99 {iEnt = fsP->MonEnt & 0xffff;
100 iMap = iEnt >> XrdXrootdMonFMap::fmShft;
101 iSlot = iEnt & XrdXrootdMonFMap::fmMask;
102 fsP->MonEnt = -1;
103 fmMutex.Lock();
104 if (fmMap[iMap].Free(iSlot)) fmUse[iMap]--;
105 if (iMap == fmHWM) while(fmHWM >= 0 && !fmUse[fmHWM]) fmHWM--;
106 fmMutex.UnLock();
107 }
108
109// Insert a close record header (mostly precomputed)
110//
112 cRec.Hdr.recFlag = crecFlag;
113 if (isDisc) cRec.Hdr.recFlag |= XrdXrootdMonFileHdr::forced;
114 cRec.Hdr.recSize = crecNLen;
115 cRec.Hdr.fileID = fsP->FileID;
116
117// Insert the I/O bytes
118//
119 cRec.Xfr.read = htonll(fsP->xfr.read);
120 cRec.Xfr.readv = htonll(fsP->xfr.readv);
121 cRec.Xfr.write = htonll(fsP->xfr.write);
122
123// Insert ops if so wanted
124//
125 if (fsOPS)
126 {cRec.Ops.read = htonl (fsP->ops.read);
127 if (fsP->ops.read)
128 {cRec.Ops.rdMin = htonl (fsP->ops.rdMin);
129 cRec.Ops.rdMax = htonl (fsP->ops.rdMax);
130 } else {
131 cRec.Ops.rdMin = cRec.Ops.rdMax = 0;
132 }
133 cRec.Ops.readv = htonl (fsP->ops.readv);
134 cRec.Ops.rsegs = htonll(fsP->ops.rsegs);
135 if (fsP->ops.readv)
136 {cRec.Ops.rsMin = htons (fsP->ops.rsMin);
137 cRec.Ops.rsMax = htons (fsP->ops.rsMax);
138 cRec.Ops.rvMin = htonl (fsP->ops.rvMin);
139 cRec.Ops.rvMax = htonl (fsP->ops.rvMax);
140 } else {
141 cRec.Ops.rsMin = cRec.Ops.rsMax = 0;
142 cRec.Ops.rvMin = cRec.Ops.rvMax = 0;
143 }
144 cRec.Ops.write = htonl (fsP->ops.write);
145 if (fsP->ops.write)
146 {cRec.Ops.wrMin = htonl (fsP->ops.wrMin);
147 cRec.Ops.wrMax = htonl (fsP->ops.wrMax);
148 } else {
149 cRec.Ops.wrMin = cRec.Ops.wrMax = 0;
150 }
151 }
152
153// Record sum of squares if so needed
154//
155 if (fsSSQ)
156 {XrdXrootdMonDouble xval;
157 xval.dreal = fsP->ssq.read;
158 cRec.Ssq.read.dlong = htonll(xval.dlong);
159 xval.dreal = fsP->ssq.readv;
160 cRec.Ssq.readv.dlong = htonll(xval.dlong);
161 xval.dreal = fsP->ssq.rsegs;
162 cRec.Ssq.rsegs.dlong = htonll(xval.dlong);
163 xval.dreal = fsP->ssq.write;
164 cRec.Ssq.write.dlong = htonll(xval.dlong);
165 }
166
167// Get a pointer to the next slot (the buffer gets locked)
168//
169 cP = GetSlot(crecSize);
170 memcpy(cP, &cRec, crecSize);
171 bfMutex.UnLock();
172}
XrdXrootdMonDouble write
XrdXrootdMonDouble read
XrdXrootdMonDouble readv
XrdXrootdMonStatXFR Xfr
XrdXrootdMonStatOPS Ops
XrdXrootdMonDouble rsegs
XrdXrootdMonStatSSQ Ssq
XrdXrootdMonFileHdr Hdr
struct XrdXrootdFileStats::@168 ssq
XrdXrootdMonStatXFR xfr
XrdXrootdMonStatOPS ops
static const int fmShft
static const int fmMask

References XrdXrootdMonDouble::dlong, XrdXrootdMonDouble::dreal, XrdXrootdFileStats::FileID, XrdXrootdMonFMap::fmMask, XrdXrootdMonFMap::fmShft, XrdXrootdMonFileHdr::forced, XrdXrootdMonFileCLS::Hdr, XrdXrootdMonFileHdr::isClose, XrdSysMutex::Lock(), XrdXrootdFileStats::MonEnt, XrdXrootdMonFileCLS::Ops, XrdXrootdFileStats::ops, XrdXrootdMonStatOPS::rdMax, XrdXrootdMonStatOPS::rdMin, XrdXrootdMonStatOPS::read, XrdXrootdMonStatSSQ::read, XrdXrootdMonStatXFR::read, XrdXrootdMonStatOPS::readv, XrdXrootdMonStatSSQ::readv, XrdXrootdMonStatXFR::readv, XrdXrootdMonFileHdr::recFlag, XrdXrootdMonFileHdr::recSize, XrdXrootdMonFileHdr::recType, XrdXrootdMonStatOPS::rsegs, XrdXrootdMonStatSSQ::rsegs, XrdXrootdMonStatOPS::rsMax, XrdXrootdMonStatOPS::rsMin, XrdXrootdMonStatOPS::rvMax, XrdXrootdMonStatOPS::rvMin, XrdXrootdMonFileCLS::Ssq, XrdXrootdFileStats::ssq, XrdSysMutex::UnLock(), XrdXrootdMonStatOPS::write, XrdXrootdMonStatSSQ::write, XrdXrootdMonStatXFR::write, XrdXrootdMonStatOPS::wrMax, XrdXrootdMonStatOPS::wrMin, XrdXrootdMonFileCLS::Xfr, and XrdXrootdFileStats::xfr.

Referenced by XrdXrootdFileTable::Del(), and XrdXrootdFileTable::Recycle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Defaults()

void XrdXrootdMonFile::Defaults ( int intv,
int opts,
int iocnt,
int fbsz )
static

Definition at line 178 of file XrdXrootdMonFile.cc.

179{
180
181// Set the reporting interval and I/O counter
182//
183 repTime = intv;
184 xfrCnt = xfrcnt;
185 xfrRem = xfrcnt;
186 fBsz = (fbsz <= 0 ? 65472 : fbsz);
187
188// Expand out the options
189//
190 fsXFR = (opts & XROOTD_MON_FSXFR) != 0;
191 fsLFN = (opts & XROOTD_MON_FSLFN) != 0;
192 fsOPS = (opts & (XROOTD_MON_FSOPS | XROOTD_MON_FSSSQ)) != 0;
193 fsSSQ = (opts & XROOTD_MON_FSSSQ) != 0;
194
195// Set monitoring level
196//
197 if (fsSSQ) fsLVL = XrdXrootdFileStats::monSsq;
198 else if (fsOPS) fsLVL = XrdXrootdFileStats::monOps;
199 else if (intv) fsLVL = XrdXrootdFileStats::monOn;
200 else fsLVL = XrdXrootdFileStats::monOff;
201}
struct myOpts opts
#define XROOTD_MON_FSSSQ
#define XROOTD_MON_FSLFN
#define XROOTD_MON_FSOPS
#define XROOTD_MON_FSXFR

References XrdXrootdFileStats::monOff, XrdXrootdFileStats::monOn, XrdXrootdFileStats::monOps, XrdXrootdFileStats::monSsq, opts, XROOTD_MON_FSLFN, XROOTD_MON_FSOPS, XROOTD_MON_FSSSQ, and XROOTD_MON_FSXFR.

Referenced by XrdXrootdMonitor::Defaults().

+ Here is the caller graph for this function:

◆ Disc()

void XrdXrootdMonFile::Disc ( unsigned int usrID)
static

Definition at line 207 of file XrdXrootdMonFile.cc.

208{
209 static short drecSize = htons(sizeof(XrdXrootdMonFileDSC));
211
212// Get a pointer to the next slot (the buffer gets locked)
213//
214 dP = (XrdXrootdMonFileDSC *)GetSlot(sizeof(XrdXrootdMonFileDSC));
215
216// Fill out the record. It's pretty simple
217//
219 dP->Hdr.recFlag = 0;
220 dP->Hdr.recSize = drecSize;
221 dP->Hdr.userID = usrID;
222 bfMutex.UnLock();
223}
XrdXrootdMonFileHdr Hdr

References XrdXrootdMonFileDSC::Hdr, XrdXrootdMonFileHdr::isDisc, XrdXrootdMonFileHdr::recFlag, XrdXrootdMonFileHdr::recSize, XrdXrootdMonFileHdr::recType, and XrdSysMutex::UnLock().

Referenced by XrdXrootdProtocol::Recycle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoIt()

void XrdXrootdMonFile::DoIt ( )
virtual

Implements XrdJob.

Definition at line 229 of file XrdXrootdMonFile.cc.

230{
231
232// First check if we need to report all the I/O stats
233//
234 xfrRem--;
235 if (!xfrRem) DoXFR();
236
237// Check if we should flush the buffer
238//
239 bfMutex.Lock();
240 if (repNext) Flush();
241 bfMutex.UnLock();
242
243// Reschedule ourselves
244//
245 XrdXrootdMonInfo::Sched->Schedule((XrdJob *)this, time(0)+repTime);
246}
void Schedule(XrdJob *jp)
XrdScheduler * Sched

References XrdSysMutex::Lock(), XrdXrootdMonInfo::Sched, XrdScheduler::Schedule(), and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ Init()

bool XrdXrootdMonFile::Init ( )
static

Definition at line 324 of file XrdXrootdMonFile.cc.

325{
326 XrdXrootdMonFile *mfP;
327 int alignment, pagsz = getpagesize();
328
329// Allocate a socket buffer
330//
331 alignment = (fBsz < pagsz ? 1024 : pagsz);
332 if (posix_memalign((void **)&repBuff, alignment, fBsz))
333 {XrdXrootdMonInfo::eDest->Emsg("MonFile", "Unable to allocate monitor buffer.");
334 return false;
335 }
336
337// Set the header (always present)
338//
339 repHdr = (XrdXrootdMonHeader *)repBuff;
340 repHdr->code = XROOTD_MON_MAPFSTA;
341 repHdr->pseq = 0;
343
344// Set the time record (always present)
345//
346 repTOD = (XrdXrootdMonFileTOD *)(repBuff + sizeof(XrdXrootdMonHeader));
349 repTOD->Hdr.recSize = htons(sizeof(XrdXrootdMonFileTOD));
350 repTOD->sID = static_cast<kXR_int64>(XrdXrootdMonInfo::mySID);
351
352// Establish first real record in the buffer (always fixed)
353//
354 repFirst = repBuff+sizeof(XrdXrootdMonHeader)+sizeof(XrdXrootdMonFileTOD);
355
356// Calculate the end nut the next slot always starts with a null pointer
357//
358 repLast = repBuff+fBsz-1;
359 repNext = 0;
360
361// Calculate the close record size and the initial flags
362//
363 crecSize = sizeof(XrdXrootdMonFileHdr) + sizeof(XrdXrootdMonStatXFR);
364 if (fsSSQ || fsOPS)
365 {crecSize += sizeof(XrdXrootdMonStatOPS);
367 } else crecFlag = 0;
368 if (fsSSQ)
369 {crecSize += sizeof(XrdXrootdMonStatSSQ);
370 crecFlag |= XrdXrootdMonFileHdr::hasSSQ;
371 }
372 crecNLen = htons(static_cast<short>(crecSize));
373
374// Preformat the i/o record
375//
377 xfrRec.Hdr.recFlag = 0;
378 xfrRec.Hdr.recSize = htons(static_cast<short>(sizeof(xfrRec)));
379
380// Calculate the tod record size
381//
382 trecNLen = htons(static_cast<short>(sizeof(XrdXrootdMonFileTOD)));
383
384// Allocate an instance of ourselves so we can schedule ourselves
385//
386 mfP = new XrdXrootdMonFile();
387
388// Schedule an the flushes
389//
390 XrdXrootdMonInfo::Sched->Schedule((XrdJob *)mfP, time(0)+repTime);
391 return true;
392}
long long kXR_int64
Definition XPtypes.hh:98
XrdXrootdMonFileHdr Hdr
const kXR_char XROOTD_MON_MAPFSTA
XrdXrootdMonFileHdr Hdr
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdSysError * eDest

References XrdXrootdMonFile(), XrdXrootdMonHeader::code, XrdXrootdMonInfo::eDest, XrdSysError::Emsg(), XrdXrootdMonFileHdr::hasOPS, XrdXrootdMonFileHdr::hasSID, XrdXrootdMonFileHdr::hasSSQ, XrdXrootdMonFileTOD::Hdr, XrdXrootdMonFileXFR::Hdr, XrdXrootdMonFileHdr::isTime, XrdXrootdMonFileHdr::isXfr, XrdXrootdMonInfo::mySID, XrdXrootdMonHeader::pseq, XrdXrootdMonFileHdr::recFlag, XrdXrootdMonFileHdr::recSize, XrdXrootdMonFileHdr::recType, XrdXrootdMonInfo::Sched, XrdScheduler::Schedule(), XrdXrootdMonFileTOD::sID, XrdXrootdMonInfo::startTime, XrdXrootdMonHeader::stod, and XROOTD_MON_MAPFSTA.

Referenced by XrdXrootdMonitor::Init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Open()

void XrdXrootdMonFile::Open ( XrdXrootdFileStats * fsP,
const char * Path,
unsigned int uDID,
bool isRW )
static

Definition at line 464 of file XrdXrootdMonFile.cc.

466{
467 static const int minRecSz = sizeof(XrdXrootdMonFileOPN)
468 - sizeof(XrdXrootdMonFileLFN);
470 int i = 0, sNum = -1, rLen, pLen = 0;
471
472// Assign the path a dictionary id if not assigned via file monitoring
473//
474 if (fsP->FileID == 0) fsP->FileID = XrdXrootdMonitor::GetDictID();
475
476// Add this open to the map table if we are doing I/O stats.
477//
478 if (fsXFR)
479 {fmMutex.Lock();
480 for (i = 0; i < XrdXrootdMonFMap::mapNum; i++)
481 if (fmUse[i] < XrdXrootdMonFMap::fmSize)
482 {if ((sNum = fmMap[i].Insert(fsP)) >= 0)
483 {fmUse[i]++;
484 if (i > fmHWM) fmHWM = i;
485 break;
486 }
487 }
488 fmMutex.UnLock();
489 }
490
491// Generate the cookie (real or virtual) to find the entry in the map table.
492// Supply the monitoring options for effeciency.
493//
494 fsP->MonEnt = (sNum | (i << XrdXrootdMonFMap::fmShft)) & 0xffff;
495 fsP->monLvl = fsLVL;
496 fsP->xfrXeq = 0;
497
498// Compute the size of this record
499//
500 rLen = minRecSz;
501 if (fsLFN)
502 {pLen = strlen(Path);
503 rLen += sizeof(kXR_unt32) + pLen;
504 i = (rLen + 8) & ~0x00000003;
505 pLen = pLen + (i - rLen);
506 rLen = i;
507 }
508
509// Get a pointer to the next slot (the buffer gets locked)
510//
511 oP = (XrdXrootdMonFileOPN *)GetSlot(rLen);
512
513// Fill out the record
514//
516 oP->Hdr.recFlag = (isRW ? XrdXrootdMonFileHdr::hasRW : 0);
517 oP->Hdr.recSize = htons(static_cast<short>(rLen));
518 oP->Hdr.fileID = fsP->FileID;
519 oP->fsz = htonll(fsP->fSize);
520
521// Append user and path if so wanted (sizes have been verified)
522//
523 if (fsLFN)
525 oP->ufn.user = uDID;
526 strncpy(oP->ufn.lfn, Path, pLen);
527 }
528 bfMutex.UnLock();
529}
unsigned int kXR_unt32
Definition XPtypes.hh:90
XrdOucString Path
XrdXrootdMonFileLFN ufn
XrdXrootdMonFileHdr Hdr
static const int fmSize
static const int mapNum
static kXR_unt32 GetDictID(bool hbo=false)

References XrdXrootdFileStats::FileID, XrdXrootdMonFMap::fmShft, XrdXrootdMonFMap::fmSize, XrdXrootdFileStats::fSize, XrdXrootdMonFileOPN::fsz, XrdXrootdMonitor::GetDictID(), XrdXrootdMonFileHdr::hasLFN, XrdXrootdMonFileHdr::hasRW, XrdXrootdMonFileOPN::Hdr, XrdXrootdMonFileHdr::isOpen, XrdXrootdMonFileLFN::lfn, XrdSysMutex::Lock(), XrdXrootdMonFMap::mapNum, XrdXrootdFileStats::MonEnt, XrdXrootdFileStats::monLvl, Path, XrdXrootdMonFileHdr::recFlag, XrdXrootdMonFileHdr::recSize, XrdXrootdMonFileHdr::recType, XrdXrootdMonFileOPN::ufn, XrdSysMutex::UnLock(), XrdXrootdMonFileLFN::user, and XrdXrootdFileStats::xfrXeq.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: