Logo ROOT   6.08/07
Reference Guide
TDCacheFile.h
Go to the documentation of this file.
1 // @(#)root/dcache:$Id$
2 // Author: Grzegorz Mazur 20/01/2002
3 // Updated: William Tanenbaum 21/11/2003
4 // Updated: Tgiran Mkrtchyan 28/06/2004
5 
6 /*************************************************************************
7  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
8  * All rights reserved. *
9  * *
10  * For the licensing terms see $ROOTSYS/LICENSE. *
11  * For the list of contributors see $ROOTSYS/README/CREDITS. *
12  *************************************************************************/
13 
14 #ifndef ROOT_TDCacheFile
15 #define ROOT_TDCacheFile
16 
17 #ifndef ROOT_TFile
18 #include "TFile.h"
19 #endif
20 #ifndef ROOT_TSystem
21 #include "TSystem.h"
22 #endif
23 #ifndef ROOT_TString
24 #include "TString.h"
25 #endif
26 
27 #include <sys/stat.h>
28 
29 #define RAHEAD_BUFFER_SIZE 131072
30 
31 class TDCacheFile : public TFile {
32 
33 private:
34  Bool_t fStatCached; ///<! (transient) is file status cached?
35  struct stat64 fStatBuffer; ///<! (transient) Cached file status buffer (for performance)
36 
37  TDCacheFile() : fStatCached(kFALSE) { }
38 
39  // Interface to basic system I/O routines
40  Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode);
41  Int_t SysClose(Int_t fd);
42  Int_t SysRead(Int_t fd, void *buf, Int_t len);
43  Int_t SysWrite(Int_t fd, const void *buf, Int_t len);
44  Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence);
45  Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime);
46  Int_t SysSync(Int_t fd);
47 
48 public:
49  TDCacheFile(const char *path, Option_t *option="",
50  const char *ftitle="", Int_t compress=1);
51 
52  ~TDCacheFile();
53 
54  Bool_t ReadBuffer(char *buf, Int_t len);
55  Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
56  Bool_t WriteBuffer(const char *buf, Int_t len);
57 
58  Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
59 
60  void ResetErrno() const;
61 
62  static Bool_t Stage(const char *path, UInt_t secs,
63  const char *location = 0);
64  static Bool_t CheckFile(const char *path, const char *location = 0);
65 
66  /// Note: This must be kept in sync with values \#defined in dcap.h
71  };
72 
73  static void SetOpenTimeout(UInt_t secs);
75 
76  static void SetReplyHostName(const char *host_name);
77  static const char *GetDcapVersion();
78  static TString GetDcapPath(const char *path);
79 
80 
81  ClassDef(TDCacheFile,1) //A ROOT file that reads/writes via a dCache server
82 };
83 
84 
85 class TDCacheSystem : public TSystem {
86 
87 private:
88  void *fDirp; ///< directory handler
89 
90  void *GetDirPtr() const { return fDirp; }
91 
92 public:
93  TDCacheSystem();
94  virtual ~TDCacheSystem() { }
95 
96  Int_t MakeDirectory(const char *name);
97  void *OpenDirectory(const char *name);
98  void FreeDirectory(void *dirp);
99  const char *GetDirEntry(void *dirp);
100  Int_t GetPathInfo(const char *path, FileStat_t &buf);
101  Bool_t AccessPathName(const char *path, EAccessMode mode);
102 
103  ClassDef(TDCacheSystem,0) // Directory handler for DCache
104 };
105 
106 #endif
A TDCacheFile is like a normal TFile except that it may read and write its data via a dCache server (...
Definition: TDCacheFile.h:31
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system seek. All arguments like in POSIX lseek.
long long Long64_t
Definition: RtypesCore.h:69
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Int_t SysSync(Int_t fd)
Interface to system sync.
const char Option_t
Definition: RtypesCore.h:62
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
Bool_t fStatCached
! (transient) is file status cached?
Definition: TDCacheFile.h:34
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
static void SetOnError(EOnErrorAction=kOnErrorDefault)
Set on error handler.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write.
static void SetOpenTimeout(UInt_t secs)
Set file open timeout.
Bool_t WriteBuffer(const char *buf, Int_t len)
Write specified byte range to remote file via dCache daemon.
#define ClassDef(name, id)
Definition: Rtypes.h:254
static const char * GetDcapVersion()
Return dCache version string.
void * fDirp
directory handler
Definition: TDCacheFile.h:88
static Bool_t CheckFile(const char *path, const char *location=0)
CheckFile() returns kTRUE on success and kFALSE on failure.
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read.
static TString GetDcapPath(const char *path)
Transform the input path into a path usuable by the dcap C library, i.e either dcap://nodename.org/where/filename.root or /pnfs/where/filename.root.
void ResetErrno() const
Method resetting the dc_errno and errno.
unsigned int UInt_t
Definition: RtypesCore.h:42
static void SetReplyHostName(const char *host_name)
Set reply host name.
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len, where pos[i] is the seek position of block i of...
long Long_t
Definition: RtypesCore.h:50
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open.
EAccessMode
Definition: TSystem.h:54
struct stat64 fStatBuffer
! (transient) Cached file status buffer (for performance)
Definition: TDCacheFile.h:35
Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via dCache daemon.
Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close.
virtual ~TDCacheSystem()
Definition: TDCacheFile.h:94
EOnErrorAction
Note: This must be kept in sync with values #defined in dcap.h.
Definition: TDCacheFile.h:67
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:258
~TDCacheFile()
Close and cleanup dCache file.
void * GetDirPtr() const
Definition: TDCacheFile.h:90
char name[80]
Definition: TGX11.cxx:109
static Bool_t Stage(const char *path, UInt_t secs, const char *location=0)
Stage() returns kTRUE on success and kFALSE on failure.