XRootD
XrdCmsProtocol.hh
Go to the documentation of this file.
1 #ifndef __CMS_PROTOCOL_H__
2 #define __CMS_PROTOCOL_H__
3 /******************************************************************************/
4 /* */
5 /* X r d C m s P r o t o c o l . 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 
33 #include "Xrd/XrdProtocol.hh"
34 #include "XrdCms/XrdCmsParser.hh"
35 #include "XrdCms/XrdCmsTypes.hh"
36 #include "XrdSys/XrdSysPthread.hh"
37 
38 class XrdLink;
39 class XrdCmsManager;
40 class XrdCmsNode;
41 class XrdCmsRRData;
42 class XrdCmsRouting;
43 
45 {
46 friend class XrdCmsJob;
47 public:
48 
49 static XrdCmsProtocol *Alloc(const char *theRole = "", XrdCmsManager *mP=0,
50  const char *theMan = 0, int thePort=0);
51 
52  void DoIt();
53 
54  int Execute(XrdCmsRRData &Data);
55 
56  XrdProtocol *Match(XrdLink *lp); // Upon accept
57 
58  int Process(XrdLink *lp); // Initial entry
59 
60  void Recycle(XrdLink *lp, int consec, const char *reason);
61 
62  void Ref(int rcnt);
63 
64  int Stats(char *buff, int blen, int do_sync=0);
65 
66  XrdCmsProtocol() : XrdProtocol("cms protocol handler") {Init();}
68 
69 private:
70 
71 XrdCmsRouting *Admit();
72 XrdCmsRouting *Admit_DataServer(int);
73 XrdCmsRouting *Admit_Redirector(int);
74 XrdCmsRouting *Admit_Supervisor(int);
75 SMask_t AddPath(XrdCmsNode *nP, const char *pType, const char *Path);
76 int Authenticate();
77 void ConfigCheck(unsigned char *theConfig);
78 enum Bearing {isDown, isLateral, isUp};
79 const char *Dispatch(Bearing cDir, int maxWait, int maxTries);
80 void Init(const char *iRole="?", XrdCmsManager *uMan=0,
81  const char *iMan="?", int iPort=0);
82 XrdCmsRouting *Login_Failed(const char *Reason);
83 void Pander(const char *manager, int mport);
84 void Reissue(XrdCmsRRData &Data);
85 void Reply_Delay(XrdCmsRRData &Data, kXR_unt32 theDelay);
86 void Reply_Error(XrdCmsRRData &Data, int ecode, const char *etext);
87 bool SendPing();
88 void Sync();
89 
90 static XrdSysMutex ProtMutex;
91 static XrdCmsProtocol *ProtStack;
92 static XrdCmsParser ProtArgs;
93  XrdCmsProtocol *ProtLink;
94 
95  XrdCmsRouting *Routing; // Request routing for this instance
96 
97 static const int maxReqSize = 16384;
98  XrdSysMutex refMutex;
99  XrdSysSemaphore *refWait;
100  XrdLink *Link;
101 static int readWait;
102 const char *myRole;
103  XrdCmsNode *myNode;
104  XrdCmsManager *Manager;
105 const char *myMan;
106  int myManPort;
107  int refCount;
108  short RSlot; // True only for redirectors
109  char loggedIn; // True if login succeeded
110  bool isNBSQ; // True if nbsq is active
111 };
112 #endif
unsigned int kXR_unt32
Definition: XPtypes.hh:90
unsigned long long SMask_t
Definition: XrdCmsTypes.hh:33
XrdOucString Path
void Recycle(XrdLink *lp, int consec, const char *reason)
int Process(XrdLink *lp)
void Ref(int rcnt)
int Execute(XrdCmsRRData &Data)
int Stats(char *buff, int blen, int do_sync=0)
static XrdCmsProtocol * Alloc(const char *theRole="", XrdCmsManager *mP=0, const char *theMan=0, int thePort=0)
XrdProtocol * Match(XrdLink *lp)
SyncImpl< false > Sync(Ctx< File > file, uint16_t timeout=0)
Factory for creating SyncImpl objects.