xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdCms
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
46
class
XrdCmsRRQInfo
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
short
Rsvd
;
58
SMask_t
rwVec
;
// R/W servers for corresponding path (if isLU is true)
59
60
XrdCmsRRQInfo
() :
isLU
(0) {}
61
XrdCmsRRQInfo
(
int
rinst,
short
rnum,
kXR_unt32
id
,
int
minQ=0)
62
:
Key
(0),
ID
(id),
Rinst
(rinst),
Rnum
(rnum),
63
isRW
(0),
isLU
(0),
minR
(minQ),
actR
(0),
Rsvd
(0),
64
rwVec
(0) {}
65
~XrdCmsRRQInfo
() {}
66
};
67
68
/******************************************************************************/
69
/* X r d C m s R R Q S l o t */
70
/******************************************************************************/
71
72
class
XrdCmsRRQSlot
73
{
74
friend
class
XrdCmsRRQ
;
75
76
static
XrdCmsRRQSlot
*
Alloc
(
XrdCmsRRQInfo
*
Info
);
77
78
void
Recycle
();
79
80
XrdCmsRRQSlot
();
81
~XrdCmsRRQSlot
() {}
82
83
private
:
84
85
static
XrdSysMutex
myMutex
;
86
static
XrdCmsRRQSlot
*
freeSlot
;
87
static
short
initSlot
;
88
89
XrdOucDLlist<XrdCmsRRQSlot>
Link
;
90
XrdCmsRRQSlot
*
Cont
;
91
XrdCmsRRQSlot
*
LkUp
;
92
XrdCmsRRQInfo
Info
;
93
SMask_t
Arg1
;
94
SMask_t
Arg2
;
95
unsigned
int
Expire
;
96
int
slotNum
;
97
};
98
99
/******************************************************************************/
100
/* X r d C m s R R Q */
101
/******************************************************************************/
102
103
class
XrdCmsRRQ
104
{
105
public
:
106
107
short
Add
(
short
Snum,
XrdCmsRRQInfo
*ip);
108
109
void
Del
(
short
Snum,
const
void
*Key);
110
111
int
Init
(
int
Tint=0,
int
Tdly=0);
112
113
int
Ready
(
int
Snum,
const
void
*Key,
SMask_t
mask1,
SMask_t
mask2);
114
115
void
*
Respond
();
116
117
struct
Info
118
{
long
long
Add2Q
;
// Number added to queue
119
long
long
PBack
;
// Number that we could piggy-back
120
long
long
Resp
;
// Number of reponses for a waiting request
121
long
long
Multi
;
// Number of multiple response fielded
122
long
long
luFast
;
// Fast lookups
123
long
long
luSlow
;
// Slow lookups
124
long
long
rdFast
;
// Fast redirects
125
long
long
rdSlow
;
// Slow redirects
126
};
127
128
void
Statistics
(
Info
&Data) {
myMutex
.
Lock
(); Data =
Stats
;
myMutex
.
UnLock
();}
129
130
void
*
TimeOut
();
131
132
XrdCmsRRQ
() :
isWaiting
(0),
isReady
(0),
133
luFast
(0),
luSlow
(0),
rdFast
(0),
rdSlow
(0),
134
Tslice
(178),
Tdelay
(5),
myClock
(0) {}
135
~XrdCmsRRQ
() {}
136
137
private
:
138
139
void
sendLocResp
(
XrdCmsRRQSlot
*lP);
140
void
sendLwtResp
(
XrdCmsRRQSlot
*rP);
141
void
sendRedResp
(
XrdCmsRRQSlot
*rP);
142
static
const
int
numSlots
= 1024;
143
144
XrdSysMutex
myMutex
;
145
XrdSysSemaphore
isWaiting
;
146
XrdSysSemaphore
isReady
;
147
XrdCmsRRQSlot
Slot
[
numSlots
];
148
XrdOucDLlist<XrdCmsRRQSlot>
waitQ
;
149
XrdOucDLlist<XrdCmsRRQSlot>
readyQ
;
// Redirect/Locate ready queue
150
static
const
int
iov_cnt
= 2;
151
struct
iovec
data_iov
[
iov_cnt
];
152
struct
iovec
redr_iov
[
iov_cnt
];
153
XrdCms::CmsResponse
dataResp
;
154
XrdCms::CmsResponse
redrResp
;
155
XrdCms::CmsResponse
waitResp
;
156
union
{
char
hostbuff
[288];
157
char
databuff
[
XrdCms::CmsLocateRequest::RILen
158
*
STMax
];
159
};
160
Info
Stats
;
161
int
luFast
;
162
int
luSlow
;
163
int
rdFast
;
164
int
rdSlow
;
165
int
Tslice
;
166
int
Tdelay
;
167
unsigned
int
myClock
;
168
};
169
170
namespace
XrdCms
171
{
172
extern
XrdCmsRRQ
RRQ
;
173
}
174
#endif
Generated by
1.8.3.1