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
13
#include <sys/uio.h>
14
15
#include "
XProtocol/XPtypes.hh
"
16
#include "
XProtocol/YProtocol.hh
"
17
18
#include "
XrdCms/XrdCmsTypes.hh
"
19
#include "
XrdOuc/XrdOucDLlist.hh
"
20
#include "
XrdSys/XrdSysPthread.hh
"
21
22
/******************************************************************************/
23
/* X r d C m s R R Q I n f o */
24
/******************************************************************************/
25
26
class
XrdCmsRRQInfo
27
{
28
public
:
29
void
*
Key
;
// Key link, which is the cache line address
30
kXR_unt32
ID
;
// Response link, which is the request ID
31
int
Rinst
;
// Redirector instance
32
short
Rnum
;
// Redirector number (RTable slot number)
33
char
isRW
;
// True if r/w access wanted
34
char
isLU
;
// True if locate response wanted
35
char
minR
;
// Minimum number of responses for fast redispatch
36
char
actR
;
// Actual number of responses
37
short
Rsvd
;
38
SMask_t
rwVec
;
// R/W servers for corresponding path (if isLU is true)
39
40
XrdCmsRRQInfo
() :
isLU
(0) {}
41
XrdCmsRRQInfo
(
int
rinst,
short
rnum,
kXR_unt32
id
,
int
minQ=0)
42
:
Key
(0),
ID
(id),
Rinst
(rinst),
Rnum
(rnum),
43
isRW
(0),
isLU
(0),
minR
(minQ),
actR
(0) {}
44
~XrdCmsRRQInfo
() {}
45
};
46
47
/******************************************************************************/
48
/* X r d C m s R R Q S l o t */
49
/******************************************************************************/
50
51
class
XrdCmsRRQSlot
52
{
53
friend
class
XrdCmsRRQ
;
54
55
static
XrdCmsRRQSlot
*
Alloc
(
XrdCmsRRQInfo
*
Info
);
56
57
void
Recycle
();
58
59
XrdCmsRRQSlot
();
60
~XrdCmsRRQSlot
() {}
61
62
private
:
63
64
static
XrdSysMutex
myMutex
;
65
static
XrdCmsRRQSlot
*
freeSlot
;
66
static
short
initSlot
;
67
68
XrdOucDLlist<XrdCmsRRQSlot>
Link
;
69
XrdCmsRRQSlot
*
Cont
;
70
XrdCmsRRQSlot
*
LkUp
;
71
XrdCmsRRQInfo
Info
;
72
SMask_t
Arg1
;
73
SMask_t
Arg2
;
74
unsigned
int
Expire
;
75
int
slotNum
;
76
};
77
78
/******************************************************************************/
79
/* X r d C m s R R Q */
80
/******************************************************************************/
81
82
class
XrdCmsRRQ
83
{
84
public
:
85
86
short
Add
(
short
Snum,
XrdCmsRRQInfo
*ip);
87
88
void
Del
(
short
Snum,
const
void
*Key);
89
90
int
Init
(
int
Tint=0,
int
Tdly=0);
91
92
int
Ready
(
int
Snum,
const
void
*Key,
SMask_t
mask1,
SMask_t
mask2);
93
94
void
*
Respond
();
95
96
struct
Info
97
{
long
long
Add2Q
;
// Number added to queue
98
long
long
PBack
;
// Number that we could piggy-back
99
long
long
Resp
;
// Number of reponses for a waiting request
100
long
long
Multi
;
// Number of multiple response fielded
101
long
long
luFast
;
// Fast lookups
102
long
long
luSlow
;
// Slow lookups
103
long
long
rdFast
;
// Fast redirects
104
long
long
rdSlow
;
// Slow redirects
105
};
106
107
void
Statistics
(
Info
&Data) {
myMutex
.
Lock
(); Data =
Stats
;
myMutex
.
UnLock
();}
108
109
void
*
TimeOut
();
110
111
XrdCmsRRQ
() :
isWaiting
(0),
isReady
(0),
Tslice
(178),
112
Tdelay
(5),
myClock
(0) {}
113
~XrdCmsRRQ
() {}
114
115
private
:
116
117
int
sendLocResp
(
XrdCmsRRQSlot
*lP);
118
void
sendResponse
(
XrdCmsRRQInfo
*
Info
,
int
doredir,
int
totlen = 0);
119
static
const
int
numSlots
= 1024;
120
121
XrdSysMutex
myMutex
;
122
XrdSysSemaphore
isWaiting
;
123
XrdSysSemaphore
isReady
;
124
XrdCmsRRQSlot
Slot
[
numSlots
];
125
XrdOucDLlist<XrdCmsRRQSlot>
waitQ
;
126
XrdOucDLlist<XrdCmsRRQSlot>
readyQ
;
// Redirect/Locate ready queue
127
static
const
int
iov_cnt
= 2;
128
struct
iovec
data_iov
[
iov_cnt
];
129
struct
iovec
redr_iov
[
iov_cnt
];
130
XrdCms::CmsResponse
dataResp
;
131
XrdCms::CmsResponse
redrResp
;
132
XrdCms::CmsResponse
waitResp
;
133
union
{
char
hostbuff
[288];
134
char
databuff
[
XrdCms::CmsLocateRequest::RILen
135
*
STMax
];
136
};
137
Info
Stats
;
138
int
Tslice
;
139
int
Tdelay
;
140
unsigned
int
myClock
;
141
};
142
143
namespace
XrdCms
144
{
145
extern
XrdCmsRRQ
RRQ
;
146
}
147
#endif
Generated by
1.8.1.2