Loading...
Searching...
No Matches
XrdCmsPrepare Class Reference

`#include <XrdCmsPrepare.hh>`

Inheritance diagram for XrdCmsPrepare:
Collaboration diagram for XrdCmsPrepare:

## Public Member Functions

| XrdCmsPrepare ()
| ~XrdCmsPrepare ()
int | Add (XrdCmsPrepArgs &pargs)
int | Del (char *reqid)
void | DoIt ()
int | Exists (char *path)
void | Gone (char *path)
void | Inform (const char *cmd, XrdCmsPrepArgs *pargs)
void | Init ()
int | isOK ()
int | Pending ()
void | Prepare (XrdCmsPrepArgs *pargs)
void | Reset (const char *iName, const char *aPath, int aMode)
int | setParms (const char *ifpgm, char *ifmsg=0)
int | setParms (int rcnt, int stime, int deco=0)
int | setParms (XrdOucName2Name *n2n)
Public Member Functions inherited from XrdJob
| XrdJob (const char *desc="")
virtual | ~XrdJob ()

## Additional Inherited Members

Public Attributes inherited from XrdJob
const char * | Comment
XrdJob * | NextJob

## Detailed Description

Definition at line 46 of file XrdCmsPrepare.hh.

## Constructor & Destructor Documentation

## XrdCmsPrepare()

XrdCmsPrepare::XrdCmsPrepare | ( |  | ) |

Definition at line 77 of file XrdCmsPrepare.cc.

: XrdJob("Prep cache scrubber"),
prepSched(&Say)
{prepif = 0;
preppid = 0;
resetcnt = scrub2rst = 3;
scrubtime= 20*60;
NumFiles = 0;
lastemsg = time(0);
Relay = 0; // This will be initialized via Init()!
PrepFrm = 0;
prepOK = 0;
N2N = 0;
}
XrdJob::XrdJob
XrdJob(const char *desc="")
Definition XrdJob.hh:51
XrdCms::Say
XrdSysError Say
Definition XrdCmsManager.cc:62

References XrdJob::XrdJob(), and XrdCms::Say.

Here is the call graph for this function:

## ~XrdCmsPrepare()

XrdCmsPrepare::~XrdCmsPrepare | ( |  | ) |

inline

Definition at line 79 of file XrdCmsPrepare.hh.

{} // Never gets deleted

## Member Function Documentation

## Add()

int XrdCmsPrepare::Add | ( | XrdCmsPrepArgs & | pargs | ) |

Definition at line 95 of file XrdCmsPrepare.cc.

