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