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 
33 class XrdSysError;
34 
36 {
37 public:
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 
43 static const int maxSNlen = 63; // Maximum space name length (+1 for null)
44 static const int minSNbsz = 64;
45 
46 static void Adjust(int Gent, off_t Space, sType=Serv);
47 
48 static void Adjust(const char *GName, off_t Space, sType=Serv);
49 
50 static int Assign(const char *GName, long long &bytesUsed);
51 
52 static const int haveUsage = 1;
53 static const int haveQuota = 2;
54 
55 static int Init(); // Return the "or" of havexxxx (above)
56 
57 static int Init(const char *aPath, const char *qFile, int isSOL);
58 
59 static int Quotas();
60 
61 static int Readjust();
62 
63 static void Refresh();
64 
65 static int Unassign(const char *GName);
66 
67 static 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 
73 struct uEnt {char gName[minSNbsz];
74  long long Bytes[Totn]; // One of sType, above
75  };
76 
77 static long long Usage(const char *GName, struct uEnt &uVal, int rrd=0);
78 
79 private:
80 static int findEnt(const char *GName);
81 static int Readjust(int);
82 static int UsageLock(int Dolock=1);
83 
84 static const int ULen = sizeof(long long);
85 static const int DataSz = 16384;
86 static const int maxEnt = DataSz/sizeof(uEnt);
87 
88 static const char *qFname;
89 static const char *uFname;
90 static uEnt uData[maxEnt];
91 static short uDvec[maxEnt];
92 static time_t lastMtime;
93 static int fencEnt;
94 static int freeEnt;
95 static int aFD;
96 static int Solitary;
97 };
98 #endif
~XrdOssSpace()
Definition: XrdOssSpace.hh:71
Definition: XrdOssSpace.hh:40
static void Adjust(int Gent, off_t Space, sType=Serv)
static const int ULen
Definition: XrdOssSpace.hh:84
static const int haveUsage
Definition: XrdOssSpace.hh:52
static int freeEnt
Definition: XrdOssSpace.hh:94
Definition: XrdOssSpace.hh:39
Definition: XrdOssSpace.hh:39
static const int maxEnt
Definition: XrdOssSpace.hh:86
static const char * uFname
Definition: XrdOssSpace.hh:89
static const int haveQuota
Definition: XrdOssSpace.hh:53
char gName[minSNbsz]
Definition: XrdOssSpace.hh:73
static uEnt uData[maxEnt]
Definition: XrdOssSpace.hh:90
static int fencEnt
Definition: XrdOssSpace.hh:93
static short uDvec[maxEnt]
Definition: XrdOssSpace.hh:91
static int Quotas()
Definition: XrdSysError.hh:89
static time_t lastMtime
Definition: XrdOssSpace.hh:92
static int findEnt(const char *GName)
static const char * qFname
Definition: XrdOssSpace.hh:88
Definition: XrdOssSpace.hh:39
sType
Definition: XrdOssSpace.hh:39
Definition: XrdOssSpace.hh:40
static int Solitary
Definition: XrdOssSpace.hh:96
Definition: XrdOssSpace.hh:35
static int Readjust()
XrdOssSpace()
Definition: XrdOssSpace.hh:70
static void Refresh()
Definition: XrdOssSpace.hh:40
Definition: XrdOssSpace.hh:40
static const int minSNbsz
Definition: XrdOssSpace.hh:44
static int aFD
Definition: XrdOssSpace.hh:95
static const int DataSz
Definition: XrdOssSpace.hh:85
static int Init()
static const int maxSNlen
Definition: XrdOssSpace.hh:43
Definition: XrdOssSpace.hh:41
static int Assign(const char *GName, long long &bytesUsed)
Definition: XrdOssSpace.hh:73
long long Bytes[Totn]
Definition: XrdOssSpace.hh:74
static int Unassign(const char *GName)
Definition: XrdOssSpace.hh:39
static int UsageLock(int Dolock=1)
static long long Usage(int gent)
Definition: XrdOssSpace.hh:67