ROOT  6.06/09
Reference Guide
TDavixFile.h
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Adrien Devresse and Tigran Mkrtchyan
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TDavixFile
13 #define ROOT_TDavixFile
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TDavixFile //
18 // //
19 // A TDavixFile is like a normal TFile except that it uses //
20 // libdavix to read/write remote files. //
21 // It supports HTTP and HTTPS in a number of dialects and options //
22 // e.g. S3 is one of them //
23 // Other caracteristics come from the full support of Davix, //
24 // e.g. full redirection support in any circumstance //
25 // //
26 // Authors: Adrien Devresse (CERN IT/SDC) //
27 // Tigran Mkrtchyan (DESY) //
28 // //
29 // Checks, refactoring and ROOT5 porting: //
30 // Fabrizio Furano (CERN IT/SDC) //
31 // //
32 // September 2013 //
33 // //
34 //////////////////////////////////////////////////////////////////////////
35 
36 //
37 // Parameters that influence the behavior of TDavixFile/TDavixSystem. The names should be self-explanatory
38 //
39 //Davix.Debug
40 //Davix.GSI.UserProxy
41 //Davix.GSI.UserCert
42 //Davix.GSI.UserKey
43 
44 //Davix.GSI.CAdir
45 //Davix.GSI.CACheck
46 //Davix.GSI.GridMode
47 //
48 // Environment variables:
49 // X509_USER_CERT, X509_USER_KEY, X509_USER_PROXY ... usual meaning for the X509 Grid things. gEnv vars have higher priority.
50 
51 #include "TFile.h"
52 #include "TUrl.h"
53 #include "TSystem.h"
54 #include "TMutex.h"
55 
56 class TDavixFileInternal;
57 struct Davix_fd;
58 
59 
60 class TDavixFile : public TFile {
61 private:
63 
64  void Init(Bool_t init);
65  Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len);
66  Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len);
67  Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
68  Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len);
69  Int_t DavixStat(struct stat *st) const;
70 
71  // perfStats
73  void eventStop(Double_t t, Long64_t len);
74 
75 public:
76  ///
77  /// Open function for TDavixFile
78  ///
79  /// TDavixFile supports several options :
80  ///
81  /// - GRID_MODE=yes : enable the grid authentication and CA support
82  /// - CA_CHECK=no : remove all the certificate authority check, this option can create a security vulnerability
83  /// - S3_SECKEY=string : Amazon S3 secret token
84  /// - S3_ACCKEY=string : Amazon S3 access token
85  ///
86  /// Several parameters can be used if separated with whitespace
87 
88  TDavixFile(const char* url, Option_t *option="", const char *ftitle="", Int_t compress=1);
89 
90  ~TDavixFile();
91 
92  // TFile interface.
93  virtual Long64_t GetSize() const;
94  virtual void Seek(Long64_t offset, ERelativeTo pos = kBeg);
95  virtual Bool_t ReadBuffer(char *buf, Int_t len);
96  virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
97  virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
98  virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
99  virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength);
100 
101  // TDavixFile options
102  /// Enable or disable certificate authority check
103  void setCACheck(Bool_t check);
104 
105  /// Enable the grid mode
106  /// The grid Mode configure automatically all grid-CA path, VOMS authentication
107  /// and grid related extension for a grid analysis usage
108  void enableGridMode();
109 
110  ClassDef(TDavixFile, 0)
111 };
112 
113 #endif
long long Long64_t
Definition: RtypesCore.h:69
void Init(Bool_t init)
Initialize a TFile object.
Definition: TDavixFile.cxx:423
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:45
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via HTTP.
Definition: TDavixFile.cxx:469
Double_t eventStart()
Definition: TDavixFile.cxx:614
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TDavixFileInternal * d_ptr
Definition: TDavixFile.h:62
Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len)
Definition: TDavixFile.cxx:635
ERelativeTo
Definition: TFile.h:160
virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength)
Write a buffer to the file.
Definition: TDavixFile.cxx:541
void eventStop(Double_t t, Long64_t len)
set TFile state info
Definition: TDavixFile.cxx:624
Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Definition: TDavixFile.cxx:695
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition: TDavixFile.cxx:442
Int_t DavixStat(struct stat *st) const
virtual Long64_t GetSize() const
Returns the current file size.
Definition: TDavixFile.cxx:600
Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len)
Definition: TDavixFile.cxx:655
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Definition: TDavixFile.cxx:506
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
Definition: TDavixFile.cxx:522
static Int_t init()
double Double_t
Definition: RtypesCore.h:55
void enableGridMode()
Enable the grid mode The grid Mode configure automatically all grid-CA path, VOMS authentication and ...
Definition: TDavixFile.cxx:566
TDavixFile(const char *url, Option_t *option="", const char *ftitle="", Int_t compress=1)
Open function for TDavixFile.
Definition: TDavixFile.cxx:405
Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len)
Definition: TDavixFile.cxx:675
void setCACheck(Bool_t check)
Enable or disable certificate authority check.
Definition: TDavixFile.cxx:559