XrdClPostMasterInterfaces.hh

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
00003 // Author: Lukasz Janyst <ljanyst@cern.ch>
00004 //------------------------------------------------------------------------------
00005 // This file is part of the XRootD software suite.
00006 //
00007 // XRootD is free software: you can redistribute it and/or modify
00008 // it under the terms of the GNU Lesser General Public License as published by
00009 // the Free Software Foundation, either version 3 of the License, or
00010 // (at your option) any later version.
00011 //
00012 // XRootD is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU Lesser General Public License
00018 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
00019 //
00020 // In applying this licence, CERN does not waive the privileges and immunities
00021 // granted to it by virtue of its status as an Intergovernmental Organization
00022 // or submit itself to any jurisdiction.
00023 //------------------------------------------------------------------------------
00024 
00025 #ifndef __XRD_CL_POST_MASTER_INTERFACES_HH__
00026 #define __XRD_CL_POST_MASTER_INTERFACES_HH__
00027 
00028 #include <stdint.h>
00029 #include <ctime>
00030 
00031 #include "XrdCl/XrdClStatus.hh"
00032 #include "XrdCl/XrdClAnyObject.hh"
00033 #include "XrdCl/XrdClURL.hh"
00034 
00035 namespace XrdCl
00036 {
00037   class Channel;
00038   class Message;
00039   class URL;
00040 
00041   //----------------------------------------------------------------------------
00043   //----------------------------------------------------------------------------
00044   class MessageFilter
00045   {
00046     public:
00047       virtual ~MessageFilter() {}
00048 
00049       //------------------------------------------------------------------------
00052       //------------------------------------------------------------------------
00053       virtual bool Filter( const Message *msg ) = 0;
00054   };
00055 
00056   //----------------------------------------------------------------------------
00058   //----------------------------------------------------------------------------
00059   class IncomingMsgHandler
00060   {
00061     public:
00062       //------------------------------------------------------------------------
00064       //------------------------------------------------------------------------
00065       enum Action
00066       {
00067         Take          = 0x0001,    
00068         Ignore        = 0x0002,    
00069         RemoveHandler = 0x0004,    
00070 
00071         Raw           = 0x0008,    
00072 
00073 
00074         NoProcess     = 0x0010     
00075 
00076 
00077       };
00078 
00079       //------------------------------------------------------------------------
00081       //------------------------------------------------------------------------
00082       enum StreamEvent
00083       {
00084         Ready      = 1, 
00085         Broken     = 2, 
00086         Timeout    = 3, 
00087         FatalError = 4  
00088       };
00089 
00090       //------------------------------------------------------------------------
00092       //------------------------------------------------------------------------
00093 
00094       virtual ~IncomingMsgHandler() {}
00095 
00096       //------------------------------------------------------------------------
00102       //------------------------------------------------------------------------
00103       virtual uint16_t Examine( Message *msg ) = 0;
00104 
00105       //------------------------------------------------------------------------
00109       //------------------------------------------------------------------------
00110       virtual void Process( Message *msg ) { (void)msg; };
00111 
00112       //------------------------------------------------------------------------
00122       //------------------------------------------------------------------------
00123       virtual Status ReadMessageBody( Message  *msg,
00124                                       int       socket,
00125                                       uint32_t &bytesRead )
00126       {
00127         (void)msg; (void)socket; (void)bytesRead;
00128         return Status( stOK, suDone );
00129       };
00130 
00131       //------------------------------------------------------------------------
00138       //------------------------------------------------------------------------
00139       virtual uint8_t OnStreamEvent( StreamEvent event,
00140                                      uint16_t    streamNum,
00141                                      Status      status )
00142       {
00143         (void)event; (void)streamNum; (void)status;
00144         return 0;
00145       };
00146   };
00147 
00148   //----------------------------------------------------------------------------
00150   //----------------------------------------------------------------------------
00151   class OutgoingMsgHandler
00152   {
00153     public:
00154       virtual ~OutgoingMsgHandler() {}
00155 
00156       //------------------------------------------------------------------------
00158       //------------------------------------------------------------------------
00159       virtual void OnStatusReady( const Message *message,
00160                                   Status         status ) = 0;
00161 
00162       //------------------------------------------------------------------------
00170       //------------------------------------------------------------------------
00171       virtual void OnReadyToSend( Message *msg, uint16_t streamNum )
00172       {
00173         (void)msg; (void)streamNum;
00174       };
00175 
00176       //------------------------------------------------------------------------
00180       //------------------------------------------------------------------------
00181       virtual bool IsRaw() const { return false; }
00182 
00183       //------------------------------------------------------------------------
00192       //------------------------------------------------------------------------
00193       virtual Status WriteMessageBody( int       socket,
00194                                        uint32_t &bytesRead )
00195       {
00196         (void)socket; (void)bytesRead;
00197         return Status();
00198       }
00199   };
00200 
00201   //----------------------------------------------------------------------------
00203   //----------------------------------------------------------------------------
00204   class ChannelEventHandler
00205   {
00206     public:
00207       //------------------------------------------------------------------------
00209       //------------------------------------------------------------------------
00210       enum ChannelEvent
00211       {
00212         StreamReady  = 1, 
00213         StreamBroken = 2, 
00214         FatalError   = 4  
00215       };
00216 
00217       //------------------------------------------------------------------------
00219       //------------------------------------------------------------------------
00220       virtual ~ChannelEventHandler() {};
00221 
00222       //------------------------------------------------------------------------
00230       //------------------------------------------------------------------------
00231       virtual bool OnChannelEvent( ChannelEvent event,
00232                                    Status       status,
00233                                    uint16_t     stream ) = 0;
00234   };
00235 
00236   //----------------------------------------------------------------------------
00238   //----------------------------------------------------------------------------
00239   struct HandShakeData
00240   {
00241     //--------------------------------------------------------------------------
00243     //--------------------------------------------------------------------------
00244     HandShakeData( const URL *addr, uint16_t stream, uint16_t subStream ):
00245       step(0), out(0), in(0), url(addr), streamId(stream),
00246       subStreamId( subStream ), startTime( time(0) ), serverAddr(0)
00247     {}
00248     uint16_t     step;           
00249     Message     *out;            
00250     Message     *in;             
00251     const URL   *url;            
00252     uint16_t     streamId;       
00253     uint16_t     subStreamId;    
00254     time_t       startTime;      
00255     const void  *serverAddr;     
00256     std::string  clientName;     
00257     std::string  streamName;     
00258   };
00259 
00260   //----------------------------------------------------------------------------
00263   //----------------------------------------------------------------------------
00264   struct PathID
00265   {
00266     PathID( uint16_t u = 0, uint16_t d = 0 ): up(u), down(d) {}
00267     uint16_t up;
00268     uint16_t down;
00269   };
00270 
00271   //----------------------------------------------------------------------------
00274   //----------------------------------------------------------------------------
00275   struct TransportQuery
00276   {
00277     static const uint16_t Name = 1; 
00278     static const uint16_t Auth = 2; 
00279   };
00280 
00281   //----------------------------------------------------------------------------
00283   //----------------------------------------------------------------------------
00284   class TransportHandler
00285   {
00286     public:
00287 
00288       //------------------------------------------------------------------------
00290       //------------------------------------------------------------------------
00291       enum StreamAction
00292       {
00293         NoAction     = 0x0000, 
00294         DigestMsg    = 0x0001, 
00295 
00296         AbortStream  = 0x0002, 
00297 
00298 
00299         CloseStream  = 0x0004, 
00300 
00301         ResumeStream = 0x0008, 
00302 
00303         HoldStream   = 0x0010  
00304       };
00305 
00306 
00307       virtual ~TransportHandler() {}
00308 
00309       //------------------------------------------------------------------------
00320       //------------------------------------------------------------------------
00321       virtual Status GetHeader( Message *message, int socket ) = 0;
00322 
00323       //------------------------------------------------------------------------
00332       //------------------------------------------------------------------------
00333       virtual Status GetBody( Message *message, int socket ) = 0;
00334 
00335       //------------------------------------------------------------------------
00337       //------------------------------------------------------------------------
00338       virtual void InitializeChannel( AnyObject &channelData ) = 0;
00339 
00340       //------------------------------------------------------------------------
00342       //------------------------------------------------------------------------
00343       virtual void FinalizeChannel( AnyObject &channelData ) = 0;
00344 
00345       //------------------------------------------------------------------------
00347       //------------------------------------------------------------------------
00348       virtual Status HandShake( HandShakeData *handShakeData,
00349                                 AnyObject     &channelData ) = 0;
00350 
00351       //------------------------------------------------------------------------
00353       //------------------------------------------------------------------------
00354       virtual bool IsStreamTTLElapsed( time_t     inactiveTime,
00355                                        uint16_t   streamId,
00356                                        AnyObject &channelData ) = 0;
00357 
00358       //------------------------------------------------------------------------
00361       //------------------------------------------------------------------------
00362       virtual Status IsStreamBroken( time_t     inactiveTime,
00363                                      uint16_t   streamId,
00364                                      AnyObject &channelData ) = 0;
00365 
00366       //------------------------------------------------------------------------
00372       //------------------------------------------------------------------------
00373       virtual PathID Multiplex( Message   *msg,
00374                                 AnyObject &channelData,
00375                                 PathID    *hint = 0 ) = 0;
00376 
00377       //------------------------------------------------------------------------
00383       //------------------------------------------------------------------------
00384       virtual PathID MultiplexSubStream( Message   *msg,
00385                                          uint16_t   streamId,
00386                                          AnyObject &channelData,
00387                                          PathID    *hint = 0 ) = 0;
00388 
00389       //------------------------------------------------------------------------
00391       //------------------------------------------------------------------------
00392       virtual uint16_t StreamNumber( AnyObject &channelData ) = 0;
00393 
00394       //------------------------------------------------------------------------
00396       //------------------------------------------------------------------------
00397       virtual uint16_t SubStreamNumber( AnyObject &channelData ) = 0;
00398 
00399       //------------------------------------------------------------------------
00401       //------------------------------------------------------------------------
00402       virtual void Disconnect( AnyObject &channelData,
00403                                uint16_t   streamId,
00404                                uint16_t   subStreamId ) = 0;
00405 
00406       //------------------------------------------------------------------------
00408       //------------------------------------------------------------------------
00409       virtual Status Query( uint16_t   query,
00410                             AnyObject &result,
00411                             AnyObject &channelData ) = 0;
00412 
00413       //------------------------------------------------------------------------
00415       //------------------------------------------------------------------------
00416       virtual uint32_t MessageReceived( Message   *msg,
00417                                         uint16_t   streamId,
00418                                         uint16_t   subStream,
00419                                         AnyObject &channelData ) = 0;
00420 
00421       //------------------------------------------------------------------------
00423       //------------------------------------------------------------------------
00424       virtual void MessageSent( Message   *msg,
00425                                 uint16_t   streamId,
00426                                 uint16_t   subStream,
00427                                 uint32_t   bytesSent,
00428                                 AnyObject &channelData ) = 0;
00429   };
00430 }
00431 
00432 #endif // __XRD_CL_POST_MASTER_INTERFACES_HH__

Generated on 12 Dec 2014 for xrootd by  doxygen 1.4.7