TDCacheFile.h

Go to the documentation of this file.
00001 // @(#)root/dcache:$Id: TDCacheFile.h 34444 2010-07-16 02:17:39Z pcanal $
00002 // Author: Grzegorz Mazur   20/01/2002
00003 // Updated: William Tanenbaum 21/11/2003
00004 // Updated: Tgiran Mkrtchyan 28/06/2004
00005 
00006 /*************************************************************************
00007  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00008  * All rights reserved.                                                  *
00009  *                                                                       *
00010  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00011  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00012  *************************************************************************/
00013 
00014 #ifndef ROOT_TDCacheFile
00015 #define ROOT_TDCacheFile
00016 
00017 
00018 //////////////////////////////////////////////////////////////////////////
00019 //                                                                      //
00020 // TDCacheFile                                                          //
00021 //                                                                      //
00022 // A TDCacheFile is like a normal TFile except that it reads and writes //
00023 // its data via a dCache server.                                        //
00024 //                                                                      //
00025 //////////////////////////////////////////////////////////////////////////
00026 
00027 
00028 #ifndef ROOT_TFile
00029 #include "TFile.h"
00030 #endif
00031 #ifndef ROOT_TSystem
00032 #include "TSystem.h"
00033 #endif
00034 #ifndef ROOT_TString
00035 #include "TString.h"
00036 #endif
00037 
00038 #include <sys/stat.h>
00039 
00040 #define RAHEAD_BUFFER_SIZE 131072
00041 
00042 class TDCacheFile : public TFile {
00043 
00044 private:
00045    Bool_t fStatCached;       //! (transient) is file status cached?
00046    struct stat64 fStatBuffer;  //! (transient) Cached file status buffer (for performance)
00047 
00048    TDCacheFile() : fStatCached(kFALSE) { }
00049 
00050    // Interface to basic system I/O routines
00051    Int_t    SysOpen(const char *pathname, Int_t flags, UInt_t mode);
00052    Int_t    SysClose(Int_t fd);
00053    Int_t    SysRead(Int_t fd, void *buf, Int_t len);
00054    Int_t    SysWrite(Int_t fd, const void *buf, Int_t len);
00055    Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
00056    Int_t    SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
00057    Int_t    SysSync(Int_t fd);
00058 
00059 public:
00060    TDCacheFile(const char *path, Option_t *option="",
00061                const char *ftitle="", Int_t compress=1);
00062 
00063    ~TDCacheFile();
00064 
00065    Bool_t  ReadBuffer(char *buf, Int_t len);
00066    Bool_t  ReadBuffer(char *buf, Long64_t pos, Int_t len);
00067    Bool_t  WriteBuffer(const char *buf, Int_t len);
00068 
00069    Bool_t  ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
00070 
00071    void    ResetErrno() const;
00072 
00073    static Bool_t Stage(const char *path, UInt_t secs,
00074                        const char *location = 0);
00075    static Bool_t CheckFile(const char *path, const char *location = 0);
00076 
00077    // Note: This must be kept in sync with values #defined in dcap.h
00078    enum OnErrorAction {
00079       kOnErrorRetry   =  1,
00080       kOnErrorFail    =  0,
00081       kOnErrorDefault = -1
00082    };
00083 
00084    static void SetOpenTimeout(UInt_t secs);
00085    static void SetOnError(OnErrorAction = kOnErrorDefault);
00086 
00087    static void SetReplyHostName(const char *host_name);
00088    static const char *GetDcapVersion();
00089    static TString GetDcapPath(const char *path);
00090 
00091 
00092    ClassDef(TDCacheFile,1)  //A ROOT file that reads/writes via a dCache server
00093 };
00094 
00095 
00096 class TDCacheSystem : public TSystem {
00097 
00098 private:
00099    void    *fDirp;   // directory handler
00100 
00101    void    *GetDirPtr() const { return fDirp; }
00102 
00103 public:
00104    TDCacheSystem();
00105    virtual ~TDCacheSystem() { }
00106 
00107    Int_t       MakeDirectory(const char *name);
00108    void       *OpenDirectory(const char *name);
00109    void        FreeDirectory(void *dirp);
00110    const char *GetDirEntry(void *dirp);
00111    Int_t       GetPathInfo(const char *path, FileStat_t &buf);
00112    Bool_t      AccessPathName(const char *path, EAccessMode mode);
00113 
00114    ClassDef(TDCacheSystem,0)  // Directory handler for DCache
00115 };
00116 
00117 #endif

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