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 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <ctime>
34 #include <sys/types.h>
35 
36 #include "XrdFrm/XrdFrmTSort.hh"
37 #include "XrdOss/XrdOssSpace.hh"
38 
39 class XrdFrmFileset;
40 class XrdOucPolProg;
41 class XrdOucStream;
42 class XrdOucTList;
43 
45 {
46 public:
47 
48 static void Display();
49 
50 static int Init(XrdOucTList *sP=0, long long minV=-1, int hVal=-1);
51 
52 static XrdFrmPurge *Policy(const char *sname) {return Find(sname);}
53 static XrdFrmPurge *Policy(const char *sname, long long minV, long long maxV,
54  int hVal, int xVal);
55 
56 static void Purge();
57 
58  XrdFrmPurge(const char *snp, XrdFrmPurge *spp=0);
59  ~XrdFrmPurge() {Clear();}
60 
61 private:
62 
63 // Methods
64 //
65 static void Add(XrdFrmFileset *fsp);
66  XrdFrmFileset*Advance();
67  void Clear();
68  void Defer(XrdFrmFileset *sP, time_t xTime);
69 const char *Eligible(XrdFrmFileset *sP, time_t &xTime, int hTime=0);
70 static XrdFrmPurge *Find(const char *snp);
71 static int LowOnSpace();
72  int PurgeFile();
73  int PurgeFile(XrdFrmFileset *fP, const char *pFN);
74 static void Scan();
75 static void Stats(int Final);
76  void Track(XrdFrmFileset *sP);
77 const char *XPolOK(XrdFrmFileset *sP);
78 static XrdOucProg *PolProg;
79 static XrdOucStream *PolStream;
80 
81 // Static Variables
82 
83 static time_t lastReset;
84 static time_t nextReset;
85 
86 static XrdFrmPurge *First;
87 static XrdFrmPurge *Default;
88 
89 static int Left2Do;
90 
91 // Variables local to each object
92 //
93 long long freeSpace; // Current free space
94 long long fconMaxsp; // Current free space contiguous
95 long long usedSpace; // Curreny used space (if supported)
96 long long pmaxSpace; // PMax space (computed once)
97 long long totlSpace; // Total space (computed once)
98 long long contSpace; // Total contg (computed once)
99 long long purgBytes; // Purged bytes on last purge cycle
100 long long minFSpace; // Minimum free space
101 long long maxFSpace; // Maximum free space (what we purge to)
102 char *spaceTotl;
103 char *spaceTotP;
104 int spaceTLen;
105 int spaceTLep;
106 int Hold; // Hold value
107 int Hold2x; // Hold x2 (what we actually use)
108 int Ext; // External policy applies
109 int numFiles; // Total number of files
110 int prgFiles; // Total number of purged
111 int Enabled;
112 int Stop;
113 int SNlen;
114 
115 XrdFrmPurge *Next;
116 XrdFrmTSort FSTab;
117 char SName[XrdOssSpace::minSNbsz];
118 
119 static const int DeferQsz = 16;
120 XrdFrmFileset *DeferQ[DeferQsz];
121 time_t DeferT[DeferQsz];
122 };
123 #endif
static void Purge()
Definition: XrdFrmPurge.cc:586
static void Display()
Definition: XrdFrmPurge.cc:295
static int Init(XrdOucTList *sP=0, long long minV=-1, int hVal=-1)
Definition: XrdFrmPurge.cc:409
XrdFrmPurge(const char *snp, XrdFrmPurge *spp=0)
Definition: XrdFrmPurge.cc:164
static XrdFrmPurge * Policy(const char *sname)
Definition: XrdFrmPurge.hh:52
static const int minSNbsz
Definition: XrdOssSpace.hh:45
FinalOperation Final