XRootD
Loading...
Searching...
No Matches
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
39class XrdFrmFileset;
40class XrdOucPolProg;
41class XrdOucStream;
42class XrdOucTList;
43
45{
46public:
47
48static void Display();
49
50static int Init(XrdOucTList *sP=0, long long minV=-1, int hVal=-1);
51
52static XrdFrmPurge *Policy(const char *sname) {return Find(sname);}
53static XrdFrmPurge *Policy(const char *sname, long long minV, long long maxV,
54 int hVal, int xVal);
55
56static void Purge();
57
58 XrdFrmPurge(const char *snp, XrdFrmPurge *spp=0);
59 ~XrdFrmPurge() {Clear();}
60
61private:
62
63// Methods
64//
65static void Add(XrdFrmFileset *fsp);
66 XrdFrmFileset*Advance();
67 void Clear();
68 void Defer(XrdFrmFileset *sP, time_t xTime);
69const char *Eligible(XrdFrmFileset *sP, time_t &xTime, int hTime=0);
70static XrdFrmPurge *Find(const char *snp);
71static int LowOnSpace();
72 int PurgeFile();
73 int PurgeFile(XrdFrmFileset *fP, const char *pFN);
74static void Scan();
75static void Stats(int Final);
76 void Track(XrdFrmFileset *sP);
77const char *XPolOK(XrdFrmFileset *sP);
78static XrdOucProg *PolProg;
79static XrdOucStream *PolStream;
80
81// Static Variables
82
83static time_t lastReset;
84static time_t nextReset;
85
86static XrdFrmPurge *First;
87static XrdFrmPurge *Default;
88
89static int Left2Do;
90
91// Variables local to each object
92//
93long long freeSpace; // Current free space
94long long fconMaxsp; // Current free space contiguous
95long long usedSpace; // Curreny used space (if supported)
96long long pmaxSpace; // PMax space (computed once)
97long long totlSpace; // Total space (computed once)
98long long contSpace; // Total contg (computed once)
99long long purgBytes; // Purged bytes on last purge cycle
100long long minFSpace; // Minimum free space
101long long maxFSpace; // Maximum free space (what we purge to)
102char *spaceTotl;
103char *spaceTotP;
104int spaceTLen;
105int spaceTLep;
106int Hold; // Hold value
107int Hold2x; // Hold x2 (what we actually use)
108int Ext; // External policy applies
109int numFiles; // Total number of files
110int prgFiles; // Total number of purged
111int Enabled;
112int Stop;
113int SNlen;
114
115XrdFrmPurge *Next;
116XrdFrmTSort FSTab;
117char SName[XrdOssSpace::minSNbsz];
118
119static const int DeferQsz = 16;
120XrdFrmFileset *DeferQ[DeferQsz];
121time_t DeferT[DeferQsz];
122};
123#endif
static void Purge()
static XrdFrmPurge * Policy(const char *sname)
static void Display()
static int Init(XrdOucTList *sP=0, long long minV=-1, int hVal=-1)
static const int minSNbsz