{
char *pdata[XrdOucMsubs::maxElem+2], prtybuff[8], *pP=prtybuff;
int rc, pdlen[XrdOucMsubs::maxElem + 2];
// Check if we are using the built-in mechanism
//
if (PrepFrm)
{rc = PrepFrm->Add('+',pargs.path, pargs.opaque,pargs.Ident,pargs.reqid,
pargs.notify,pargs.mode,atoi(pargs.prty));
if (rc) Say.Emsg("Add", rc, "prepare", pargs.path);
else {PTMutex.Lock();
if (!PTable.Add(pargs.path, 0, 0, Hash_data_is_key)) NumFiles++;
PTMutex.UnLock();
}
return rc == 0;
}
// Restart the scheduler if need be
//
PTMutex.Lock();
if (!prepif || !prepSched.isAlive())
{Say.Emsg("Add","No prepare manager; prepare",pargs.reqid,"ignored.");
PTMutex.UnLock();
return 0;
}
// Write out the header line
//
if (!prepMsg)
{*pP++ = pargs.prty[0]; *pP = '\0';
pdata[0] = (char *)"+ "; pdlen[0] = 2;
pdata[1] = pargs.reqid; pdlen[1] = strlen(pargs.reqid);
pdata[2] = (char *)" "; pdlen[2] = 1;
pdata[3] = pargs.notify; pdlen[3] = strlen(pargs.notify);
pdata[4] = (char *)" "; pdlen[4] = 1;
pdata[5] = prtybuff; pdlen[5] = strlen(prtybuff);
pdata[6] = (char *)" "; pdlen[6] = 1;
pdata[7] = pargs.mode; pdlen[7] = strlen(pargs.mode);
pdata[8] = (char *)" "; pdlen[8] = 1;
pdata[9] = pargs.path; pdlen[9] = strlen(pargs.path);
pdata[10] = (char *)"\n"; pdlen[10] = 1;
pdata[11]= 0; pdlen[11]= 0;
if (!(rc = prepSched.Put((const char **)pdata, (const int *)pdlen)))
if (!PTable.Add(pargs.path, 0, 0, Hash_data_is_key)) NumFiles++;
} else {
int Oflag = (index(pargs.mode, (int)'w') ? O_RDWR : 0);
mode_t Prty = atoi(pargs.prty);
XrdOucEnv Env(pargs.opaque);
XrdOucMsubsInfo Info(pargs.Ident, &Env, N2N, pargs.path,
pargs.notify, Prty, Oflag, pargs.mode, pargs.reqid);
int k = prepMsg->Subs(Info, pdata, pdlen);
pdata[k] = (char *)"\n"; pdlen[k++] = 1;
pdata[k] = 0; pdlen[k] = 0;
if (!(rc = prepSched.Put((const char **)pdata, (const int *)pdlen)))
if (!PTable.Add(pargs.path, 0, 0, Hash_data_is_key)) NumFiles++;
}
// All done
//
PTMutex.UnLock();
return rc == 0;
}
Hash_data_is_key
@ Hash_data_is_key
Definition XrdOucHash.hh:52
XrdCmsPrepArgs::Ident
char * Ident
Definition XrdCmsPrepArgs.hh:46
XrdCmsPrepArgs::mode
char * mode
Definition XrdCmsPrepArgs.hh:50
XrdCmsPrepArgs::notify
char * notify
Definition XrdCmsPrepArgs.hh:48
XrdCmsPrepArgs::prty
char * prty
Definition XrdCmsPrepArgs.hh:49
XrdCmsPrepArgs::opaque
char * opaque
Definition XrdCmsPrepArgs.hh:52
XrdCmsPrepArgs::path
char * path
Definition XrdCmsPrepArgs.hh:51
XrdCmsPrepArgs::reqid
char * reqid
Definition XrdCmsPrepArgs.hh:47
XrdOucMsubs::maxElem
static const int maxElem
Definition XrdOucMsubs.hh:94
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95
TPC::Info
@ Info
Definition XrdHttpTpcTPC.hh:29

References Hash_data_is_key, XrdCmsPrepArgs::Ident, XrdOucMsubs::maxElem, XrdCmsPrepArgs::mode, XrdCmsPrepArgs::notify, XrdCmsPrepArgs::opaque, XrdCmsPrepArgs::path, XrdCmsPrepArgs::prty, XrdCmsPrepArgs::reqid, and XrdCms::Say.

Referenced by Prepare().

Here is the caller graph for this function:

## Del()

int XrdCmsPrepare::Del | ( | char * | reqid | ) |

Definition at line 163 of file XrdCmsPrepare.cc.

{
char *pdata[4];
int rc, pdlen[4];
// Use our built-in mechanism if so wanted
//
if (PrepFrm)
{if ((rc = PrepFrm->Del('-', reqid)))
Say.Emsg("Del", rc, "unprepare", reqid);
return rc == 0;
}
// Restart the scheduler if need be
//
PTMutex.Lock();
if (!prepif || !prepSched.isAlive())
{Say.Emsg("Del","No prepare manager; unprepare",reqid,"ignored.");
PTMutex.UnLock();
return 0;
}
// Write out the delete request
//
pdata[0] = (char *)"- ";
pdlen[0] = 2;
pdata[1] = reqid;
pdlen[1] = strlen(reqid);
pdata[2] = (char *)"\n";
pdlen[2] = 1;
pdata[3] = (char *)0;
pdlen[3] = 0;
rc = prepSched.Put((const char **)pdata, (const int *)pdlen);
PTMutex.UnLock();
return rc == 0;
}

References XrdCms::Say.

## DoIt()

void XrdCmsPrepare::DoIt | ( |  | ) |

virtual

Implements XrdJob.

Definition at line 204 of file XrdCmsPrepare.cc.

{
// Simply scrub the cache
//
Scrub();
Sched->Schedule((XrdJob *)this,scrubtime+time(0));
}
XrdScheduler::Schedule
void Schedule(XrdJob *jp)
Definition XrdScheduler.cc:373
XrdCms::Sched
XrdScheduler * Sched
Definition XrdCmsConfig.cc:114

References XrdJob::XrdJob(), and XrdCms::Sched.

Here is the call graph for this function:

## Exists()

