|
xrootd
|
00001 #ifndef __XRDCMSRRQ_HH__ 00002 #define __XRDCMSRRQ_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s R R Q . 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 <sys/uio.h> 00014 00015 #include "XProtocol/XPtypes.hh" 00016 #include "XProtocol/YProtocol.hh" 00017 00018 #include "XrdCms/XrdCmsTypes.hh" 00019 #include "XrdOuc/XrdOucDLlist.hh" 00020 #include "XrdSys/XrdSysPthread.hh" 00021 00022 /******************************************************************************/ 00023 /* X r d C m s R R Q I n f o */ 00024 /******************************************************************************/ 00025 00026 class XrdCmsRRQInfo 00027 { 00028 public: 00029 void *Key; // Key link, which is the cache line address 00030 kXR_unt32 ID; // Response link, which is the request ID 00031 int Rinst; // Redirector instance 00032 short Rnum; // Redirector number (RTable slot number) 00033 char isRW; // True if r/w access wanted 00034 char isLU; // True if locate response wanted 00035 char minR; // Minimum number of responses for fast redispatch 00036 char actR; // Actual number of responses 00037 short Rsvd; 00038 SMask_t rwVec; // R/W servers for corresponding path (if isLU is true) 00039 00040 XrdCmsRRQInfo() : isLU(0) {} 00041 XrdCmsRRQInfo(int rinst, short rnum, kXR_unt32 id, int minQ=0) 00042 : Key(0), ID(id), Rinst(rinst), Rnum(rnum), 00043 isRW(0), isLU(0), minR(minQ), actR(0) {} 00044 ~XrdCmsRRQInfo() {} 00045 }; 00046 00047 /******************************************************************************/ 00048 /* X r d C m s R R Q S l o t */ 00049 /******************************************************************************/ 00050 00051 class XrdCmsRRQSlot 00052 { 00053 friend class XrdCmsRRQ; 00054 00055 static XrdCmsRRQSlot *Alloc(XrdCmsRRQInfo *Info); 00056 00057 void Recycle(); 00058 00059 XrdCmsRRQSlot(); 00060 ~XrdCmsRRQSlot() {} 00061 00062 private: 00063 00064 static XrdSysMutex myMutex; 00065 static XrdCmsRRQSlot *freeSlot; 00066 static short initSlot; 00067 00068 XrdOucDLlist<XrdCmsRRQSlot> Link; 00069 XrdCmsRRQSlot *Cont; 00070 XrdCmsRRQSlot *LkUp; 00071 XrdCmsRRQInfo Info; 00072 SMask_t Arg1; 00073 SMask_t Arg2; 00074 unsigned int Expire; 00075 int slotNum; 00076 }; 00077 00078 /******************************************************************************/ 00079 /* X r d C m s R R Q */ 00080 /******************************************************************************/ 00081 00082 class XrdCmsRRQ 00083 { 00084 public: 00085 00086 short Add(short Snum, XrdCmsRRQInfo *ip); 00087 00088 void Del(short Snum, const void *Key); 00089 00090 int Init(int Tint=0, int Tdly=0); 00091 00092 int Ready(int Snum, const void *Key, SMask_t mask1, SMask_t mask2); 00093 00094 void *Respond(); 00095 00096 struct Info 00097 {long long Add2Q; // Number added to queue 00098 long long PBack; // Number that we could piggy-back 00099 long long Resp; // Number of reponses for a waiting request 00100 long long Multi; // Number of multiple response fielded 00101 long long luFast; // Fast lookups 00102 long long luSlow; // Slow lookups 00103 long long rdFast; // Fast redirects 00104 long long rdSlow; // Slow redirects 00105 }; 00106 00107 void Statistics(Info &Data) {myMutex.Lock(); Data = Stats; myMutex.UnLock();} 00108 00109 void *TimeOut(); 00110 00111 XrdCmsRRQ() : isWaiting(0), isReady(0), Tslice(178), 00112 Tdelay(5), myClock(0) {} 00113 ~XrdCmsRRQ() {} 00114 00115 private: 00116 00117 int sendLocResp(XrdCmsRRQSlot *lP); 00118 void sendResponse(XrdCmsRRQInfo *Info, int doredir, int totlen = 0); 00119 static const int numSlots = 1024; 00120 00121 XrdSysMutex myMutex; 00122 XrdSysSemaphore isWaiting; 00123 XrdSysSemaphore isReady; 00124 XrdCmsRRQSlot Slot[numSlots]; 00125 XrdOucDLlist<XrdCmsRRQSlot> waitQ; 00126 XrdOucDLlist<XrdCmsRRQSlot> readyQ; // Redirect/Locate ready queue 00127 static const int iov_cnt = 2; 00128 struct iovec data_iov[iov_cnt]; 00129 struct iovec redr_iov[iov_cnt]; 00130 XrdCms::CmsResponse dataResp; 00131 XrdCms::CmsResponse redrResp; 00132 XrdCms::CmsResponse waitResp; 00133 union {char hostbuff[288]; 00134 char databuff[XrdCms::CmsLocateRequest::RILen 00135 *STMax]; 00136 }; 00137 Info Stats; 00138 int Tslice; 00139 int Tdelay; 00140 unsigned int myClock; 00141 }; 00142 00143 namespace XrdCms 00144 { 00145 extern XrdCmsRRQ RRQ; 00146 } 00147 #endif
1.7.5