Logo ROOT   6.07/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 //Davix.S3.AccessKey
49 //Davix.S3.SecretKey
50 //Davix.S3.Region
51 //Davix.S3.Token
52 //
53 // Environment variables:
54 // X509_USER_CERT, X509_USER_KEY, X509_USER_PROXY ... usual meaning for the X509 Grid things. gEnv vars have higher priority.
55 // S3_ACCESS_KEY, S3_SECRET_KEY, S3_REGION, S3_TOKEN. gEnv vars have higher priority.
56 
57 #include "TFile.h"
58 #include "TUrl.h"
59 #include "TSystem.h"
60 #include "TMutex.h"
61 
62 class TDavixFileInternal;
63 struct Davix_fd;
64 
65 
66 class TDavixFile : public TFile {
67 private:
69 
70  void Init(Bool_t init);
71  Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len);
72  Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len);
73  Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
74  Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len);
75  Int_t DavixStat(struct stat *st) const;
76 
77  // perfStats
79  void eventStop(Double_t t, Long64_t len);
80 
81 public:
82  ///
83  /// Open function for TDavixFile
84  ///
85  /// TDavixFile supports several options :
86  ///
87  /// - GRID_MODE=yes : enable the grid authentication and CA support
88  /// - CA_CHECK=no : remove all the certificate authority check, this option can create a security vulnerability
89  /// - S3_SECKEY=string : Amazon S3 secret token
90  /// - S3_ACCKEY=string : Amazon S3 access token
91  /// - S3_REGION=string : Amazon S3 region. Optional, if provided, davix will use v4 signatures.
92  /// - S3_TOKEN=string : Amazon STS temporary credentials token.
93  ///
94  /// Several parameters can be used if separated with whitespace
95 
96  TDavixFile(const char* url, Option_t *option="", const char *ftitle="", Int_t compress=1);
97 
98  ~TDavixFile();
99 
100  // TFile interface.
101  virtual Long64_t GetSize() const;
102  virtual void Seek(Long64_t offset, ERelativeTo pos = kBeg);
103  virtual Bool_t ReadBuffer(char *buf, Int_t len);
104  virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
105  virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
106  virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
107  virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength);
108 
109  // TDavixFile options
110  /// Enable or disable certificate authority check
111  void setCACheck(Bool_t check);
112 
113  /// Enable the grid mode
114  /// The grid Mode configure automatically all grid-CA path, VOMS authentication
115  /// and grid related extension for a grid analysis usage
116  void enableGridMode();
117 
118  ClassDef(TDavixFile, 0)
119 };
120 
121 #endif
long long Long64_t
Definition: RtypesCore.h:69
void Init(Bool_t init)
Initialize a TFile object.
Definition: TDavixFile.cxx:451
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
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via HTTP.
Definition: TDavixFile.cxx:497
Double_t eventStart()
Definition: TDavixFile.cxx:642
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TDavixFileInternal * d_ptr
Definition: TDavixFile.h:68
Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len)
Definition: TDavixFile.cxx:663
ERelativeTo
Definition: TFile.h:169
virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength)
Write a buffer to the file.
Definition: TDavixFile.cxx:569
void eventStop(Double_t t, Long64_t len)
set TFile state info
Definition: TDavixFile.cxx:652
Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Definition: TDavixFile.cxx:723
#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:470
Int_t DavixStat(struct stat *st) const
virtual Long64_t GetSize() const
Returns the current file size.
Definition: TDavixFile.cxx:628
Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len)
Definition: TDavixFile.cxx:683
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Definition: TDavixFile.cxx:534
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:550
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:594
TDavixFile(const char *url, Option_t *option="", const char *ftitle="", Int_t compress=1)
Open function for TDavixFile.
Definition: TDavixFile.cxx:433
Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len)
Definition: TDavixFile.cxx:703
void setCACheck(Bool_t check)
Enable or disable certificate authority check.
Definition: TDavixFile.cxx:587