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"
32 #include "XrdCl/XrdClAnyObject.hh"
33 #include "XrdCl/XrdClURL.hh"
34 
35 class XrdNetAddr;
36 
37 namespace 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 
58  //----------------------------------------------------------------------------
60  //----------------------------------------------------------------------------
62  {
63  public:
64  //------------------------------------------------------------------------
66  //------------------------------------------------------------------------
67  enum Action
68  {
69  Take = 0x0001,
70  Ignore = 0x0002,
71  RemoveHandler = 0x0004,
72  Raw = 0x0008,
74  NoProcess = 0x0010
77  };
80 
81  //------------------------------------------------------------------------
83  //------------------------------------------------------------------------
85  {
86  Ready = 1,
87  Broken = 2,
88  Timeout = 3,
90  };
91 
92  //------------------------------------------------------------------------
94  //------------------------------------------------------------------------
95 
96  virtual ~IncomingMsgHandler() {}
97 
98  //------------------------------------------------------------------------
104  //------------------------------------------------------------------------
105  virtual uint16_t Examine( Message *msg ) = 0;
106 
107  //------------------------------------------------------------------------
111  //------------------------------------------------------------------------
112  virtual void Process( Message *msg ) { (void)msg; };
113 
114  //------------------------------------------------------------------------
124  //------------------------------------------------------------------------
126  int socket,
127  uint32_t &bytesRead )
128  {
129  (void)msg; (void)socket; (void)bytesRead;
130  return Status( stOK, suDone );
131  };
132 
133  //------------------------------------------------------------------------
140  //------------------------------------------------------------------------
141  virtual uint8_t OnStreamEvent( StreamEvent event,
142  uint16_t streamNum,
143  Status status )
144  {
145  (void)event; (void)streamNum; (void)status;
146  return 0;
147  };
148  };
149 
150  //----------------------------------------------------------------------------
152  //----------------------------------------------------------------------------
154  {
155  public:
156  virtual ~OutgoingMsgHandler() {}
157 
158  //------------------------------------------------------------------------
160  //------------------------------------------------------------------------
161  virtual void OnStatusReady( const Message *message,
162  Status status ) = 0;
163 
164  //------------------------------------------------------------------------
172  //------------------------------------------------------------------------
173  virtual void OnReadyToSend( Message *msg, uint16_t streamNum )
174  {
175  (void)msg; (void)streamNum;
176  };
177 
178  //------------------------------------------------------------------------
182  //------------------------------------------------------------------------
183  virtual bool IsRaw() const { return false; }
184 
185  //------------------------------------------------------------------------
194  //------------------------------------------------------------------------
195  virtual Status WriteMessageBody( int socket,
196  uint32_t &bytesRead )
197  {
198  (void)socket; (void)bytesRead;
199  return Status();
200  }
201  };
202 
203  //----------------------------------------------------------------------------
205  //----------------------------------------------------------------------------
207  {
208  public:
209  //------------------------------------------------------------------------
211  //------------------------------------------------------------------------
213  {
217  };
218 
219  //------------------------------------------------------------------------
221  //------------------------------------------------------------------------
222  virtual ~ChannelEventHandler() {};
223 
224  //------------------------------------------------------------------------
232  //------------------------------------------------------------------------
233  virtual bool OnChannelEvent( ChannelEvent event,
234  Status status,
235  uint16_t stream ) = 0;
236  };
237 
238  //----------------------------------------------------------------------------
240  //----------------------------------------------------------------------------
241 
243  {
244  //--------------------------------------------------------------------------
246  //--------------------------------------------------------------------------
247  HandShakeData( const URL *addr, uint16_t stream, uint16_t subStream ):
248  step(0), out(0), in(0), url(addr), streamId(stream),
249  subStreamId( subStream ), startTime( time(0) ), serverAddr(0)
250  {}
251  uint16_t step;
254  const URL *url;
255  uint16_t streamId;
256  uint16_t subStreamId;
257  time_t startTime;
258  const
259  XrdNetAddr *serverAddr;
260  std::string clientName;
261  std::string streamName;
262  };
263 
264  //----------------------------------------------------------------------------
267  //----------------------------------------------------------------------------
268  struct PathID
269  {
270  PathID( uint16_t u = 0, uint16_t d = 0 ): up(u), down(d) {}
271  uint16_t up;
272  uint16_t down;
273  };
274 
275  //----------------------------------------------------------------------------
278  //----------------------------------------------------------------------------
280  {
281  static const uint16_t Name = 1;
282  static const uint16_t Auth = 2;
283  };
284 
285  //----------------------------------------------------------------------------
287  //----------------------------------------------------------------------------
289  {
290  public:
291 
292  //------------------------------------------------------------------------
294  //------------------------------------------------------------------------
296  {
297  NoAction = 0x0000,
298  DigestMsg = 0x0001,
299  AbortStream = 0x0002,
301  CloseStream = 0x0004,
304  ResumeStream = 0x0008,
306  HoldStream = 0x0010
308  };
309 
310 
311  virtual ~TransportHandler() {}
312 
313  //------------------------------------------------------------------------
324  //------------------------------------------------------------------------
325  virtual Status GetHeader( Message *message, int socket ) = 0;
326 
327  //------------------------------------------------------------------------
336  //------------------------------------------------------------------------
337  virtual Status GetBody( Message *message, int socket ) = 0;
338 
339  //------------------------------------------------------------------------
341  //------------------------------------------------------------------------
342  virtual void InitializeChannel( AnyObject &channelData ) = 0;
343 
344  //------------------------------------------------------------------------
346  //------------------------------------------------------------------------
347  virtual void FinalizeChannel( AnyObject &channelData ) = 0;
348 
349  //------------------------------------------------------------------------
351  //------------------------------------------------------------------------
352  virtual Status HandShake( HandShakeData *handShakeData,
353  AnyObject &channelData ) = 0;
354 
355  //------------------------------------------------------------------------
357  //------------------------------------------------------------------------
358  virtual bool IsStreamTTLElapsed( time_t inactiveTime,
359  uint16_t streamId,
360  AnyObject &channelData ) = 0;
361 
362  //------------------------------------------------------------------------
365  //------------------------------------------------------------------------
366  virtual Status IsStreamBroken( time_t inactiveTime,
367  uint16_t streamId,
368  AnyObject &channelData ) = 0;
369 
370  //------------------------------------------------------------------------
376  //------------------------------------------------------------------------
377  virtual PathID Multiplex( Message *msg,
378  AnyObject &channelData,
379  PathID *hint = 0 ) = 0;
380 
381  //------------------------------------------------------------------------
387  //------------------------------------------------------------------------
388  virtual PathID MultiplexSubStream( Message *msg,
389  uint16_t streamId,
390  AnyObject &channelData,
391  PathID *hint = 0 ) = 0;
392 
393  //------------------------------------------------------------------------
395  //------------------------------------------------------------------------
396  virtual uint16_t StreamNumber( AnyObject &channelData ) = 0;
397 
398  //------------------------------------------------------------------------
400  //------------------------------------------------------------------------
401  virtual uint16_t SubStreamNumber( AnyObject &channelData ) = 0;
402 
403  //------------------------------------------------------------------------
405  //------------------------------------------------------------------------
406  virtual void Disconnect( AnyObject &channelData,
407  uint16_t streamId,
408  uint16_t subStreamId ) = 0;
409 
410  //------------------------------------------------------------------------
412  //------------------------------------------------------------------------
413  virtual Status Query( uint16_t query,
414  AnyObject &result,
415  AnyObject &channelData ) = 0;
416 
417  //------------------------------------------------------------------------
419  //------------------------------------------------------------------------
420  virtual uint32_t MessageReceived( Message *msg,
421  uint16_t streamId,
422  uint16_t subStream,
423  AnyObject &channelData ) = 0;
424 
425  //------------------------------------------------------------------------
427  //------------------------------------------------------------------------
428  virtual void MessageSent( Message *msg,
429  uint16_t streamId,
430  uint16_t subStream,
431  uint32_t bytesSent,
432  AnyObject &channelData ) = 0;
433  };
434 }
435 
436 #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:73
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:69
Message filter.
Definition: XrdClPostMasterInterfaces.hh:46
Definition: XrdClPostMasterInterfaces.hh:71
virtual ~IncomingMsgHandler()
Event types that the message handler may receive.
Definition: XrdClPostMasterInterfaces.hh:96
Stream has been broken and won't be recovered.
Definition: XrdClPostMasterInterfaces.hh:89
virtual bool IsRaw() const
Definition: XrdClPostMasterInterfaces.hh:183
virtual Status GetHeader(Message *message, int socket)=0
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
const XrdNetAddr * serverAddr
Server address.
Definition: XrdClPostMasterInterfaces.hh:259
time_t startTime
Timestamp of when the handshake started.
Definition: XrdClPostMasterInterfaces.hh:257
virtual Status WriteMessageBody(int socket, uint32_t &bytesRead)
Definition: XrdClPostMasterInterfaces.hh:195
virtual ~ChannelEventHandler()
Destructor.
Definition: XrdClPostMasterInterfaces.hh:222
StreamAction
Stream actions that may be triggered by incoming control messages.
Definition: XrdClPostMasterInterfaces.hh:295
const URL * url
Destination URL.
Definition: XrdClPostMasterInterfaces.hh:254
virtual PathID Multiplex(Message *msg, AnyObject &channelData, PathID *hint=0)=0
Definition: XrdClPostMasterInterfaces.hh:268
const uint16_t suDone
Definition: XrdClStatus.hh:38
uint16_t subStreamId
Sub-stream id.
Definition: XrdClPostMasterInterfaces.hh:256
std::string clientName
Client name (an IPv6 representation)
Definition: XrdClPostMasterInterfaces.hh:260
static const uint16_t Name
Transport name, returns const char *.
Definition: XrdClPostMasterInterfaces.hh:281
Message * in
Message that has been received.
Definition: XrdClPostMasterInterfaces.hh:253
StreamEvent
Events that may have occurred to the stream.
Definition: XrdClPostMasterInterfaces.hh:84
uint16_t up
Definition: XrdClPostMasterInterfaces.hh:271
Procedure execution status.
Definition: XrdClStatus.hh:106
virtual uint16_t Examine(Message *msg)=0
virtual Status IsStreamBroken(time_t inactiveTime, uint16_t streamId, AnyObject &channelData)=0
uint16_t step
Handshake step.
Definition: XrdClPostMasterInterfaces.hh:251
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:255
Data structure that carries the handshake information.
Definition: XrdClPostMasterInterfaces.hh:242
virtual Status GetBody(Message *message, int socket)=0
Definition: XrdClPostMasterInterfaces.hh:298
virtual ~TransportHandler()
Definition: XrdClPostMasterInterfaces.hh:311
virtual Status HandShake(HandShakeData *handShakeData, AnyObject &channelData)=0
HandHake.
Perform the handshake and the authentication for each physical stream.
Definition: XrdClPostMasterInterfaces.hh:288
Stream has been broken and won't be recovered.
Definition: XrdClPostMasterInterfaces.hh:216
The stream is broken.
Definition: XrdClPostMasterInterfaces.hh:215
The declared timeout has occurred.
Definition: XrdClPostMasterInterfaces.hh:88
Definition: XrdClEnv.hh:28
Channel event handler.
Definition: XrdClPostMasterInterfaces.hh:206
The stream has become connected.
Definition: XrdClPostMasterInterfaces.hh:214
The stream is broken.
Definition: XrdClPostMasterInterfaces.hh:87
Message handler.
Definition: XrdClPostMasterInterfaces.hh:61
virtual uint8_t OnStreamEvent(StreamEvent event, uint16_t streamNum, Status status)
Definition: XrdClPostMasterInterfaces.hh:141
virtual uint16_t SubStreamNumber(AnyObject &channelData)=0
Return a number of substreams per stream that should be created.
uint16_t down
Definition: XrdClPostMasterInterfaces.hh:272
virtual bool IsStreamTTLElapsed(time_t inactiveTime, uint16_t streamId, AnyObject &channelData)=0
Check if the stream should be disconnected.
Definition: XrdClPostMasterInterfaces.hh:305
Action
Actions to be taken after a message is processed by the handler.
Definition: XrdClPostMasterInterfaces.hh:67
Definition: XrdClPostMasterInterfaces.hh:300
Definition: XrdClPostMasterInterfaces.hh:279
URL representation.
Definition: XrdClURL.hh:30
No action.
Definition: XrdClPostMasterInterfaces.hh:297
virtual ~MessageFilter()
Definition: XrdClPostMasterInterfaces.hh:49
virtual Status ReadMessageBody(Message *msg, int socket, uint32_t &bytesRead)
Definition: XrdClPostMasterInterfaces.hh:125
virtual void InitializeChannel(AnyObject &channelData)=0
Initialize channel.
virtual void Process(Message *msg)
Definition: XrdClPostMasterInterfaces.hh:112
Ignore the message.
Definition: XrdClPostMasterInterfaces.hh:70
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:86
virtual ~OutgoingMsgHandler()
Definition: XrdClPostMasterInterfaces.hh:156
Definition: XrdClPostMasterInterfaces.hh:76
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.
Message status handler.
Definition: XrdClPostMasterInterfaces.hh:153
PathID(uint16_t u=0, uint16_t d=0)
Definition: XrdClPostMasterInterfaces.hh:270
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:173
ChannelEvent
Events that may have occurred to the channel.
Definition: XrdClPostMasterInterfaces.hh:212
virtual uint32_t MessageReceived(Message *msg, uint16_t streamId, uint16_t subStream, AnyObject &channelData)=0
Check if the message invokes a stream action.
Definition: XrdClPostMasterInterfaces.hh:303
HandShakeData(const URL *addr, uint16_t stream, uint16_t subStream)
Constructor.
Definition: XrdClPostMasterInterfaces.hh:247
Message * out
Message to be sent out.
Definition: XrdClPostMasterInterfaces.hh:252
Stop sending requests [not yet implemented].
Definition: XrdClPostMasterInterfaces.hh:307
std::string streamName
Name of the stream.
Definition: XrdClPostMasterInterfaces.hh:261
static const uint16_t Auth
Transport name, returns std::string *.
Definition: XrdClPostMasterInterfaces.hh:282
virtual PathID MultiplexSubStream(Message *msg, uint16_t streamId, AnyObject &channelData, PathID *hint=0)=0