xrootd
XrdOssSpace.hh
Go to the documentation of this file.
1#ifndef _OSS_SPACE_H
2#define _OSS_SPACE_H
3/******************************************************************************/
4/* */
5/* X r d O s s S p a c e . h h */
6/* */
7/* (c) 2008 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
33class XrdSysError;
34
36{
37public:
38
39 enum sType {Serv = 0, Pstg = 1, Purg = 2, Admin = 3,
40 RsvA = 4, RsvB = 5, RsvC = 6, addT = 7,
41 Totn = 8};
42
43static const int maxSNlen = 63; // Maximum space name length (+1 for null)
44static const int minSNbsz = 64;
45
46static void Adjust(int Gent, off_t Space, sType=Serv);
47
48static void Adjust(const char *GName, off_t Space, sType=Serv);
49
50static int Assign(const char *GName, long long &bytesUsed);
51
52static const int haveUsage = 1;
53static const int haveQuota = 2;
54
55static int Init(); // Return the "or" of havexxxx (above)
56
57static int Init(const char *aPath, const char *qFile, int isSOL);
58
59static int Quotas();
60
61static int Readjust();
62
63static void Refresh();
64
65static int Unassign(const char *GName);
66
67static long long Usage(int gent) {return (gent < 0 || gent >= maxEnt
68 ? 0 : uData[gent].Bytes[Serv]);}
69
70 XrdOssSpace() {} // Everything is static
71 ~XrdOssSpace() {} // Never gets deleted
72
73struct uEnt {char gName[minSNbsz];
74 long long Bytes[Totn]; // One of sType, above
75 };
76
77static long long Usage(const char *GName, struct uEnt &uVal, int rrd=0);
78
79private:
80static int findEnt(const char *GName);
81static int Readjust(int);
82static int UsageLock(int Dolock=1);
83
84static const int ULen = sizeof(long long);
85static const int DataSz = 16384;
86static const int maxEnt = DataSz/sizeof(uEnt);
87
88static const char *qFname;
89static const char *uFname;
91static short uDvec[maxEnt];
92static time_t lastMtime;
93static int fencEnt;
94static int freeEnt;
95static int aFD;
96static int Solitary;
97};
98#endif
Definition: XrdOssSpace.hh:36
static int freeEnt
Definition: XrdOssSpace.hh:94
static int Unassign(const char *GName)
static short uDvec[maxEnt]
Definition: XrdOssSpace.hh:91
static void Refresh()
static int Solitary
Definition: XrdOssSpace.hh:96
static const char * uFname
Definition: XrdOssSpace.hh:89
static void Adjust(const char *GName, off_t Space, sType=Serv)
static int Quotas()
static int Init(const char *aPath, const char *qFile, int isSOL)
sType
Definition: XrdOssSpace.hh:39
@ RsvC
Definition: XrdOssSpace.hh:40
@ Serv
Definition: XrdOssSpace.hh:39
@ RsvA
Definition: XrdOssSpace.hh:40
@ Purg
Definition: XrdOssSpace.hh:39
@ Totn
Definition: XrdOssSpace.hh:41
@ RsvB
Definition: XrdOssSpace.hh:40
@ Pstg
Definition: XrdOssSpace.hh:39
@ addT
Definition: XrdOssSpace.hh:40
@ Admin
Definition: XrdOssSpace.hh:39
static void Adjust(int Gent, off_t Space, sType=Serv)
static long long Usage(const char *GName, struct uEnt &uVal, int rrd=0)
static time_t lastMtime
Definition: XrdOssSpace.hh:92
static const int minSNbsz
Definition: XrdOssSpace.hh:44
static int findEnt(const char *GName)
static const char * qFname
Definition: XrdOssSpace.hh:88
static uEnt uData[maxEnt]
Definition: XrdOssSpace.hh:90
static const int haveQuota
Definition: XrdOssSpace.hh:53
static const int maxEnt
Definition: XrdOssSpace.hh:86
XrdOssSpace()
Definition: XrdOssSpace.hh:70
static long long Usage(int gent)
Definition: XrdOssSpace.hh:67
static int Readjust(int)
static int UsageLock(int Dolock=1)
static const int DataSz
Definition: XrdOssSpace.hh:85
~XrdOssSpace()
Definition: XrdOssSpace.hh:71
static const int haveUsage
Definition: XrdOssSpace.hh:52
static int fencEnt
Definition: XrdOssSpace.hh:93
static int Init()
static int Assign(const char *GName, long long &bytesUsed)
static int Readjust()
static const int maxSNlen
Definition: XrdOssSpace.hh:43
static int aFD
Definition: XrdOssSpace.hh:95
static const int ULen
Definition: XrdOssSpace.hh:84
Definition: XrdSysError.hh:90
Definition: XrdOssSpace.hh:73
char gName[minSNbsz]
Definition: XrdOssSpace.hh:73
long long Bytes[Totn]
Definition: XrdOssSpace.hh:74