XrdClFileSystem.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_FILE_SYSTEM_HH__
00026 #define __XRD_CL_FILE_SYSTEM_HH__
00027 
00028 #include "XrdCl/XrdClURL.hh"
00029 #include "XrdCl/XrdClStatus.hh"
00030 #include "XrdOuc/XrdOucEnum.hh"
00031 #include "XrdOuc/XrdOucCompiler.hh"
00032 #include "XrdCl/XrdClXRootDResponses.hh"
00033 #include "XrdSys/XrdSysPthread.hh"
00034 #include "XProtocol/XProtocol.hh"
00035 #include <string>
00036 #include <vector>
00037 
00038 namespace XrdCl
00039 {
00040   class PostMaster;
00041   class Message;
00042   class FileSystemPlugIn;
00043   struct MessageSendParams;
00044 
00045   //----------------------------------------------------------------------------
00047   //----------------------------------------------------------------------------
00048   struct QueryCode
00049   {
00050     //--------------------------------------------------------------------------
00052     //--------------------------------------------------------------------------
00053     enum Code
00054     {
00055       Config         = kXR_Qconfig,    
00056       ChecksumCancel = kXR_Qckscan,    
00057       Checksum       = kXR_Qcksum,     
00058       Opaque         = kXR_Qopaque,    
00059       OpaqueFile     = kXR_Qopaquf,    
00060       Prepare        = kXR_QPrep,      
00061       Space          = kXR_Qspace,     
00062       Stats          = kXR_QStats,     
00063       Visa           = kXR_Qvisa,      
00064       XAttr          = kXR_Qxattr      
00065     };
00066   };
00067 
00068   //----------------------------------------------------------------------------
00070   //----------------------------------------------------------------------------
00071   struct OpenFlags
00072   {
00073     //--------------------------------------------------------------------------
00075     //--------------------------------------------------------------------------
00076     enum Flags
00077     {
00078       None     = 0,              
00079       Compress = kXR_compress,   
00080 
00081       Delete   = kXR_delete,     
00082 
00083       Force    = kXR_force,      
00084 
00085       MakePath = kXR_mkpath,     
00086 
00087       New      = kXR_new,        
00088 
00089       NoWait   = kXR_nowait,     
00090 
00091 
00092 
00093 
00094 
00095       Append   = kXR_open_apnd,  
00096       Read     = kXR_open_read,  
00097       Update   = kXR_open_updt,  
00098       Write    = kXR_open_wrto,  
00099       POSC     = kXR_posc,       
00100 
00101       Refresh  = kXR_refresh,    
00102 
00103       Replica  = kXR_replica,    
00104 
00105       SeqIO    = kXR_seqio,      
00106       PrefName = kXR_prefname    
00107 
00108     };
00109   };
00110   XRDOUC_ENUM_OPERATORS( OpenFlags::Flags )
00111 
00112   //----------------------------------------------------------------------------
00114   //----------------------------------------------------------------------------
00115   struct Access
00116   {
00117     //--------------------------------------------------------------------------
00119     //--------------------------------------------------------------------------
00120     enum Mode
00121     {
00122       None = 0,
00123       UR   = kXR_ur,         
00124       UW   = kXR_uw,         
00125       UX   = kXR_ux,         
00126       GR   = kXR_gr,         
00127       GW   = kXR_gw,         
00128       GX   = kXR_gx,         
00129       OR   = kXR_or,         
00130       OW   = kXR_ow,         
00131       OX   = kXR_ox          
00132     };
00133   };
00134   XRDOUC_ENUM_OPERATORS( Access::Mode )
00135 
00136   //----------------------------------------------------------------------------
00138   //----------------------------------------------------------------------------
00139   struct MkDirFlags
00140   {
00141     enum Flags
00142     {
00143       None     = 0,  
00144       MakePath = 1   
00145     };
00146   };
00147   XRDOUC_ENUM_OPERATORS( MkDirFlags::Flags )
00148 
00149   //----------------------------------------------------------------------------
00151   //----------------------------------------------------------------------------
00152   struct DirListFlags
00153   {
00154     enum Flags
00155     {
00156       None   = 0,  
00157       Stat   = 1,  
00158       Locate = 2  
00159 
00160     };
00161   };
00162   XRDOUC_ENUM_OPERATORS( DirListFlags::Flags )
00163 
00164   //----------------------------------------------------------------------------
00166   //----------------------------------------------------------------------------
00167   struct PrepareFlags
00168   {
00169     enum Flags
00170     {
00171       None        = 0,            
00172       Colocate    = kXR_coloc,    
00173       Fresh       = kXR_fresh,    
00174 
00175       Stage       = kXR_stage,    
00176 
00177       WriteMode   = kXR_wmode     
00178 
00179     };
00180   };
00181   XRDOUC_ENUM_OPERATORS( PrepareFlags::Flags )
00182 
00183   //----------------------------------------------------------------------------
00185   //----------------------------------------------------------------------------
00186   class FileSystem
00187   {
00188     friend class AssignLBHandler;
00189     friend class ForkHandler;
00190 
00191     public:
00192       typedef std::vector<LocationInfo> LocationList; 
00193 
00194       //------------------------------------------------------------------------
00199       //------------------------------------------------------------------------
00200       FileSystem( const URL &url, bool enablePlugIns = true );
00201 
00202       //------------------------------------------------------------------------
00204       //------------------------------------------------------------------------
00205       ~FileSystem();
00206 
00207       //------------------------------------------------------------------------
00218       //------------------------------------------------------------------------
00219       XRootDStatus Locate( const std::string &path,
00220                            OpenFlags::Flags   flags,
00221                            ResponseHandler   *handler,
00222                            uint16_t           timeout = 0 )
00223                            XRD_WARN_UNUSED_RESULT;
00224 
00225       //------------------------------------------------------------------------
00234       //------------------------------------------------------------------------
00235       XRootDStatus Locate( const std::string  &path,
00236                            OpenFlags::Flags    flags,
00237                            LocationInfo      *&response,
00238                            uint16_t            timeout  = 0 )
00239                            XRD_WARN_UNUSED_RESULT;
00240 
00241       //------------------------------------------------------------------------
00252       //------------------------------------------------------------------------
00253       XRootDStatus DeepLocate( const std::string &path,
00254                                OpenFlags::Flags   flags,
00255                                ResponseHandler   *handler,
00256                                uint16_t           timeout = 0 )
00257                                XRD_WARN_UNUSED_RESULT;
00258 
00259       //------------------------------------------------------------------------
00268       //------------------------------------------------------------------------
00269       XRootDStatus DeepLocate( const std::string  &path,
00270                                OpenFlags::Flags   flags,
00271                                LocationInfo      *&response,
00272                                uint16_t            timeout  = 0 )
00273                                XRD_WARN_UNUSED_RESULT;
00274 
00275       //------------------------------------------------------------------------
00284       //------------------------------------------------------------------------
00285       XRootDStatus Mv( const std::string &source,
00286                        const std::string &dest,
00287                        ResponseHandler   *handler,
00288                        uint16_t           timeout = 0 )
00289                        XRD_WARN_UNUSED_RESULT;
00290 
00291       //------------------------------------------------------------------------
00299       //------------------------------------------------------------------------
00300       XRootDStatus Mv( const std::string &source,
00301                        const std::string &dest,
00302                        uint16_t           timeout = 0 )
00303                        XRD_WARN_UNUSED_RESULT;
00304 
00305       //------------------------------------------------------------------------
00316       //------------------------------------------------------------------------
00317       XRootDStatus Query( QueryCode::Code  queryCode,
00318                           const Buffer    &arg,
00319                           ResponseHandler *handler,
00320                           uint16_t         timeout = 0 )
00321                           XRD_WARN_UNUSED_RESULT;
00322 
00323       //------------------------------------------------------------------------
00332       //------------------------------------------------------------------------
00333       XRootDStatus Query( QueryCode::Code   queryCode,
00334                           const Buffer     &arg,
00335                           Buffer          *&response,
00336                           uint16_t          timeout = 0 )
00337                           XRD_WARN_UNUSED_RESULT;
00338 
00339       //------------------------------------------------------------------------
00348       //------------------------------------------------------------------------
00349       XRootDStatus Truncate( const std::string &path,
00350                              uint64_t           size,
00351                              ResponseHandler   *handler,
00352                              uint16_t           timeout = 0 )
00353                              XRD_WARN_UNUSED_RESULT;
00354 
00355       //------------------------------------------------------------------------
00363       //------------------------------------------------------------------------
00364       XRootDStatus Truncate( const std::string &path,
00365                              uint64_t           size,
00366                              uint16_t           timeout = 0 )
00367                              XRD_WARN_UNUSED_RESULT;
00368 
00369       //------------------------------------------------------------------------
00377       //------------------------------------------------------------------------
00378       XRootDStatus Rm( const std::string &path,
00379                        ResponseHandler   *handler,
00380                        uint16_t           timeout = 0 )
00381                        XRD_WARN_UNUSED_RESULT;
00382 
00383       //------------------------------------------------------------------------
00390       //------------------------------------------------------------------------
00391       XRootDStatus Rm( const std::string &path,
00392                        uint16_t           timeout = 0 )
00393                        XRD_WARN_UNUSED_RESULT;
00394 
00395       //------------------------------------------------------------------------
00405       //------------------------------------------------------------------------
00406       XRootDStatus MkDir( const std::string &path,
00407                           MkDirFlags::Flags  flags,
00408                           Access::Mode       mode,
00409                           ResponseHandler   *handler,
00410                           uint16_t           timeout = 0 )
00411                           XRD_WARN_UNUSED_RESULT;
00412 
00413       //------------------------------------------------------------------------
00422       //------------------------------------------------------------------------
00423       XRootDStatus MkDir( const std::string &path,
00424                           MkDirFlags::Flags  flags,
00425                           Access::Mode       mode,
00426                           uint16_t           timeout = 0 )
00427                           XRD_WARN_UNUSED_RESULT;
00428 
00429       //------------------------------------------------------------------------
00437       //------------------------------------------------------------------------
00438       XRootDStatus RmDir( const std::string &path,
00439                           ResponseHandler   *handler,
00440                           uint16_t           timeout = 0 )
00441                           XRD_WARN_UNUSED_RESULT;
00442 
00443       //------------------------------------------------------------------------
00450       //------------------------------------------------------------------------
00451       XRootDStatus RmDir( const std::string &path,
00452                           uint16_t           timeout = 0 )
00453                           XRD_WARN_UNUSED_RESULT;
00454 
00455       //------------------------------------------------------------------------
00464       //------------------------------------------------------------------------
00465       XRootDStatus ChMod( const std::string &path,
00466                           Access::Mode       mode,
00467                           ResponseHandler   *handler,
00468                           uint16_t           timeout = 0 )
00469                           XRD_WARN_UNUSED_RESULT;
00470 
00471       //------------------------------------------------------------------------
00479       //------------------------------------------------------------------------
00480       XRootDStatus ChMod( const std::string &path,
00481                           Access::Mode       mode,
00482                           uint16_t           timeout = 0 )
00483                           XRD_WARN_UNUSED_RESULT;
00484 
00485       //------------------------------------------------------------------------
00492       //------------------------------------------------------------------------
00493       XRootDStatus Ping( ResponseHandler *handler,
00494                          uint16_t         timeout = 0 )
00495                          XRD_WARN_UNUSED_RESULT;
00496 
00497       //------------------------------------------------------------------------
00503       //------------------------------------------------------------------------
00504       XRootDStatus Ping( uint16_t timeout = 0 ) XRD_WARN_UNUSED_RESULT;
00505 
00506       //------------------------------------------------------------------------
00516       //------------------------------------------------------------------------
00517       XRootDStatus Stat( const std::string &path,
00518                          ResponseHandler   *handler,
00519                          uint16_t           timeout = 0 )
00520                          XRD_WARN_UNUSED_RESULT;
00521 
00522       //------------------------------------------------------------------------
00531       //------------------------------------------------------------------------
00532       XRootDStatus Stat( const std::string  &path,
00533                          StatInfo          *&response,
00534                          uint16_t            timeout = 0 )
00535                          XRD_WARN_UNUSED_RESULT;
00536 
00537       //------------------------------------------------------------------------
00547       //------------------------------------------------------------------------
00548       XRootDStatus StatVFS( const std::string &path,
00549                             ResponseHandler   *handler,
00550                             uint16_t           timeout = 0 )
00551                             XRD_WARN_UNUSED_RESULT;
00552 
00553       //------------------------------------------------------------------------
00561       //------------------------------------------------------------------------
00562       XRootDStatus StatVFS( const std::string  &path,
00563                             StatInfoVFS       *&response,
00564                             uint16_t            timeout = 0 )
00565                             XRD_WARN_UNUSED_RESULT;
00566 
00567       //------------------------------------------------------------------------
00576       //------------------------------------------------------------------------
00577       XRootDStatus Protocol( ResponseHandler *handler,
00578                              uint16_t         timeout = 0 )
00579                              XRD_WARN_UNUSED_RESULT;
00580 
00581       //------------------------------------------------------------------------
00588       //------------------------------------------------------------------------
00589       XRootDStatus Protocol( ProtocolInfo *&response,
00590                              uint16_t       timeout = 0 )
00591                              XRD_WARN_UNUSED_RESULT;
00592 
00593       //------------------------------------------------------------------------
00604       //------------------------------------------------------------------------
00605       XRootDStatus DirList( const std::string   &path,
00606                             DirListFlags::Flags  flags,
00607                             ResponseHandler     *handler,
00608                             uint16_t             timeout = 0 )
00609                             XRD_WARN_UNUSED_RESULT;
00610 
00611       //------------------------------------------------------------------------
00620       //------------------------------------------------------------------------
00621       XRootDStatus DirList( const std::string    &path,
00622                             DirListFlags::Flags   flags,
00623                             DirectoryList       *&response,
00624                             uint16_t              timeout = 0 )
00625                             XRD_WARN_UNUSED_RESULT;
00626 
00627       //------------------------------------------------------------------------
00637       //------------------------------------------------------------------------
00638       XRootDStatus SendInfo( const std::string &info,
00639                              ResponseHandler   *handler,
00640                              uint16_t           timeout = 0 )
00641                              XRD_WARN_UNUSED_RESULT;
00642 
00643       //------------------------------------------------------------------------
00651       //------------------------------------------------------------------------
00652       XRootDStatus SendInfo( const std::string  &info,
00653                              Buffer            *&response,
00654                              uint16_t            timeout = 0 )
00655                              XRD_WARN_UNUSED_RESULT;
00656 
00657       //------------------------------------------------------------------------
00669       //------------------------------------------------------------------------
00670       XRootDStatus Prepare( const std::vector<std::string> &fileList,
00671                             PrepareFlags::Flags             flags,
00672                             uint8_t                         priority,
00673                             ResponseHandler                *handler,
00674                             uint16_t                        timeout = 0 )
00675                             XRD_WARN_UNUSED_RESULT;
00676 
00677       //------------------------------------------------------------------------
00687       //------------------------------------------------------------------------
00688       XRootDStatus Prepare( const std::vector<std::string>  &fileList,
00689                             PrepareFlags::Flags              flags,
00690                             uint8_t                          priority,
00691                             Buffer                         *&response,
00692                             uint16_t                         timeout = 0 )
00693                             XRD_WARN_UNUSED_RESULT;
00694 
00695       //------------------------------------------------------------------------
00700       //------------------------------------------------------------------------
00701       bool SetProperty( const std::string &name, const std::string &value );
00702 
00703       //------------------------------------------------------------------------
00707       //------------------------------------------------------------------------
00708       bool GetProperty( const std::string &name, std::string &value ) const;
00709 
00710     private:
00711       FileSystem(const FileSystem &other);
00712       FileSystem &operator = (const FileSystem &other);
00713 
00714       //------------------------------------------------------------------------
00715       // Send a message in a locked environment
00716       //------------------------------------------------------------------------
00717       Status Send( Message                 *msg,
00718                    ResponseHandler         *handler,
00719                    MessageSendParams       &params );
00720 
00721       //------------------------------------------------------------------------
00722       // Assign a load balancer if it has not already been assigned
00723       //------------------------------------------------------------------------
00724       void AssignLoadBalancer( const URL &url );
00725 
00726       //------------------------------------------------------------------------
00727       // Lock the internal lock
00728       //------------------------------------------------------------------------
00729       void Lock()
00730       {
00731         pMutex.Lock();
00732       }
00733 
00734       //------------------------------------------------------------------------
00735       // Unlock the internal lock
00736       //------------------------------------------------------------------------
00737       void UnLock()
00738       {
00739         pMutex.UnLock();
00740       }
00741 
00742       XrdSysMutex       pMutex;
00743       bool              pLoadBalancerLookupDone;
00744       bool              pFollowRedirects;
00745       URL              *pUrl;
00746       FileSystemPlugIn *pPlugIn;
00747   };
00748 }
00749 
00750 #endif // __XRD_CL_FILE_SYSTEM_HH__

Generated on 5 Oct 2016 for xrootd by  doxygen 1.4.7