xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdCl
XrdClXRootDMsgHandler.hh
Go to the documentation of this file.
1
//------------------------------------------------------------------------------
2
// Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3
// Author: Lukasz Janyst <ljanyst@cern.ch>
4
//------------------------------------------------------------------------------
5
// XRootD is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU Lesser General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// XRootD is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17
//------------------------------------------------------------------------------
18
19
#ifndef __XRD_CL_XROOTD_MSG_HANDLER_HH__
20
#define __XRD_CL_XROOTD_MSG_HANDLER_HH__
21
22
#include "
XrdCl/XrdClPostMasterInterfaces.hh
"
23
#include "
XrdCl/XrdClXRootDResponses.hh
"
24
#include "
XrdCl/XrdClDefaultEnv.hh
"
25
#include "
XrdCl/XrdClMessage.hh
"
26
#include "
XProtocol/XProtocol.hh
"
27
28
namespace
XrdCl
29
{
30
class
PostMaster;
31
class
SIDManager;
32
class
URL;
33
34
//----------------------------------------------------------------------------
36
//----------------------------------------------------------------------------
37
class
XRootDMsgHandler
:
public
IncomingMsgHandler
,
38
public
OutgoingMsgHandler
39
{
40
public
:
41
//------------------------------------------------------------------------
50
//------------------------------------------------------------------------
51
XRootDMsgHandler
(
Message
*msg,
52
ResponseHandler
*respHandler,
53
const
URL
*url,
54
SIDManager
*sidMgr ):
55
pRequest
( msg ),
56
pResponse
( 0 ),
57
pResponseHandler
( respHandler ),
58
pUrl
( *url ),
59
pSidMgr
( sidMgr ),
60
pExpiration
( 0 ),
61
pRedirectAsAnswer
( false ),
62
pHosts
( 0 ),
63
pHasLoadBalancer
( false ),
64
pHasSessionId
( false ),
65
pChunkList
( 0 ),
66
pRedirectCounter
( 0 ),
67
68
pAsyncOffset
( 0 ),
69
pAsyncReadSize
( 0 ),
70
pAsyncReadBuffer
( 0 ),
71
pAsyncMsgSize
( 0 ),
72
73
pReadRawStarted
( false ),
74
pReadRawCurrentOffset
( 0 ),
75
76
pReadVRawMsgOffset
( 0 ),
77
pReadVRawChunkHeaderDone
( false ),
78
pReadVRawChunkHeaderStarted
( false ),
79
pReadVRawSizeError
( false ),
80
pReadVRawChunkIndex
( -1 ),
81
pReadVRawMsgDiscard
( false ),
82
83
pOtherRawStarted
( false )
84
{
85
pPostMaster
=
DefaultEnv::GetPostMaster
();
86
if
( msg->
GetSessionId
() )
87
pHasSessionId
=
true
;
88
memset( &
pReadVRawChunkHeader
, 0,
sizeof
(
readahead_list
) );
89
}
90
91
//------------------------------------------------------------------------
93
//------------------------------------------------------------------------
94
~XRootDMsgHandler
()
95
{
96
if
( !
pHasSessionId
)
97
delete
pRequest
;
98
delete
pResponse
;
99
std::vector<Message *>::iterator it;
100
for
( it =
pPartialResps
.begin(); it !=
pPartialResps
.end(); ++it )
101
delete
*it;
102
}
103
104
//------------------------------------------------------------------------
110
//------------------------------------------------------------------------
111
virtual
uint16_t
Examine
(
Message
*msg );
112
113
//------------------------------------------------------------------------
117
//------------------------------------------------------------------------
118
virtual
void
Process
(
Message
*msg );
119
120
//------------------------------------------------------------------------
130
//------------------------------------------------------------------------
131
virtual
Status
ReadMessageBody
(
Message
*msg,
132
int
socket,
133
uint32_t &bytesRead );
134
135
//------------------------------------------------------------------------
141
//------------------------------------------------------------------------
142
virtual
uint8_t
OnStreamEvent
(
StreamEvent
event,
143
uint16_t streamNum,
144
Status
status );
145
146
//------------------------------------------------------------------------
148
//------------------------------------------------------------------------
149
virtual
void
OnStatusReady
(
const
Message
*message,
150
Status
status );
151
152
//------------------------------------------------------------------------
154
//------------------------------------------------------------------------
155
virtual
bool
IsRaw
()
const
;
156
157
//------------------------------------------------------------------------
166
//------------------------------------------------------------------------
167
virtual
Status
WriteMessageBody
(
int
socket,
168
uint32_t &bytesRead );
169
170
//------------------------------------------------------------------------
174
//------------------------------------------------------------------------
175
void
WaitDone
( time_t now );
176
177
//------------------------------------------------------------------------
179
//------------------------------------------------------------------------
180
void
SetExpiration
( time_t expiration )
181
{
182
pExpiration
= expiration;
183
}
184
185
//------------------------------------------------------------------------
188
//------------------------------------------------------------------------
189
void
SetRedirectAsAnswer
(
bool
redirectAsAnswer )
190
{
191
pRedirectAsAnswer
= redirectAsAnswer;
192
}
193
194
//------------------------------------------------------------------------
196
//------------------------------------------------------------------------
197
const
Message
*
GetRequest
()
const
198
{
199
return
pRequest
;
200
}
201
202
//------------------------------------------------------------------------
204
//------------------------------------------------------------------------
205
void
SetLoadBalancer
(
const
HostInfo
&loadBalancer )
206
{
207
if
( !loadBalancer.
url
.
IsValid
() )
208
return
;
209
pLoadBalancer
= loadBalancer;
210
pHasLoadBalancer
=
true
;
211
}
212
213
//------------------------------------------------------------------------
215
//------------------------------------------------------------------------
216
void
SetHostList
(
HostList
*hostList )
217
{
218
delete
pHosts
;
219
pHosts
= hostList;
220
}
221
222
//------------------------------------------------------------------------
224
//------------------------------------------------------------------------
225
void
SetChunkList
(
ChunkList
*chunkList )
226
{
227
pChunkList
= chunkList;
228
if
( chunkList )
229
pChunkStatus
.resize( chunkList->size() );
230
else
231
pChunkStatus
.clear();
232
}
233
234
//------------------------------------------------------------------------
236
//------------------------------------------------------------------------
237
void
SetRedirectCounter
( uint16_t redirectCounter )
238
{
239
pRedirectCounter
= redirectCounter;
240
}
241
242
private
:
243
//------------------------------------------------------------------------
245
//------------------------------------------------------------------------
246
Status
ReadRawRead
(
Message
*msg,
247
int
socket,
248
uint32_t &bytesRead );
249
250
//------------------------------------------------------------------------
252
//------------------------------------------------------------------------
253
Status
ReadRawReadV
(
Message
*msg,
254
int
socket,
255
uint32_t &bytesRead );
256
257
//------------------------------------------------------------------------
259
//------------------------------------------------------------------------
260
Status
ReadRawOther
(
Message
*msg,
261
int
socket,
262
uint32_t &bytesRead );
263
264
//------------------------------------------------------------------------
267
//------------------------------------------------------------------------
268
Status
ReadAsync
(
int
socket, uint32_t &btesRead );
269
270
//------------------------------------------------------------------------
272
//------------------------------------------------------------------------
273
void
HandleError
(
Status
status,
Message
*msg = 0 );
274
275
//------------------------------------------------------------------------
277
//------------------------------------------------------------------------
278
Status
RetryAtServer
(
const
URL
&url );
279
280
//------------------------------------------------------------------------
282
//------------------------------------------------------------------------
283
void
HandleResponse
();
284
285
//------------------------------------------------------------------------
287
//------------------------------------------------------------------------
288
XRootDStatus
*
ProcessStatus
();
289
290
//------------------------------------------------------------------------
293
//------------------------------------------------------------------------
294
Status
ParseResponse
(
AnyObject
*&response );
295
296
//------------------------------------------------------------------------
299
//------------------------------------------------------------------------
300
Status
RewriteRequestRedirect
(
const
URL::ParamsMap
&newCgi );
301
302
//------------------------------------------------------------------------
304
//------------------------------------------------------------------------
305
Status
RewriteRequestWait
();
306
307
//------------------------------------------------------------------------
309
//------------------------------------------------------------------------
310
Status
PostProcessReadV
(
VectorReadInfo
*vReadInfo );
311
312
//------------------------------------------------------------------------
314
//------------------------------------------------------------------------
315
Status
UnPackReadVResponse
(
Message
*msg );
316
317
//------------------------------------------------------------------------
319
//------------------------------------------------------------------------
320
void
UpdateTriedCGI
();
321
322
//------------------------------------------------------------------------
324
//------------------------------------------------------------------------
325
void
SwitchOnRefreshFlag
();
326
327
//------------------------------------------------------------------------
328
// Helper struct for async reading of chunks
329
//------------------------------------------------------------------------
330
struct
ChunkStatus
331
{
332
ChunkStatus
():
sizeError
( false ),
done
( false ) {}
333
bool
sizeError
;
334
bool
done
;
335
};
336
337
Message
*
pRequest
;
338
Message
*
pResponse
;
339
std::vector<Message *>
pPartialResps
;
340
ResponseHandler
*
pResponseHandler
;
341
URL
pUrl
;
342
PostMaster
*
pPostMaster
;
343
SIDManager
*
pSidMgr
;
344
Status
pStatus
;
345
time_t
pExpiration
;
346
bool
pRedirectAsAnswer
;
347
HostList
*
pHosts
;
348
bool
pHasLoadBalancer
;
349
HostInfo
pLoadBalancer
;
350
bool
pHasSessionId
;
351
std::string
pRedirectCgi
;
352
ChunkList
*
pChunkList
;
353
std::vector<ChunkStatus>
pChunkStatus
;
354
uint16_t
pRedirectCounter
;
355
356
uint32_t
pAsyncOffset
;
357
uint32_t
pAsyncReadSize
;
358
char
*
pAsyncReadBuffer
;
359
uint32_t
pAsyncMsgSize
;
360
361
bool
pReadRawStarted
;
362
uint32_t
pReadRawCurrentOffset
;
363
364
uint32_t
pReadVRawMsgOffset
;
365
bool
pReadVRawChunkHeaderDone
;
366
bool
pReadVRawChunkHeaderStarted
;
367
bool
pReadVRawSizeError
;
368
int32_t
pReadVRawChunkIndex
;
369
readahead_list
pReadVRawChunkHeader
;
370
bool
pReadVRawMsgDiscard
;
371
372
bool
pOtherRawStarted
;
373
};
374
}
375
376
#endif // __XRD_CL_XROOTD_MSG_HANDLER_HH__
Generated by
1.8.3.1