Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TFile.h"
18#include "TSystem.h"
19#include "TString.h"
20
21#include <sys/stat.h>
22
23#define RAHEAD_BUFFER_SIZE 131072
24
25class TDCacheFile : public TFile {
26
27private:
28 Bool_t fStatCached; ///<! (transient) is file status cached?
29 struct stat64 fStatBuffer; ///<! (transient) Cached file status buffer (for performance)
30
32
33 // Interface to basic system I/O routines
34 Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override;
35 Int_t SysClose(Int_t fd) override;
36 Int_t SysRead(Int_t fd, void *buf, Int_t len) override;
37 Int_t SysWrite(Int_t fd, const void *buf, Int_t len) override;
38 Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence) override;
39 Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override;
40 Int_t SysSync(Int_t fd) override;
41
42public:
43 TDCacheFile(const char *path, Option_t *option="",
45
46 ~TDCacheFile() override;
47
48 Bool_t ReadBuffer(char *buf, Int_t len) override;
49 Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len) override;
50 Bool_t WriteBuffer(const char *buf, Int_t len) override;
51
52 Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override;
53
54 void ResetErrno() const override;
55
56 static Bool_t Stage(const char *path, UInt_t secs,
57 const char *location = 0);
58 static Bool_t CheckFile(const char *path, const char *location = 0);
59
60 /// Note: This must be kept in sync with values \#defined in dcap.h
65 };
66
67 static void SetOpenTimeout(UInt_t secs);
69
70 static void SetReplyHostName(const char *host_name);
71 static const char *GetDcapVersion();
72 static TString GetDcapPath(const char *path);
73
74
75 ClassDefOverride(TDCacheFile,1) //A ROOT file that reads/writes via a dCache server
76};
77
78
79class TDCacheSystem : public TSystem {
80
81private:
82 void *fDirp; ///< directory handler
83
84 void *GetDirPtr() const override { return fDirp; }
85
86public:
88 ~TDCacheSystem() override { }
89
90 Int_t MakeDirectory(const char *name) override;
91 void *OpenDirectory(const char *name) override;
92 void FreeDirectory(void *dirp) override;
93 const char *GetDirEntry(void *dirp) override;
94 Int_t GetPathInfo(const char *path, FileStat_t &buf) override;
95 Bool_t AccessPathName(const char *path, EAccessMode mode) override;
96
97 ClassDefOverride(TDCacheSystem,0) // Directory handler for DCache
98};
99
100#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
long long Long64_t
Definition RtypesCore.h:69
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:110
EAccessMode
Definition TSystem.h:41
A TDCacheFile is like a normal TFile except that it may read and write its data via a dCache server (...
Definition TDCacheFile.h:25
void ResetErrno() const override
Method resetting the dc_errno and errno.
Bool_t fStatCached
! (transient) is file status cached?
Definition TDCacheFile.h:28
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override
Read the nbuf blocks described in arrays pos and len, where pos[i] is the seek position of block i of...
static Bool_t CheckFile(const char *path, const char *location=0)
CheckFile() returns kTRUE on success and kFALSE on failure.
Int_t SysSync(Int_t fd) override
Interface to system sync.
static void SetOnError(EOnErrorAction=kOnErrorDefault)
Set on error handler.
static void SetOpenTimeout(UInt_t secs)
Set file open timeout.
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence) override
Interface to system seek. All arguments like in POSIX lseek.
EOnErrorAction
Note: This must be kept in sync with values #defined in dcap.h.
Definition TDCacheFile.h:61
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override
Get info about a file: id, size, flags, modification time.
static Bool_t Stage(const char *path, UInt_t secs, const char *location=0)
Stage() returns kTRUE on success and kFALSE on failure.
~TDCacheFile() override
Close and cleanup dCache file.
struct stat64 fStatBuffer
! (transient) Cached file status buffer (for performance)
Definition TDCacheFile.h:29
static const char * GetDcapVersion()
Return dCache version string.
Int_t SysWrite(Int_t fd, const void *buf, Int_t len) override
Interface to system write. All arguments like in POSIX write.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override
Interface to system open. All arguments like in POSIX open.
Int_t SysRead(Int_t fd, void *buf, Int_t len) override
Interface to system read. All arguments like in POSIX read.
Int_t SysClose(Int_t fd) override
Interface to system close. All arguments like in POSIX close.
static TString GetDcapPath(const char *path)
Transform the input path into a path usuable by the dcap C library, i.e either dcap://nodename....
Bool_t ReadBuffer(char *buf, Int_t len) override
Read specified byte range from remote file via dCache daemon.
Bool_t WriteBuffer(const char *buf, Int_t len) override
Write specified byte range to remote file via dCache daemon.
static void SetReplyHostName(const char *host_name)
Set reply host name.
void * fDirp
directory handler
Definition TDCacheFile.h:82
~TDCacheSystem() override
Definition TDCacheFile.h:88
Int_t MakeDirectory(const char *name) override
Create a directory.
Int_t GetPathInfo(const char *path, FileStat_t &buf) override
Get info about a file.
void * OpenDirectory(const char *name) override
Open a directory.
Bool_t AccessPathName(const char *path, EAccessMode mode) override
Returns FALSE if one can access a file using the specified access mode.
void FreeDirectory(void *dirp) override
Close a directory.
TDCacheSystem()
Create helper class that allows directory access via dCache.
void * GetDirPtr() const override
Definition TDCacheFile.h:84
const char * GetDirEntry(void *dirp) override
Get a directory entry.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
Basic string class.
Definition TString.h:139
Abstract base class defining a generic interface to the underlying Operating System.
Definition TSystem.h:266
@ kUseCompiledDefault
Use the compile-time default setting.
Definition Compression.h:53