Loading...
Searching...
No Matches
XrdCmsCache Class Reference

`#include <XrdCmsCache.hh>`

Collaboration diagram for XrdCmsCache:

## Public Member Functions

| XrdCmsCache ()
| ~XrdCmsCache ()
int | AddFile (XrdCmsSelect &Sel, SMask_t mask)
void | Bounce (SMask_t smask, int SNum)
int | DelFile (XrdCmsSelect &Sel, SMask_t mask)
void | Drop (SMask_t mask, int SNum, int xHi)
int | GetFile (XrdCmsSelect &Sel, SMask_t mask)
int | Init (int fxHold, int fxDelay, int fxQuery, int seFS, int nxHold)
void * | TickTock ()
int | UnkFile (XrdCmsSelect &Sel, SMask_t mask)
int | WT4File (XrdCmsSelect &Sel, SMask_t mask)

## Public Attributes

XrdCmsPList_Anchor | Paths

## Static Public Attributes

static const int | min_nxTime = 60

## Friends

class | XrdCmsCacheJob

## Detailed Description

Definition at line 44 of file XrdCmsCache.hh.

## Constructor & Destructor Documentation

## XrdCmsCache()

XrdCmsCache::XrdCmsCache | ( |  | ) |

inline

Definition at line 83 of file XrdCmsCache.hh.

: okVec(0), Tick(8*60*60), Tock(0), BClock(0),
nilTMO(0),
DLTime(5), QDelay(5), Bhits(0), Bmiss(0), vecHi(-1),
isDFS(0)
{memset(Bounced, 0, sizeof(Bounced));
memset(Bhistory, 0, sizeof(Bhistory));
}

## ~XrdCmsCache()

XrdCmsCache::~XrdCmsCache | ( |  | ) |

inline

Definition at line 90 of file XrdCmsCache.hh.

{} // Never gets deleted

## Member Function Documentation

## AddFile()

int XrdCmsCache::AddFile | ( | XrdCmsSelect & | Sel,
|  | SMask_t | mask )

Definition at line 117 of file XrdCmsCache.cc.

