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, 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;
104 
107 unsigned int Bounced[STMax];
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
Definition: YProtocol.hh:77
Definition: XrdCmsNash.hh:35
void Dispatch(XrdCmsSelect &Sel, XrdCmsKeyItem *cinfo, short roQ, short rwQ)
int GetFile(XrdCmsSelect &Sel, SMask_t mask)
static const unsigned int TickRate
Definition: XrdCmsKey.hh:150
int UnkFile(XrdCmsSelect &Sel, SMask_t mask)
Definition: XrdCmsPList.hh:95
~XrdCmsCache()
Definition: XrdCmsCache.hh:90
unsigned int Tock
Definition: XrdCmsCache.hh:110
void * TickTock()
int DelFile(XrdCmsSelect &Sel, SMask_t mask)
friend class XrdCmsCacheJob
Definition: XrdCmsCache.hh:47
struct XrdCmsCache::@69 Bhistory[XrdCmsKeyItem::TickRate]
unsigned int End
Definition: XrdCmsCache.hh:102
SMask_t getBVec(unsigned int todA, unsigned int &todB)
int Bhits
Definition: XrdCmsCache.hh:115
int AddFile(XrdCmsSelect &Sel, SMask_t mask)
unsigned int BClock
Definition: XrdCmsCache.hh:111
XrdCmsNash CTable
Definition: XrdCmsCache.hh:106
int nilTMO
Definition: XrdCmsCache.hh:112
SMask_t Vec
Definition: XrdCmsCache.hh:100
Definition: XrdCmsKey.hh:125
int WT4File(XrdCmsSelect &Sel, SMask_t mask)
unsigned int Start
Definition: XrdCmsCache.hh:101
void Recycle(XrdCmsKeyItem *theList)
Definition: XrdSysPthread.hh:165
int isDFS
Definition: XrdCmsCache.hh:118
int QDelay
Definition: XrdCmsCache.hh:114
int DLTime
Definition: XrdCmsCache.hh:113
Definition: XrdCmsCache.hh:44
unsigned long long SMask_t
Definition: XrdCmsTypes.hh:33
XrdCmsCache Cache
XrdCmsPList_Anchor Paths
Definition: XrdCmsCache.hh:49
SMask_t okVec
Definition: XrdCmsCache.hh:108
#define STMax
Definition: XrdCmsTypes.hh:39
int vecHi
Definition: XrdCmsCache.hh:117
void Drop(SMask_t mask, int SNum, int xHi)
XrdSysMutex myMutex
Definition: XrdCmsCache.hh:105
unsigned int Bounced[STMax]
Definition: XrdCmsCache.hh:107
XrdCmsCache()
Definition: XrdCmsCache.hh:83
Definition: XrdMacaroonsHandler.hh:18
int Bmiss
Definition: XrdCmsCache.hh:116
Definition: XrdCmsRRQ.hh:46
void Bounce(SMask_t smask, int SNum)
unsigned int Tick
Definition: XrdCmsCache.hh:109
void Add2Q(XrdCmsRRQInfo *Info, XrdCmsKeyItem *cp, int selOpts)
Definition: XrdCmsSelect.hh:43
static const int min_nxTime
Definition: XrdCmsCache.hh:81
int Init(int fxHold, int fxDelay, int fxQuery, int seFS, int nxHold)