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 <cstring>
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, int nxHold);
78 
79 void *TickTock();
80 
81 static const int min_nxTime = 60;
82 
83  XrdCmsCache() : 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  }
90  ~XrdCmsCache() {} // Never gets deleted
91 
92 private:
93 
94 void Add2Q(XrdCmsRRQInfo *Info, XrdCmsKeyItem *cp, int selOpts);
95 void Dispatch(XrdCmsSelect &Sel, XrdCmsKeyItem *cinfo,
96  short roQ, short rwQ);
97 SMask_t getBVec(unsigned int todA, unsigned int &todB);
98 void Recycle(XrdCmsKeyItem *theList);
99 
100 struct {SMask_t Vec;
101  unsigned int Start;
102  unsigned int End;
103  } Bhistory[XrdCmsKeyItem::TickRate];
104 
105 XrdSysMutex myMutex;
106 XrdCmsNash CTable;
107 unsigned int Bounced[STMax];
108 SMask_t okVec;
109 unsigned int Tick;
110 unsigned int Tock;
111 unsigned int BClock;
112  int nilTMO;
113  int DLTime;
114  int QDelay;
115  int Bhits;
116  int Bmiss;
117  int vecHi;
118  int isDFS;
119 };
120 
121 namespace XrdCms
122 {
123 extern XrdCmsCache Cache;
124 }
125 #endif
#define STMax
Definition: XrdCmsTypes.hh:39
unsigned long long SMask_t
Definition: XrdCmsTypes.hh:33
@ Info
void Bounce(SMask_t smask, int SNum)
Definition: XrdCmsCache.cc:343
int GetFile(XrdCmsSelect &Sel, SMask_t mask)
Definition: XrdCmsCache.cc:232
int DelFile(XrdCmsSelect &Sel, SMask_t mask)
Definition: XrdCmsCache.cc:191
int AddFile(XrdCmsSelect &Sel, SMask_t mask)
Definition: XrdCmsCache.cc:117
XrdCmsPList_Anchor Paths
Definition: XrdCmsCache.hh:49
int UnkFile(XrdCmsSelect &Sel, SMask_t mask)
Definition: XrdCmsCache.cc:278
void Drop(SMask_t mask, int SNum, int xHi)
Definition: XrdCmsCache.cc:359
int WT4File(XrdCmsSelect &Sel, SMask_t mask)
Definition: XrdCmsCache.cc:306
int Init(int fxHold, int fxDelay, int fxQuery, int seFS, int nxHold)
Definition: XrdCmsCache.cc:380
static const int min_nxTime
Definition: XrdCmsCache.hh:81
void * TickTock()
Definition: XrdCmsCache.cc:427
static const unsigned int TickRate
Definition: XrdCmsKey.hh:150
XrdCmsCache Cache
Definition: XrdPfcFile.hh:204