• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

XrdOlbCache.hh

Go to the documentation of this file.
00001 #ifndef __OLB_CACHE__H
00002 #define __OLB_CACHE__H
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d O l b C a c h e . h h                         */
00006 /*                                                                            */
00007 /* (c) 2003 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-AC03-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //         $Id: XrdOlbCache.hh,v 1.7 2007/07/26 15:18:23 ganis Exp $
00014   
00015 #include "Xrd/XrdJob.hh"
00016 #include "Xrd/XrdScheduler.hh"
00017 #include "XrdOlb/XrdOlbPList.hh"
00018 #include "XrdOlb/XrdOlbTypes.hh"
00019 #include "XrdOuc/XrdOucHash.hh"
00020 #include "XrdSys/XrdSysPthread.hh"
00021  
00022 /******************************************************************************/
00023 /*                     S t r u c t   o o l b _ C I n f o                      */
00024 /******************************************************************************/
00025   
00026 struct XrdOlbCInfo
00027        {SMask_t hfvec;    // Servers who are staging or have the file
00028         SMask_t pfvec;    // Servers who are staging         the file
00029         SMask_t sbvec;    // Servers that are suspect (eventually TOE clock)
00030         int     deadline;
00031         short   roPend;   // Redirectors waiting for R/O response
00032         short   rwPend;   // Redirectors waiting for R/W response
00033 
00034         XrdOlbCInfo() {roPend = rwPend = 0;}
00035        ~XrdOlbCInfo();
00036        };
00037 
00038 /******************************************************************************/
00039 /*                      C l a s s   o o l b _ C a c h e                       */
00040 /******************************************************************************/
00041 
00042 class XrdOlbRRQInfo;
00043   
00044 class XrdOlbCache
00045 {
00046 public:
00047 friend class XrdOlbCache_Scrubber;
00048 
00049 XrdOlbPList_Anchor Paths;
00050 
00051 // AddFile() returns true if this is the first addition, false otherwise
00052 //
00053 int        AddFile(const char *path, SMask_t mask, int isrw=-1, 
00054                    int dltime=0, XrdOlbRRQInfo *Info=0);
00055 
00056 // DelCache() deletes a specific cache line
00057 //
00058 void       DelCache(const char *path);
00059 
00060 // DelFile() returns true if this is the last deletion, false otherwise
00061 //
00062 int        DelFile(const char *path, SMask_t mask, int dltime=0);
00063 
00064 // GetFile() returns true if we actually found the file
00065 //
00066 int        GetFile(const char *path, XrdOlbCInfo &cinfo,
00067                    int isrw=0, XrdOlbRRQInfo *Info=0);
00068 
00069 void       Apply(int (*func)(const char *, XrdOlbCInfo *, void *), void *Arg);
00070 
00071 void       Bounce(SMask_t mask, char *path=0);
00072 
00073 void       Extract(const char *pathpfx, XrdOucHash<char> *hashp);
00074 
00075 void       Reset(int servid);
00076 
00077 void       Scrub();
00078 
00079 void       setLifetime(int lsec) {LifeTime = lsec;}
00080 
00081            XrdOlbCache() {LifeTime = 8*60*60;}
00082           ~XrdOlbCache() {}   // Never gets deleted
00083 
00084 private:
00085 
00086 void                    Add2Q(XrdOlbRRQInfo *Info, XrdOlbCInfo *cp, int isrw);
00087 void                    Dispatch(XrdOlbCInfo *cinfo, short roQ, short rwQ);
00088 XrdSysMutex             PTMutex;
00089 XrdOucHash<XrdOlbCInfo> PTable;
00090 int                     LifeTime;
00091 };
00092  
00093 /******************************************************************************/
00094 /*             C l a s s   o o l b _ C a c h e _ S c r u b b e r              */
00095 /******************************************************************************/
00096   
00097 class XrdOlbCache_Scrubber : public XrdJob
00098 {
00099 public:
00100 
00101 void  DoIt() {CacheP->Scrub();
00102               SchedP->Schedule((XrdJob *)this, CacheP->LifeTime+time(0));
00103              }
00104       XrdOlbCache_Scrubber(XrdOlbCache *cp, XrdScheduler *sp)
00105                         : XrdJob("File cache scrubber")
00106                 {CacheP = cp; SchedP = sp;}
00107      ~XrdOlbCache_Scrubber() {}
00108 
00109 private:
00110 
00111 XrdScheduler    *SchedP;
00112 XrdOlbCache     *CacheP;
00113 };
00114 
00115 namespace XrdOlb
00116 {
00117 extern    XrdOlbCache Cache;
00118 }
00119 #endif

Generated on Wed Sep 1 2010 for xrootd by  doxygen 1.7.1