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

#include <XrdFrmPurge.hh>

+ Collaboration diagram for XrdFrmPurge:

Public Member Functions

 XrdFrmPurge (const char *snp, XrdFrmPurge *spp=0)
 
 ~XrdFrmPurge ()
 

Static Public Member Functions

static void Display ()
 
static int Init (XrdOucTList *sP=0, long long minV=-1, int hVal=-1)
 
static XrdFrmPurgePolicy (const char *sname)
 
static XrdFrmPurgePolicy (const char *sname, long long minV, long long maxV, int hVal, int xVal)
 
static void Purge ()
 

Detailed Description

Definition at line 44 of file XrdFrmPurge.hh.

Constructor & Destructor Documentation

◆ XrdFrmPurge()

XrdFrmPurge::XrdFrmPurge ( const char * snp,
XrdFrmPurge * spp = 0 )

Definition at line 164 of file XrdFrmPurge.cc.

164 : FSTab(1)
165{
166 strncpy(SName, snp, sizeof(SName)-1); SName[sizeof(SName)-1] = '\0';
167 Next = spp;
168 freeSpace = 0;
169 usedSpace =-1;
170 pmaxSpace = 0;
171 totlSpace = 0;
172 contSpace = 0;
173 minFSpace = 0;
174 maxFSpace = 0;
175 Enabled = 0;
176 Stop = 0;
177 SNlen = strlen(SName);
178 memset(DeferQ, 0, sizeof(DeferQ));
179 Clear();
180}

Referenced by Policy().

+ Here is the caller graph for this function:

◆ ~XrdFrmPurge()

XrdFrmPurge::~XrdFrmPurge ( )
inline

Definition at line 59 of file XrdFrmPurge.hh.

59{Clear();}

Member Function Documentation

◆ Display()

void XrdFrmPurge::Display ( )
static

Definition at line 295 of file XrdFrmPurge.cc.

296{
298 XrdFrmPurge *spP = First;
299 XrdOucTList *tP;
300 const char *isExt;
301 char buff[1024], minfsp[32], maxfsp[32];
302
303// Type header
304//
305 Say.Say("=====> ", "Purge configuration:");
306
307// Display what we will scan
308//
309 while(vP)
310 {Say.Say("=====> ", "Scanning ", (vP->Val?"r/w: ":"r/o: "), vP->Name);
311 tP = vP->Dir;
312 while(tP) {Say.Say("=====> ", "Excluded ", tP->text); tP = tP->next;}
313 vP = vP->Next;
314 }
315
316// Display directory hold value
317//
318 if (Config.dirHold < 0) strcpy(buff, "forever");
319 else sprintf(buff, "%d", Config.dirHold);
320 Say.Say("=====> ", "Directory hold: ", buff);
321
322// Run through all of the policies, displaying each one
323//
324 spP = First;
325 while(spP)
326 {if (spP->Enabled)
327 {XrdOucUtils::fmtBytes(spP->minFSpace, minfsp, sizeof(minfsp));
328 XrdOucUtils::fmtBytes(spP->maxFSpace, maxfsp, sizeof(maxfsp));
329 isExt = spP->Ext ? " polprog" : "";
330 sprintf(buff, "policy %s min %s max %s free; hold: %d%s",
331 spP->SName, minfsp, maxfsp, spP->Hold, isExt);
332 } else sprintf(buff, "policy %s nopurge", spP->SName);
333 Say.Say("=====> ", buff);
334 spP = spP->Next;
335 }
336}
XrdOucPup XrdCmsParser::Pup & Say
VPInfo * pathList
XrdOucTList * next
static int fmtBytes(long long val, char *buff, int bsz)
XrdFrmConfig Config

References XrdFrm::Config, XrdFrmConfig::VPInfo::Dir, XrdFrmConfig::dirHold, XrdOucUtils::fmtBytes(), XrdFrmConfig::VPInfo::Name, XrdFrmConfig::VPInfo::Next, XrdOucTList::next, XrdFrmConfig::pathList, Say, XrdOucTList::text, and XrdFrmConfig::VPInfo::Val.

