XRootD
Loading...
Searching...
No Matches
XrdCmsBaseFS.hh
Go to the documentation of this file.
1
#ifndef __CMS_BASEFS_H__
2
#define __CMS_BASEFS_H__
3
/******************************************************************************/
4
/* */
5
/* X r d C m s B a s e F S . h h */
6
/* */
7
/* (c) 2011 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 <cstdlib>
34
#include <cstring>
35
36
#include "
XrdCms/XrdCmsPList.hh
"
37
#include "
XrdCms/XrdCmsRRData.hh
"
38
#include "
XrdCms/XrdCmsTypes.hh
"
39
#include "
XrdOuc/XrdOucHash.hh
"
40
#include "
XrdSys/XrdSysPthread.hh
"
41
42
/******************************************************************************/
43
/* C l a s s X r d C m s B a s e F R */
44
/******************************************************************************/
45
46
class
XrdCmsPInfo
;
47
48
class
XrdCmsBaseFR
49
{
50
public
:
51
52
SMask_t
Route
;
53
SMask_t
RouteW
;
54
XrdCmsBaseFR
*
Next
;
55
char
*
Buff
;
56
char
*
Path
;
57
short
PathLen
;
58
short
PDirLen
;
59
kXR_unt32
Sid
;
60
kXR_char
Mod
;
61
62
XrdCmsBaseFR
(
XrdCmsRRData
&Arg,
XrdCmsPInfo
&Who,
int
Dln)
63
:
Route
(Who.rovec),
RouteW
(Who.rwvec),
Next
(0),
64
PathLen
(Arg.
PathLen
),
PDirLen
(Dln),
65
Sid
(Arg.Request.streamid),
66
Mod
(Arg.Request.modifier)
67
{
if
(Arg.
Buff
)
68
{
Path
=Arg.
Path
;
Buff
=Arg.
Buff
; Arg.
Buff
=0;}
69
else
Buff
=
Path
= strdup(Arg.
Path
);
70
}
71
72
XrdCmsBaseFR
(
XrdCmsRRData
*aP,
XrdCmsPInfo
&Who,
int
Dln)
73
:
Route
(Who.rovec),
RouteW
(Who.rwvec),
74
Next
(0),
Buff
(0),
Path
(aP->
Path
),
75
PathLen
(aP->
PathLen
),
PDirLen
(Dln),
76
Sid
(aP->Request.streamid),
77
Mod
(aP->Request.modifier)
78
{}
79
80
~XrdCmsBaseFR
() {
if
(
Buff
) free(
Buff
);
Buff
= 0;}
81
};
82
83
/******************************************************************************/
84
/* C l a s s X r d C m s B a s e F S */
85
/******************************************************************************/
86
87
class
XrdCmsBaseFS
88
{
89
public
:
90
91
int
dfsTries
() {
return
dfsMaxTries;}
92
93
// Exists() returns a tri-logic state:
94
// CmsHaveRequest::Online -> File is known to exist and is available
95
// CmsHaveRequest::Pending -> File is known to exist but is not available
96
// 0 -> File state unknown, result will be provided later
97
// -1 -> File is known not to exist
98
//
99
int
Exists
(
XrdCmsRRData
&Arg,
XrdCmsPInfo
&Who,
int
noLim=0);
100
101
// The following exists works as above but limits are never enforced and it
102
// never returns 0. Additionally, the fnpos parameter works as follows:
103
//
104
// > 0 -> Offset into path to the last slash before the filename.
105
// = 0 -> A valid offset has not been calculated nor should it be calculated.
106
// < 0 -> A valid offset has not been calculated, fnpos = -(length of Path).
107
108
int
Exists
(
char
*
Path
,
int
fnPos,
int
UpAT=0);
109
110
// Valid Opts for Init()
111
//
112
static
const
int
Cntrl
= 0x0001;
// Centralize stat() o/w distribute it
113
static
const
int
DFSys
= 0x0002;
// Distributed filesystem o/w jbods
114
static
const
int
Immed
= 0x0004;
// Redirect immediately o/w preselect
115
static
const
int
Servr
= 0x0100;
// This is a pure server node
116
117
void
Init
(
int
Opts,
int
DMlife,
int
DPLife);
118
119
inline
int
isDFS
() {
return
dfsSys;}
120
121
inline
int
Limit
() {
return
theQ.rLimit;}
122
123
void
Limit
(
int
rLim,
int
qMax);
124
125
inline
int
Local
() {
return
lclStat;}
126
127
void
Pacer
();
128
129
void
Runner
();
130
131
static
const
int
dfltDfsTries
= 2;
132
static
const
int
dfltStgTries
= 3;
133
134
void
SetTries
(
bool
xdfs,
int
tcnt)
135
{
if
(xdfs) dfsMaxTries =
136
(tcnt < 0 ?
dfltDfsTries
: tcnt);
137
else
stgMaxTries =
138
(tcnt < 1 ?
dfltStgTries
: tcnt);
139
}
140
141
void
Start
();
142
143
int
stgTries
() {
return
stgMaxTries;}
144
145
inline
int
Trim
() {
return
preSel;}
146
147
inline
int
Traverse
() {
return
Punt;}
148
149
XrdCmsBaseFS
(
void
(*theCB)(
XrdCmsBaseFR
*,
int
))
150
: cBack(theCB), dfsMaxTries(
dfltDfsTries
),
151
stgMaxTries(
dfltStgTries
),
152
dmLife(0), dpLife(0), lclStat(0), preSel(1),
153
dfsSys(0), Server(0), Fixed(0), Punt(0) {}
154
~XrdCmsBaseFS
() {}
155
156
private
:
157
158
struct
dMoP {
int
Present;};
159
160
int
Bypass();
161
int
FStat(
char
*
Path
,
int
fnPos,
int
upat=0);
162
int
hasDir(
char
*
Path
,
int
fnPos);
163
void
Queue(
XrdCmsRRData
&Arg,
XrdCmsPInfo
&Who,
164
int
dln,
int
Frc=0);
165
void
Xeq(
XrdCmsBaseFR
*rP);
166
167
XrdSysMutex
fsMutex;
168
XrdOucHash<dMoP>
fsDirMP;
169
void (*cBack)(
XrdCmsBaseFR
*, int);
170
171
struct
RequestQ
172
{
XrdSysMutex
Mutex;
173
XrdSysSemaphore
pqAvail;
174
XrdSysSemaphore
rqAvail;
175
XrdCmsBaseFR
*pqFirst;
176
XrdCmsBaseFR
*pqLast;
177
XrdCmsBaseFR
*rqFirst;
178
XrdCmsBaseFR
*rqLast;
179
int
rLimit;
// Maximum number of requests per second
180
int
qHWM;
// Queue high watermark
181
int
qMax;
// Maximum elements to be queued
182
int
qNum;
// Total number of queued elements (pq + rq)
183
int
rLeft;
// Number of non-queue requests allowed
184
int
rAgain;
// Value to reinitialize rLeft
185
RequestQ() : pqAvail(0), rqAvail(0),
186
pqFirst(0), pqLast(0), rqFirst(0), rqLast(0),
187
rLimit(0), qHWM(0), qMax(1), qNum(0),
188
rLeft(0), rAgain(0) {}
189
~RequestQ() {}
190
} theQ;
191
192
int
dfsMaxTries;
193
int
stgMaxTries;
194
int
dmLife;
195
int
dpLife;
196
char
lclStat;
// 1-> Local stat() calls wanted
197
char
preSel;
// 1-> Preselect before redirect
198
char
dfsSys;
// 1-> Distributed Filesystem
199
char
Server;
// 1-> This is a data server
200
char
Fixed;
// 1-> Use fixed rate processing
201
char
Punt;
// 1-> Pass through any forwarding
202
};
203
namespace
XrdCms
204
{
205
extern
XrdCmsBaseFS
baseFS
;
206
}
207
#endif
kXR_unt32
unsigned int kXR_unt32
Definition
XPtypes.hh:90
kXR_char
unsigned char kXR_char
Definition
XPtypes.hh:65
XrdCmsPList.hh
XrdCmsRRData.hh
XrdCmsTypes.hh
SMask_t
unsigned long long SMask_t
Definition
XrdCmsTypes.hh:33
XrdOucHash.hh
Exists
bool Exists
Definition
XrdSecgsiProxy.cc:97
Path
XrdOucString Path
Definition
XrdSecpwdSrvAdmin.cc:160
XrdSysPthread.hh
XrdCmsBaseFR
Definition
XrdCmsBaseFS.hh:49
XrdCmsBaseFR::Mod
kXR_char Mod
Definition
XrdCmsBaseFS.hh:60
XrdCmsBaseFR::XrdCmsBaseFR
XrdCmsBaseFR(XrdCmsRRData &Arg, XrdCmsPInfo &Who, int Dln)
Definition
XrdCmsBaseFS.hh:62
XrdCmsBaseFR::PathLen
short PathLen
Definition
XrdCmsBaseFS.hh:57
XrdCmsBaseFR::XrdCmsBaseFR
XrdCmsBaseFR(XrdCmsRRData *aP, XrdCmsPInfo &Who, int Dln)
Definition
XrdCmsBaseFS.hh:72
XrdCmsBaseFR::Path
char * Path
Definition
XrdCmsBaseFS.hh:56
XrdCmsBaseFR::Sid
kXR_unt32 Sid
Definition
XrdCmsBaseFS.hh:59
XrdCmsBaseFR::PDirLen
short PDirLen
Definition
XrdCmsBaseFS.hh:58
XrdCmsBaseFR::~XrdCmsBaseFR
~XrdCmsBaseFR()
Definition
XrdCmsBaseFS.hh:80
XrdCmsBaseFR::Buff
char * Buff
Definition
XrdCmsBaseFS.hh:55
XrdCmsBaseFR::RouteW
SMask_t RouteW
Definition
XrdCmsBaseFS.hh:53
XrdCmsBaseFR::Route
SMask_t Route
Definition
XrdCmsBaseFS.hh:52
XrdCmsBaseFR::Next
XrdCmsBaseFR * Next
Definition
XrdCmsBaseFS.hh:54
XrdCmsBaseFS
Definition
XrdCmsBaseFS.hh:88
XrdCmsBaseFS::Traverse
int Traverse()
Definition
XrdCmsBaseFS.hh:147
XrdCmsBaseFS::~XrdCmsBaseFS
~XrdCmsBaseFS()
Definition
XrdCmsBaseFS.hh:154
XrdCmsBaseFS::dfltStgTries
static const int dfltStgTries
Definition
XrdCmsBaseFS.hh:132
XrdCmsBaseFS::Pacer
void Pacer()
Definition
XrdCmsBaseFS.cc:278
XrdCmsBaseFS::dfltDfsTries
static const int dfltDfsTries
Definition
XrdCmsBaseFS.hh:131
XrdCmsBaseFS::dfsTries
int dfsTries()
Definition
XrdCmsBaseFS.hh:91
XrdCmsBaseFS::Local
int Local()
Definition
XrdCmsBaseFS.hh:125
XrdCmsBaseFS::isDFS
int isDFS()
Definition
XrdCmsBaseFS.hh:119
XrdCmsBaseFS::stgTries
int stgTries()
Definition
XrdCmsBaseFS.hh:143
XrdCmsBaseFS::Start
void Start()
Definition
XrdCmsBaseFS.cc:379
XrdCmsBaseFS::SetTries
void SetTries(bool xdfs, int tcnt)
Definition
XrdCmsBaseFS.hh:134
XrdCmsBaseFS::Immed
static const int Immed
Definition
XrdCmsBaseFS.hh:114
XrdCmsBaseFS::Runner
void Runner()
Definition
XrdCmsBaseFS.cc:354
XrdCmsBaseFS::Limit
int Limit()
Definition
XrdCmsBaseFS.hh:121
XrdCmsBaseFS::Servr
static const int Servr
Definition
XrdCmsBaseFS.hh:115
XrdCmsBaseFS::Init
void Init(int Opts, int DMlife, int DPLife)
Definition
XrdCmsBaseFS.cc:245
XrdCmsBaseFS::XrdCmsBaseFS
XrdCmsBaseFS(void(*theCB)(XrdCmsBaseFR *, int))
Definition
XrdCmsBaseFS.hh:149
XrdCmsBaseFS::Trim
int Trim()
Definition
XrdCmsBaseFS.hh:145
XrdCmsBaseFS::Cntrl
static const int Cntrl
Definition
XrdCmsBaseFS.hh:112
XrdCmsBaseFS::DFSys
static const int DFSys
Definition
XrdCmsBaseFS.hh:113
XrdCmsPInfo
Definition
XrdCmsPList.hh:45
XrdCmsRRData
Definition
XrdCmsRRData.hh:52
XrdCmsRRData::Buff
char * Buff
Definition
XrdCmsRRData.hh:71
XrdCmsRRData::Path
char * Path
Definition
XrdCmsRRData.hh:55
XrdOucHash
Definition
XrdOucHash.hh:128
XrdSysMutex
Definition
XrdSysPthread.hh:165
XrdSysSemaphore
Definition
XrdSysPthread.hh:494
XrdCms
Definition
YProtocol.hh:78
XrdCms::baseFS
XrdCmsBaseFS baseFS
XrdCms
XrdCmsBaseFS.hh
Generated by
1.10.0