xrootd
|
00001 #ifndef __FRMPURGE__ 00002 #define __FRMPURGE__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d F r m P u r g e . 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 <time.h> 00014 #include <sys/types.h> 00015 00016 #include "XrdFrmUtil/XrdFrmTSort.hh" 00017 #include "XrdOss/XrdOssSpace.hh" 00018 00019 class XrdFrmFileset; 00020 class XrdOucPolProg; 00021 class XrdOucStream; 00022 class XrdOucTList; 00023 00024 class XrdFrmPurge 00025 { 00026 public: 00027 00028 static void Display(); 00029 00030 static int Init(XrdOucTList *sP=0, long long minV=-1, int hVal=-1); 00031 00032 static XrdFrmPurge *Policy(const char *sname) {return Find(sname);} 00033 static XrdFrmPurge *Policy(const char *sname, long long minV, long long maxV, 00034 int hVal, int xVal); 00035 00036 static void Purge(); 00037 00038 XrdFrmPurge(const char *snp, XrdFrmPurge *spp=0); 00039 ~XrdFrmPurge() {Clear();} 00040 00041 private: 00042 00043 // Methods 00044 // 00045 static void Add(XrdFrmFileset *fsp); 00046 XrdFrmFileset*Advance(); 00047 void Clear(); 00048 void Defer(XrdFrmFileset *sP, time_t xTime); 00049 const char *Eligible(XrdFrmFileset *sP, time_t &xTime, int hTime=0); 00050 static XrdFrmPurge *Find(const char *snp); 00051 static int LowOnSpace(); 00052 int PurgeFile(); 00053 static void Scan(); 00054 static void Stats(int Final); 00055 void Track(XrdFrmFileset *sP); 00056 const char *XPolOK(XrdFrmFileset *sP); 00057 static XrdOucProg *PolProg; 00058 static XrdOucStream *PolStream; 00059 00060 // Static Variables 00061 00062 static time_t lastReset; 00063 static time_t nextReset; 00064 00065 static XrdFrmPurge *First; 00066 static XrdFrmPurge *Default; 00067 00068 static int Left2Do; 00069 00070 // Variables local to each object 00071 // 00072 long long freeSpace; // Current free space 00073 long long fconMaxsp; // Current free space contiguous 00074 long long usedSpace; // Curreny used space (if supported) 00075 long long pmaxSpace; // PMax space (computed once) 00076 long long totlSpace; // Total space (computed once) 00077 long long contSpace; // Total contg (computed once) 00078 long long purgBytes; // Purged bytes on last purge cycle 00079 long long minFSpace; // Minimum free space 00080 long long maxFSpace; // Maximum free space (what we purge to) 00081 char *spaceTotl; 00082 char *spaceTotP; 00083 int spaceTLen; 00084 int spaceTLep; 00085 int Hold; // Hold value 00086 int Hold2x; // Hold x2 (what we actually use) 00087 int Ext; // External policy applies 00088 int numFiles; // Total number of files 00089 int prgFiles; // Total number of purged 00090 int Enabled; 00091 int Stop; 00092 int SNlen; 00093 00094 XrdFrmPurge *Next; 00095 XrdFrmTSort FSTab; 00096 char SName[XrdOssSpace::minSNbsz]; 00097 00098 static const int DeferQsz = 16; 00099 XrdFrmFileset *DeferQ[DeferQsz]; 00100 time_t DeferT[DeferQsz]; 00101 }; 00102 #endif