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 class XrdNetAddr;
00036 
00037 namespace XrdCl
00038 {
00039   class Channel;
00040   class Message;
00041   class URL;
00042 
00043   //----------------------------------------------------------------------------
00045   //----------------------------------------------------------------------------
00046   class MessageFilter
00047   {
00048     public:
00049       virtual ~MessageFilter() {}
00050 
00051       //------------------------------------------------------------------------
00054       //------------------------------------------------------------------------
00055       virtual bool Filter( const Message *msg ) = 0;
00056 
00057       //------------------------------------------------------------------------
00061       //------------------------------------------------------------------------
00062       virtual uint16_t GetSid() const = 0;
00063   };
00064 
00065   //----------------------------------------------------------------------------
00067   //----------------------------------------------------------------------------
00068   class IncomingMsgHandler
00069   {
00070     public:
00071       //------------------------------------------------------------------------
00073       //------------------------------------------------------------------------
00074       enum Action
00075       {
00076         Take          = 0x0001,    
00077         Ignore        = 0x0002,    
00078         RemoveHandler = 0x0004,    
00079 
00080         Raw           = 0x0008,    
00081 
00082 
00083         NoProcess     = 0x0010     
00084 
00085 
00086       };
00087 
00088       //------------------------------------------------------------------------
00090       //------------------------------------------------------------------------
00091       enum StreamEvent
00092       {
00093         Ready      = 1, 
00094         Broken     = 2, 
00095         Timeout    = 3, 
00096         FatalError = 4  
00097       };
00098 
00099       //------------------------------------------------------------------------
00101       //------------------------------------------------------------------------
00102 
00103       virtual ~IncomingMsgHandler() {}
00104 
00105       //------------------------------------------------------------------------
00111       //------------------------------------------------------------------------
00112       virtual uint16_t Examine( Message *msg ) = 0;
00113 
00114       //------------------------------------------------------------------------
00118       //------------------------------------------------------------------------
00119       virtual uint16_t GetSid() const = 0;
00120 
00121       //------------------------------------------------------------------------
00125       //------------------------------------------------------------------------
00126       virtual void Process( Message *msg ) { (void)msg; };
00127 
00128       //------------------------------------------------------------------------
00138       //------------------------------------------------------------------------
00139       virtual Status ReadMessageBody( Message  *msg,
00140                                       int       socket,
00141                                       uint32_t &bytesRead )
00142       {
00143         (void)msg; (void)socket; (void)bytesRead;
00144         return Status( stOK, suDone );
00145       };
00146 
00147       //------------------------------------------------------------------------
00154       //------------------------------------------------------------------------
00155       virtual uint8_t OnStreamEvent( StreamEvent event,
00156                                      uint16_t    streamNum,
00157                                      Status      status )
00158       {
00159         (void)event; (void)streamNum; (void)status;
00160         return 0;
00161       };
00162   };
00163 
00164   //----------------------------------------------------------------------------
00166   //----------------------------------------------------------------------------
00167   class OutgoingMsgHandler
00168   {
00169     public:
00170       virtual ~OutgoingMsgHandler() {}
00171 
00172       //------------------------------------------------------------------------
00174       //------------------------------------------------------------------------
00175       virtual void OnStatusReady( const Message *message,
00176                                   Status         status ) = 0;
00177 
00178       //------------------------------------------------------------------------
00186       //------------------------------------------------------------------------
00187       virtual void OnReadyToSend( Message *msg, uint16_t streamNum )
00188       {
00189         (void)msg; (void)streamNum;
00190       };
00191 
00192       //------------------------------------------------------------------------
00196       //------------------------------------------------------------------------
00197       virtual bool IsRaw() const { return false; }
00198 
00199       //------------------------------------------------------------------------
00208       //------------------------------------------------------------------------
00209       virtual Status WriteMessageBody( int       socket,
00210                                        uint32_t &bytesRead )
00211       {
00212         (void)socket; (void)bytesRead;
00213         return Status();
00214       }
00215   };
00216 
00217   //----------------------------------------------------------------------------
00219   //----------------------------------------------------------------------------
00220   class ChannelEventHandler
00221   {
00222     public:
00223       //------------------------------------------------------------------------
00225       //------------------------------------------------------------------------
00226       enum ChannelEvent
00227       {
00228         StreamReady  = 1, 
00229         StreamBroken = 2, 
00230         FatalError   = 4  
00231       };
00232 
00233       //------------------------------------------------------------------------
00235       //------------------------------------------------------------------------
00236       virtual ~ChannelEventHandler() {};
00237 
00238       //------------------------------------------------------------------------
00246       //------------------------------------------------------------------------
00247       virtual bool OnChannelEvent( ChannelEvent event,
00248                                    Status       status,
00249                                    uint16_t     stream ) = 0;
00250   };
00251 
00252   //----------------------------------------------------------------------------
00254   //----------------------------------------------------------------------------
00255 
00256   struct HandShakeData
00257   {
00258     //--------------------------------------------------------------------------
00260     //--------------------------------------------------------------------------
00261     HandShakeData( const URL *addr, uint16_t stream, uint16_t subStream ):
00262       step(0), out(0), in(0), url(addr), streamId(stream),
00263       subStreamId( subStream ), startTime( time(0) ), serverAddr(0)
00264     {}
00265     uint16_t     step;           
00266     Message     *out;            
00267     Message     *in;             
00268     const URL   *url;            
00269     uint16_t     streamId;       
00270     uint16_t     subStreamId;    
00271     time_t       startTime;      
00272     const
00273     XrdNetAddr  *serverAddr;     
00274     std::string  clientName;     
00275     std::string  streamName;     
00276   };
00277 
00278   //----------------------------------------------------------------------------
00281   //----------------------------------------------------------------------------
00282   struct PathID
00283   {
00284     PathID( uint16_t u = 0, uint16_t d = 0 ): up(u), down(d) {}
00285     uint16_t up;
00286     uint16_t down;
00287   };
00288 
00289   //----------------------------------------------------------------------------
00292   //----------------------------------------------------------------------------
00293   struct TransportQuery
00294   {
00295     static const uint16_t Name = 1; 
00296     static const uint16_t Auth = 2; 
00297   };
00298 
00299   //----------------------------------------------------------------------------
00301   //----------------------------------------------------------------------------
00302   class TransportHandler
00303   {
00304     public:
00305 
00306       //------------------------------------------------------------------------
00308       //------------------------------------------------------------------------
00309       enum StreamAction
00310       {
00311         NoAction     = 0x0000, 
00312         DigestMsg    = 0x0001, 
00313 
00314         AbortStream  = 0x0002, 
00315 
00316 
00317         CloseStream  = 0x0004, 
00318 
00319         ResumeStream = 0x0008, 
00320 
00321         HoldStream   = 0x0010, 
00322         RequestClose = 0x0020  
00323       };
00324 
00325 
00326       virtual ~TransportHandler() {}
00327 
00328       //------------------------------------------------------------------------
00339       //------------------------------------------------------------------------
00340       virtual Status GetHeader( Message *message, int socket ) = 0;
00341 
00342       //------------------------------------------------------------------------
00351       //------------------------------------------------------------------------
00352       virtual Status GetBody( Message *message, int socket ) = 0;
00353 
00354       //------------------------------------------------------------------------
00356       //------------------------------------------------------------------------
00357       virtual void InitializeChannel( AnyObject &channelData ) = 0;
00358 
00359       //------------------------------------------------------------------------
00361       //------------------------------------------------------------------------
00362       virtual void FinalizeChannel( AnyObject &channelData ) = 0;
00363 
00364       //------------------------------------------------------------------------
00366       //------------------------------------------------------------------------
00367       virtual Status HandShake( HandShakeData *handShakeData,
00368                                 AnyObject     &channelData ) = 0;
00369 
00370       //------------------------------------------------------------------------
00372       //------------------------------------------------------------------------
00373       virtual bool IsStreamTTLElapsed( time_t     inactiveTime,
00374                                        uint16_t   streamId,
00375                                        AnyObject &channelData ) = 0;
00376 
00377       //------------------------------------------------------------------------
00380       //------------------------------------------------------------------------
00381       virtual Status IsStreamBroken( time_t     inactiveTime,
00382                                      uint16_t   streamId,
00383                                      AnyObject &channelData ) = 0;
00384 
00385       //------------------------------------------------------------------------
00391       //------------------------------------------------------------------------
00392       virtual PathID Multiplex( Message   *msg,
00393                                 AnyObject &channelData,
00394                                 PathID    *hint = 0 ) = 0;
00395 
00396       //------------------------------------------------------------------------
00402       //------------------------------------------------------------------------
00403       virtual PathID MultiplexSubStream( Message   *msg,
00404                                          uint16_t   streamId,
00405                                          AnyObject &channelData,
00406                                          PathID    *hint = 0 ) = 0;
00407 
00408       //------------------------------------------------------------------------
00410       //------------------------------------------------------------------------
00411       virtual uint16_t StreamNumber( AnyObject &channelData ) = 0;
00412 
00413       //------------------------------------------------------------------------
00415       //------------------------------------------------------------------------
00416       virtual uint16_t SubStreamNumber( AnyObject &channelData ) = 0;
00417 
00418       //------------------------------------------------------------------------
00420       //------------------------------------------------------------------------
00421       virtual void Disconnect( AnyObject &channelData,
00422                                uint16_t   streamId,
00423                                uint16_t   subStreamId ) = 0;
00424 
00425       //------------------------------------------------------------------------
00427       //------------------------------------------------------------------------
00428       virtual Status Query( uint16_t   query,
00429                             AnyObject &result,
00430                             AnyObject &channelData ) = 0;
00431 
00432       //------------------------------------------------------------------------
00434       //------------------------------------------------------------------------
00435       virtual uint32_t MessageReceived( Message   *msg,
00436                                         uint16_t   streamId,
00437                                         uint16_t   subStream,
00438                                         AnyObject &channelData ) = 0;
00439 
00440       //------------------------------------------------------------------------
00442       //------------------------------------------------------------------------
00443       virtual void MessageSent( Message   *msg,
00444                                 uint16_t   streamId,
00445                                 uint16_t   subStream,
00446                                 uint32_t   bytesSent,
00447                                 AnyObject &channelData ) = 0;
00448   };
00449 }
00450 
00451 #endif // __XRD_CL_POST_MASTER_INTERFACES_HH__

Generated on 5 Oct 2016 for xrootd by  doxygen 1.4.7