xrootd
XrdClPostMasterInterfaces.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_POST_MASTER_INTERFACES_HH__
20 #define __XRD_CL_POST_MASTER_INTERFACES_HH__
21 
22 #include <stdint.h>
23 #include <ctime>
24 
25 #include "XrdCl/XrdClStatus.hh"
26 #include "XrdCl/XrdClAnyObject.hh"
27 #include "XrdCl/XrdClURL.hh"
28 
29 namespace XrdCl
30 {
31  class Channel;
32  class Message;
33  class URL;
34 
35  //----------------------------------------------------------------------------
37  //----------------------------------------------------------------------------
39  {
40  public:
41  virtual ~MessageFilter() {}
42 
43  //------------------------------------------------------------------------
46  //------------------------------------------------------------------------
47  virtual bool Filter( const Message *msg ) = 0;
48  };
49 
50  //----------------------------------------------------------------------------
52  //----------------------------------------------------------------------------
54  {
55  public:
56  //------------------------------------------------------------------------
58  //------------------------------------------------------------------------
59  enum Action
60  {
61  Take = 0x0001,
62  Ignore = 0x0002,
63  RemoveHandler = 0x0004,
64  Raw = 0x0008,
66  NoProcess = 0x0010
69  };
72 
73  //------------------------------------------------------------------------
75  //------------------------------------------------------------------------
77  {
78  Ready = 1,
79  Broken = 2,
80  Timeout = 3,
82  };
83 
84  //------------------------------------------------------------------------
86  //------------------------------------------------------------------------
87 
88  virtual ~IncomingMsgHandler() {}
89 
90  //------------------------------------------------------------------------
96  //------------------------------------------------------------------------
97  virtual uint16_t Examine( Message *msg ) = 0;
98 
99  //------------------------------------------------------------------------
103  //------------------------------------------------------------------------
104  virtual void Process( Message *msg ) { (void)msg; };
105 
106  //------------------------------------------------------------------------
116  //------------------------------------------------------------------------
118  int socket,
119  uint32_t &bytesRead )
120  {
121  (void)msg; (void)socket; (void)bytesRead;
122  return Status( stOK, suDone );
123  };
124 
125  //------------------------------------------------------------------------
132  //------------------------------------------------------------------------
133  virtual uint8_t OnStreamEvent( StreamEvent event,
134  uint16_t streamNum,
135  Status status )
136  {
137  (void)event; (void)streamNum; (void)status;
138  return 0;
139  };
140  };
141 
142  //----------------------------------------------------------------------------
144  //----------------------------------------------------------------------------
146  {
147  public:
148  virtual ~OutgoingMsgHandler() {}
149 
150  //------------------------------------------------------------------------
152  //------------------------------------------------------------------------
153  virtual void OnStatusReady( const Message *message,
154  Status status ) = 0;
155 
156  //------------------------------------------------------------------------
164  //------------------------------------------------------------------------
165  virtual void OnReadyToSend( Message *msg, uint16_t streamNum )
166  {
167  (void)msg; (void)streamNum;
168  };
169 
170  //------------------------------------------------------------------------
174  //------------------------------------------------------------------------
175  virtual bool IsRaw() const { return false; }
176 
177  //------------------------------------------------------------------------
186  //------------------------------------------------------------------------
187  virtual Status WriteMessageBody( int socket,
188  uint32_t &bytesRead )
189  {
190  (void)socket; (void)bytesRead;
191  return Status();
192  }
193  };
194 
195  //----------------------------------------------------------------------------
197  //----------------------------------------------------------------------------
199  {
200  public:
201  //------------------------------------------------------------------------
203  //------------------------------------------------------------------------
205  {
209  };
210 
211  //------------------------------------------------------------------------
213  //------------------------------------------------------------------------
214  virtual ~ChannelEventHandler() {};
215 
216  //------------------------------------------------------------------------
224  //------------------------------------------------------------------------
225  virtual bool OnChannelEvent( ChannelEvent event,
226  Status status,
227  uint16_t stream ) = 0;
228  };
229 
230  //----------------------------------------------------------------------------
232  //----------------------------------------------------------------------------
234  {
235  //--------------------------------------------------------------------------
237  //--------------------------------------------------------------------------
238  HandShakeData( const URL *addr, uint16_t stream, uint16_t subStream ):
239  step(0), out(0), in(0), url(addr), streamId(stream),
240  subStreamId( subStream ), startTime( time(0) ), serverAddr(0)
241  {}
242  uint16_t step;
245  const URL *url;
246  uint16_t streamId;
247  uint16_t subStreamId;
248  time_t startTime;
249  const void *serverAddr;
250  std::string clientName;
251  std::string streamName;
252  };
253 
254  //----------------------------------------------------------------------------
257  //----------------------------------------------------------------------------
258  struct PathID
259  {
260  PathID( uint16_t u = 0, uint16_t d = 0 ): up(u), down(d) {}
261  uint16_t up;
262  uint16_t down;
263  };
264 
265  //----------------------------------------------------------------------------
268  //----------------------------------------------------------------------------
270  {
271  static const uint16_t Name = 1;
272  static const uint16_t Auth = 2;
273  };
274 
275  //----------------------------------------------------------------------------
277  //----------------------------------------------------------------------------
279  {
280  public:
281 
282  //------------------------------------------------------------------------
284  //------------------------------------------------------------------------
286  {
287  NoAction = 0x0000,
288  DigestMsg = 0x0001,
289  AbortStream = 0x0002,
291  CloseStream = 0x0004,
294  ResumeStream = 0x0008,
296  HoldStream = 0x0010
298  };
299 
300 
301  virtual ~TransportHandler() {}
302 
303  //------------------------------------------------------------------------
314  //------------------------------------------------------------------------
315  virtual Status GetHeader( Message *message, int socket ) = 0;
316 
317  //------------------------------------------------------------------------
326  //------------------------------------------------------------------------
327  virtual Status GetBody( Message *message, int socket ) = 0;
328 
329  //------------------------------------------------------------------------
331  //------------------------------------------------------------------------
332  virtual void InitializeChannel( AnyObject &channelData ) = 0;
333 
334  //------------------------------------------------------------------------
336  //------------------------------------------------------------------------
337  virtual void FinalizeChannel( AnyObject &channelData ) = 0;
338 
339  //------------------------------------------------------------------------
341  //------------------------------------------------------------------------
342  virtual Status HandShake( HandShakeData *handShakeData,
343  AnyObject &channelData ) = 0;
344 
345  //------------------------------------------------------------------------
347  //------------------------------------------------------------------------
348  virtual bool IsStreamTTLElapsed( time_t inactiveTime,
349  AnyObject &channelData ) = 0;
350 
351  //------------------------------------------------------------------------
357  //------------------------------------------------------------------------
358  virtual PathID Multiplex( Message *msg,
359  AnyObject &channelData,
360  PathID *hint = 0 ) = 0;
361 
362  //------------------------------------------------------------------------
368  //------------------------------------------------------------------------
369  virtual PathID MultiplexSubStream( Message *msg,
370  AnyObject &channelData,
371  PathID *hint = 0 ) = 0;
372 
373  //------------------------------------------------------------------------
375  //------------------------------------------------------------------------
376  virtual uint16_t StreamNumber( AnyObject &channelData ) = 0;
377 
378  //------------------------------------------------------------------------
380  //------------------------------------------------------------------------
381  virtual uint16_t SubStreamNumber( AnyObject &channelData ) = 0;
382 
383  //------------------------------------------------------------------------
385  //------------------------------------------------------------------------
386  virtual void Disconnect( AnyObject &channelData,
387  uint16_t streamId,
388  uint16_t subStreamId ) = 0;
389 
390  //------------------------------------------------------------------------
392  //------------------------------------------------------------------------
393  virtual Status Query( uint16_t query,
394  AnyObject &result,
395  AnyObject &channelData ) = 0;
396 
397  //------------------------------------------------------------------------
399  //------------------------------------------------------------------------
400  virtual uint32_t StreamAction( Message *msg, AnyObject &channelData ) = 0;
401  };
402 }
403 
404 #endif // __XRD_CL_POST_MASTER_INTERFACES_HH__
Definition: XrdClAnyObject.hh:32
const uint16_t stOK
Everything went OK.
Definition: XrdClStatus.hh:31
Definition: XrdClPostMasterInterfaces.hh:65
virtual bool OnChannelEvent(ChannelEvent event, Status status, uint16_t stream)=0
virtual void FinalizeChannel(AnyObject &channelData)=0
Finalize channel.
Take ownership over the message.
Definition: XrdClPostMasterInterfaces.hh:61
Message filter.
Definition: XrdClPostMasterInterfaces.hh:38
Definition: XrdClPostMasterInterfaces.hh:63
virtual ~IncomingMsgHandler()
Event types that the message handler may receive.
Definition: XrdClPostMasterInterfaces.hh:88
Stream has been broken and won't be recovered.
Definition: XrdClPostMasterInterfaces.hh:81
virtual bool IsRaw() const
Definition: XrdClPostMasterInterfaces.hh:175
virtual Status GetHeader(Message *message, int socket)=0
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
time_t startTime
Timestamp of when the handshake started.
Definition: XrdClPostMasterInterfaces.hh:248
virtual Status WriteMessageBody(int socket, uint32_t &bytesRead)
Definition: XrdClPostMasterInterfaces.hh:187
virtual ~ChannelEventHandler()
Destructor.
Definition: XrdClPostMasterInterfaces.hh:214
StreamAction
Stream actions that may be triggered by incoming control messages.
Definition: XrdClPostMasterInterfaces.hh:285
const URL * url
Destination URL.
Definition: XrdClPostMasterInterfaces.hh:245
virtual PathID Multiplex(Message *msg, AnyObject &channelData, PathID *hint=0)=0
Definition: XrdClPostMasterInterfaces.hh:258
const uint16_t suDone
Definition: XrdClStatus.hh:38
uint16_t subStreamId
Sub-stream id.
Definition: XrdClPostMasterInterfaces.hh:247
std::string clientName
Client name (an IPv6 representation)
Definition: XrdClPostMasterInterfaces.hh:250
static const uint16_t Name
Transport name, returns const char *.
Definition: XrdClPostMasterInterfaces.hh:271
Message * in
Message that has been received.
Definition: XrdClPostMasterInterfaces.hh:244
const void * serverAddr
Server address in the form of sockaddr.
Definition: XrdClPostMasterInterfaces.hh:249
StreamEvent
Events that may have occurred to the stream.
Definition: XrdClPostMasterInterfaces.hh:76
uint16_t up
Definition: XrdClPostMasterInterfaces.hh:261
Procedure execution status.
Definition: XrdClStatus.hh:104
virtual uint16_t Examine(Message *msg)=0
uint16_t step
Handshake step.
Definition: XrdClPostMasterInterfaces.hh:242
virtual uint16_t StreamNumber(AnyObject &channelData)=0
Return a number of streams that should be created.
virtual Status Query(uint16_t query, AnyObject &result, AnyObject &channelData)=0
Query the channel.
virtual bool Filter(const Message *msg)=0
uint16_t streamId
Stream number.
Definition: XrdClPostMasterInterfaces.hh:246
Data structure that carries the handshake information.
Definition: XrdClPostMasterInterfaces.hh:233
virtual Status GetBody(Message *message, int socket)=0
Definition: XrdClPostMasterInterfaces.hh:288
virtual ~TransportHandler()
Definition: XrdClPostMasterInterfaces.hh:301
virtual Status HandShake(HandShakeData *handShakeData, AnyObject &channelData)=0
HandHake.
Perform the handshake and the authentication for each physical stream.
Definition: XrdClPostMasterInterfaces.hh:278
Stream has been broken and won't be recovered.
Definition: XrdClPostMasterInterfaces.hh:208
The stream is broken.
Definition: XrdClPostMasterInterfaces.hh:207
The declared timeout has occurred.
Definition: XrdClPostMasterInterfaces.hh:80
Channel event handler.
Definition: XrdClPostMasterInterfaces.hh:198
The stream has become connected.
Definition: XrdClPostMasterInterfaces.hh:206
The stream is broken.
Definition: XrdClPostMasterInterfaces.hh:79
Message handler.
Definition: XrdClPostMasterInterfaces.hh:53
virtual uint8_t OnStreamEvent(StreamEvent event, uint16_t streamNum, Status status)
Definition: XrdClPostMasterInterfaces.hh:133
virtual uint16_t SubStreamNumber(AnyObject &channelData)=0
Return a number of substreams per stream that should be created.
virtual bool IsStreamTTLElapsed(time_t inactiveTime, AnyObject &channelData)=0
Check if the stream should be disconnected.
uint16_t down
Definition: XrdClPostMasterInterfaces.hh:262
Definition: XrdClPostMasterInterfaces.hh:295
Action
Actions to be taken after a message is processed by the handler.
Definition: XrdClPostMasterInterfaces.hh:59
Definition: XrdClPostMasterInterfaces.hh:290
Definition: XrdClPostMasterInterfaces.hh:269
URL representation.
Definition: XrdClURL.hh:30
No action.
Definition: XrdClPostMasterInterfaces.hh:287
virtual ~MessageFilter()
Definition: XrdClPostMasterInterfaces.hh:41
virtual Status ReadMessageBody(Message *msg, int socket, uint32_t &bytesRead)
Definition: XrdClPostMasterInterfaces.hh:117
virtual void InitializeChannel(AnyObject &channelData)=0
Initialize channel.
virtual void Process(Message *msg)
Definition: XrdClPostMasterInterfaces.hh:104
Ignore the message.
Definition: XrdClPostMasterInterfaces.hh:62
virtual void Disconnect(AnyObject &channelData, uint16_t streamId, uint16_t subStreamId)=0
The stream has been disconnected, do the cleanups.
The stream has become connected.
Definition: XrdClPostMasterInterfaces.hh:78
virtual ~OutgoingMsgHandler()
Definition: XrdClPostMasterInterfaces.hh:148
Definition: XrdClPostMasterInterfaces.hh:68
Message status handler.
Definition: XrdClPostMasterInterfaces.hh:145
PathID(uint16_t u=0, uint16_t d=0)
Definition: XrdClPostMasterInterfaces.hh:260
virtual void OnStatusReady(const Message *message, Status status)=0
The requested action has been performed and the status is available.
virtual void OnReadyToSend(Message *msg, uint16_t streamNum)
Definition: XrdClPostMasterInterfaces.hh:165
ChannelEvent
Events that may have occurred to the channel.
Definition: XrdClPostMasterInterfaces.hh:204
Definition: XrdClPostMasterInterfaces.hh:293
HandShakeData(const URL *addr, uint16_t stream, uint16_t subStream)
Constructor.
Definition: XrdClPostMasterInterfaces.hh:238
Message * out
Message to be sent out.
Definition: XrdClPostMasterInterfaces.hh:243
virtual PathID MultiplexSubStream(Message *msg, AnyObject &channelData, PathID *hint=0)=0
Stop sending requests [not yet implemented].
Definition: XrdClPostMasterInterfaces.hh:297
std::string streamName
Name of the stream.
Definition: XrdClPostMasterInterfaces.hh:251
static const uint16_t Auth
Transport name, returns std::string *.
Definition: XrdClPostMasterInterfaces.hh:272