xrootd
XrdClPostMasterInterfaces.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
3// Author: Lukasz Janyst <ljanyst@cern.ch>
4//------------------------------------------------------------------------------
5// This file is part of the XRootD software suite.
6//
7// XRootD is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// XRootD is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19//
20// In applying this licence, CERN does not waive the privileges and immunities
21// granted to it by virtue of its status as an Intergovernmental Organization
22// or submit itself to any jurisdiction.
23//------------------------------------------------------------------------------
24
25#ifndef __XRD_CL_POST_MASTER_INTERFACES_HH__
26#define __XRD_CL_POST_MASTER_INTERFACES_HH__
27
28#include <stdint.h>
29#include <ctime>
30
31#include "XrdCl/XrdClStatus.hh"
33#include "XrdCl/XrdClURL.hh"
34
35class XrdNetAddr;
36
37namespace XrdCl
38{
39 class Channel;
40 class Message;
41 class URL;
42
43 //----------------------------------------------------------------------------
45 //----------------------------------------------------------------------------
47 {
48 public:
49 virtual ~MessageFilter() {}
50
51 //------------------------------------------------------------------------
54 //------------------------------------------------------------------------
55 virtual bool Filter( const Message *msg ) = 0;
56
57 //------------------------------------------------------------------------
61 //------------------------------------------------------------------------
62 virtual uint16_t GetSid() const = 0;
63 };
64
65 //----------------------------------------------------------------------------
67 //----------------------------------------------------------------------------
69 {
70 public:
71 //------------------------------------------------------------------------
73 //------------------------------------------------------------------------
74 enum Action
75 {
76 Take = 0x0001,
77 Ignore = 0x0002,
78 RemoveHandler = 0x0004,
80 Raw = 0x0008,
83 NoProcess = 0x0010
86 };
87
88 //------------------------------------------------------------------------
90 //------------------------------------------------------------------------
92 {
93 Ready = 1,
94 Broken = 2,
95 Timeout = 3,
96 FatalError = 4
97 };
98
99 //------------------------------------------------------------------------
101 //------------------------------------------------------------------------
102
104
105 //------------------------------------------------------------------------
111 //------------------------------------------------------------------------
112 virtual uint16_t Examine( Message *msg ) = 0;
113
114 //------------------------------------------------------------------------
118 //------------------------------------------------------------------------
119 virtual uint16_t GetSid() const = 0;
120
121 //------------------------------------------------------------------------
125 //------------------------------------------------------------------------
126 virtual void Process( Message *msg ) { (void)msg; };
127
128 //------------------------------------------------------------------------
138 //------------------------------------------------------------------------
140 int socket,
141 uint32_t &bytesRead )
142 {
143 (void)msg; (void)socket; (void)bytesRead;
144 return Status( stOK, suDone );
145 };
146
147 //------------------------------------------------------------------------
154 //------------------------------------------------------------------------
155 virtual uint8_t OnStreamEvent( StreamEvent event,
156 uint16_t streamNum,
157 Status status )
158 {
159 (void)event; (void)streamNum; (void)status;
160 return 0;
161 };
162 };
163
164 //----------------------------------------------------------------------------
166 //----------------------------------------------------------------------------
168 {
169 public:
171
172 //------------------------------------------------------------------------
174 //------------------------------------------------------------------------
175 virtual void OnStatusReady( const Message *message,
176 Status status ) = 0;
177
178 //------------------------------------------------------------------------
186 //------------------------------------------------------------------------
187 virtual void OnReadyToSend( Message *msg, uint16_t streamNum )
188 {
189 (void)msg; (void)streamNum;
190 };
191
192 //------------------------------------------------------------------------
196 //------------------------------------------------------------------------
197 virtual bool IsRaw() const { return false; }
198
199 //------------------------------------------------------------------------
208 //------------------------------------------------------------------------
209 virtual Status WriteMessageBody( int socket,
210 uint32_t &bytesRead )
211 {
212 (void)socket; (void)bytesRead;
213 return Status();
214 }
215 };
216
217 //----------------------------------------------------------------------------
219 //----------------------------------------------------------------------------
221 {
222 public:
223 //------------------------------------------------------------------------
225 //------------------------------------------------------------------------
227 {
230 FatalError = 4
231 };
232
233 //------------------------------------------------------------------------
235 //------------------------------------------------------------------------
237
238 //------------------------------------------------------------------------
246 //------------------------------------------------------------------------
247 virtual bool OnChannelEvent( ChannelEvent event,
248 Status status,
249 uint16_t stream ) = 0;
250 };
251
252 //----------------------------------------------------------------------------
254 //----------------------------------------------------------------------------
255
257 {
258 //--------------------------------------------------------------------------
260 //--------------------------------------------------------------------------
261 HandShakeData( const URL *addr, uint16_t stream, uint16_t subStream ):
262 step(0), out(0), in(0), url(addr), streamId(stream),
263 subStreamId( subStream ), startTime( time(0) ), serverAddr(0)
264 {}
265 uint16_t step;
268 const URL *url;
269 uint16_t streamId;
270 uint16_t subStreamId;
271 time_t startTime;
272 const
274 std::string clientName;
275 std::string streamName;
276 };
277
278 //----------------------------------------------------------------------------
281 //----------------------------------------------------------------------------
282 struct PathID
283 {
284 PathID( uint16_t u = 0, uint16_t d = 0 ): up(u), down(d) {}
285 uint16_t up;
286 uint16_t down;
287 };
288
289 //----------------------------------------------------------------------------
292 //----------------------------------------------------------------------------
294 {
295 static const uint16_t Name = 1;
296 static const uint16_t Auth = 2;
297 };
298
299 //----------------------------------------------------------------------------
301 //----------------------------------------------------------------------------
303 {
304 public:
305
306 //------------------------------------------------------------------------
308 //------------------------------------------------------------------------
310 {
311 NoAction = 0x0000,
312 DigestMsg = 0x0001,
314 AbortStream = 0x0002,
317 CloseStream = 0x0004,
319 ResumeStream = 0x0008,
321 HoldStream = 0x0010,
322 RequestClose = 0x0020
323 };
324
325
326 virtual ~TransportHandler() {}
327
328 //------------------------------------------------------------------------
339 //------------------------------------------------------------------------
340 virtual Status GetHeader( Message *message, int socket ) = 0;
341
342 //------------------------------------------------------------------------
351 //------------------------------------------------------------------------
352 virtual Status GetBody( Message *message, int socket ) = 0;
353
354 //------------------------------------------------------------------------
356 //------------------------------------------------------------------------
357 virtual void InitializeChannel( AnyObject &channelData ) = 0;
358
359 //------------------------------------------------------------------------
361 //------------------------------------------------------------------------
362 virtual void FinalizeChannel( AnyObject &channelData ) = 0;
363
364 //------------------------------------------------------------------------
366 //------------------------------------------------------------------------
367 virtual Status HandShake( HandShakeData *handShakeData,
368 AnyObject &channelData ) = 0;
369
370 //------------------------------------------------------------------------
372 //------------------------------------------------------------------------
373 virtual bool IsStreamTTLElapsed( time_t inactiveTime,
374 uint16_t streamId,
375 AnyObject &channelData ) = 0;
376
377 //------------------------------------------------------------------------
380 //------------------------------------------------------------------------
381 virtual Status IsStreamBroken( time_t inactiveTime,
382 uint16_t streamId,
383 AnyObject &channelData ) = 0;
384
385 //------------------------------------------------------------------------
391 //------------------------------------------------------------------------
392 virtual PathID Multiplex( Message *msg,
393 AnyObject &channelData,
394 PathID *hint = 0 ) = 0;
395
396 //------------------------------------------------------------------------
402 //------------------------------------------------------------------------
404 uint16_t streamId,
405 AnyObject &channelData,
406 PathID *hint = 0 ) = 0;
407
408 //------------------------------------------------------------------------
410 //------------------------------------------------------------------------
411 virtual uint16_t StreamNumber( AnyObject &channelData ) = 0;
412
413 //------------------------------------------------------------------------
415 //------------------------------------------------------------------------
416 virtual uint16_t SubStreamNumber( AnyObject &channelData ) = 0;
417
418 //------------------------------------------------------------------------
420 //------------------------------------------------------------------------
421 virtual void Disconnect( AnyObject &channelData,
422 uint16_t streamId,
423 uint16_t subStreamId ) = 0;
424
425 //------------------------------------------------------------------------
427 //------------------------------------------------------------------------
428 virtual Status Query( uint16_t query,
429 AnyObject &result,
430 AnyObject &channelData ) = 0;
431
432 //------------------------------------------------------------------------
434 //------------------------------------------------------------------------
435 virtual uint32_t MessageReceived( Message *msg,
436 uint16_t streamId,
437 uint16_t subStream,
438 AnyObject &channelData ) = 0;
439
440 //------------------------------------------------------------------------
442 //------------------------------------------------------------------------
443 virtual void MessageSent( Message *msg,
444 uint16_t streamId,
445 uint16_t subStream,
446 uint32_t bytesSent,
447 AnyObject &channelData ) = 0;
448 };
449}
450
451#endif // __XRD_CL_POST_MASTER_INTERFACES_HH__
Definition: XrdClAnyObject.hh:33
Channel event handler.
Definition: XrdClPostMasterInterfaces.hh:221
virtual bool OnChannelEvent(ChannelEvent event, Status status, uint16_t stream)=0
ChannelEvent
Events that may have occurred to the channel.
Definition: XrdClPostMasterInterfaces.hh:227
@ StreamBroken
The stream is broken.
Definition: XrdClPostMasterInterfaces.hh:229
@ StreamReady
The stream has become connected.
Definition: XrdClPostMasterInterfaces.hh:228
@ FatalError
Stream has been broken and won't be recovered.
Definition: XrdClPostMasterInterfaces.hh:230
virtual ~ChannelEventHandler()
Destructor.
Definition: XrdClPostMasterInterfaces.hh:236
Message handler.
Definition: XrdClPostMasterInterfaces.hh:69
Action
Actions to be taken after a message is processed by the handler.
Definition: XrdClPostMasterInterfaces.hh:75
@ Raw
Definition: XrdClPostMasterInterfaces.hh:80
@ Ignore
Ignore the message.
Definition: XrdClPostMasterInterfaces.hh:77
@ Take
Take ownership over the message.
Definition: XrdClPostMasterInterfaces.hh:76
@ RemoveHandler
Definition: XrdClPostMasterInterfaces.hh:78
@ NoProcess
Definition: XrdClPostMasterInterfaces.hh:83
virtual ~IncomingMsgHandler()
Event types that the message handler may receive.
Definition: XrdClPostMasterInterfaces.hh:103
virtual void Process(Message *msg)
Definition: XrdClPostMasterInterfaces.hh:126
virtual uint16_t GetSid() const =0
virtual Status ReadMessageBody(Message *msg, int socket, uint32_t &bytesRead)
Definition: XrdClPostMasterInterfaces.hh:139
virtual uint16_t Examine(Message *msg)=0
StreamEvent
Events that may have occurred to the stream.
Definition: XrdClPostMasterInterfaces.hh:92
@ Broken
The stream is broken.
Definition: XrdClPostMasterInterfaces.hh:94
@ Timeout
The declared timeout has occurred.
Definition: XrdClPostMasterInterfaces.hh:95
@ Ready
The stream has become connected.
Definition: XrdClPostMasterInterfaces.hh:93
@ FatalError
Stream has been broken and won't be recovered.
Definition: XrdClPostMasterInterfaces.hh:96
virtual uint8_t OnStreamEvent(StreamEvent event, uint16_t streamNum, Status status)
Definition: XrdClPostMasterInterfaces.hh:155
Message filter.
Definition: XrdClPostMasterInterfaces.hh:47
virtual uint16_t GetSid() const =0
virtual ~MessageFilter()
Definition: XrdClPostMasterInterfaces.hh:49
virtual bool Filter(const Message *msg)=0
The message representation used throughout the system.
Definition: XrdClMessage.hh:30
Message status handler.
Definition: XrdClPostMasterInterfaces.hh:168
virtual void OnReadyToSend(Message *msg, uint16_t streamNum)
Definition: XrdClPostMasterInterfaces.hh:187
virtual void OnStatusReady(const Message *message, Status status)=0
The requested action has been performed and the status is available.
virtual ~OutgoingMsgHandler()
Definition: XrdClPostMasterInterfaces.hh:170
virtual Status WriteMessageBody(int socket, uint32_t &bytesRead)
Definition: XrdClPostMasterInterfaces.hh:209
virtual bool IsRaw() const
Definition: XrdClPostMasterInterfaces.hh:197
Perform the handshake and the authentication for each physical stream.
Definition: XrdClPostMasterInterfaces.hh:303
virtual void MessageSent(Message *msg, uint16_t streamId, uint16_t subStream, uint32_t bytesSent, AnyObject &channelData)=0
Notify the transport about a message having been sent.
StreamAction
Stream actions that may be triggered by incoming control messages.
Definition: XrdClPostMasterInterfaces.hh:310
@ NoAction
No action.
Definition: XrdClPostMasterInterfaces.hh:311
@ DigestMsg
Definition: XrdClPostMasterInterfaces.hh:312
@ RequestClose
Send a close request.
Definition: XrdClPostMasterInterfaces.hh:322
@ AbortStream
Definition: XrdClPostMasterInterfaces.hh:314
@ HoldStream
Stop sending requests [not yet implemented].
Definition: XrdClPostMasterInterfaces.hh:321
@ CloseStream
Definition: XrdClPostMasterInterfaces.hh:317
@ ResumeStream
Definition: XrdClPostMasterInterfaces.hh:319
virtual bool IsStreamTTLElapsed(time_t inactiveTime, uint16_t streamId, AnyObject &channelData)=0
Check if the stream should be disconnected.
virtual Status IsStreamBroken(time_t inactiveTime, uint16_t streamId, AnyObject &channelData)=0
virtual Status GetBody(Message *message, int socket)=0
virtual uint16_t SubStreamNumber(AnyObject &channelData)=0
Return a number of substreams per stream that should be created.
virtual void InitializeChannel(AnyObject &channelData)=0
Initialize channel.
virtual PathID Multiplex(Message *msg, AnyObject &channelData, PathID *hint=0)=0
virtual Status Query(uint16_t query, AnyObject &result, AnyObject &channelData)=0
Query the channel.
virtual Status GetHeader(Message *message, int socket)=0
virtual void FinalizeChannel(AnyObject &channelData)=0
Finalize channel.
virtual PathID MultiplexSubStream(Message *msg, uint16_t streamId, AnyObject &channelData, PathID *hint=0)=0
virtual uint16_t StreamNumber(AnyObject &channelData)=0
Return a number of streams that should be created.
virtual ~TransportHandler()
Definition: XrdClPostMasterInterfaces.hh:326
virtual void Disconnect(AnyObject &channelData, uint16_t streamId, uint16_t subStreamId)=0
The stream has been disconnected, do the cleanups.
virtual Status HandShake(HandShakeData *handShakeData, AnyObject &channelData)=0
HandHake.
virtual uint32_t MessageReceived(Message *msg, uint16_t streamId, uint16_t subStream, AnyObject &channelData)=0
Check if the message invokes a stream action.
URL representation.
Definition: XrdClURL.hh:31
Definition: XrdNetAddr.hh:42
Definition: XrdClAnyObject.hh:26
const uint16_t stOK
Everything went OK.
Definition: XrdClStatus.hh:31
const uint16_t suDone
Definition: XrdClStatus.hh:38
Data structure that carries the handshake information.
Definition: XrdClPostMasterInterfaces.hh:257
uint16_t streamId
Stream number.
Definition: XrdClPostMasterInterfaces.hh:269
uint16_t step
Handshake step.
Definition: XrdClPostMasterInterfaces.hh:265
time_t startTime
Timestamp of when the handshake started.
Definition: XrdClPostMasterInterfaces.hh:271
std::string streamName
Name of the stream.
Definition: XrdClPostMasterInterfaces.hh:275
std::string clientName
Client name (an IPv6 representation)
Definition: XrdClPostMasterInterfaces.hh:274
const URL * url
Destination URL.
Definition: XrdClPostMasterInterfaces.hh:268
const XrdNetAddr * serverAddr
Server address.
Definition: XrdClPostMasterInterfaces.hh:273
Message * in
Message that has been received.
Definition: XrdClPostMasterInterfaces.hh:267
HandShakeData(const URL *addr, uint16_t stream, uint16_t subStream)
Constructor.
Definition: XrdClPostMasterInterfaces.hh:261
uint16_t subStreamId
Sub-stream id.
Definition: XrdClPostMasterInterfaces.hh:270
Message * out
Message to be sent out.
Definition: XrdClPostMasterInterfaces.hh:266
Definition: XrdClPostMasterInterfaces.hh:283
uint16_t down
Definition: XrdClPostMasterInterfaces.hh:286
PathID(uint16_t u=0, uint16_t d=0)
Definition: XrdClPostMasterInterfaces.hh:284
uint16_t up
Definition: XrdClPostMasterInterfaces.hh:285
Procedure execution status.
Definition: XrdClStatus.hh:110
Definition: XrdClPostMasterInterfaces.hh:294
static const uint16_t Name
Transport name, returns const char *.
Definition: XrdClPostMasterInterfaces.hh:295
static const uint16_t Auth
Transport name, returns std::string *.
Definition: XrdClPostMasterInterfaces.hh:296