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 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <string.h>
34 
35 #include "Xrd/XrdJob.hh"
36 #include "Xrd/XrdScheduler.hh"
37 #include "XrdCms/XrdCmsKey.hh"
38 #include "XrdCms/XrdCmsNash.hh"
39 #include "XrdCms/XrdCmsPList.hh"
40 #include "XrdSys/XrdSysPthread.hh"
41 #include "XrdCms/XrdCmsSelect.hh"
42 #include "XrdCms/XrdCmsTypes.hh"
43 
45 {
46 public:
47 friend class XrdCmsCacheJob;
48 
50 
51 // AddFile() returns true if this is the first addition, false otherwise. See
52 // method for detailed information on processing.
53 //
54 int AddFile(XrdCmsSelect &Sel, SMask_t mask);
55 
56 // DelFile() returns true if this is the last deletion, false otherwise
57 //
58 int DelFile(XrdCmsSelect &Sel, SMask_t mask);
59 
60 // GetFile() returns true if we actually found the file
61 //
62 int GetFile(XrdCmsSelect &Sel, SMask_t mask);
63 
64 // UnkFile() updates the unqueried vector and returns 1 upon success, 0 o/w.
65 //
66 int UnkFile(XrdCmsSelect &Sel, SMask_t mask);
67 
68 // WT4File() adds a request to the callback queue and returns a 0 if added
69 // of a wait time to be returned to the client.
70 //
71 int WT4File(XrdCmsSelect &Sel, SMask_t mask);
72 
73 void Bounce(SMask_t smask, int SNum);
74 
75 void Drop(SMask_t mask, int SNum, int xHi);
76 
77 int Init(int fxHold, int fxDelay, int fxQuery, int seFS);
78 
79 void *TickTock();
80 
81  XrdCmsCache() : okVec(0), Tick(8*60*60), Tock(0), BClock(0),
82  DLTime(5), QDelay(5), Bhits(0), Bmiss(0), vecHi(-1),
83  isDFS(0)
84  {memset(Bounced, 0, sizeof(Bounced));
85  memset(Bhistory, 0, sizeof(Bhistory));
86  }
87  ~XrdCmsCache() {} // Never gets deleted
88 
89 private:
90 
91 void Add2Q(XrdCmsRRQInfo *Info, XrdCmsKeyItem *cp, int isrw);
92 void Dispatch(XrdCmsSelect &Sel, XrdCmsKeyItem *cinfo,
93  short roQ, short rwQ);
94 SMask_t getBVec(unsigned int todA, unsigned int &todB);
95 void Recycle(XrdCmsKeyItem *theList);
96 
97 struct {SMask_t Vec;
98  unsigned int Start;
99  unsigned int End;
101 
104 unsigned int Bounced[STMax];
106 unsigned int Tick;
107 unsigned int Tock;
108 unsigned int BClock;
109  int DLTime;
110  int QDelay;
111  int Bhits;
112  int Bmiss;
113  int vecHi;
114  int isDFS;
115 };
116 
117 namespace XrdCms
118 {
119 extern XrdCmsCache Cache;
120 }
121 #endif