TXNetFile.h

Go to the documentation of this file.
00001 // @(#)root/netx:$Id: TXNetFile.h 34444 2010-07-16 02:17:39Z pcanal $
00002 /*************************************************************************
00003  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00004  * All rights reserved.                                                  *
00005  *                                                                       *
00006  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00007  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00008  *************************************************************************/
00009 
00010 #ifndef ROOT_TXNetFile
00011 #define ROOT_TXNetFile
00012 
00013 
00014 //////////////////////////////////////////////////////////////////////////
00015 //                                                                      //
00016 // TXNetFile                                                            //
00017 //                                                                      //
00018 // Authors: Alvise Dorigo, Fabrizio Furano                              //
00019 //          INFN Padova, 2003                                           //
00020 // Interfaced to the posix client: G. Ganis, CERN                       //
00021 //                                                                      //
00022 // TXNetFile is an extension of TNetFile able to deal with new xrootd   //
00023 // server. Its new features are:                                        //
00024 //  - Automatic server kind recognition (xrootd load balancer, xrootd   //
00025 //    data server, old rootd)                                           //
00026 //  - Backward compatibility with old rootd server (acts as an old      //
00027 //    TNetFile)                                                         //
00028 //  - Fault tolerance for read/write operations (read/write timeouts    //
00029 //    and retry)                                                        //
00030 //  - Internal connection timeout (tunable indipendently from the OS    //
00031 //    one) handled by threads                                           //
00032 //  - handling of redirections from server                              //
00033 //  - Single TCP physical channel for multiple TXNetFile's instances    //
00034 //    inside the same application                                       //
00035 //    So, each TXNetFile object client must send messages containing    //
00036 //    its ID (streamid). The server, of course, will respond with       //
00037 //    messages containing the client's ID, in order to make the client  //
00038 //    able to recognize its message by matching its streamid with that  //
00039 //    one contained in the server's response.                           //
00040 //  - Tunable log verbosity level (0 = nothing, 3 = dump read/write     //
00041 //    buffers too!)                                                     //
00042 //  - Many parameters configurable via TEnv facility (see SetParm()     //
00043 //    methods)                                                          //
00044 //                                                                      //
00045 //////////////////////////////////////////////////////////////////////////
00046 
00047 #ifndef ROOT_TNetFile
00048 #include "TNetFile.h"
00049 #endif
00050 #ifndef ROOT_TString
00051 #include "TString.h"
00052 #endif
00053 #ifndef ROOT_TUrl
00054 #include "TUrl.h"
00055 #endif
00056 #ifdef OLDXRDOUC
00057 #  include "XrdSysToOuc.h"
00058 #endif
00059 
00060 class TFileStager;
00061 class TSocket;
00062 class XrdClient;
00063 class XrdSysRecMutex;
00064 
00065 class TXNetFile : public TNetFile {
00066 
00067 friend class TXNetSystem;
00068 
00069 private:
00070    // Members
00071    XrdClient         *fClient;       // Handle to the client object
00072    Bool_t             fIsRootd;      // Nature of remote file server
00073 
00074    // Static members
00075    static Bool_t  fgInitDone;    // Avoid initializing more than once
00076    static Bool_t  fgRootdBC;     // Control rootd backward compatibility
00077    static TFileStager *fgFileStager; // Stager for IsStaged checks
00078 
00079    XrdSysRecMutex    *fInitMtx;     // Protects fInitDone, serializes the
00080                                    // attempts to Init() for this object only
00081 
00082    // Methods
00083    TXNetFile(const TXNetFile&);  // Not implemented
00084    TXNetFile& operator=(const TXNetFile&);  // Not implemented
00085    void    CreateXClient(const char *url, Option_t *option, Int_t netopt,
00086                          Bool_t parallelopen);
00087 
00088    Int_t   ParseOptions(const char *opts, Int_t &cachesz, Int_t &readaheadsz,
00089                         Int_t &rmpolicy, Int_t &mxredir, Int_t &rastrategy, Int_t &readtrimblksz);
00090 
00091    // Synchronizes the cache size in XrdClient
00092    // XrdClient cannot have a cache size smaller than the one in TFile
00093    void    SynchronizeCacheSize();
00094 
00095    void    Init(Bool_t create);
00096    Bool_t  Open(Option_t *option, Bool_t parallelopen);
00097    Int_t   SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags,
00098                    Long_t *modtime);
00099    Int_t   SysOpen(const char *pathname, Int_t flags, UInt_t mode);
00100    Int_t   SysClose(Int_t fd);
00101 
00102    // Static methods
00103    static void FormUrl(TUrl uut, TString &uu);
00104    static Int_t GetRootdProtocol(TSocket *s);
00105    static void SetEnv();
00106 
00107 public:
00108    TXNetFile() : TNetFile(), fClient(0), fIsRootd(0), fInitMtx(0) {}
00109    TXNetFile(const char *url, Option_t *option = "", const char *fTitle = "",
00110              Int_t compress = 1, Int_t netopt = 0, Bool_t parallelopen = kFALSE,
00111              const char *logicalurl = 0);
00112 
00113    virtual ~TXNetFile();
00114 
00115    virtual void     Close(const Option_t *opt ="");
00116    virtual void     ResetCache();
00117    virtual void     Flush();
00118    virtual Int_t    GetBytesToPrefetch() const;
00119    virtual Bool_t   ReadBufferAsync(Long64_t offs, Int_t len);
00120    virtual TFile::EAsyncOpenStatus GetAsyncOpenStatus();
00121    virtual Bool_t   IsOpen() const;
00122 
00123    virtual void     Print(Option_t *option="") const;
00124    virtual Bool_t   ReadBuffer(char *buf, Int_t len);
00125    virtual Bool_t   ReadBuffer(char *buf, Long64_t pos, Int_t len);
00126    virtual Bool_t   ReadBuffers(char *buf,  Long64_t *pos, Int_t *len, Int_t nbuf);
00127    virtual Int_t    ReOpen(const Option_t *mode);
00128    virtual Bool_t   WriteBuffer(const char *buffer, Int_t BufferLength);
00129 
00130    ClassDef(TXNetFile,0) // TFile implementation to deal with new xrootd server.
00131 };
00132 
00133 #endif

Generated on Tue Jul 5 14:46:12 2011 for ROOT_528-00b_version by  doxygen 1.5.1