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 XrdFrmPurge * | Policy (const char *sname)
static XrdFrmPurge * | Policy (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.

: FSTab(1)
{
strncpy(SName, snp, sizeof(SName)-1); SName[sizeof(SName)-1] = '\0';
Next = spp;
freeSpace = 0;
usedSpace =-1;
pmaxSpace = 0;
totlSpace = 0;
contSpace = 0;
minFSpace = 0;
maxFSpace = 0;
Enabled = 0;
Stop = 0;
SNlen = strlen(SName);
memset(DeferQ, 0, sizeof(DeferQ));
Clear();
}

References XrdFrmPurge().

Referenced by XrdFrmPurge(), Display(), Init(), Policy(), Policy(), and Purge().

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

## ~XrdFrmPurge()

XrdFrmPurge::~XrdFrmPurge | ( |  | ) |

inline

Definition at line 59 of file XrdFrmPurge.hh.

{Clear();}

## Member Function Documentation

## Display()

void XrdFrmPurge::Display | ( |  | ) |

static

Definition at line 295 of file XrdFrmPurge.cc.

{
XrdFrmConfig::VPInfo *vP = Config.pathList;
XrdFrmPurge *spP = First;
XrdOucTList *tP;
const char *isExt;
char buff[1024], minfsp[32], maxfsp[32];
// Type header
//
Say.Say("=====> ", "Purge configuration:");
// Display what we will scan
//
while(vP)
{Say.Say("=====> ", "Scanning ", (vP->Val?"r/w: ":"r/o: "), vP->Name);
tP = vP->Dir;
while(tP) {Say.Say("=====> ", "Excluded ", tP->text); tP = tP->next;}
vP = vP->Next;
}
// Display directory hold value
//
if (Config.dirHold < 0) strcpy(buff, "forever");
else sprintf(buff, "%d", Config.dirHold);
Say.Say("=====> ", "Directory hold: ", buff);
// Run through all of the policies, displaying each one
//
spP = First;
while(spP)
{if (spP->Enabled)
{XrdOucUtils::fmtBytes(spP->minFSpace, minfsp, sizeof(minfsp));
XrdOucUtils::fmtBytes(spP->maxFSpace, maxfsp, sizeof(maxfsp));
isExt = spP->Ext ? " polprog" : "";
sprintf(buff, "policy %s min %s max %s free; hold: %d%s",
spP->SName, minfsp, maxfsp, spP->Hold, isExt);
} else sprintf(buff, "policy %s nopurge", spP->SName);
Say.Say("=====> ", buff);
spP = spP->Next;
}
}
Say
XrdOucPup XrdCmsParser::Pup & Say
Definition XrdCmsParser.cc:124
XrdFrmConfig::pathList
VPInfo * pathList
Definition XrdFrmConfig.hh:130
XrdFrmConfig::dirHold
int dirHold
Definition XrdFrmConfig.hh:147
XrdFrmPurge::XrdFrmPurge
XrdFrmPurge(const char *snp, XrdFrmPurge *spp=0)
Definition XrdFrmPurge.cc:164
XrdOucTList::next
XrdOucTList * next
Definition XrdOucTList.hh:45
XrdOucTList::text
char * text
Definition XrdOucTList.hh:46
XrdOucUtils::fmtBytes
static int fmtBytes(long long val, char *buff, int bsz)
Definition XrdOucUtils.cc:436
XrdFrm::Config
XrdFrmConfig Config
XrdFrmConfig::VPInfo::Val
int Val
Definition XrdFrmConfig.hh:125
XrdFrmConfig::VPInfo::Name
char * Name
Definition XrdFrmConfig.hh:123
XrdFrmConfig::VPInfo::Next
VPInfo * Next
Definition XrdFrmConfig.hh:122
XrdFrmConfig::VPInfo::Dir
XrdOucTList * Dir
Definition XrdFrmConfig.hh:124

References XrdFrmPurge(), XrdFrm::Config, XrdFrmConfig::VPInfo::Dir, XrdOucUtils::fmtBytes(), XrdFrmConfig::VPInfo::Name, XrdFrmConfig::VPInfo::Next, XrdOucTList::next, 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.

{
static char pVec[] = {char(XrdFrmConfig::PP_sname),
char(XrdFrmConfig::PP_pfn),
char(XrdFrmConfig::PP_fsize),
char(XrdFrmConfig::PP_atime),
char(XrdFrmConfig::PP_mtime)
};
XrdFrmConfig::VPInfo *vP;
XrdFrmPurge *xP, *ppP = 0, *spP = First;
XrdOucTList *tP;
char xBuff[32];
int setIt, rc, haveExt = 0;
// The first step is to remove any defined policies for which there is no space
//
while(spP)
{vP = Config.VPList;
while(vP && strcmp(spP->SName, vP->Name)) vP = vP->Next;
if (!vP && strcmp("public", spP->SName))
{Say.Emsg("Init", "Purge policy", spP->SName,
"deleted; space not defined.");
if (ppP) ppP->Next = spP->Next;
else First = spP->Next;
xP = spP; spP = spP->Next; delete xP;
} else {ppP = spP; spP = spP->Next;}
}
// For each space enable it and optionally over-ride policy
//
spP = First;
while(spP)
{setIt = 1;
if ((tP = sP))
{while(tP && strcmp(tP->text, spP->SName)) tP = tP->next;
if (!tP) setIt = 0;
}
if (setIt)
{if (minV) spP->minFSpace = spP->maxFSpace = minV;
if (hVal >= 0) {spP->Hold = hVal; spP->Hold2x = hVal*2;}
if (spP->minFSpace && spP->Hold >= 0)
{spP->Enabled = 1; haveExt |= spP->Ext;}
}
spP = spP->Next;
}
// Go through each space policy getting the actual space and calculating
// the targets based on the policy (we need to do this only once)
//
spP = First; ppP = 0;
while(spP)
{XrdOssVSInfo vsInfo;
if ((rc = Config.ossFS->StatVS(&vsInfo, spP->SName, 1)))
{Say.Emsg("Init", rc, "calculate space for", spP->SName);
if (ppP) ppP->Next = spP->Next;
else First = spP->Next;
xP = spP; spP = spP->Next; delete xP; continue;
}
spP->totlSpace = vsInfo.Total;
spP->spaceTLen = sprintf(xBuff, "%lld", vsInfo.Total);
spP->spaceTotl = strdup(xBuff);
spP->pmaxSpace = vsInfo.Large;
spP->spaceTLep = sprintf(xBuff, "%lld", vsInfo.Large);
spP->spaceTotP = strdup(xBuff);
if (spP->minFSpace < 0)
{spP->minFSpace = vsInfo.Total * XRDABS(spP->minFSpace) / 100LL;
spP->maxFSpace = vsInfo.Total * XRDABS(spP->maxFSpace) / 100LL;
} else if (vsInfo.Total < spP->minFSpace
|| vsInfo.Total < spP->maxFSpace)
Say.Emsg("Init", "Warning: ", spP->SName, " min/max free "
"space policy exceeds total available!");
ppP = spP; spP = spP->Next;
}
// Make sure "public" still exists. While this should not happen, we check for
// this possibility anyway.
//
if (!(Default = Find("public")))
{Say.Emsg("Init", "Unable to start purge; no public policy found.");
return 0;
}
// If a policy program is present, then we need to verify it
//
if (Config.pProg && haveExt)
{PolProg = new XrdOucProg(&Say);
if (PolProg->Setup(Config.pProg) || PolProg->Start()) return 0;
PolStream = PolProg->getStream();
if (!Config.pVecNum)
{memcpy(Config.pVec, pVec, sizeof(pVec));
Config.pVecNum = sizeof(pVec);
}
}
// All went well
//
return 1;
}
XRDABS
#define XRDABS(x)
Definition XrdSysPlatform.hh:298
XrdFrmConfig::PP_sname
@ PP_sname
Definition XrdFrmConfig.hh:156
XrdFrmConfig::PP_atime
@ PP_atime
Definition XrdFrmConfig.hh:155
XrdFrmConfig::PP_mtime
@ PP_mtime
Definition XrdFrmConfig.hh:156
XrdFrmConfig::PP_fsize
@ PP_fsize
Definition XrdFrmConfig.hh:155
XrdFrmConfig::PP_pfn
@ PP_pfn
Definition XrdFrmConfig.hh:156
XrdFrmConfig::pProg
char * pProg
Definition XrdFrmConfig.hh:151
XrdFrmConfig::VPList
struct XrdFrmConfig::VPInfo * VPList
XrdFrmConfig::ossFS
XrdOss * ossFS
Definition XrdFrmConfig.hh:91
XrdFrmConfig::pVec
char pVec[pVecMax]
Definition XrdFrmConfig.hh:150
XrdFrmConfig::pVecNum
int pVecNum
Definition XrdFrmConfig.hh:148
XrdOssVSInfo::Large
long long Large
Definition XrdOssVS.hh:92
XrdOssVSInfo::Total
long long Total
Definition XrdOssVS.hh:90
XrdOss::StatVS
virtual int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0)
Definition XrdOss.cc:117

