xrootd
|
00001 #ifndef __CMS_CACHE__H 00002 #define __CMS_CACHE__H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s C a c h e . h h */ 00006 /* */ 00007 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id$ 00014 00015 #include <string.h> 00016 00017 #include "Xrd/XrdJob.hh" 00018 #include "Xrd/XrdScheduler.hh" 00019 #include "XrdCms/XrdCmsKey.hh" 00020 #include "XrdCms/XrdCmsNash.hh" 00021 #include "XrdCms/XrdCmsPList.hh" 00022 #include "XrdSys/XrdSysPthread.hh" 00023 #include "XrdCms/XrdCmsSelect.hh" 00024 #include "XrdCms/XrdCmsTypes.hh" 00025 00026 class XrdCmsCache 00027 { 00028 public: 00029 friend class XrdCmsCacheJob; 00030 00031 XrdCmsPList_Anchor Paths; 00032 00033 // AddFile() returns true if this is the first addition, false otherwise. See 00034 // method for detailed information on processing. 00035 // 00036 int AddFile(XrdCmsSelect &Sel, SMask_t mask); 00037 00038 // DelFile() returns true if this is the last deletion, false otherwise 00039 // 00040 int DelFile(XrdCmsSelect &Sel, SMask_t mask); 00041 00042 // GetFile() returns true if we actually found the file 00043 // 00044 int GetFile(XrdCmsSelect &Sel, SMask_t mask); 00045 00046 // UnkFile() updates the unqueried vector and returns 1 upon success, 0 o/w. 00047 // 00048 int UnkFile(XrdCmsSelect &Sel, SMask_t mask); 00049 00050 // WT4File() adds a request to the callback queue and returns a 0 if added 00051 // of a wait time to be returned to the client. 00052 // 00053 int WT4File(XrdCmsSelect &Sel, SMask_t mask); 00054 00055 void Bounce(SMask_t smask, int SNum); 00056 00057 void Drop(SMask_t mask, int SNum, int xHi); 00058 00059 int Init(int fxHold, int fxDelay); 00060 00061 void *TickTock(); 00062 00063 XrdCmsCache() : okVec(0), Tick(8*60*60), Tock(0), BClock(0), 00064 DLTime(5), Bhits(0), Bmiss(0), vecHi(-1) 00065 {memset(Bounced, 0, sizeof(Bounced)); 00066 memset(Bhistory, 0, sizeof(Bhistory)); 00067 } 00068 ~XrdCmsCache() {} // Never gets deleted 00069 00070 private: 00071 00072 void Add2Q(XrdCmsRRQInfo *Info, XrdCmsKeyItem *cp, int isrw); 00073 void Dispatch(XrdCmsKeyItem *cinfo, short roQ, short rwQ); 00074 SMask_t getBVec(unsigned int todA, unsigned int &todB); 00075 void Recycle(XrdCmsKeyItem *theList); 00076 00077 struct {SMask_t Vec; 00078 unsigned int Start; 00079 unsigned int End; 00080 } Bhistory[XrdCmsKeyItem::TickRate]; 00081 00082 XrdSysMutex myMutex; 00083 XrdCmsNash CTable; 00084 unsigned int Bounced[STMax]; 00085 SMask_t okVec; 00086 unsigned int Tick; 00087 unsigned int Tock; 00088 unsigned int BClock; 00089 int DLTime; 00090 int Bhits; 00091 int Bmiss; 00092 int vecHi; 00093 }; 00094 00095 namespace XrdCms 00096 { 00097 extern XrdCmsCache Cache; 00098 } 00099 #endif