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"
38#include "XrdCms/XrdCmsTypes.hh"
39#include "XrdOuc/XrdOucHash.hh"
41
42/******************************************************************************/
43/* C l a s s X r d C m s B a s e F R */
44/******************************************************************************/
45
46class XrdCmsPInfo;
47
49{
50public:
51
55char *Buff;
56char *Path;
57short PathLen;
58short PDirLen;
61
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
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
88{
89public:
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//
112static const int Cntrl = 0x0001; // Centralize stat() o/w distribute it
113static const int DFSys = 0x0002; // Distributed filesystem o/w jbods
114static const int Immed = 0x0004; // Redirect immediately o/w preselect
115static const int Servr = 0x0100; // This is a pure server node
116
117 void Init(int Opts, int DMlife, int DPLife);
118
119inline int isDFS() {return dfsSys;}
120
121inline int Limit() {return theQ.rLimit;}
122
123 void Limit(int rLim, int qMax);
124
125inline int Local() {return lclStat;}
126
127 void Pacer();
128
129 void Runner();
130
131static const int dfltDfsTries = 2;
132static 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
145inline int Trim() {return preSel;}
146
147inline int Traverse() {return Punt;}
148
149 XrdCmsBaseFS(void (*theCB)(XrdCmsBaseFR *, int))
150 : cBack(theCB), dfsMaxTries(dfltDfsTries),
152 dmLife(0), dpLife(0), lclStat(0), preSel(1),
153 dfsSys(0), Server(0), Fixed(0), Punt(0) {}
155
156private:
157
158struct dMoP {int Present;};
159
160 int Bypass();
161 int FStat( char *Path, int fnPos, int upat=0);
162 int hasDir(char *Path, int fnPos);
164 int dln, int Frc=0);
165 void Xeq(XrdCmsBaseFR *rP);
166
169 void (*cBack)(XrdCmsBaseFR *, int);
170
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
186 pqFirst(0), pqLast(0), rqFirst(0), rqLast(0),
187 rLimit(0), qHWM(0), qMax(1), qNum(0),
188 rLeft(0), rAgain(0) {}
191
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};
203namespace XrdCms
204{
205extern XrdCmsBaseFS baseFS;
206}
207#endif
unsigned int kXR_unt32
Definition XPtypes.hh:90
unsigned char kXR_char
Definition XPtypes.hh:65
unsigned long long SMask_t
Definition XrdCmsTypes.hh:33
Definition XrdCmsBaseFS.hh:49
kXR_char Mod
Definition XrdCmsBaseFS.hh:60
XrdCmsBaseFR(XrdCmsRRData &Arg, XrdCmsPInfo &Who, int Dln)
Definition XrdCmsBaseFS.hh:62
short PathLen
Definition XrdCmsBaseFS.hh:57
XrdCmsBaseFR(XrdCmsRRData *aP, XrdCmsPInfo &Who, int Dln)
Definition XrdCmsBaseFS.hh:72
char * Path
Definition XrdCmsBaseFS.hh:56
kXR_unt32 Sid
Definition XrdCmsBaseFS.hh:59
short PDirLen
Definition XrdCmsBaseFS.hh:58
~XrdCmsBaseFR()
Definition XrdCmsBaseFS.hh:80
char * Buff
Definition XrdCmsBaseFS.hh:55
SMask_t RouteW
Definition XrdCmsBaseFS.hh:53
SMask_t Route
Definition XrdCmsBaseFS.hh:52
XrdCmsBaseFR * Next
Definition XrdCmsBaseFS.hh:54
Definition XrdCmsBaseFS.hh:88
int Traverse()
Definition XrdCmsBaseFS.hh:147
char preSel
Definition XrdCmsBaseFS.hh:197
char lclStat
Definition XrdCmsBaseFS.hh:196
~XrdCmsBaseFS()
Definition XrdCmsBaseFS.hh:154
static const int dfltStgTries
Definition XrdCmsBaseFS.hh:132
int dpLife
Definition XrdCmsBaseFS.hh:195
int dfsMaxTries
Definition XrdCmsBaseFS.hh:192
char dfsSys
Definition XrdCmsBaseFS.hh:198
int FStat(char *Path, int fnPos, int upat=0)
XrdOucHash< dMoP > fsDirMP
Definition XrdCmsBaseFS.hh:168
int dmLife
Definition XrdCmsBaseFS.hh:194
static const int dfltDfsTries
Definition XrdCmsBaseFS.hh:131
int dfsTries()
Definition XrdCmsBaseFS.hh:91
int Local()
Definition XrdCmsBaseFS.hh:125
int isDFS()
Definition XrdCmsBaseFS.hh:119
int stgMaxTries
Definition XrdCmsBaseFS.hh:193
int stgTries()
Definition XrdCmsBaseFS.hh:143
void Xeq(XrdCmsBaseFR *rP)
char Punt
Definition XrdCmsBaseFS.hh:201
void SetTries(bool xdfs, int tcnt)
Definition XrdCmsBaseFS.hh:134
struct XrdCmsBaseFS::RequestQ theQ
static const int Immed
Definition XrdCmsBaseFS.hh:114
int Limit()
Definition XrdCmsBaseFS.hh:121
void(* cBack)(XrdCmsBaseFR *, int)
Definition XrdCmsBaseFS.hh:169
int Exists(XrdCmsRRData &Arg, XrdCmsPInfo &Who, int noLim=0)
static const int Servr
Definition XrdCmsBaseFS.hh:115
void Queue(XrdCmsRRData &Arg, XrdCmsPInfo &Who, int dln, int Frc=0)
void Init(int Opts, int DMlife, int DPLife)
int Exists(char *Path, int fnPos, int UpAT=0)
XrdCmsBaseFS(void(*theCB)(XrdCmsBaseFR *, int))
Definition XrdCmsBaseFS.hh:149
char Fixed
Definition XrdCmsBaseFS.hh:200
int Trim()
Definition XrdCmsBaseFS.hh:145
int hasDir(char *Path, int fnPos)
char Server
Definition XrdCmsBaseFS.hh:199
void Limit(int rLim, int qMax)
static const int Cntrl
Definition XrdCmsBaseFS.hh:112
XrdSysMutex fsMutex
Definition XrdCmsBaseFS.hh:167
static const int DFSys
Definition XrdCmsBaseFS.hh:113
Definition XrdCmsPList.hh:45
Definition XrdCmsRRData.hh:52
char * Buff
Definition XrdCmsRRData.hh:71
char * Path
Definition XrdCmsRRData.hh:55
Definition XrdOucHash.hh:128
Definition XrdSysPthread.hh:165
Definition XrdSysPthread.hh:494
Definition YProtocol.hh:78
XrdCmsBaseFS baseFS
Definition XrdCmsBaseFS.hh:172
XrdCmsBaseFR * pqLast
Definition XrdCmsBaseFS.hh:176
RequestQ()
Definition XrdCmsBaseFS.hh:185
int rLeft
Definition XrdCmsBaseFS.hh:183
XrdSysMutex Mutex
Definition XrdCmsBaseFS.hh:172
int qNum
Definition XrdCmsBaseFS.hh:182
int qHWM
Definition XrdCmsBaseFS.hh:180
XrdSysSemaphore pqAvail
Definition XrdCmsBaseFS.hh:173
XrdCmsBaseFR * rqFirst
Definition XrdCmsBaseFS.hh:177
int qMax
Definition XrdCmsBaseFS.hh:181
XrdCmsBaseFR * pqFirst
Definition XrdCmsBaseFS.hh:175
int rAgain
Definition XrdCmsBaseFS.hh:184
int rLimit
Definition XrdCmsBaseFS.hh:179
~RequestQ()
Definition XrdCmsBaseFS.hh:189
XrdSysSemaphore rqAvail
Definition XrdCmsBaseFS.hh:174
XrdCmsBaseFR * rqLast
Definition XrdCmsBaseFS.hh:178
Definition XrdCmsBaseFS.hh:158
int Present
Definition XrdCmsBaseFS.hh:158