xrootd
XrdCmsClientMan.hh
Go to the documentation of this file.
00001 #ifndef __CMS_CLIENTMAN__
00002 #define __CMS_CLIENTMAN__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                    X r d C m s C l i e n t M a n . h h                     */
00006 /*                                                                            */
00007 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 #include <stdio.h>
00014 #include <sys/uio.h>
00015 
00016 #include "XProtocol/YProtocol.hh"
00017 
00018 #include "XrdCms/XrdCmsResp.hh"
00019 #include "XrdNet/XrdNetBuffer.hh"
00020 #include "XrdOuc/XrdOucErrInfo.hh"
00021 #include "XrdSys/XrdSysPthread.hh"
00022 
00023 class XrdInet;
00024 class XrdLink;
00025 class XrdNetBuffer;
00026 
00027 class XrdCmsClientMan
00028 {
00029 public:
00030 
00031 static char          doDebug;
00032 
00033 int                  delayResp(XrdOucErrInfo &Resp);
00034 
00035 inline int           isActive() {return Active;}
00036 
00037 XrdCmsClientMan     *nextManager() {return Next;}
00038 
00039 char                *Name() {return Host;}
00040 char                *NPfx() {return HPfx;}
00041 
00042 int                  Send(char *msg, int mlen=0);
00043 int                  Send(const struct iovec *iov, int iovcnt, int iotot=0);
00044 
00045 void                *Start();
00046 
00047 inline int           Suspended() {if (Suspend) chkStatus(); return Suspend;}
00048 
00049 void                 setNext(XrdCmsClientMan *np) {Next = np;}
00050 
00051 static void          setNetwork(XrdInet *nP) {Network = nP;}
00052 
00053 static void          setConfig(char *cfn) {ConfigFN = cfn;}
00054 
00055 int                  whatsUp(const char *user, const char *path);
00056 
00057 inline int           waitTime() {return repWait;}
00058 
00059                   XrdCmsClientMan(char *host,int port,int cw,int nr,int rw,int rd);
00060                  ~XrdCmsClientMan();
00061 
00062 private:
00063 int   Hookup();
00064 int   Receive();
00065 void  relayResp();
00066 void  chkStatus();
00067 void  setStatus();
00068 
00069 static XrdSysMutex   manMutex;
00070 static XrdNetBufferQ BuffQ;
00071 static XrdInet      *Network;
00072 static char         *ConfigFN;
00073 static const int     chkVal = 256;
00074 
00075 XrdSysSemaphore   syncResp;
00076 XrdCmsRespQ       RespQ;
00077 
00078 XrdCmsClientMan  *Next;
00079 XrdSysMutex       myData;
00080 XrdLink          *Link;
00081 char             *Host;
00082 char             *HPfx;
00083 int               Port;
00084 int               manMask;
00085 int               dally;
00086 int               Active;
00087 int               Silent;
00088 int               Suspend;
00089 int               RecvCnt;
00090 int               SendCnt;
00091 int               nrMax;
00092 int               maxMsgID;
00093 int               repWait;
00094 int               repWMax;
00095 int               minDelay;
00096 int               maxDelay;
00097 int               qTime;
00098 int               chkCount;
00099 time_t            lastUpdt;
00100 time_t            lastTOut;
00101 XrdCms::CmsRRHdr  Response;
00102 XrdNetBuffer     *NetBuff;
00103 };
00104 #endif