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