XRootD
Loading...
Searching...
No Matches
XrdOssArcBackup.hh
Go to the documentation of this file.
1#ifndef _XRDOSSARC_BACKUP_HH_
2#define _XRDOSSARC_BACKUP_HH_
3/******************************************************************************/
4/* */
5/* X r d O s s B a c k u p . 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#include <set>
35#include <string>
36
37#include "Xrd/XrdJob.hh"
38
40
41/******************************************************************************/
42/* X r d O s s A r c B a c k u p T a s k */
43/******************************************************************************/
44
45class XrdOssArcBackup;
46
48{
49public:
50
52const char* theScope;
53 char* theDSN;
54 size_t numBytes;
58
59 XrdOssArcBackupTask(XrdOssArcBackup& who, char* dsn);
61
62 bool BkpXeq();
63};
64
65/******************************************************************************/
66/* X r d O s s A r c B a c k u p */
67/******************************************************************************/
68
69class XrdOssArcBackup : public XrdJob
70{
72public:
73
74bool Archive(const char* dsName, const char* dsDir);
75
76const
77char* Arena() {return myArena;}
78
79void DoIt() override;
80
81static
82void StartWorkers(int maxw);
83
84const
85char* theScope() {return Scope;}
86
87 XrdOssArcBackup(const char* scp, bool& isOK);
89
90private:
91
92 bool Add2Bkp(const char* dsn);
93 int GetManifest();
94
95const char* Scope;
96 char* myArena;
97
98static XrdSysMutex dsBkpQMtx;
99static std::deque<XrdOssArcBackupTask*> dsBkpQ;
100static XrdSysCondVar2 dsBkpQCV;
101
102static int numRunning;
103static int maxRunning;
104
105class BkpWorker : public XrdJob
106{
107public:
108
109void DoIt() override;
110
111 BkpWorker() {}
112 ~BkpWorker() {} // Never deleted
113};
114
115struct cmp_str
116{
117 bool operator()(char const *a, char const *b) const
118 {
119 return std::strcmp(a, b) < 0;
120 }
121};
122
123XrdSysMutex dsBkpSetMtx;
124std::set<const char*, cmp_str> dsBkpSet;
125};
126#endif
XrdJob(const char *desc="")
Definition XrdJob.hh:51
virtual void DoIt()=0
XrdOssArcBackupTask(XrdOssArcBackup &who, char *dsn)
XrdOssArcBackup & Owner
XrdSysSemaphore btSem
void DoIt() override
XrdOssArcBackup(const char *scp, bool &isOK)
const char * theScope()
const char * Arena()
bool Archive(const char *dsName, const char *dsDir)
friend class XrdOssArcBackupTask
static void StartWorkers(int maxw)