{
XrdCmsKeyItem *iP;
SMask_t xmask;
int isrw = (Sel.Opts & XrdCmsSelect::Write), isnew = 0;
// Serialize processing
//
myMutex.Lock();
// Check for fast path processing
//
if ( !(iP = Sel.Path.TODRef) || !(iP->Key.Equiv(Sel.Path)))
if ((iP = Sel.Path.TODRef = CTable.Find(Sel.Path)))
Sel.Path.Ref = iP->Key.Ref;
// Add/Modify the entry
//
if (iP)
{if (!mask)
{iP->Loc.deadline = QDelay + time(0);
iP->Loc.lifeline = nilTMO + iP->Loc.deadline;
iP->Loc.hfvec = 0; iP->Loc.pfvec = 0; iP->Loc.qfvec = 0;
iP->Loc.TOD_B = BClock;
iP->Key.TOD = Tock;
} else {
xmask = iP->Loc.pfvec;
if (Sel.Opts & XrdCmsSelect::Pending) iP->Loc.pfvec |= mask;
else iP->Loc.pfvec &= ~mask;
isnew = (iP->Loc.hfvec == 0) || (iP->Loc.pfvec != xmask);
iP->Loc.hfvec |= mask;
iP->Loc.qfvec &= ~mask;
if (isrw) {iP->Loc.deadline = 0;
if (iP->Loc.roPend || iP->Loc.rwPend)
Dispatch(Sel, iP, iP->Loc.roPend, iP->Loc.rwPend);
}
else {if (!iP->Loc.rwPend) iP->Loc.deadline = 0;
if (iP->Loc.roPend) Dispatch(Sel, iP, iP->Loc.roPend, 0);
}
}
} else if (!(Sel.Opts & XrdCmsSelect::Advisory))
{Sel.Path.TOD = Tock;
if ((iP = CTable.Add(Sel.Path)))
{iP->Loc.pfvec = (Sel.Opts&XrdCmsSelect::Pending?mask:0);
iP->Loc.hfvec = mask;
iP->Loc.TOD_B = BClock;
iP->Loc.qfvec = 0;
iP->Loc.deadline = QDelay + time(0);
iP->Loc.lifeline = nilTMO + iP->Loc.deadline;
Sel.Path.Ref = iP->Key.Ref;
Sel.Path.TODRef = iP; isnew = 1;
}
}
// All done
//
myMutex.UnLock();
return isnew;
}
SMask_t
unsigned long long SMask_t
Definition XrdCmsTypes.hh:33
XrdCmsKeyItem::Loc
XrdCmsKeyLoc Loc
Definition XrdCmsKey.hh:129
XrdCmsKeyItem::Key
XrdCmsKey Key
Definition XrdCmsKey.hh:130
XrdCmsKeyLoc::hfvec
SMask_t hfvec
Definition XrdCmsKey.hh:92
XrdCmsKeyLoc::lifeline
int lifeline
Definition XrdCmsKey.hh:96
XrdCmsKeyLoc::qfvec
SMask_t qfvec
Definition XrdCmsKey.hh:94
XrdCmsKeyLoc::TOD_B
unsigned int TOD_B
Definition XrdCmsKey.hh:95
XrdCmsKeyLoc::rwPend
short rwPend
Definition XrdCmsKey.hh:102
XrdCmsKeyLoc::roPend
short roPend
Definition XrdCmsKey.hh:101
XrdCmsKeyLoc::pfvec
SMask_t pfvec
Definition XrdCmsKey.hh:93
XrdCmsKey::Equiv
int Equiv(XrdCmsKey &oth)
Definition XrdCmsKey.hh:60
XrdCmsKey::TODRef
XrdCmsKeyItem * TODRef
Definition XrdCmsKey.hh:51
XrdCmsKey::TOD
unsigned char TOD
Definition XrdCmsKey.hh:55
XrdCmsKey::Ref
unsigned char Ref
Definition XrdCmsKey.hh:56
XrdCmsSelect::Write
@ Write
Definition XrdCmsSelect.hh:56
XrdCmsSelect::Advisory
@ Advisory
Definition XrdCmsSelect.hh:71
XrdCmsSelect::Pending
@ Pending
Definition XrdCmsSelect.hh:72
XrdCmsSelect::Opts
int Opts
Definition XrdCmsSelect.hh:52
XrdCmsSelect::Path
XrdCmsKey Path
Definition XrdCmsSelect.hh:46

References XrdCmsSelect::Advisory, XrdCmsKey::Equiv(), XrdCmsKeyLoc::hfvec, XrdCmsKeyItem::Key, XrdCmsKeyLoc::lifeline, XrdCmsKeyItem::Loc, XrdCmsSelect::Opts, XrdCmsSelect::Path, XrdCmsSelect::Pending, XrdCmsKeyLoc::pfvec, XrdCmsKeyLoc::qfvec, XrdCmsKey::Ref, XrdCmsKeyLoc::roPend, XrdCmsKeyLoc::rwPend, XrdCmsKey::TOD, XrdCmsKeyLoc::TOD_B, XrdCmsKey::TODRef, and XrdCmsSelect::Write.

Here is the call graph for this function:

## Bounce()

void XrdCmsCache::Bounce | ( | SMask_t | smask,
|  | int | SNum )

Definition at line 343 of file XrdCmsCache.cc.

{
// Simply indicate that this server bounced
//
myMutex.Lock();
Bounced[SNum] = ++BClock;
okVec |= smask;
if (SNum > vecHi) vecHi = SNum;
myMutex.UnLock();
}

## DelFile()

int XrdCmsCache::DelFile | ( | XrdCmsSelect & | Sel,
|  | SMask_t | mask )

Definition at line 191 of file XrdCmsCache.cc.

