Go to the documentation of this file.00001 #ifndef __XRDOLBRRQ_HH__
00002 #define __XRDOLBRRQ_HH__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <sys/uio.h>
00016
00017 #include "XrdOlb/XrdOlbTypes.hh"
00018 #include "XrdOuc/XrdOucDLlist.hh"
00019 #include "XrdSys/XrdSysPthread.hh"
00020
00021
00022
00023
00024
00025 class XrdOlbRRQInfo
00026 {
00027 public:
00028 void *Key;
00029 int Rinst;
00030 short Rnum;
00031 char isRW;
00032 char isLU;
00033 char ID[16];
00034 SMask_t Arg;
00035
00036 XrdOlbRRQInfo() {isLU = 0;}
00037 ~XrdOlbRRQInfo() {}
00038 };
00039
00040
00041
00042
00043
00044 class XrdOlbRRQSlot
00045 {
00046 friend class XrdOlbRRQ;
00047
00048 static XrdOlbRRQSlot *Alloc(XrdOlbRRQInfo *Info);
00049
00050 void Recycle();
00051
00052 XrdOlbRRQSlot();
00053 ~XrdOlbRRQSlot() {}
00054
00055 private:
00056
00057 static XrdSysMutex myMutex;
00058 static XrdOlbRRQSlot *freeSlot;
00059 static short initSlot;
00060
00061 XrdOucDLlist<XrdOlbRRQSlot> Link;
00062 XrdOlbRRQSlot *Cont;
00063 XrdOlbRRQInfo Info;
00064 SMask_t Arg;
00065 unsigned int Expire;
00066 int slotNum;
00067 };
00068
00069
00070
00071
00072
00073 class XrdOlbRRQ
00074 {
00075 public:
00076
00077 short Add(short Snum, XrdOlbRRQInfo *ip);
00078
00079 void Del(short Snum, const void *Key);
00080
00081 int Init(int Tint=0, int Tdly=0);
00082
00083 void Ready(int Snum, const void *Key, SMask_t mask);
00084
00085 void *Respond();
00086
00087 void *TimeOut();
00088
00089 XrdOlbRRQ() : isWaiting(0), isReady(0), Tslice(133),
00090 Tdelay(5), myClock(0) {}
00091 ~XrdOlbRRQ() {}
00092
00093 private:
00094
00095 XrdOlbRRQSlot *sendLocInfo(XrdOlbRRQSlot *Sp);
00096 void sendResponse(XrdOlbRRQInfo *Info, int doredir);
00097 static const int numSlots = 1024;
00098
00099 XrdSysMutex myMutex;
00100 XrdSysSemaphore isWaiting;
00101 XrdSysSemaphore isReady;
00102 XrdOlbRRQSlot Slot[numSlots];
00103 XrdOucDLlist<XrdOlbRRQSlot> waitQ;
00104 XrdOucDLlist<XrdOlbRRQSlot> readyQ;
00105 static const int redr_iov_cnt = 3;
00106 static const int wait_iov_cnt = 2;
00107 struct iovec redr_iov[redr_iov_cnt];
00108 struct iovec wait_iov[wait_iov_cnt];
00109 char hostbuff[288];
00110 char waitbuff[16];
00111 int Tslice;
00112 int Tdelay;
00113 unsigned int myClock;
00114 };
00115
00116 namespace XrdOlb
00117 {
00118 extern XrdOlbRRQ RRQ;
00119 }
00120 #endif