xrootd
Loading...
Searching...
No Matches
XrdCmsClient.hh
Go to the documentation of this file.
1#ifndef __CMS_CLIENT__
2#define __CMS_CLIENT__
3/******************************************************************************/
4/* */
5/* X r d C m s C l i e n t . h h */
6/* */
7/* (c) 2007 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
33class XrdOucEnv;
34class XrdOucErrInfo;
35class XrdOucLogger;
36class XrdOucTList;
37struct XrdSfsPrep;
38class XrdSysLogger;
39
40/******************************************************************************/
41/* R e t u r n C o n v e n t i o n s */
42/******************************************************************************/
43
44/* The following return conventions are use by Forward(), Locate(), & Prepare()
45 Return Val Resp.errcode Resp.errtext
46 --------- ------------------- --------
47 SFS_DATA Length of data. Data to be returned to caller.
48 Action: Caller is provided data as successful response.
49
50 SFS_ERROR errno Error message text.
51 Action: Caller given error response.
52
53 SFS_REDIRECT port (0 for default) Host name
54 Action: Caller is redirected to <host>:<port>
55
56 SFS_STARTED Expected seconds n/a
57 Action: Caller is told to wait for the "expected seconds" for a
58 callback with the result. A callback must follow.
59 See how to do callbacks below.
60
61 > 0 Wait time (= retval) Reason for wait
62 Action: Caller told to wait retval seconds and retry request.
63
64 < 0 Error number Error message
65 Action: Same as SFS_ERROR. You should *always* use SFS_ERROR.
66
67 = 0 Not applicable Not applicable (see below)
68 Action: Forward() -> Return success; request forwarded.
69 Locate() -> Redirection does not apply, operation
70 should be done against local file system.
71 Prepare() -> Return success, request submitted.
72*/
73
74/******************************************************************************/
75/* C a l l b a c k C o n v e n t i o n s */
76/******************************************************************************/
77
78/* Most operations allow you to return SFS_STARTED to setup a callback.
79 Callback information is contained in the XrdOucErrInfo object passed to
80 Forward(), Locate() and Prepare(); the only methods that can apply callbacks.
81 Use a callback when the operation will take at least several seconds so as
82 to not occupy the calling thread for an excessive amount of time.
83
84 The actual mechanics of a callback are rather complicated because callbacks
85 are subject to non-causaility if not correctly handled. In order to avoid
86 such issues, you should use the XrdOucCallBack object (see XrdOucCallBack.hh)
87 to test for applicability, setup, and effect a callback.
88
89 When calling back, you return the same information you would have returned
90 had the execution path been synchronous. From that standpoint callbacks are
91 relatively easy to understand. All you are doing is defering the return of
92 information without occupying a thread while waiting to do so.
93
94 A typical scenario, using Resp and the original ErrInfo object, would be....
95
96 XrdOucCallBack cbObject; // Must be persistent for the callback duration
97
98 if (XrdOucCallBack::Allowed(Resp))
99 {cbObject.Init(Resp);
100 <hand off the cbObject to a thread that will perform the work>
101 Resp.setErrCode(<seconds end-point should wait>);
102 return SFS_STARTED; // Effect callback response!
103 }
104
105 Once the thread doing the work has a result, send it via a callback as if
106 the work was done in a synchronous fashion.
107
108 cbObject->Reply(retValue, ErrCodeValue, ErrTextValue);
109*/
110
111/******************************************************************************/
112/* C l a s s X r d C m s C l i e n t */
113/******************************************************************************/
114
116{
117public:
118
119//------------------------------------------------------------------------------
126//------------------------------------------------------------------------------
127
128virtual void Added(const char *path, int Pend=0) { (void)path; (void)Pend; }
129
130//------------------------------------------------------------------------------
140//------------------------------------------------------------------------------
141
142virtual int Configure(const char *cfn, char *Parms, XrdOucEnv *EnvInfo) = 0;
143
144//------------------------------------------------------------------------------
171//------------------------------------------------------------------------------
172
173virtual int Forward(XrdOucErrInfo &Resp, const char *cmd,
174 const char *arg1=0, const char *arg2=0,
175 XrdOucEnv *Env1=0, XrdOucEnv *Env2=0)
176{
177 (void)Resp; (void)cmd; (void)arg1; (void)arg2; (void)Env1; (void)Env2;
178 return 0;
179}
180
181//------------------------------------------------------------------------------
186//------------------------------------------------------------------------------
187
188virtual int isRemote() {return myPersona == XrdCmsClient::amRemote;}
189
190//------------------------------------------------------------------------------
217//------------------------------------------------------------------------------
218
219virtual int Locate(XrdOucErrInfo &Resp, const char *path, int flags,
220 XrdOucEnv *Info=0) = 0;
221
222//------------------------------------------------------------------------------
228// Return: A list of managers or null if none exist.
229//------------------------------------------------------------------------------
230
231virtual
232XrdOucTList *Managers() {return 0;}
233
234//------------------------------------------------------------------------------
242//------------------------------------------------------------------------------
243
244virtual int Prepare(XrdOucErrInfo &Resp, XrdSfsPrep &pargs,
245 XrdOucEnv *Info=0)
246{
247 (void)Resp; (void)pargs; (void)Info;
248 return 0;
249}
250
251//------------------------------------------------------------------------------
256//------------------------------------------------------------------------------
257
258virtual void Removed(const char *path) { (void)path; }
259
260//------------------------------------------------------------------------------
265//------------------------------------------------------------------------------
266
267virtual void Resume (int Perm=1) { (void)Perm; }
268
269//------------------------------------------------------------------------------
274//------------------------------------------------------------------------------
275
276virtual void Suspend(int Perm=1) { (void)Perm; }
277
278// The following set of functions can be used to control whether or not clients
279// are dispatched to this data server based on a virtual resource. The default
280// implementations do nothing.
281//
282//------------------------------------------------------------------------------
289//------------------------------------------------------------------------------
290
291virtual int Resource(int n) { (void)n; return 0;}
292
293//------------------------------------------------------------------------------
301//------------------------------------------------------------------------------
302
303virtual int Reserve (int n=1) { (void)n; return 0;}
304
305//------------------------------------------------------------------------------
314//------------------------------------------------------------------------------
315
316virtual int Release (int n=1) { (void)n; return 0;}
317
318//------------------------------------------------------------------------------
327//------------------------------------------------------------------------------
328
329virtual int Space(XrdOucErrInfo &Resp, const char *path,
330 XrdOucEnv *Info=0) = 0;
331
332//------------------------------------------------------------------------------
341//------------------------------------------------------------------------------
342
343virtual void Utilization(unsigned int util, bool alert=false)
344 {(void)util; (void)alert;}
345
346//------------------------------------------------------------------------------
350//------------------------------------------------------------------------------
351
354 amTarget
355 };
356
357 XrdCmsClient(Persona acting) : myPersona(acting) {}
358
359//------------------------------------------------------------------------------
361//------------------------------------------------------------------------------
362
363virtual ~XrdCmsClient() {}
364
365protected:
366
368};
369
370/******************************************************************************/
371/* I n s t a n t i a t i o n M o d e F l a g s */
372/******************************************************************************/
373
378namespace XrdCms
379{
380enum {IsProxy = 1,
383 IsMeta = 8
384 };
385}
386
387/******************************************************************************/
388/* C M S C l i e n t I n s t a n t i a t o r */
389/******************************************************************************/
390
391//------------------------------------------------------------------------------
423//------------------------------------------------------------------------------
424
425class XrdOss;
426
427typedef XrdCmsClient *(*XrdCmsClient_t)(XrdSysLogger *, int, int, XrdOss *);
428
435//------------------------------------------------------------------------------
448//------------------------------------------------------------------------------
449
450namespace XrdCms
451{
453 int opMode,
454 int myPort
455 );
456}
457
458//------------------------------------------------------------------------------
463//------------------------------------------------------------------------------
464
469#endif
Definition XrdCmsClient.hh:116
virtual int Configure(const char *cfn, char *Parms, XrdOucEnv *EnvInfo)=0
XrdCmsClient(Persona acting)
Definition XrdCmsClient.hh:357
Persona
Definition XrdCmsClient.hh:352
@ amRemote
Am a manager and issue redirects.
Definition XrdCmsClient.hh:353
@ amTarget
Am a server and field redirects.
Definition XrdCmsClient.hh:354
@ amLocal
Not affiliated with a cluster.
Definition XrdCmsClient.hh:352
virtual void Added(const char *path, int Pend=0)
Definition XrdCmsClient.hh:128
Persona myPersona
Definition XrdCmsClient.hh:367
virtual int Reserve(int n=1)
Definition XrdCmsClient.hh:303
virtual ~XrdCmsClient()
Destructor.
Definition XrdCmsClient.hh:363
virtual int Release(int n=1)
Definition XrdCmsClient.hh:316
virtual void Resume(int Perm=1)
Definition XrdCmsClient.hh:267
virtual int isRemote()
Definition XrdCmsClient.hh:188
virtual int Prepare(XrdOucErrInfo &Resp, XrdSfsPrep &pargs, XrdOucEnv *Info=0)
Definition XrdCmsClient.hh:244
virtual void Removed(const char *path)
Definition XrdCmsClient.hh:258
virtual int Forward(XrdOucErrInfo &Resp, const char *cmd, const char *arg1=0, const char *arg2=0, XrdOucEnv *Env1=0, XrdOucEnv *Env2=0)
Definition XrdCmsClient.hh:173
virtual XrdOucTList * Managers()
Definition XrdCmsClient.hh:232
virtual int Resource(int n)
Definition XrdCmsClient.hh:291
virtual void Utilization(unsigned int util, bool alert=false)
Definition XrdCmsClient.hh:343
virtual int Space(XrdOucErrInfo &Resp, const char *path, XrdOucEnv *Info=0)=0
virtual int Locate(XrdOucErrInfo &Resp, const char *path, int flags, XrdOucEnv *Info=0)=0
virtual void Suspend(int Perm=1)
Definition XrdCmsClient.hh:276
Definition XrdOss.hh:498
Definition XrdOucEnv.hh:42
Definition XrdOucErrInfo.hh:101
Definition XrdOucTList.hh:42
Definition XrdSysLogger.hh:53
Definition YProtocol.hh:78
XrdCmsClient * GetDefaultClient(XrdSysLogger *Logger, int opMode, int myPort)
@ IsTarget
The role is server and will be a redirection target.
Definition XrdCmsClient.hh:382
@ IsProxy
The role is proxy {plus one or more of the below}.
Definition XrdCmsClient.hh:380
@ IsRedir
The role is manager and will redirect users.
Definition XrdCmsClient.hh:381
@ IsMeta
The role is meta {plus one or more of the above}.
Definition XrdCmsClient.hh:383
< Prepare parameters
Definition XrdSfsInterface.hh:172