{
XrdCmsKeyItem *iP;
int gone4good;
// Lock the hash table
//
myMutex.Lock();
// Look up the entry and remove server
//
if ((iP = CTable.Find(Sel.Path)))
{iP->Loc.hfvec &= ~mask;
iP->Loc.pfvec &= ~mask;
if ((gone4good = (iP->Loc.hfvec == 0)))
{if (nilTMO) iP->Loc.lifeline = nilTMO + time(0);
if (!(Sel.Opts & XrdCmsSelect::Advisory)
&& XrdCmsKeyItem::Unload(iP) && !CTable.Recycle(iP))
Say.Emsg("DelFile", "Delete failed for", iP->Key.Val);
}
} else gone4good = 0;
// All done
//
myMutex.UnLock();
return gone4good;
}
XrdCmsKeyItem::Unload
static XrdCmsKeyItem * Unload(unsigned int theTock)
Definition XrdCmsKey.cc:172
XrdCmsKeyItem::Recycle
void Recycle()
Definition XrdCmsKey.cc:101
XrdCmsKey::Val
char * Val
Definition XrdCmsKey.hh:52
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95
XrdCms::Say
XrdSysError Say
Definition XrdCmsManager.cc:62

References XrdCmsSelect::Advisory, XrdCmsKeyLoc::hfvec, XrdCmsKeyItem::Key, XrdCmsKeyLoc::lifeline, XrdCmsKeyItem::Loc, XrdCmsSelect::Opts, XrdCmsSelect::Path, XrdCmsKeyLoc::pfvec, XrdCms::Say, XrdCmsKeyItem::Unload(), and XrdCmsKey::Val.

Here is the call graph for this function:

## Drop()

void XrdCmsCache::Drop | ( | SMask_t | mask,
|  | int | SNum,
|  | int | xHi )

Definition at line 359 of file XrdCmsCache.cc.

{
SMask_t nmask(~smask);
// Remove the node from the path list
//
Paths.Remove(smask);
// Remove the node from the list of valid nodes
//
myMutex.Lock();
Bounced[SNum] = 0;
okVec &= nmask;
vecHi = xHi;
myMutex.UnLock();
}
XrdCmsCache::Paths
XrdCmsPList_Anchor Paths
Definition XrdCmsCache.hh:49

References Paths.

## GetFile()

int XrdCmsCache::GetFile | ( | XrdCmsSelect & | Sel,
|  | SMask_t | mask )

Definition at line 232 of file XrdCmsCache.cc.

{
XrdCmsKeyItem *iP;
SMask_t bVec;
int retc;
// Lock the hash table
//
myMutex.Lock();
// Look up the entry and return location information
//
if ((iP = CTable.Find(Sel.Path)))
{if ((bVec = (iP->Loc.TOD_B < BClock
? getBVec(iP->Key.TOD, iP->Loc.TOD_B) & mask : 0)))
{iP->Loc.hfvec &= ~bVec;
iP->Loc.pfvec &= ~bVec;
iP->Loc.qfvec &= ~mask;
iP->Loc.deadline = QDelay + time(0);
iP->Loc.lifeline = nilTMO + iP->Loc.deadline;
retc = -1;
} else if (iP->Loc.deadline)
if (iP->Loc.deadline > time(0)) retc = -1;
else {iP->Loc.deadline = 0; retc = 1;}
else retc = 1;
if (nilTMO && retc == 1 && iP->Loc.hfvec == 0
&& iP->Loc.lifeline <= time(0)) retc = 0;
Sel.Vec.hf = okVec & iP->Loc.hfvec;
Sel.Vec.pf = okVec & iP->Loc.pfvec;
Sel.Vec.bf = okVec & (bVec | iP->Loc.qfvec); iP->Loc.qfvec = 0;
Sel.Path.Ref = iP->Key.Ref;
} else retc = 0;
// All done
//
myMutex.UnLock();
Sel.Path.TODRef = iP;
return retc;
}
XrdCmsSelect::Vec
struct XrdCmsSelect::@234326324321301042052133314024110005315140201317 Vec

