XrdClFileSystem.hh

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
00003 // Author: Lukasz Janyst <ljanyst@cern.ch>
00004 //------------------------------------------------------------------------------
00005 // XRootD is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // XRootD is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
00017 //------------------------------------------------------------------------------
00018 
00019 #ifndef __XRD_CL_FILE_SYSTEM_HH__
00020 #define __XRD_CL_FILE_SYSTEM_HH__
00021 
00022 #include "XrdCl/XrdClURL.hh"
00023 #include "XrdCl/XrdClStatus.hh"
00024 #include "XrdOuc/XrdOucEnum.hh"
00025 #include "XrdCl/XrdClXRootDResponses.hh"
00026 #include "XrdSys/XrdSysPthread.hh"
00027 #include "XProtocol/XProtocol.hh"
00028 #include <string>
00029 #include <vector>
00030 
00031 namespace XrdCl
00032 {
00033   class PostMaster;
00034   class Message;
00035   struct MessageSendParams;
00036 
00037   //----------------------------------------------------------------------------
00039   //----------------------------------------------------------------------------
00040   struct QueryCode
00041   {
00042     //--------------------------------------------------------------------------
00044     //--------------------------------------------------------------------------
00045     enum Code
00046     {
00047       Config         = kXR_Qconfig,    
00048       ChecksumCancel = kXR_Qckscan,    
00049       Checksum       = kXR_Qcksum,     
00050       Opaque         = kXR_Qopaque,    
00051       OpaqueFile     = kXR_Qopaquf,    
00052       Prepare        = kXR_QPrep,      
00053       Space          = kXR_Qspace,     
00054       Stats          = kXR_QStats,     
00055       Visa           = kXR_Qvisa,      
00056       XAttr          = kXR_Qxattr      
00057     };
00058   };
00059 
00060   //----------------------------------------------------------------------------
00062   //----------------------------------------------------------------------------
00063   struct OpenFlags
00064   {
00065     //--------------------------------------------------------------------------
00067     //--------------------------------------------------------------------------
00068     enum Flags
00069     {
00070       None     = 0,              
00071       Delete   = kXR_delete,     
00072 
00073       Force    = kXR_force,      
00074       MakePath = kXR_mkpath,     
00075 
00076       New      = kXR_new,        
00077 
00078       NoWait   = kXR_nowait,     
00079 
00080 
00081 
00082 
00083 
00084       Append   = kXR_open_apnd,  
00085       Read     = kXR_open_read,  
00086       Update   = kXR_open_updt,  
00087       POSC     = kXR_posc,       
00088 
00089       Refresh  = kXR_refresh,    
00090 
00091       Replica  = kXR_replica,    
00092 
00093       SeqIO    = kXR_seqio       
00094     };
00095   };
00096   XRDOUC_ENUM_OPERATORS( OpenFlags::Flags )
00097 
00098   //----------------------------------------------------------------------------
00100   //----------------------------------------------------------------------------
00101   struct Access
00102   {
00103     //--------------------------------------------------------------------------
00105     //--------------------------------------------------------------------------
00106     enum Mode
00107     {
00108       None = 0,
00109       UR   = kXR_ur,         
00110       UW   = kXR_uw,         
00111       UX   = kXR_ux,         
00112       GR   = kXR_gr,         
00113       GW   = kXR_gw,         
00114       GX   = kXR_gx,         
00115       OR   = kXR_or,         
00116       OW   = kXR_ow,         
00117       OX   = kXR_ox          
00118     };
00119   };
00120   XRDOUC_ENUM_OPERATORS( Access::Mode )
00121 
00122   //----------------------------------------------------------------------------
00124   //----------------------------------------------------------------------------
00125   struct MkDirFlags
00126   {
00127     enum Flags
00128     {
00129       None     = 0,  
00130       MakePath = 1   
00131     };
00132   };
00133   XRDOUC_ENUM_OPERATORS( MkDirFlags::Flags )
00134 
00135   //----------------------------------------------------------------------------
00137   //----------------------------------------------------------------------------
00138   struct DirListFlags
00139   {
00140     enum Flags
00141     {
00142       None   = 0,  
00143       Stat   = 1,  
00144       Locate = 2  
00145 
00146     };
00147   };
00148   XRDOUC_ENUM_OPERATORS( DirListFlags::Flags )
00149 
00150   //----------------------------------------------------------------------------
00152   //----------------------------------------------------------------------------
00153   struct PrepareFlags
00154   {
00155     enum Flags
00156     {
00157       Colocate    = kXR_coloc,    
00158       Fresh       = kXR_fresh,    
00159 
00160       Stage       = kXR_stage,    
00161 
00162       WriteMode   = kXR_wmode     
00163 
00164     };
00165   };
00166   XRDOUC_ENUM_OPERATORS( PrepareFlags::Flags )
00167 
00168   //----------------------------------------------------------------------------
00170   //----------------------------------------------------------------------------
00171   class FileSystem
00172   {
00173     friend class AssignLBHandler;
00174     friend class ForkHandler;
00175 
00176     public:
00177       typedef std::vector<LocationInfo> LocationList; 
00178 
00179       //------------------------------------------------------------------------
00183       //------------------------------------------------------------------------
00184       FileSystem( const URL &url );
00185 
00186       //------------------------------------------------------------------------
00188       //------------------------------------------------------------------------
00189       ~FileSystem();
00190 
00191       //------------------------------------------------------------------------
00202       //------------------------------------------------------------------------
00203       XRootDStatus Locate( const std::string &path,
00204                            OpenFlags::Flags   flags,
00205                            ResponseHandler   *handler,
00206                            uint16_t           timeout = 0 );
00207 
00208       //------------------------------------------------------------------------
00217       //------------------------------------------------------------------------
00218       XRootDStatus Locate( const std::string  &path,
00219                            OpenFlags::Flags    flags,
00220                            LocationInfo      *&response,
00221                            uint16_t            timeout  = 0 );
00222 
00223       //------------------------------------------------------------------------
00234       //------------------------------------------------------------------------
00235       XRootDStatus DeepLocate( const std::string &path,
00236                                OpenFlags::Flags   flags,
00237                                ResponseHandler   *handler,
00238                                uint16_t           timeout = 0 );
00239 
00240       //------------------------------------------------------------------------
00249       //------------------------------------------------------------------------
00250       XRootDStatus DeepLocate( const std::string  &path,
00251                                OpenFlags::Flags   flags,
00252                                LocationInfo      *&response,
00253                                uint16_t            timeout  = 0 );
00254 
00255       //------------------------------------------------------------------------
00264       //------------------------------------------------------------------------
00265       XRootDStatus Mv( const std::string &source,
00266                        const std::string &dest,
00267                        ResponseHandler   *handler,
00268                        uint16_t           timeout = 0 );
00269 
00270       //------------------------------------------------------------------------
00278       //------------------------------------------------------------------------
00279       XRootDStatus Mv( const std::string &source,
00280                        const std::string &dest,
00281                        uint16_t           timeout = 0 );
00282 
00283       //------------------------------------------------------------------------
00294       //------------------------------------------------------------------------
00295       XRootDStatus Query( QueryCode::Code  queryCode,
00296                           const Buffer    &arg,
00297                           ResponseHandler *handler,
00298                           uint16_t         timeout = 0 );
00299 
00300       //------------------------------------------------------------------------
00309       //------------------------------------------------------------------------
00310       XRootDStatus Query( QueryCode::Code   queryCode,
00311                           const Buffer     &arg,
00312                           Buffer          *&response,
00313                           uint16_t          timeout = 0 );
00314 
00315       //------------------------------------------------------------------------
00324       //------------------------------------------------------------------------
00325       XRootDStatus Truncate( const std::string &path,
00326                              uint64_t           size,
00327                              ResponseHandler   *handler,
00328                              uint16_t           timeout = 0 );
00329 
00330       //------------------------------------------------------------------------
00338       //------------------------------------------------------------------------
00339       XRootDStatus Truncate( const std::string &path,
00340                              uint64_t           size,
00341                              uint16_t           timeout = 0 );
00342 
00343       //------------------------------------------------------------------------
00351       //------------------------------------------------------------------------
00352       XRootDStatus Rm( const std::string &path,
00353                        ResponseHandler   *handler,
00354                        uint16_t           timeout = 0 );
00355 
00356       //------------------------------------------------------------------------
00363       //------------------------------------------------------------------------
00364       XRootDStatus Rm( const std::string &path,
00365                        uint16_t           timeout = 0 );
00366 
00367       //------------------------------------------------------------------------
00377       //------------------------------------------------------------------------
00378       XRootDStatus MkDir( const std::string &path,
00379                           MkDirFlags::Flags  flags,
00380                           Access::Mode       mode,
00381                           ResponseHandler   *handler,
00382                           uint16_t           timeout = 0 );
00383 
00384       //------------------------------------------------------------------------
00393       //------------------------------------------------------------------------
00394       XRootDStatus MkDir( const std::string &path,
00395                           MkDirFlags::Flags  flags,
00396                           Access::Mode       mode,
00397                           uint16_t           timeout = 0 );
00398 
00399       //------------------------------------------------------------------------
00407       //------------------------------------------------------------------------
00408       XRootDStatus RmDir( const std::string &path,
00409                           ResponseHandler   *handler,
00410                           uint16_t           timeout = 0 );
00411 
00412       //------------------------------------------------------------------------
00419       //------------------------------------------------------------------------
00420       XRootDStatus RmDir( const std::string &path,
00421                           uint16_t           timeout = 0 );
00422 
00423       //------------------------------------------------------------------------
00432       //------------------------------------------------------------------------
00433       XRootDStatus ChMod( const std::string &path,
00434                           Access::Mode       mode,
00435                           ResponseHandler   *handler,
00436                           uint16_t           timeout = 0 );
00437 
00438       //------------------------------------------------------------------------
00446       //------------------------------------------------------------------------
00447       XRootDStatus ChMod( const std::string &path,
00448                           Access::Mode       mode,
00449                           uint16_t           timeout = 0 );
00450 
00451       //------------------------------------------------------------------------
00458       //------------------------------------------------------------------------
00459       XRootDStatus Ping( ResponseHandler *handler,
00460                          uint16_t         timeout = 0 );
00461 
00462       //------------------------------------------------------------------------
00468       //------------------------------------------------------------------------
00469       XRootDStatus Ping( uint16_t timeout = 0 );
00470 
00471       //------------------------------------------------------------------------
00481       //------------------------------------------------------------------------
00482       XRootDStatus Stat( const std::string &path,
00483                          ResponseHandler   *handler,
00484                          uint16_t           timeout = 0 );
00485 
00486       //------------------------------------------------------------------------
00494       //------------------------------------------------------------------------
00495       XRootDStatus Stat( const std::string  &path,
00496                          StatInfo          *&response,
00497                          uint16_t            timeout = 0 );
00498 
00499       //------------------------------------------------------------------------
00509       //------------------------------------------------------------------------
00510       XRootDStatus StatVFS( const std::string &path,
00511                             ResponseHandler   *handler,
00512                             uint16_t           timeout = 0 );
00513 
00514       //------------------------------------------------------------------------
00522       //------------------------------------------------------------------------
00523       XRootDStatus StatVFS( const std::string  &path,
00524                             StatInfoVFS       *&response,
00525                             uint16_t            timeout = 0 );
00526 
00527       //------------------------------------------------------------------------
00536       //------------------------------------------------------------------------
00537       XRootDStatus Protocol( ResponseHandler *handler,
00538                              uint16_t         timeout = 0 );
00539 
00540       //------------------------------------------------------------------------
00547       //------------------------------------------------------------------------
00548       XRootDStatus Protocol( ProtocolInfo *&response,
00549                              uint16_t       timeout = 0 );
00550 
00551       //------------------------------------------------------------------------
00562       //------------------------------------------------------------------------
00563       XRootDStatus DirList( const std::string   &path,
00564                             DirListFlags::Flags  flags,
00565                             ResponseHandler     *handler,
00566                             uint16_t             timeout = 0 );
00567 
00568       //------------------------------------------------------------------------
00577       //------------------------------------------------------------------------
00578       XRootDStatus DirList( const std::string    &path,
00579                             DirListFlags::Flags   flags,
00580                             DirectoryList       *&response,
00581                             uint16_t              timeout = 0 );
00582 
00583       //------------------------------------------------------------------------
00593       //------------------------------------------------------------------------
00594       XRootDStatus SendInfo( const std::string &info,
00595                              ResponseHandler   *handler,
00596                              uint16_t           timeout = 0 );
00597 
00598       //------------------------------------------------------------------------
00606       //------------------------------------------------------------------------
00607       XRootDStatus SendInfo( const std::string  &info,
00608                              Buffer            *&response,
00609                              uint16_t            timeout = 0 );
00610 
00611       //------------------------------------------------------------------------
00623       //------------------------------------------------------------------------
00624       XRootDStatus Prepare( const std::vector<std::string> &fileList,
00625                             PrepareFlags::Flags             flags,
00626                             uint8_t                         priority,
00627                             ResponseHandler                *handler,
00628                             uint16_t                        timeout = 0 );
00629 
00630       //------------------------------------------------------------------------
00640       //------------------------------------------------------------------------
00641       XRootDStatus Prepare( const std::vector<std::string>  &fileList,
00642                             PrepareFlags::Flags              flags,
00643                             uint8_t                          priority,
00644                             Buffer                         *&response,
00645                             uint16_t                         timeout = 0 );
00646 
00647     private:
00648 
00649       //------------------------------------------------------------------------
00650       // Send a message in a locked environment
00651       //------------------------------------------------------------------------
00652       Status Send( Message                 *msg,
00653                    ResponseHandler         *handler,
00654                    const MessageSendParams &params );
00655 
00656       //------------------------------------------------------------------------
00657       // Assign a load balancer if it has not already been assigned
00658       //------------------------------------------------------------------------
00659       void AssignLoadBalancer( const URL &url );
00660 
00661       //------------------------------------------------------------------------
00662       // Lock the internal lock
00663       //------------------------------------------------------------------------
00664       void Lock()
00665       {
00666         pMutex.Lock();
00667       }
00668 
00669       //------------------------------------------------------------------------
00670       // Unlock the internal lock
00671       //------------------------------------------------------------------------
00672       void UnLock()
00673       {
00674         pMutex.UnLock();
00675       }
00676 
00677       XrdSysMutex  pMutex;
00678       bool         pLoadBalancerLookupDone;
00679       URL         *pUrl;
00680   };
00681 }
00682 
00683 #endif // __XRD_CL_FILE_SYSTEM_HH__

Generated on 16 Jan 2014 for xrootd by  doxygen 1.4.7