XRootD
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.

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

◆ ~XrdCmsCache()

XrdCmsCache::~XrdCmsCache ( )
inline

Definition at line 90 of file XrdCmsCache.hh.

90{} // Never gets deleted

Member Function Documentation

◆ AddFile()

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

Definition at line 117 of file XrdCmsCache.cc.

118{
119 XrdCmsKeyItem *iP;
120 SMask_t xmask;
121 int isrw = (Sel.Opts & XrdCmsSelect::Write), isnew = 0;
122
123// Serialize processing
124//
125 myMutex.Lock();
126
127// Check for fast path processing
128//
129 if ( !(iP = Sel.Path.TODRef) || !(iP->Key.Equiv(Sel.Path)))
130 if ((iP = Sel.Path.TODRef = CTable.Find(Sel.Path)))
131 Sel.Path.Ref = iP->Key.Ref;
132
133// Add/Modify the entry
134//
135 if (iP)
136 {if (!mask)
137 {iP->Loc.deadline = QDelay + time(0);
138 iP->Loc.lifeline = nilTMO + iP->Loc.deadline;
139 iP->Loc.hfvec = 0; iP->Loc.pfvec = 0; iP->Loc.qfvec = 0;
140 iP->Loc.TOD_B = BClock;
141 iP->Key.TOD = Tock;
142 } else {
143 xmask = iP->Loc.pfvec;
144 if (Sel.Opts & XrdCmsSelect::Pending) iP->Loc.pfvec |= mask;
145 else iP->Loc.pfvec &= ~mask;
146 isnew = (iP->Loc.hfvec == 0) || (iP->Loc.pfvec != xmask);
147 iP->Loc.hfvec |= mask;
148 iP->Loc.qfvec &= ~mask;
149 if (isrw) {iP->Loc.deadline = 0;
150 if (iP->Loc.roPend || iP->Loc.rwPend)
151 Dispatch(Sel, iP, iP->Loc.roPend, iP->Loc.rwPend);
152 }
153 else {if (!iP->Loc.rwPend) iP->Loc.deadline = 0;
154 if (iP->Loc.roPend) Dispatch(Sel, iP, iP->Loc.roPend, 0);
155 }
156 }
157 } else if (!(Sel.Opts & XrdCmsSelect::Advisory))
158 {Sel.Path.TOD = Tock;
159 if ((iP = CTable.Add(Sel.Path)))
160 {iP->Loc.pfvec = (Sel.Opts&XrdCmsSelect::Pending?mask:0);
161 iP->Loc.hfvec = mask;
162 iP->Loc.TOD_B = BClock;
163 iP->Loc.qfvec = 0;
164 iP->Loc.deadline = QDelay + time(0);
165 iP->Loc.lifeline = nilTMO + iP->Loc.deadline;
166 Sel.Path.Ref = iP->Key.Ref;
167 Sel.Path.TODRef = iP; isnew = 1;
168 }
169 }
170
171// All done
172//
173 myMutex.UnLock();
174 return isnew;
175}
unsigned long long SMask_t
XrdCmsKeyLoc Loc
Definition XrdCmsKey.hh:129
XrdCmsKey Key
Definition XrdCmsKey.hh:130
SMask_t hfvec
Definition XrdCmsKey.hh:92
SMask_t qfvec
Definition XrdCmsKey.hh:94
unsigned int TOD_B
Definition XrdCmsKey.hh:95
SMask_t pfvec
Definition XrdCmsKey.hh:93
int Equiv(XrdCmsKey &oth)
Definition XrdCmsKey.hh:60
XrdCmsKeyItem * TODRef
Definition XrdCmsKey.hh:51
unsigned char TOD
Definition XrdCmsKey.hh:55
unsigned char Ref
Definition XrdCmsKey.hh:56
XrdCmsKeyItem * Add(XrdCmsKey &Key)
Definition XrdCmsNash.cc:54
XrdCmsKeyItem * Find(XrdCmsKey &Key)
XrdCmsKey Path

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

Referenced by XrdCmsNode::do_Have(), XrdCmsNode::do_StateFWD(), XrdCmsCluster::Locate(), and XrdCmsCluster::Select().

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

◆ Bounce()

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

Definition at line 343 of file XrdCmsCache.cc.

344{
345
346// Simply indicate that this server bounced
347//
348 myMutex.Lock();
349 Bounced[SNum] = ++BClock;
350 okVec |= smask;
351 if (SNum > vecHi) vecHi = SNum;
352 myMutex.UnLock();
353}

References XrdSysMutex::Lock(), and XrdSysMutex::UnLock().

Referenced by XrdCmsNode::do_Status().

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

◆ DelFile()

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

Definition at line 191 of file XrdCmsCache.cc.