References XrdCmsKeyLoc::hfvec, XrdCmsKeyItem::Key, XrdCmsKeyLoc::lifeline, XrdCmsKeyItem::Loc, XrdCmsSelect::Path, XrdCmsKeyLoc::pfvec, XrdCmsKeyLoc::qfvec, XrdCmsKey::Ref, XrdCmsKey::TOD, XrdCmsKeyLoc::TOD_B, XrdCmsKey::TODRef, and XrdCmsSelect::Vec.

## Init()

int XrdCmsCache::Init | ( | int | fxHold,
|  | int | fxDelay,
|  | int | fxQuery,
|  | int | seFS,
|  | int | nxHold )

Definition at line 380 of file XrdCmsCache.cc.

{
XrdCmsKeyItem *iP;
pthread_t tid;
// Indicate whether we are a shared-everything setup as this changes how we
// dispatch clients to newly discovered files (see Dispatch()).
//
isDFS = seFS;
// Initialize the delay time and the bounce clock tick window
//
DLTime = fxDelay; QDelay = fxQuery;
if (!(Tick = fxHold/XrdCmsKeyItem::TickRate)) Tick = 1;
// Set the timeout for nil entries if one needs to be set. Since this may cause
// an infinite lookup delay, adjust it to be no less than 10 minutes longer
// than the overall deadline for lookups (QDelay/fxQuery).
//
if (nxHold)
{if (nxHold < fxQuery+min_nxTime) nxHold = fxQuery+min_nxTime;
nilTMO = static_cast<unsigned int>(nxHold);
}
// Start the clock thread
//
if (XrdSysThread::Run(&tid, XrdCmsStartTickTock, (void *)this,
0, "Cache Clock"))
{Say.Emsg("Init", errno, "start cache clock");
return 0;
}
// Get the first reserve of cache items
//
iP = XrdCmsKeyItem::Alloc(0);
XrdCmsKeyItem::Unload((unsigned int)0);
iP->Recycle();
// All done
//
return 1;
}
XrdCmsStartTickTock
void * XrdCmsStartTickTock(void *carg)
Definition XrdCmsCache.cc:79
XrdCmsCache::min_nxTime
static const int min_nxTime
Definition XrdCmsCache.hh:81
XrdCmsKeyItem::Alloc
static XrdCmsKeyItem * Alloc(unsigned int theTock)
Definition XrdCmsKey.cc:71
XrdCmsKeyItem::TickRate
static const unsigned int TickRate
Definition XrdCmsKey.hh:150
XrdSysThread::Run
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
Definition XrdSysPthread.cc:307

References XrdCmsKeyItem::Alloc(), min_nxTime, XrdCmsKeyItem::Recycle(), XrdSysThread::Run(), XrdCms::Say, XrdCmsKeyItem::TickRate, XrdCmsKeyItem::Unload(), and XrdCmsStartTickTock().

Here is the call graph for this function:

## TickTock()

void * XrdCmsCache::TickTock | ( |  | ) |

Definition at line 427 of file XrdCmsCache.cc.

{
XrdCmsKeyItem *iP;
// Simply adjust the clock and trim old entries
//
do {XrdSysTimer::Snooze(Tick);
myMutex.Lock();
Tock = (Tock+1) & XrdCmsKeyItem::TickMask;
Bhistory[Tock].Start = Bhistory[Tock].End = 0;
iP = XrdCmsKeyItem::Unload(Tock);
myMutex.UnLock();
if (iP) Sched->Schedule((XrdJob *)new XrdCmsCacheJob(iP));
} while(1);
// Keep compiler happy
//
return (void *)0;
}
XrdCmsCache::XrdCmsCacheJob
friend class XrdCmsCacheJob
Definition XrdCmsCache.hh:47
XrdCmsKeyItem::TickMask
static const unsigned int TickMask
Definition XrdCmsKey.hh:151
XrdScheduler::Schedule
void Schedule(XrdJob *jp)
Definition XrdScheduler.cc:373
XrdSysTimer::Snooze
static void Snooze(int seconds)
Definition XrdSysTimer.cc:168
XrdCms::Sched
XrdScheduler * Sched
Definition XrdCmsConfig.cc:114

