XRootD
XrdCmsClientMan.hh
Go to the documentation of this file.
1 #ifndef __CMS_CLIENTMAN__
2 #define __CMS_CLIENTMAN__
3 /******************************************************************************/
4 /* */
5 /* X r d C m s C l i e n t M a n . 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 <cstdio>
34 #include <sys/uio.h>
35 
36 #include "XProtocol/YProtocol.hh"
37 
38 #include "XrdCms/XrdCmsResp.hh"
39 #include "XrdOuc/XrdOucBuffer.hh"
40 #include "XrdOuc/XrdOucErrInfo.hh"
41 #include "XrdSys/XrdSysAtomics.hh"
42 #include "XrdSys/XrdSysPthread.hh"
43 
44 class XrdInet;
45 class XrdLink;
46 
48 {
49 public:
50 
51 static char doDebug;
52 
53 int delayResp(XrdOucErrInfo &Resp);
54 
55 inline int isActive() {AtomicRet(myData, Active);}
56 
57 XrdCmsClientMan *nextManager() {return Next;}
58 
59 char *Name() {return Host;}
60 char *NPfx() {return HPfx;}
61 
62 int manPort() {return Port;}
63 
64 int Send(unsigned int &iMan, char *msg, int mlen=0);
65 int Send(unsigned int &iMan, const struct iovec *iov,
66  int iovcnt, int iotot=0);
67 
68 void *Start();
69 
70 inline int Suspended() {AtomicBeg(myData);
71  int sVal = AtomicGet(Suspend);
72  AtomicEnd(myData);
73  if (!sVal) return sVal;
74  return chkStatus();
75  }
76 
77 void setNext(XrdCmsClientMan *np) {Next = np;}
78 
79 static void setNetwork(XrdInet *nP) {Network = nP;}
80 
81 static void setConfig(const char *cfn) {ConfigFN = cfn;}
82 
83 int whatsUp(const char *user, const char *path,
84  unsigned int iMan);
85 
86 inline int waitTime() {AtomicRet(myData, repWait);}
87 
88  XrdCmsClientMan(char *host,int port,int cw,int nr,int rw,int rd);
90 
91 private:
92 int Hookup();
93 int Receive();
94 void relayResp();
95 int chkStatus();
96 void setStatus();
97 
98 static XrdSysMutex manMutex;
99 static XrdOucBuffPool BuffPool;
100 static XrdInet *Network;
101 static const char *ConfigFN;
102 static const int chkVal = 256;
103 
104 XrdSysSemaphore syncResp;
105 XrdCmsRespQ RespQ;
106 
107 XrdCmsClientMan *Next;
108 XrdSysMutex myData;
109 XrdLink *Link;
110 char *Host;
111 char *HPfx;
112 int Port;
113 unsigned int manInst;
114 int manMask;
115 int dally;
116 int Active;
117 int Silent;
118 int Suspend;
119 int RecvCnt;
120 int SendCnt;
121 int nrMax;
122 int maxMsgID;
123 int repWait;
124 int repWMax;
125 int minDelay;
126 int maxDelay;
127 int qTime;
128 int chkCount;
129 time_t lastUpdt;
130 time_t lastTOut;
131 XrdCms::CmsRRHdr Response;
132 XrdOucBuffer *NetBuff;
133 };
134 #endif
#define AtomicBeg(Mtx)
#define AtomicGet(x)
#define AtomicEnd(Mtx)
#define AtomicRet(mtx, x)
void setNext(XrdCmsClientMan *np)
XrdCmsClientMan * nextManager()
int Send(unsigned int &iMan, char *msg, int mlen=0)
int delayResp(XrdOucErrInfo &Resp)
static void setConfig(const char *cfn)
static void setNetwork(XrdInet *nP)
int whatsUp(const char *user, const char *path, unsigned int iMan)
static char doDebug
XrdCmsClientMan(char *host, int port, int cw, int nr, int rw, int rd)