00001 #ifndef __CMS_CLIENTMAN__
00002 #define __CMS_CLIENTMAN__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <stdio.h>
00034 #include <sys/uio.h>
00035
00036 #include "XProtocol/YProtocol.hh"
00037
00038 #include "XrdCms/XrdCmsResp.hh"
00039 #include "XrdOuc/XrdOucBuffer.hh"
00040 #include "XrdOuc/XrdOucErrInfo.hh"
00041 #include "XrdSys/XrdSysAtomics.hh"
00042 #include "XrdSys/XrdSysPthread.hh"
00043
00044 class XrdInet;
00045 class XrdLink;
00046
00047 class XrdCmsClientMan
00048 {
00049 public:
00050
00051 static char doDebug;
00052
00053 int delayResp(XrdOucErrInfo &Resp);
00054
00055 inline int isActive() {AtomicRet(myData, Active);}
00056
00057 XrdCmsClientMan *nextManager() {return Next;}
00058
00059 char *Name() {return Host;}
00060 char *NPfx() {return HPfx;}
00061
00062 int manPort() {return Port;}
00063
00064 int Send(unsigned int &iMan, char *msg, int mlen=0);
00065 int Send(unsigned int &iMan, const struct iovec *iov,
00066 int iovcnt, int iotot=0);
00067
00068 void *Start();
00069
00070 inline int Suspended() {AtomicBeg(myData);
00071 int sVal = AtomicGet(Suspend);
00072 AtomicEnd(myData);
00073 if (!sVal) return sVal;
00074 return chkStatus();
00075 }
00076
00077 void setNext(XrdCmsClientMan *np) {Next = np;}
00078
00079 static void setNetwork(XrdInet *nP) {Network = nP;}
00080
00081 static void setConfig(const char *cfn) {ConfigFN = cfn;}
00082
00083 int whatsUp(const char *user, const char *path,
00084 unsigned int iMan);
00085
00086 inline int waitTime() {AtomicRet(myData, repWait);}
00087
00088 XrdCmsClientMan(char *host,int port,int cw,int nr,int rw,int rd);
00089 ~XrdCmsClientMan();
00090
00091 private:
00092 int Hookup();
00093 int Receive();
00094 void relayResp();
00095 int chkStatus();
00096 void setStatus();
00097
00098 static XrdSysMutex manMutex;
00099 static XrdOucBuffPool BuffPool;
00100 static XrdInet *Network;
00101 static const char *ConfigFN;
00102 static const int chkVal = 256;
00103
00104 XrdSysSemaphore syncResp;
00105 XrdCmsRespQ RespQ;
00106
00107 XrdCmsClientMan *Next;
00108 XrdSysMutex myData;
00109 XrdLink *Link;
00110 char *Host;
00111 char *HPfx;
00112 int Port;
00113 unsigned int manInst;
00114 int manMask;
00115 int dally;
00116 int Active;
00117 int Silent;
00118 int Suspend;
00119 int RecvCnt;
00120 int SendCnt;
00121 int nrMax;
00122 int maxMsgID;
00123 int repWait;
00124 int repWMax;
00125 int minDelay;
00126 int maxDelay;
00127 int qTime;
00128 int chkCount;
00129 time_t lastUpdt;
00130 time_t lastTOut;
00131 XrdCms::CmsRRHdr Response;
00132 XrdOucBuffer *NetBuff;
00133 };
00134 #endif