int XrdCmsPrepare::Exists | ( | char * | path | ) |

Definition at line 216 of file XrdCmsPrepare.cc.

{
int Found;
// Lock the hash table
//
PTMutex.Lock();
// Look up the entry
//
Found = (NumFiles ? PTable.Find(path) != 0 : 0);
// All done
//
PTMutex.UnLock();
return Found;
}

## Gone()

void XrdCmsPrepare::Gone | ( | char * | path | ) |

Definition at line 238 of file XrdCmsPrepare.cc.

{
// Lock the hash table
//
PTMutex.Lock();
// Delete the entry
//
if (NumFiles > 0 && PTable.Del(path) == 0) NumFiles--;
// All done
//
PTMutex.UnLock();
}

## Inform()

void XrdCmsPrepare::Inform | ( | const char * | cmd,
|  | XrdCmsPrepArgs * | pargs )

Definition at line 258 of file XrdCmsPrepare.cc.

{
EPNAME("Inform")
struct iovec Msg[8];
char *mdest, *minfo;
// See if requestor wants a response
//
if (!index(pargs->mode, (int)'n')
|| strncmp("udp://", pargs->notify, 6)
|| !Relay)
{DEBUG(pargs->Ident <<' ' <<cmd <<' ' <<pargs->reqid <<" not sent to "
<<pargs->notify);
return;
}
// Extract out destination and argument
//
mdest = pargs->notify+6;
if ((minfo = index(mdest, (int)'/')))
{*minfo = '\0'; minfo++;}
if (!minfo || !*minfo) minfo = (char *)"*";
DEBUG("Sending " <<mdest <<": " <<cmd <<' '<<pargs->reqid <<' ' <<minfo);
// Create message to be sent
//
Msg[0].iov_base = (char *)cmd; Msg[0].iov_len = strlen(cmd);
Msg[1].iov_base = (char *)" "; Msg[1].iov_len = 1;
Msg[2].iov_base = pargs->reqid; Msg[2].iov_len = strlen(pargs->reqid);
Msg[3].iov_base = (char *)" "; Msg[3].iov_len = 1;
Msg[4].iov_base = minfo; Msg[4].iov_len = strlen(minfo);
Msg[5].iov_base = (char *)" "; Msg[5].iov_len = 1;
Msg[6].iov_base = pargs->path; Msg[6].iov_len = (pargs->pathlen)-1;
Msg[7].iov_base = (char *)"\n"; Msg[7].iov_len = 1;
// Send the message and return
//
Relay->Send(Msg, 8, mdest);
}
DEBUG
#define DEBUG(x)
Definition XrdBwmTrace.hh:54
EPNAME
#define EPNAME(x)
Definition XrdBwmTrace.hh:56
if
if(ec< 0) ec
XrdCmsPrepArgs::pathlen
int pathlen
Definition XrdCmsPrepArgs.hh:55

References DEBUG, EPNAME, XrdCmsPrepArgs::Ident, XrdCmsPrepArgs::mode, XrdCmsPrepArgs::notify, XrdCmsPrepArgs::path, XrdCmsPrepArgs::pathlen, and XrdCmsPrepArgs::reqid.

Referenced by Prepare().

Here is the caller graph for this function:

## Init()

void XrdCmsPrepare::Init | ( |  | ) |

Definition at line 302 of file XrdCmsPrepare.cc.

{
// Obtain a msg object. We need to do it outside of a global constructor!
//
Relay = new XrdNetMsg(&Say);
}

References XrdCms::Say.

## isOK()

int XrdCmsPrepare::isOK | ( |  | ) |

inline

Definition at line 64 of file XrdCmsPrepare.hh.

{return prepOK;}

## Pending()

int XrdCmsPrepare::Pending | ( |  | ) |

inline

Definition at line 66 of file XrdCmsPrepare.hh.

{return NumFiles;}

## Prepare()

void XrdCmsPrepare::Prepare | ( | XrdCmsPrepArgs * | pargs | ) |

Definition at line 313 of file XrdCmsPrepare.cc.