192{
193 XrdCmsKeyItem *iP;
194 int gone4good;
195
196// Lock the hash table
197//
198 myMutex.Lock();
199
200// Look up the entry and remove server
201//
202 if ((iP = CTable.Find(Sel.Path)))
203 {iP->Loc.hfvec &= ~mask;
204 iP->Loc.pfvec &= ~mask;
205 if ((gone4good = (iP->Loc.hfvec == 0)))
206 {if (nilTMO) iP->Loc.lifeline = nilTMO + time(0);
207 if (!(Sel.Opts & XrdCmsSelect::Advisory)
208 && XrdCmsKeyItem::Unload(iP) && !CTable.Recycle(iP))
209 Say.Emsg("DelFile", "Delete failed for", iP->Key.Val);
210 }
211 } else gone4good = 0;
212
213// All done
214//
215 myMutex.UnLock();
216 return gone4good;
217}
static XrdCmsKeyItem * Unload(unsigned int theTock)
Definition XrdCmsKey.cc:172
char * Val
Definition XrdCmsKey.hh:52
int Recycle(XrdCmsKeyItem *rip)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdSysError Say

References XrdCmsSelect::Advisory, XrdSysError::Emsg(), XrdCmsNash::Find(), XrdCmsKeyLoc::hfvec, XrdCmsKeyItem::Key, XrdCmsKeyLoc::lifeline, XrdCmsKeyItem::Loc, XrdSysMutex::Lock(), XrdCmsSelect::Opts, XrdCmsSelect::Path, XrdCmsKeyLoc::pfvec, XrdCmsNash::Recycle(), XrdCms::Say, XrdCmsKeyItem::Unload(), XrdSysMutex::UnLock(), and XrdCmsKey::Val.

Referenced by XrdCmsNode::do_Gone(), XrdCmsNode::do_Mv(), XrdCmsNode::do_Rm(), and XrdCmsNode::do_Rmdir().

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

◆ Drop()

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

Definition at line 359 of file XrdCmsCache.cc.

360{
361 SMask_t nmask(~smask);
362
363// Remove the node from the path list
364//
365 Paths.Remove(smask);
366
367// Remove the node from the list of valid nodes
368//
369 myMutex.Lock();
370 Bounced[SNum] = 0;
371 okVec &= nmask;
372 vecHi = xHi;
373 myMutex.UnLock();
374}
XrdCmsPList_Anchor Paths
void Remove(SMask_t mask)

References XrdSysMutex::Lock(), Paths, XrdCmsPList_Anchor::Remove(), and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ GetFile()

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

Definition at line 232 of file XrdCmsCache.cc.

233{
234 XrdCmsKeyItem *iP;
235 SMask_t bVec;
236 int retc;
237
238// Lock the hash table
239//
240 myMutex.Lock();
241
242// Look up the entry and return location information
243//
244 if ((iP = CTable.Find(Sel.Path)))
245 {if ((bVec = (iP->Loc.TOD_B < BClock
246 ? getBVec(iP->Key.TOD, iP->Loc.TOD_B) & mask : 0)))
247 {iP->Loc.hfvec &= ~bVec;
248 iP->Loc.pfvec &= ~bVec;
249 iP->Loc.qfvec &= ~mask;
250 iP->Loc.deadline = QDelay + time(0);
251 iP->Loc.lifeline = nilTMO + iP->Loc.deadline;
252 retc = -1;
253 } else if (iP->Loc.deadline)
254 if (iP->Loc.deadline > time(0)) retc = -1;
255 else {iP->Loc.deadline = 0; retc = 1;}
256 else retc = 1;
257
258 if (nilTMO && retc == 1 && iP->Loc.hfvec == 0
259 && iP->Loc.lifeline <= time(0)) retc = 0;
260
261 Sel.Vec.hf = okVec & iP->Loc.hfvec;
262 Sel.Vec.pf = okVec & iP->Loc.pfvec;
263 Sel.Vec.bf = okVec & (bVec | iP->Loc.qfvec); iP->Loc.qfvec = 0;
264 Sel.Path.Ref = iP->Key.Ref;
265 } else retc = 0;
266
267// All done
268//
269 myMutex.UnLock();
270 Sel.Path.TODRef = iP;
271 return retc;
272}
struct XrdCmsSelect::@93 Vec

References XrdCmsNash::Find(), XrdCmsKeyLoc::hfvec, XrdCmsKeyItem::Key, XrdCmsKeyLoc::lifeline, XrdCmsKeyItem::Loc, XrdSysMutex::Lock(), XrdCmsSelect::Path, XrdCmsKeyLoc::pfvec, XrdCmsKeyLoc::qfvec, XrdCmsKey::Ref, XrdCmsKey::TOD, XrdCmsKeyLoc::TOD_B, XrdCmsKey::TODRef, XrdSysMutex::UnLock(), and XrdCmsSelect::Vec.

Referenced by XrdCmsNode::do_StateFWD(), XrdCmsCluster::Locate(), and XrdCmsCluster::Select().

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

◆ Init()

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

Definition at line 380 of file XrdCmsCache.cc.

