00001 #ifndef __XRDCMSRRQ_HH__
00002 #define __XRDCMSRRQ_HH__
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 <sys/uio.h>
00034
00035 #include "XProtocol/XPtypes.hh"
00036 #include "XProtocol/YProtocol.hh"
00037
00038 #include "XrdCms/XrdCmsTypes.hh"
00039 #include "XrdOuc/XrdOucDLlist.hh"
00040 #include "XrdSys/XrdSysPthread.hh"
00041
00042
00043
00044
00045
00046 class XrdCmsRRQInfo
00047 {
00048 public:
00049 void *Key;
00050 kXR_unt32 ID;
00051 int Rinst;
00052 short Rnum;
00053 char isRW;
00054 char isLU;
00055 char minR;
00056 char actR;
00057 char lsLU;
00058 char ifOP;
00059 SMask_t rwVec;
00060
00061 XrdCmsRRQInfo() : isLU(0), ifOP(0) {}
00062 XrdCmsRRQInfo(int rinst, short rnum, kXR_unt32 id, int minQ=0)
00063 : Key(0), ID(id), Rinst(rinst), Rnum(rnum),
00064 isRW(0), isLU(0), minR(minQ), actR(0), lsLU(0), ifOP(0),
00065 rwVec(0) {}
00066 ~XrdCmsRRQInfo() {}
00067 };
00068
00069
00070
00071
00072
00073 class XrdCmsRRQSlot
00074 {
00075 friend class XrdCmsRRQ;
00076
00077 static XrdCmsRRQSlot *Alloc(XrdCmsRRQInfo *Info);
00078
00079 void Recycle();
00080
00081 XrdCmsRRQSlot();
00082 ~XrdCmsRRQSlot() {}
00083
00084 private:
00085
00086 static XrdSysMutex myMutex;
00087 static XrdCmsRRQSlot *freeSlot;
00088 static short initSlot;
00089
00090 XrdOucDLlist<XrdCmsRRQSlot> Link;
00091 XrdCmsRRQSlot *Cont;
00092 XrdCmsRRQSlot *LkUp;
00093 XrdCmsRRQInfo Info;
00094 SMask_t Arg1;
00095 SMask_t Arg2;
00096 unsigned int Expire;
00097 int slotNum;
00098 };
00099
00100
00101
00102
00103
00104 class XrdCmsRRQ
00105 {
00106 public:
00107
00108 short Add(short Snum, XrdCmsRRQInfo *ip);
00109
00110 void Del(short Snum, const void *Key);
00111
00112 int Init(int Tint=0, int Tdly=0);
00113
00114 int Ready(int Snum, const void *Key, SMask_t mask1, SMask_t mask2);
00115
00116 void *Respond();
00117
00118 struct Info
00119 {
00120 Info()
00121 {Reset();}
00122
00123 void Reset()
00124 {Add2Q = 0;
00125 PBack = 0;
00126 Resp = 0;
00127 Multi = 0;
00128 luFast = 0;
00129 luSlow = 0;
00130 rdFast = 0;
00131 rdSlow = 0;
00132 }
00133
00134 long long Add2Q;
00135 long long PBack;
00136 long long Resp;
00137 long long Multi;
00138 long long luFast;
00139 long long luSlow;
00140 long long rdFast;
00141 long long rdSlow;
00142 };
00143
00144 void Statistics(Info &Data) {myMutex.Lock(); Data = Stats; myMutex.UnLock();}
00145
00146 void *TimeOut();
00147
00148 XrdCmsRRQ() : isWaiting(0), isReady(0),
00149 luFast(0), luSlow(0), rdFast(0), rdSlow(0),
00150 Tslice(178), Tdelay(5), myClock(0) {}
00151 ~XrdCmsRRQ() {}
00152
00153 private:
00154
00155 void sendLocResp(XrdCmsRRQSlot *lP);
00156 void sendLwtResp(XrdCmsRRQSlot *rP);
00157 void sendRedResp(XrdCmsRRQSlot *rP);
00158 static const int numSlots = 1024;
00159
00160 XrdSysMutex myMutex;
00161 XrdSysSemaphore isWaiting;
00162 XrdSysSemaphore isReady;
00163 XrdCmsRRQSlot Slot[numSlots];
00164 XrdOucDLlist<XrdCmsRRQSlot> waitQ;
00165 XrdOucDLlist<XrdCmsRRQSlot> readyQ;
00166 static const int iov_cnt = 2;
00167 struct iovec data_iov[iov_cnt];
00168 struct iovec redr_iov[iov_cnt];
00169 XrdCms::CmsResponse dataResp;
00170 XrdCms::CmsResponse redrResp;
00171 XrdCms::CmsResponse waitResp;
00172 union {char hostbuff[288];
00173 char databuff[XrdCms::CmsLocateRequest::RHLen
00174 *STMax];
00175 };
00176 Info Stats;
00177 int luFast;
00178 int luSlow;
00179 int rdFast;
00180 int rdSlow;
00181 int Tslice;
00182 int Tdelay;
00183 unsigned int myClock;
00184 };
00185
00186 namespace XrdCms
00187 {
00188 extern XrdCmsRRQ RRQ;
00189 }
00190 #endif