References XrdFrmPurge(), XrdFrm::Config, XrdOssVSInfo::Large, XrdFrmConfig::VPInfo::Name, XrdFrmConfig::VPInfo::Next, XrdOucTList::next, XrdFrmConfig::PP_atime, XrdFrmConfig::PP_fsize, XrdFrmConfig::PP_mtime, XrdFrmConfig::PP_pfn, XrdFrmConfig::PP_sname, Say, XrdOucTList::text, XrdOssVSInfo::Total, and XRDABS.

Referenced by mainConfig().

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

## Policy() [1/2]

XrdFrmPurge * XrdFrmPurge::Policy | ( | const char * | sname | ) |

inline static

Definition at line 52 of file XrdFrmPurge.hh.

{return Find(sname);}

References XrdFrmPurge().

Referenced by mainConfig().

Here is the call graph for this function:
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.

{
XrdFrmPurge *psP;
// Find or create a new policy
//
if (!(psP = Find(sname))) First = psP = new XrdFrmPurge(sname, First);
// Fill out the policy
//
psP->minFSpace = minV;
psP->maxFSpace = maxV;
psP->Hold = hVal;
psP->Hold2x = hVal*2;
psP->Ext = xVal;
return psP;
}

References XrdFrmPurge().

Here is the call graph for this function:

## Purge()

void XrdFrmPurge::Purge | ( |  | ) |

static

Definition at line 586 of file XrdFrmPurge.cc.

{
XrdFrmPurge *psP = First;
// Check if are low on space, if not, ignore the call
//
if (!LowOnSpace())
{Say.Emsg("Purge", "Purge cycle skipped; all policies met.");
return;
}
// Report data at the start of the purge cycle
//
Say.Emsg("Purge", "Purge cycle started.");
Stats(0);
// Cycle through each space until we no longer can cycle
//
do{psP = First;
while(psP && Left2Do)
{if (!(psP->Stop) && (psP->Stop = psP->PurgeFile())) Left2Do--;
psP = psP->Next;
}
} while(Left2Do);
// Report data at the end of the purge cycle
//
Stats(1);
Say.Emsg("Purge", "Purge cycle ended.");
}

References XrdFrmPurge(), and Say.

Referenced by main().

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

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

- XrdFrmPurge.hh
- XrdFrmPurge.cc