381{
382 XrdCmsKeyItem *iP;
383 pthread_t tid;
384
385// Indicate whether we are a shared-everything setup as this changes how we
386// dispatch clients to newly discovered files (see Dispatch()).
387//
388 isDFS = seFS;
389
390// Initialize the delay time and the bounce clock tick window
391//
392 DLTime = fxDelay; QDelay = fxQuery;
393 if (!(Tick = fxHold/XrdCmsKeyItem::TickRate)) Tick = 1;
394
395// Set the timeout for nil entries if one needs to be set. Since this may cause
396// an infinite lookup delay, adjust it to be no less than 10 minutes longer
397// than the overall deadline for lookups (QDelay/fxQuery).
398//
399 if (nxHold)
400 {if (nxHold < fxQuery+min_nxTime) nxHold = fxQuery+min_nxTime;
401 nilTMO = static_cast<unsigned int>(nxHold);
402 }
403
404// Start the clock thread
405//
406 if (XrdSysThread::Run(&tid, XrdCmsStartTickTock, (void *)this,
407 0, "Cache Clock"))
408 {Say.Emsg("Init", errno, "start cache clock");
409 return 0;
410 }
411
412// Get the first reserve of cache items
413//
414 iP = XrdCmsKeyItem::Alloc(0);
415 XrdCmsKeyItem::Unload((unsigned int)0);
416 iP->Recycle();
417
418// All done
419//
420 return 1;
421}
void * XrdCmsStartTickTock(void *carg)
static const int min_nxTime
static XrdCmsKeyItem * Alloc(unsigned int theTock)
Definition XrdCmsKey.cc:71
static const unsigned int TickRate
Definition XrdCmsKey.hh:150
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)

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

Referenced by XrdCmsConfig::Configure2().

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

◆ TickTock()

void * XrdCmsCache::TickTock ( )

Definition at line 427 of file XrdCmsCache.cc.

428{
429 XrdCmsKeyItem *iP;
430
431// Simply adjust the clock and trim old entries
432//
433 do {XrdSysTimer::Snooze(Tick);
434 myMutex.Lock();
435 Tock = (Tock+1) & XrdCmsKeyItem::TickMask;
436 Bhistory[Tock].Start = Bhistory[Tock].End = 0;
437 iP = XrdCmsKeyItem::Unload(Tock);
438 myMutex.UnLock();
439 if (iP) Sched->Schedule((XrdJob *)new XrdCmsCacheJob(iP));
440 } while(1);
441
442// Keep compiler happy
443//
444 return (void *)0;
445}
friend class XrdCmsCacheJob
static const unsigned int TickMask
Definition XrdCmsKey.hh:151
void Schedule(XrdJob *jp)
static void Snooze(int seconds)
XrdScheduler * Sched

References XrdSysMutex::Lock(), XrdCms::Sched, XrdScheduler::Schedule(), XrdSysTimer::Snooze(), XrdCmsKeyItem::TickMask, XrdCmsKeyItem::Unload(), XrdSysMutex::UnLock(), 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.

279{
280 EPNAME("UnkFile");
281 XrdCmsKeyItem *iP;
282
283// Make sure we have the proper information. If so, lock the hash table
284//
285 myMutex.Lock();
286
287// Look up the entry and if valid update the unqueried vector. Note that
288// this method may only be called after GetFile() or AddFile() for a new entry
289//
290 if ((iP = Sel.Path.TODRef))
291 {if (iP->Key.Equiv(Sel.Path)) iP->Loc.qfvec = mask;
292 else iP = 0;
293 }
294
295// Return result
296//
297 myMutex.UnLock();
298 DEBUG("rc=" <<(iP ? 1 : 0) <<" path=" <<Sel.Path.Val);
299 return (iP ? 1 : 0);
300}
#define DEBUG(x)
#define EPNAME(x)

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

Referenced by XrdCmsCluster::Locate(), and XrdCmsCluster::Select().

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

◆ WT4File()

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

Definition at line 306 of file XrdCmsCache.cc.

307{
308 EPNAME("WT4File");
309 XrdCmsKeyItem *iP;
310 time_t Now;
311 int retc;
312
313// Make sure we have the proper information. If so, lock the hash table
314//
315 if (!Sel.InfoP) return DLTime;
316 myMutex.Lock();
317
318// Look up the entry and if valid add it to the callback queue. Note that
319// this method may only be called after GetFile() or AddFile() for a new entry
320//
321 if (!(iP = Sel.Path.TODRef) || !(iP->Key.Equiv(Sel.Path))) retc = DLTime;
322 else if (iP->Loc.hfvec != mask) retc = 1;
323 else {Now = time(0); retc = 0;
324 if (iP->Loc.deadline && iP->Loc.deadline <= Now)
325 iP->Loc.deadline = DLTime + Now;
326 Add2Q(Sel.InfoP, iP, Sel.Opts);
327 }
328
329// Return result
330//
331 myMutex.UnLock();
332 DEBUG("rc=" <<retc <<" path=" <<Sel.Path.Val);
333 return retc;
334}
XrdCmsRRQInfo * InfoP

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

Referenced by XrdCmsCluster::Locate(), and XrdCmsCluster::Select().

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

Friends And Related Symbol Documentation

◆ XrdCmsCacheJob

friend class XrdCmsCacheJob
friend

Definition at line 47 of file XrdCmsCache.hh.

Referenced by TickTock().

Member Data Documentation

◆ min_nxTime

const int XrdCmsCache::min_nxTime = 60
static

Definition at line 81 of file XrdCmsCache.hh.

Referenced by Init().

◆ Paths


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