Referenced by main().

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

◆ Init()

int XrdFrmPurge::Init ( XrdOucTList * sP = 0,
long long minV = -1,
int hVal = -1 )
static

Definition at line 409 of file XrdFrmPurge.cc.

410{
411 static char pVec[] = {char(XrdFrmConfig::PP_sname),
416 };
417
419 XrdFrmPurge *xP, *ppP = 0, *spP = First;
420 XrdOucTList *tP;
421 char xBuff[32];
422 int setIt, rc, haveExt = 0;
423
424// The first step is to remove any defined policies for which there is no space
425//
426 while(spP)
427 {vP = Config.VPList;
428 while(vP && strcmp(spP->SName, vP->Name)) vP = vP->Next;
429 if (!vP && strcmp("public", spP->SName))
430 {Say.Emsg("Init", "Purge policy", spP->SName,
431 "deleted; space not defined.");
432 if (ppP) ppP->Next = spP->Next;
433 else First = spP->Next;
434 xP = spP; spP = spP->Next; delete xP;
435 } else {ppP = spP; spP = spP->Next;}
436 }
437
438// For each space enable it and optionally over-ride policy
439//
440 spP = First;
441 while(spP)
442 {setIt = 1;
443 if ((tP = sP))
444 {while(tP && strcmp(tP->text, spP->SName)) tP = tP->next;
445 if (!tP) setIt = 0;
446 }
447 if (setIt)
448 {if (minV) spP->minFSpace = spP->maxFSpace = minV;
449 if (hVal >= 0) {spP->Hold = hVal; spP->Hold2x = hVal*2;}
450 if (spP->minFSpace && spP->Hold >= 0)
451 {spP->Enabled = 1; haveExt |= spP->Ext;}
452 }
453 spP = spP->Next;
454 }
455
456// Go through each space policy getting the actual space and calculating
457// the targets based on the policy (we need to do this only once)
458//
459 spP = First; ppP = 0;
460 while(spP)
461 {XrdOssVSInfo vsInfo;
462 if ((rc = Config.ossFS->StatVS(&vsInfo, spP->SName, 1)))
463 {Say.Emsg("Init", rc, "calculate space for", spP->SName);
464 if (ppP) ppP->Next = spP->Next;
465 else First = spP->Next;
466 xP = spP; spP = spP->Next; delete xP; continue;
467 }
468 spP->totlSpace = vsInfo.Total;
469 spP->spaceTLen = sprintf(xBuff, "%lld", vsInfo.Total);
470 spP->spaceTotl = strdup(xBuff);
471 spP->pmaxSpace = vsInfo.Large;
472 spP->spaceTLep = sprintf(xBuff, "%lld", vsInfo.Large);
473 spP->spaceTotP = strdup(xBuff);
474 if (spP->minFSpace < 0)
475 {spP->minFSpace = vsInfo.Total * XRDABS(spP->minFSpace) / 100LL;
476 spP->maxFSpace = vsInfo.Total * XRDABS(spP->maxFSpace) / 100LL;
477 } else if (vsInfo.Total < spP->minFSpace
478 || vsInfo.Total < spP->maxFSpace)
479 Say.Emsg("Init", "Warning: ", spP->SName, " min/max free "
480 "space policy exceeds total available!");
481 ppP = spP; spP = spP->Next;
482 }
483
484// Make sure "public" still exists. While this should not happen, we check for
485// this possibility anyway.
486//
487 if (!(Default = Find("public")))
488 {Say.Emsg("Init", "Unable to start purge; no public policy found.");
489 return 0;
490 }
491
492// If a policy program is present, then we need to verify it
493//
494 if (Config.pProg && haveExt)
495 {PolProg = new XrdOucProg(&Say);
496 if (PolProg->Setup(Config.pProg) || PolProg->Start()) return 0;
497 PolStream = PolProg->getStream();
498 if (!Config.pVecNum)
499 {memcpy(Config.pVec, pVec, sizeof(pVec));
500 Config.pVecNum = sizeof(pVec);
501 }
502 }
503
504// All went well
505//
506 return 1;
507}
#define XRDABS(x)
struct XrdFrmConfig::VPInfo * VPList
XrdOss * ossFS
char pVec[pVecMax]
long long Large
Definition XrdOssVS.hh:92
long long Total
Definition XrdOssVS.hh:90
virtual int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0)
Definition XrdOss.cc:117
int Start(void)
int Setup(const char *prog, XrdSysError *errP=0, int(*Proc)(XrdOucStream *, char **, int)=0)
XrdOucStream * getStream() const
Definition XrdOucProg.hh:68