{
EPNAME("Prepare");
int rc;
// Check if this file is not online, prepare it
//
if (!(rc = isOnline(pargs->path)))
{DEBUG("Preparing " <<pargs->reqid <<' ' <<pargs->notify <<' '
<<pargs->prty <<' ' <<pargs->mode <<' ' <<pargs->path);
if (!Config.DiskSS) Say.Emsg("Prepare","staging disallowed; ignoring prep",
pargs->Ident, pargs->reqid);
else Add(*pargs);
return;
}
// If the file is really online, inform the requestor
//
if (rc > 0) Inform("avail", pargs);
}
XrdCmsConfig::DiskSS
bool DiskSS
Definition XrdCmsConfig.hh:123
XrdCmsPrepare::Inform
void Inform(const char *cmd, XrdCmsPrepArgs *pargs)
Definition XrdCmsPrepare.cc:258
XrdCmsPrepare::Add
int Add(XrdCmsPrepArgs &pargs)
Definition XrdCmsPrepare.cc:95
XrdCms::Config
XrdCmsConfig Config
Definition XrdCmsConfig.cc:108

References Add(), XrdCms::Config, DEBUG, EPNAME, XrdCmsPrepArgs::Ident, Inform(), XrdCmsPrepArgs::mode, XrdCmsPrepArgs::notify, XrdCmsPrepArgs::path, XrdCmsPrepArgs::prty, XrdCmsPrepArgs::reqid, and XrdCms::Say.

Here is the call graph for this function:

## Reset()

void XrdCmsPrepare::Reset | ( | const char * | iName,
|  | const char * | aPath,
|  | int | aMode )

Definition at line 338 of file XrdCmsPrepare.cc.

{
EPNAME("Reset");
char baseAP[1024], *Slash;
// This is a call from the configurator. No need to do anything if we have
// no interface to initialize.
//
if (!prepif) return;
// If this is a built-in mechanism, then allocate the prepare interface
// and initialize it. This is a one-time thing and it better work right away.
// In any case, do a standard reset.
//
if (!*prepif)
{PrepFrm = new XrdFrcProxy(Say.logger(), iName);
DEBUG("Initializing internal FRM prepare interface.");
strcpy(baseAP, aPath); baseAP[strlen(baseAP)-1] = '\0';
if ((Slash = rindex(baseAP, '/'))) *Slash = '\0';
if (!(prepOK = PrepFrm->Init(XrdFrcProxy::opStg, baseAP, aMode)))
{Say.Emsg("Reset", "Built-in prepare init failed; prepare disabled.");
return;
}
}
// Reset the interface and schedule a scrub
//
Reset();
if (scrubtime) Sched->Schedule((XrdJob *)this,scrubtime+time(0));
}
XrdCmsPrepare::Reset
void Reset(const char *iName, const char *aPath, int aMode)
Definition XrdCmsPrepare.cc:338
XrdFrcProxy::opStg
static const int opStg
Definition XrdFrcProxy.hh:52
XrdSysError::logger
XrdSysLogger * logger(XrdSysLogger *lp=0)
Definition XrdSysError.hh:141

References XrdJob::XrdJob(), DEBUG, EPNAME, XrdFrcProxy::opStg, Reset(), XrdCms::Say, and XrdCms::Sched.

Referenced by Reset().

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

## setParms() [1/3]

int XrdCmsPrepare::setParms | ( | const char * | ifpgm,
|  | char * | ifmsg = 0 )

Definition at line 381 of file XrdCmsPrepare.cc.

{if (ifpgm)
{const char *Slash = rindex(ifpgm, '/');
if (prepif) free(prepif);
if (Slash && !strcmp(Slash+1, "frm_xfragent")) ifpgm = "";
prepif = strdup(ifpgm);
}
if (ifmsg)
{if (prepMsg) delete prepMsg;
prepMsg = new XrdOucMsubs(&Say);
if (!(prepMsg->Parse("prepmsg", ifmsg)))
{delete prepMsg; prepMsg = 0; return 1;}
}
return 0;
}

References XrdCms::Say.

## setParms() [2/3]

int XrdCmsPrepare::setParms | ( | int | rcnt,
|  | int | stime,
|  | int | deco = 0 )

Definition at line 374 of file XrdCmsPrepare.cc.

{if (rcnt > 0) resetcnt = scrub2rst = rcnt;
if (stime > 0) scrubtime = stime;
doEcho = deco;
return 0;
}

## setParms() [3/3]

int XrdCmsPrepare::setParms | ( | XrdOucName2Name * | n2n | ) |

inline

Definition at line 76 of file XrdCmsPrepare.hh.

{N2N = n2n; return 0;}

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

- XrdCmsPrepare.hh
- XrdCmsPrepare.cc