xrootd
XrdFrmFiles.hh
Go to the documentation of this file.
00001 #ifndef __FRMFILES__HH
00002 #define __FRMFILES__HH
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d F r m F i l e s . h h                         */
00006 /*                                                                            */
00007 /* (c) 2009 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 #include <string.h>
00014 #include <sys/types.h>
00015 
00016 #include "XrdFrm/XrdFrmXAttr.hh"
00017 #include "XrdOss/XrdOssPath.hh"
00018 #include "XrdOuc/XrdOucHash.hh"
00019 #include "XrdOuc/XrdOucNSWalk.hh"
00020 #include "XrdOuc/XrdOucXAttr.hh"
00021 
00022 class  XrdOucTList;
00023 
00024 /******************************************************************************/
00025 /*                   C l a s s   X r d F r m F i l e s e t                    */
00026 /******************************************************************************/
00027   
00028 class  XrdFrmFileset
00029 {
00030 public:
00031 friend class XrdFrmFiles;
00032 
00033 // The following are the extended attributes describing file characteristics
00034 //
00035 XrdOucXAttr<XrdFrmXAttrCpy> cpyInfo;   // Last copy time
00036 XrdOucXAttr<XrdFrmXAttrPin> pinInfo;   // Pin information
00037 
00038 // These are inline function to return most common file information
00039 //
00040 inline XrdOucNSWalk::NSEnt *baseFile() {return File[XrdOssPath::isBase];}
00041 const  char                *basePath() {return Mkfn(baseFile());}
00042 inline XrdOucNSWalk::NSEnt *failFile() {return File[XrdOssPath::isFail];}
00043 const  char                *failPath() {return Mkfn(failFile());}
00044 inline XrdOucNSWalk::NSEnt *lockFile() {return File[XrdOssPath::isLock];}
00045 const  char                *lockPath() {return Mkfn(lockFile());}
00046 inline XrdOucNSWalk::NSEnt * pfnFile() {return File[XrdOssPath::isPfn ];}
00047 const  char                * pfnPath() {return Mkfn(pfnFile());}
00048 inline XrdOucNSWalk::NSEnt * pinFile() {return File[XrdOssPath::isPin ];}
00049 const  char                * pinPath() {return Mkfn(pinFile());}
00050 
00051 inline XrdOucNSWalk::NSEnt * xyzFile(XrdOssPath::theSfx sfx) {return File[sfx];}
00052 const  char                * xyzPath(XrdOssPath::theSfx sfx)
00053                                     {return Mkfn(File[sfx]);}
00054 
00055 int                         dirPath(char *dBuff, int dBlen);
00056 
00057 static void                 Purge() {BadFiles.Purge();}
00058 
00059 int                         Refresh(int isMig=0, int doLock=1);
00060 
00061 int                         Screen(int needLF=1);
00062 
00063 int                         setCpyTime(int Refresh=0);
00064 
00065                      XrdFrmFileset(XrdFrmFileset *sP=0, XrdOucTList *diP=0);
00066                     ~XrdFrmFileset();
00067 
00068 // The following are public to ease management of this object
00069 //
00070 XrdFrmFileset *Next;
00071 int            Age;
00072 
00073 private:
00074 int         chkLock(const char *Path);
00075 const char *Mkfn(XrdOucNSWalk::NSEnt *fP);
00076 void        Remfix(const char *fType, const char *fPath);
00077 
00078 // These are the basic set of files related to the base file. Two other file
00079 // suffixes are ignore for fileset purposes (".anew" and ".stage").
00080 //
00081 XrdOucNSWalk::NSEnt *File[XrdOssPath::sfxNum];
00082 
00083 XrdOucTList         *dInfo;     // Shared directory information
00084 
00085 static XrdOucHash<char> BadFiles;
00086 
00087 static const int     dLen = 0;  // Index to directory path length in dInfo
00088 static const int     dRef = 1;  // Index to the reference counter in dInfo
00089 };
00090 
00091 /******************************************************************************/
00092 /*                     C l a s s   X r d F r m F i l e s                      */
00093 /******************************************************************************/
00094   
00095 class  XrdFrmFiles
00096 {
00097 public:
00098 
00099 XrdFrmFileset *Get(int &rc, int noBase=0);
00100 
00101 static const int Recursive = 0x0001;   // List filesets recursively
00102 static const int CompressD = 0x0002;   // Use shared directory object (not MT)
00103 static const int NoAutoDel = 0x0004;   // Do not automatically delete objects
00104 static const int GetCpyTim = 0x0008;   // Initialize cpyInfo attribute on Get()
00105 
00106             XrdFrmFiles(const char *dname, int opts=Recursive,
00107                         XrdOucTList *XList=0, XrdOucNSWalk::CallBack *cbP=0);
00108 
00109            ~XrdFrmFiles();
00110 
00111 private:
00112 void Complain(const char *dPath);
00113 int  oldFile(XrdOucNSWalk::NSEnt *fP, XrdOucTList *dP, int fType);
00114 int  Process(XrdOucNSWalk::NSEnt *nP, const char *dPath);
00115 
00116 XrdOucHash<XrdFrmFileset>fsTab;
00117 
00118 XrdOucNSWalk             nsObj;
00119 XrdFrmFileset           *fsList;
00120 XrdOucHash_Options       manMem;
00121 int                      shareD;
00122 int                      getCPT;
00123 };
00124 #endif