References XrdFrm::Config, XrdOucProg::getStream(), XrdOssVSInfo::Large, XrdFrmConfig::VPInfo::Name, XrdFrmConfig::VPInfo::Next, XrdOucTList::next, XrdFrmConfig::ossFS, XrdFrmConfig::PP_atime, XrdFrmConfig::PP_fsize, XrdFrmConfig::PP_mtime, XrdFrmConfig::PP_pfn, XrdFrmConfig::PP_sname, XrdFrmConfig::pProg, XrdFrmConfig::pVec, XrdFrmConfig::pVecNum, Say, XrdOucProg::Setup(), XrdOucProg::Start(), XrdOss::StatVS(), XrdOucTList::text, XrdOssVSInfo::Total, XrdFrmConfig::VPList, and XRDABS.

Referenced by mainConfig().

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

◆ Policy() [1/2]

static XrdFrmPurge * XrdFrmPurge::Policy ( const char * sname)
inlinestatic

Definition at line 52 of file XrdFrmPurge.hh.

52{return Find(sname);}

Referenced by mainConfig().

+ Here is the caller graph for this function:

◆ Policy() [2/2]

XrdFrmPurge * XrdFrmPurge::Policy ( const char * sname,
long long minV,
long long maxV,
int hVal,
int xVal )
static

Definition at line 563 of file XrdFrmPurge.cc.

565{
566 XrdFrmPurge *psP;
567
568// Find or create a new policy
569//
570 if (!(psP = Find(sname))) First = psP = new XrdFrmPurge(sname, First);
571
572// Fill out the policy
573//
574 psP->minFSpace = minV;
575 psP->maxFSpace = maxV;
576 psP->Hold = hVal;
577 psP->Hold2x = hVal*2;
578 psP->Ext = xVal;
579 return psP;
580}
XrdFrmPurge(const char *snp, XrdFrmPurge *spp=0)

References XrdFrmPurge().

+ Here is the call graph for this function:

◆ Purge()

void XrdFrmPurge::Purge ( )
static

Definition at line 586 of file XrdFrmPurge.cc.

587{
588 XrdFrmPurge *psP = First;
589
590// Check if are low on space, if not, ignore the call
591//
592 if (!LowOnSpace())
593 {Say.Emsg("Purge", "Purge cycle skipped; all policies met.");
594 return;
595 }
596
597// Report data at the start of the purge cycle
598//
599 Say.Emsg("Purge", "Purge cycle started.");
600 Stats(0);
601
602// Cycle through each space until we no longer can cycle
603//
604do{psP = First;
605 while(psP && Left2Do)
606 {if (!(psP->Stop) && (psP->Stop = psP->PurgeFile())) Left2Do--;
607 psP = psP->Next;
608 }
609 } while(Left2Do);
610
611// Report data at the end of the purge cycle
612//
613 Stats(1);
614 Say.Emsg("Purge", "Purge cycle ended.");
615}

References Say.

Referenced by main().

+ Here is the caller graph for this function:

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