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 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
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 "XrdNet/XrdNetBuffer.hh"
00040 #include "XrdOuc/XrdOucErrInfo.hh"
00041 #include "XrdSys/XrdSysPthread.hh"
00042 
00043 class XrdInet;
00044 class XrdLink;
00045 class XrdNetBuffer;
00046 
00047 class XrdCmsClientMan
00048 {
00049 public:
00050 
00051 static char          doDebug;
00052 
00053 int                  delayResp(XrdOucErrInfo &Resp);
00054 
00055 inline int           isActive() {return Active;}
00056 
00057 XrdCmsClientMan     *nextManager() {return Next;}
00058 
00059 char                *Name() {return Host;}
00060 char                *NPfx() {return HPfx;}
00061 
00062 int                  Send(char *msg, int mlen=0);
00063 int                  Send(const struct iovec *iov, int iovcnt, int iotot=0);
00064 
00065 void                *Start();
00066 
00067 inline int           Suspended() {if (Suspend) chkStatus(); return Suspend;}
00068 
00069 void                 setNext(XrdCmsClientMan *np) {Next = np;}
00070 
00071 static void          setNetwork(XrdInet *nP) {Network = nP;}
00072 
00073 static void          setConfig(const char *cfn) {ConfigFN = cfn;}
00074 
00075 int                  whatsUp(const char *user, const char *path);
00076 
00077 inline int           waitTime() {return repWait;}
00078 
00079                   XrdCmsClientMan(char *host,int port,int cw,int nr,int rw,int rd);
00080                  ~XrdCmsClientMan();
00081 
00082 private:
00083 int   Hookup();
00084 int   Receive();
00085 void  relayResp();
00086 void  chkStatus();
00087 void  setStatus();
00088 
00089 static XrdSysMutex   manMutex;
00090 static XrdNetBufferQ BuffQ;
00091 static XrdInet      *Network;
00092 static const char   *ConfigFN;
00093 static const int     chkVal = 256;
00094 
00095 XrdSysSemaphore   syncResp;
00096 XrdCmsRespQ       RespQ;
00097 
00098 XrdCmsClientMan  *Next;
00099 XrdSysMutex       myData;
00100 XrdLink          *Link;
00101 char             *Host;
00102 char             *HPfx;
00103 int               Port;
00104 int               manMask;
00105 int               dally;
00106 int               Active;
00107 int               Silent;
00108 int               Suspend;
00109 int               RecvCnt;
00110 int               SendCnt;
00111 int               nrMax;
00112 int               maxMsgID;
00113 int               repWait;
00114 int               repWMax;
00115 int               minDelay;
00116 int               maxDelay;
00117 int               qTime;
00118 int               chkCount;
00119 time_t            lastUpdt;
00120 time_t            lastTOut;
00121 XrdCms::CmsRRHdr  Response;
00122 XrdNetBuffer     *NetBuff;
00123 };
00124 #endif