xrootd
XrdCmsCache.hh
Go to the documentation of this file.
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 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
00031 /******************************************************************************/
00032 
00033 #include <string.h>
00034   
00035 #include "Xrd/XrdJob.hh"
00036 #include "Xrd/XrdScheduler.hh"
00037 #include "XrdCms/XrdCmsKey.hh"
00038 #include "XrdCms/XrdCmsNash.hh"
00039 #include "XrdCms/XrdCmsPList.hh"
00040 #include "XrdSys/XrdSysPthread.hh"
00041 #include "XrdCms/XrdCmsSelect.hh"
00042 #include "XrdCms/XrdCmsTypes.hh"
00043   
00044 class XrdCmsCache
00045 {
00046 public:
00047 friend class XrdCmsCacheJob;
00048 
00049 XrdCmsPList_Anchor Paths;
00050 
00051 // AddFile() returns true if this is the first addition, false otherwise. See
00052 //           method for detailed information on processing.
00053 //
00054 int         AddFile(XrdCmsSelect &Sel, SMask_t mask);
00055 
00056 // DelFile() returns true if this is the last deletion, false otherwise
00057 //
00058 int         DelFile(XrdCmsSelect &Sel, SMask_t mask);
00059 
00060 // GetFile() returns true if we actually found the file
00061 //
00062 int         GetFile(XrdCmsSelect &Sel, SMask_t mask);
00063 
00064 // UnkFile() updates the unqueried vector and returns 1 upon success, 0 o/w.
00065 //
00066 int         UnkFile(XrdCmsSelect &Sel, SMask_t mask);
00067 
00068 // WT4File() adds a request to the callback queue and returns a 0 if added
00069 //           of a wait time to be returned to the client.
00070 //
00071 int         WT4File(XrdCmsSelect &Sel, SMask_t mask);
00072 
00073 void        Bounce(SMask_t smask, int SNum);
00074 
00075 void        Drop(SMask_t mask, int SNum, int xHi);
00076 
00077 int         Init(int fxHold, int fxDelay, int fxQuery, int seFS);
00078 
00079 void       *TickTock();
00080 
00081             XrdCmsCache() : okVec(0), Tick(8*60*60), Tock(0), BClock(0), 
00082                             DLTime(5), QDelay(5), Bhits(0), Bmiss(0), vecHi(-1),
00083                             isDFS(0)
00084                           {memset(Bounced,  0, sizeof(Bounced));
00085                            memset(Bhistory, 0, sizeof(Bhistory));
00086                           }
00087            ~XrdCmsCache() {}   // Never gets deleted
00088 
00089 private:
00090 
00091 void          Add2Q(XrdCmsRRQInfo *Info, XrdCmsKeyItem *cp, int isrw);
00092 void          Dispatch(XrdCmsSelect &Sel, XrdCmsKeyItem *cinfo,
00093                        short roQ, short rwQ);
00094 SMask_t       getBVec(unsigned int todA, unsigned int &todB);
00095 void          Recycle(XrdCmsKeyItem *theList);
00096 
00097 struct  {SMask_t      Vec;
00098          unsigned int Start;
00099          unsigned int End;
00100         }             Bhistory[XrdCmsKeyItem::TickRate];
00101 
00102 XrdSysMutex   myMutex;
00103 XrdCmsNash    CTable;
00104 unsigned int  Bounced[STMax];
00105 SMask_t       okVec;
00106 unsigned int  Tick;
00107 unsigned int  Tock;
00108 unsigned int  BClock;
00109          int  DLTime;
00110          int  QDelay;
00111          int  Bhits;
00112          int  Bmiss;
00113          int  vecHi;
00114          int  isDFS;
00115 };
00116 
00117 namespace XrdCms
00118 {
00119 extern    XrdCmsCache Cache;
00120 }
00121 #endif