References XrdCms::Sched, XrdSysTimer::Snooze(), XrdCmsKeyItem::TickMask, XrdCmsKeyItem::Unload(), and XrdCmsCacheJob.

Referenced by XrdCmsStartTickTock().

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

## UnkFile()

int XrdCmsCache::UnkFile | ( | XrdCmsSelect & | Sel,
|  | SMask_t | mask )

Definition at line 278 of file XrdCmsCache.cc.

{
EPNAME("UnkFile");
XrdCmsKeyItem *iP;
// Make sure we have the proper information. If so, lock the hash table
//
myMutex.Lock();
// Look up the entry and if valid update the unqueried vector. Note that
// this method may only be called after GetFile() or AddFile() for a new entry
//
if ((iP = Sel.Path.TODRef))
{if (iP->Key.Equiv(Sel.Path)) iP->Loc.qfvec = mask;
else iP = 0;
}
// Return result
//
myMutex.UnLock();
DEBUG("rc=" <<(iP ? 1 : 0) <<" path=" <<Sel.Path.Val);
return (iP ? 1 : 0);
}
DEBUG
#define DEBUG(x)
Definition XrdBwmTrace.hh:54
EPNAME
#define EPNAME(x)
Definition XrdBwmTrace.hh:56

References DEBUG, EPNAME, XrdCmsKey::Equiv(), XrdCmsKeyItem::Key, XrdCmsKeyItem::Loc, XrdCmsSelect::Path, XrdCmsKeyLoc::qfvec, XrdCmsKey::TODRef, and XrdCmsKey::Val.

Here is the call graph for this function:

## WT4File()

int XrdCmsCache::WT4File | ( | XrdCmsSelect & | Sel,
|  | SMask_t | mask )

Definition at line 306 of file XrdCmsCache.cc.

{
EPNAME("WT4File");
XrdCmsKeyItem *iP;
time_t Now;
int retc;
// Make sure we have the proper information. If so, lock the hash table
//
if (!Sel.InfoP) return DLTime;
myMutex.Lock();
// Look up the entry and if valid add it to the callback queue. Note that
// this method may only be called after GetFile() or AddFile() for a new entry
//
if (!(iP = Sel.Path.TODRef) || !(iP->Key.Equiv(Sel.Path))) retc = DLTime;
else if (iP->Loc.hfvec != mask) retc = 1;
else {Now = time(0); retc = 0;
if (iP->Loc.deadline && iP->Loc.deadline <= Now)
iP->Loc.deadline = DLTime + Now;
Add2Q(Sel.InfoP, iP, Sel.Opts);
}
// Return result
//
myMutex.UnLock();
DEBUG("rc=" <<retc <<" path=" <<Sel.Path.Val);
return retc;
}
XrdCmsSelect::InfoP
XrdCmsRRQInfo * InfoP
Definition XrdCmsSelect.hh:47

References DEBUG, EPNAME, XrdCmsKey::Equiv(), XrdCmsKeyLoc::hfvec, XrdCmsSelect::InfoP, XrdCmsKeyItem::Key, XrdCmsKeyItem::Loc, XrdCmsSelect::Opts, XrdCmsSelect::Path, XrdCmsKey::TODRef, and XrdCmsKey::Val.

Here is the call graph for this function:

## Friends And Related Symbol Documentation

## XrdCmsCacheJob

friend class XrdCmsCacheJob

friend

Definition at line 47 of file XrdCmsCache.hh.

References XrdCmsCacheJob.

Referenced by TickTock(), and XrdCmsCacheJob.

## Member Data Documentation

## min_nxTime

const int XrdCmsCache::min_nxTime = 60

static

Definition at line 81 of file XrdCmsCache.hh.

Referenced by Init().

## Paths

XrdCmsPList_Anchor XrdCmsCache::Paths

Definition at line 49 of file XrdCmsCache.hh.

Referenced by Drop().

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

- XrdCmsCache.hh
- XrdCmsCache.cc