XRootD
XrdOssArcFSMon.hh
Go to the documentation of this file.
1 #ifndef _XRDOSSACFSMON_H
2 #define _XRDOSSACFSMON_H
3 /******************************************************************************/
4 /* */
5 /* X r d O s s A r c F S M o n . h h */
6 /* */
7 /* (c) 2024 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 <deque>
34 
35 #include "Xrd/XrdJob.hh"
36 
37 #include "XrdSys/XrdSysPthread.hh"
38 
40 
41 class XrdOssArcFSMon : public XrdJob
42 {
43 public:
44 
45 void DoIt() override;
46 
47 bool Init(const char* path, long long fVal, int fsupdt);
48 
49 bool Permit(XrdOssArcBackupTask* btP);
50 
51 void Release(size_t bytes);
52 
53  XrdOssArcFSMon() : fs_inBkp(0) {}
55 
56 private:
57 
58 size_t getFSpace(size_t &Size, const char *path);
59 
60 XrdSysMutex rmMutex;
61 std::deque<XrdOssArcBackupTask*> btWaitQ;
62 
63 const char* fs_Path;
64 
65 size_t fs_inBkp; // Bytes currently committed for backup
66 size_t fs_inUse; // Bytes currently in use (Size - Free) since last update
67 
68 size_t fs_MaxUsed; // Maximum used space allowed in bytes
69 size_t fs_MinFree; // Minimum free space allowed in bytes
70 
71 size_t fs_Free; // Filesystem free in bytes
72 size_t fs_Size; // Filesystem size in bytes
73 
74 int fs_Updt; // Interval between async free space updates
75 };
76 #endif
Definition: XrdJob.hh:43
void Release(size_t bytes)
bool Permit(XrdOssArcBackupTask *btP)
void DoIt() override
bool Init(const char *path, long long fVal, int fsupdt)