xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdCmsRRQ.hh
Go to the documentation of this file.
1 #ifndef __XRDCMSRRQ_HH__
2 #define __XRDCMSRRQ_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d C m s R R Q . h h */
6 /* */
7 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <sys/uio.h>
34 
35 #include "XProtocol/XPtypes.hh"
36 #include "XProtocol/YProtocol.hh"
37 
38 #include "XrdCms/XrdCmsTypes.hh"
39 #include "XrdOuc/XrdOucDLlist.hh"
40 #include "XrdSys/XrdSysPthread.hh"
41 
42 /******************************************************************************/
43 /* X r d C m s R R Q I n f o */
44 /******************************************************************************/
45 
47 {
48 public:
49 void *Key; // Key link, which is the cache line address
50 kXR_unt32 ID; // Response link, which is the request ID
51 int Rinst; // Redirector instance
52 short Rnum; // Redirector number (RTable slot number)
53 char isRW; // True if r/w access wanted
54 char isLU; // True if locate response wanted
55 char minR; // Minimum number of responses for fast redispatch
56 char actR; // Actual number of responses
57 char lsLU; // Lookup options
58 char ifOP; // XrdNetIF::ifType to return (cast as char)
59 SMask_t rwVec; // R/W servers for corresponding path (if isLU is true)
60 
61  XrdCmsRRQInfo() : isLU(0), ifOP(0) {}
62  XrdCmsRRQInfo(int rinst, short rnum, kXR_unt32 id, int minQ=0)
63  : Key(0), ID(id), Rinst(rinst), Rnum(rnum),
64  isRW(0), isLU(0), minR(minQ), actR(0), lsLU(0), ifOP(0),
65  rwVec(0) {}
67 };
68 
69 /******************************************************************************/
70 /* X r d C m s R R Q S l o t */
71 /******************************************************************************/
72 
74 {
75 friend class XrdCmsRRQ;
76 
78 
79  void Recycle();
80 
81  XrdCmsRRQSlot();
83 
84 private:
85 
88 static short initSlot;
89 
96 unsigned int Expire;
97  int slotNum;
98 };
99 
100 /******************************************************************************/
101 /* X r d C m s R R Q */
102 /******************************************************************************/
103 
105 {
106 public:
107 
108 short Add(short Snum, XrdCmsRRQInfo *ip);
109 
110 void Del(short Snum, const void *Key);
111 
112 int Init(int Tint=0, int Tdly=0);
113 
114 int Ready(int Snum, const void *Key, SMask_t mask1, SMask_t mask2);
115 
116 void *Respond();
117 
118 struct Info
119  {
121  {Reset();}
122 
123  void Reset()
124  {Add2Q = 0;
125  PBack = 0;
126  Resp = 0;
127  Multi = 0;
128  luFast = 0;
129  luSlow = 0;
130  rdFast = 0;
131  rdSlow = 0;
132  }
133 
134  long long Add2Q; // Number added to queue
135  long long PBack; // Number that we could piggy-back
136  long long Resp; // Number of reponses for a waiting request
137  long long Multi; // Number of multiple response fielded
138  long long luFast; // Fast lookups
139  long long luSlow; // Slow lookups
140  long long rdFast; // Fast redirects
141  long long rdSlow; // Slow redirects
142  };
143 
144 void Statistics(Info &Data) {myMutex.Lock(); Data = Stats; myMutex.UnLock();}
145 
146 void *TimeOut();
147 
149  luFast(0), luSlow(0), rdFast(0), rdSlow(0),
150  Tslice(178), Tdelay(5), myClock(0) {}
152 
153 private:
154 
155 void sendLocResp(XrdCmsRRQSlot *lP);
156 void sendLwtResp(XrdCmsRRQSlot *rP);
157 void sendRedResp(XrdCmsRRQSlot *rP);
158 static const int numSlots = 1024;
159 
165  XrdOucDLlist<XrdCmsRRQSlot> readyQ; // Redirect/Locate ready queue
166 static const int iov_cnt = 2;
167  struct iovec data_iov[iov_cnt];
168  struct iovec redr_iov[iov_cnt];
172 union {char hostbuff[288];
174  *STMax];
175  };
177  int luFast;
178  int luSlow;
179  int rdFast;
180  int rdSlow;
181  int Tslice;
182  int Tdelay;
183 unsigned int myClock;
184 };
185 
186 namespace XrdCms
187 {
188 extern XrdCmsRRQ RRQ;
189 }
190 #endif
void sendLocResp(XrdCmsRRQSlot *lP)
static XrdCmsRRQSlot * Alloc(XrdCmsRRQInfo *Info)
struct iovec data_iov[iov_cnt]
Definition: XrdCmsRRQ.hh:167
XrdCms::CmsResponse dataResp
Definition: XrdCmsRRQ.hh:169
int luSlow
Definition: XrdCmsRRQ.hh:178
unsigned int myClock
Definition: XrdCmsRRQ.hh:183
long long rdFast
Definition: XrdCmsRRQ.hh:140
int rdSlow
Definition: XrdCmsRRQ.hh:180
XrdCmsRRQSlot * LkUp
Definition: XrdCmsRRQ.hh:92
long long Resp
Definition: XrdCmsRRQ.hh:136
Info()
Definition: XrdCmsRRQ.hh:120
int Init(int Tint=0, int Tdly=0)
void Del(short Snum, const void *Key)
XrdOucDLlist< XrdCmsRRQSlot > waitQ
Definition: XrdCmsRRQ.hh:164
short Add(short Snum, XrdCmsRRQInfo *ip)
int Tdelay
Definition: XrdCmsRRQ.hh:182
char isRW
Definition: XrdCmsRRQ.hh:53
static const int RHLen
Definition: YProtocol.hh:264
unsigned int Expire
Definition: XrdCmsRRQ.hh:96
XrdCmsRRQ RRQ
Info Stats
Definition: XrdCmsRRQ.hh:176
char hostbuff[288]
Definition: XrdCmsRRQ.hh:172
XrdSysMutex myMutex
Definition: XrdCmsRRQ.hh:160
int Rinst
Definition: XrdCmsRRQ.hh:51
char minR
Definition: XrdCmsRRQ.hh:55
XrdSysSemaphore isReady
Definition: XrdCmsRRQ.hh:162
SMask_t Arg1
Definition: XrdCmsRRQ.hh:94
void * TimeOut()
struct iovec redr_iov[iov_cnt]
Definition: XrdCmsRRQ.hh:168
long long PBack
Definition: XrdCmsRRQ.hh:135
kXR_unt32 ID
Definition: XrdCmsRRQ.hh:50
int Ready(int Snum, const void *Key, SMask_t mask1, SMask_t mask2)
XrdCmsRRQInfo(int rinst, short rnum, kXR_unt32 id, int minQ=0)
Definition: XrdCmsRRQ.hh:62
short Rnum
Definition: XrdCmsRRQ.hh:52
~XrdCmsRRQInfo()
Definition: XrdCmsRRQ.hh:66
Definition: XrdSysPthread.hh:164
XrdCmsRRQInfo Info
Definition: XrdCmsRRQ.hh:93
XrdSysSemaphore isWaiting
Definition: XrdCmsRRQ.hh:161
~XrdCmsRRQSlot()
Definition: XrdCmsRRQ.hh:82
static XrdCmsRRQSlot * freeSlot
Definition: XrdCmsRRQ.hh:87
~XrdCmsRRQ()
Definition: XrdCmsRRQ.hh:151
Definition: XrdCmsRRQ.hh:104
static short initSlot
Definition: XrdCmsRRQ.hh:88
char isLU
Definition: XrdCmsRRQ.hh:54
Definition: XrdSysPthread.hh:493
static XrdSysMutex myMutex
Definition: XrdCmsRRQ.hh:86
unsigned long long SMask_t
Definition: XrdCmsTypes.hh:33
XrdCmsRRQSlot Slot[numSlots]
Definition: XrdCmsRRQ.hh:163
long long rdSlow
Definition: XrdCmsRRQ.hh:141
void Reset()
Definition: XrdCmsRRQ.hh:123
#define STMax
Definition: XrdCmsTypes.hh:39
unsigned int kXR_unt32
Definition: XPtypes.hh:90
SMask_t rwVec
Definition: XrdCmsRRQ.hh:59
SMask_t Arg2
Definition: XrdCmsRRQ.hh:95
char databuff[XrdCms::CmsLocateRequest::RHLen *STMax]
Definition: XrdCmsRRQ.hh:174
void * Key
Definition: XrdCmsRRQ.hh:49
Definition: XrdCmsRRQ.hh:118
long long Add2Q
Definition: XrdCmsRRQ.hh:134
void sendLwtResp(XrdCmsRRQSlot *rP)
int luFast
Definition: XrdCmsRRQ.hh:177
void * Respond()
long long luSlow
Definition: XrdCmsRRQ.hh:139
XrdCms::CmsResponse redrResp
Definition: XrdCmsRRQ.hh:170
void Lock()
Definition: XrdSysPthread.hh:222
static const int iov_cnt
Definition: XrdCmsRRQ.hh:166
static const int numSlots
Definition: XrdCmsRRQ.hh:158
int rdFast
Definition: XrdCmsRRQ.hh:179
char actR
Definition: XrdCmsRRQ.hh:56
char ifOP
Definition: XrdCmsRRQ.hh:58
long long luFast
Definition: XrdCmsRRQ.hh:138
XrdCmsRRQ()
Definition: XrdCmsRRQ.hh:148
int slotNum
Definition: XrdCmsRRQ.hh:97
long long Multi
Definition: XrdCmsRRQ.hh:137
Definition: YProtocol.hh:167
int Tslice
Definition: XrdCmsRRQ.hh:181
XrdCmsRRQSlot * Cont
Definition: XrdCmsRRQ.hh:91
void UnLock()
Definition: XrdSysPthread.hh:224
Definition: XrdCmsRRQ.hh:46
XrdOucDLlist< XrdCmsRRQSlot > readyQ
Definition: XrdCmsRRQ.hh:165
char lsLU
Definition: XrdCmsRRQ.hh:57
void sendRedResp(XrdCmsRRQSlot *rP)
XrdCms::CmsResponse waitResp
Definition: XrdCmsRRQ.hh:171
XrdOucDLlist< XrdCmsRRQSlot > Link
Definition: XrdCmsRRQ.hh:90
XrdCmsRRQInfo()
Definition: XrdCmsRRQ.hh:61
Definition: XrdCmsRRQ.hh:73
void Statistics(Info &Data)
Definition: XrdCmsRRQ.hh:144