xrootd
XrdFrmPurge.hh
Go to the documentation of this file.
1 #ifndef __FRMPURGE__
2 #define __FRMPURGE__
3 /******************************************************************************/
4 /* */
5 /* X r d F r m P u r g e . h h */
6 /* */
7 /* (c) 2009 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 #include <time.h>
14 #include <sys/types.h>
15 
16 #include "XrdFrm/XrdFrmTSort.hh"
17 #include "XrdOss/XrdOssSpace.hh"
18 
19 class XrdFrmFileset;
20 class XrdOucPolProg;
21 class XrdOucStream;
22 class XrdOucTList;
23 
25 {
26 public:
27 
28 static void Display();
29 
30 static int Init(XrdOucTList *sP=0, long long minV=-1, int hVal=-1);
31 
32 static XrdFrmPurge *Policy(const char *sname) {return Find(sname);}
33 static XrdFrmPurge *Policy(const char *sname, long long minV, long long maxV,
34  int hVal, int xVal);
35 
36 static void Purge();
37 
38  XrdFrmPurge(const char *snp, XrdFrmPurge *spp=0);
40 
41 private:
42 
43 // Methods
44 //
45 static void Add(XrdFrmFileset *fsp);
47  void Clear();
48  void Defer(XrdFrmFileset *sP, time_t xTime);
49 const char *Eligible(XrdFrmFileset *sP, time_t &xTime, int hTime=0);
50 static XrdFrmPurge *Find(const char *snp);
51 static int LowOnSpace();
52  int PurgeFile();
53  int PurgeFile(XrdFrmFileset *fP, const char *pFN);
54 static void Scan();
55 static void Stats(int Final);
56  void Track(XrdFrmFileset *sP);
57 const char *XPolOK(XrdFrmFileset *sP);
60 
61 // Static Variables
62 
63 static time_t lastReset;
64 static time_t nextReset;
65 
68 
69 static int Left2Do;
70 
71 // Variables local to each object
72 //
73 long long freeSpace; // Current free space
74 long long fconMaxsp; // Current free space contiguous
75 long long usedSpace; // Curreny used space (if supported)
76 long long pmaxSpace; // PMax space (computed once)
77 long long totlSpace; // Total space (computed once)
78 long long contSpace; // Total contg (computed once)
79 long long purgBytes; // Purged bytes on last purge cycle
80 long long minFSpace; // Minimum free space
81 long long maxFSpace; // Maximum free space (what we purge to)
82 char *spaceTotl;
83 char *spaceTotP;
86 int Hold; // Hold value
87 int Hold2x; // Hold x2 (what we actually use)
88 int Ext; // External policy applies
89 int numFiles; // Total number of files
90 int prgFiles; // Total number of purged
91 int Enabled;
92 int Stop;
93 int SNlen;
94 
98 
99 static const int DeferQsz = 16;
101 time_t DeferT[DeferQsz];
102 };
103 #endif