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 
13 // $Id$
14 
15 class XrdSysError;
16 
18 {
19 public:
20 
21  enum sType {Serv = 0, Pstg = 1, Purg = 2, Admin = 3,
22  RsvA = 4, RsvB = 5, RsvC = 6, addT = 7,
23  Totn = 8};
24 
25 static const int maxSNlen = 63; // Maximum space name length (+1 for null)
26 static const int minSNbsz = 64;
27 
28 static void Adjust(int Gent, off_t Space, sType=Serv);
29 
30 static void Adjust(const char *GName, off_t Space, sType=Serv);
31 
32 static int Assign(const char *GName, long long &bytesUsed);
33 
34 static const int haveUsage = 1;
35 static const int haveQuota = 2;
36 
37 static int Init(); // Return the "or" of havexxxx (above)
38 
39 static int Init(const char *aPath, const char *qFile, int isSOL);
40 
41 static int Quotas();
42 
43 static int Readjust();
44 
45 static void Refresh();
46 
47 static int Unassign(const char *GName);
48 
49 static long long Usage(int gent) {return (gent < 0 || gent >= maxEnt
50  ? 0 : uData[gent].Bytes[Serv]);}
51 
52  XrdOssSpace() {} // Everything is static
53  ~XrdOssSpace() {} // Never gets deleted
54 
55 struct uEnt {char gName[minSNbsz];
56  long long Bytes[Totn]; // One of sType, above
57  };
58 
59 static long long Usage(const char *GName, struct uEnt &uVal, int rrd=0);
60 
61 private:
62 static int findEnt(const char *GName);
63 static int Readjust(int);
64 static int UsageLock(int Dolock=1);
65 
66 static const int ULen = sizeof(long long);
67 static const int DataSz = 16384;
68 static const int maxEnt = DataSz/sizeof(uEnt);
69 
70 static const char *qFname;
71 static const char *uFname;
72 static uEnt uData[maxEnt];
73 static short uDvec[maxEnt];
74 static time_t lastMtime;
75 static int fencEnt;
76 static int freeEnt;
77 static int aFD;
78 static int Solitary;
79 };
80 #endif