xrootd
XrdCmsCache.hh
Go to the documentation of this file.
1 #ifndef __CMS_CACHE__H
2 #define __CMS_CACHE__H
3 /******************************************************************************/
4 /* */
5 /* X r d C m s C a c h e . h h */
6 /* */
7 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 #include <string.h>
14 
15 #include "Xrd/XrdJob.hh"
16 #include "Xrd/XrdScheduler.hh"
17 #include "XrdCms/XrdCmsKey.hh"
18 #include "XrdCms/XrdCmsNash.hh"
19 #include "XrdCms/XrdCmsPList.hh"
20 #include "XrdSys/XrdSysPthread.hh"
21 #include "XrdCms/XrdCmsSelect.hh"
22 #include "XrdCms/XrdCmsTypes.hh"
23 
25 {
26 public:
27 friend class XrdCmsCacheJob;
28 
30 
31 // AddFile() returns true if this is the first addition, false otherwise. See
32 // method for detailed information on processing.
33 //
34 int AddFile(XrdCmsSelect &Sel, SMask_t mask);
35 
36 // DelFile() returns true if this is the last deletion, false otherwise
37 //
38 int DelFile(XrdCmsSelect &Sel, SMask_t mask);
39 
40 // GetFile() returns true if we actually found the file
41 //
42 int GetFile(XrdCmsSelect &Sel, SMask_t mask);
43 
44 // UnkFile() updates the unqueried vector and returns 1 upon success, 0 o/w.
45 //
46 int UnkFile(XrdCmsSelect &Sel, SMask_t mask);
47 
48 // WT4File() adds a request to the callback queue and returns a 0 if added
49 // of a wait time to be returned to the client.
50 //
51 int WT4File(XrdCmsSelect &Sel, SMask_t mask);
52 
53 void Bounce(SMask_t smask, int SNum);
54 
55 void Drop(SMask_t mask, int SNum, int xHi);
56 
57 int Init(int fxHold, int fxDelay, int fxQuery, int seFS);
58 
59 void *TickTock();
60 
61  XrdCmsCache() : okVec(0), Tick(8*60*60), Tock(0), BClock(0),
62  DLTime(5), Bhits(0), Bmiss(0), vecHi(-1), isDFS(0)
63  {memset(Bounced, 0, sizeof(Bounced));
64  memset(Bhistory, 0, sizeof(Bhistory));
65  }
66  ~XrdCmsCache() {} // Never gets deleted
67 
68 private:
69 
70 void Add2Q(XrdCmsRRQInfo *Info, XrdCmsKeyItem *cp, int isrw);
71 void Dispatch(XrdCmsSelect &Sel, XrdCmsKeyItem *cinfo,
72  short roQ, short rwQ);
73 SMask_t getBVec(unsigned int todA, unsigned int &todB);
74 void Recycle(XrdCmsKeyItem *theList);
75 
76 struct {SMask_t Vec;
77  unsigned int Start;
78  unsigned int End;
80 
83 unsigned int Bounced[STMax];
85 unsigned int Tick;
86 unsigned int Tock;
87 unsigned int BClock;
88  int DLTime;
89  int QDelay;
90  int Bhits;
91  int Bmiss;
92  int vecHi;
93  int isDFS;
94 };
95 
96 namespace XrdCms
97 {
98 extern XrdCmsCache Cache;
99 }
100 #endif