Logo ROOT   6.16/01
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
63struct Davix_fd;
64
65
66class TDavixFile : public TFile {
67private:
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, bool read = true);
80
81public:
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 = ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose);
97
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 virtual TString GetNewUrl();
109
110 // TDavixFile options
111 /// Enable or disable certificate authority check
112 void setCACheck(Bool_t check);
113
114 /// Enable the grid mode
115 /// The grid Mode configure automatically all grid-CA path, VOMS authentication
116 /// and grid related extension for a grid analysis usage
117 void enableGridMode();
118
120};
121
122#endif
static Int_t init()
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
long long Long64_t
Definition: RtypesCore.h:69
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
virtual Long64_t GetSize() const
Returns the current file size.
Definition: TDavixFile.cxx:743
void Init(Bool_t init)
Initialize a TFile object.
Definition: TDavixFile.cxx:552
TDavixFile(const char *url, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose)
Open function for TDavixFile.
Definition: TDavixFile.cxx:534
Int_t DavixStat(struct stat *st) const
Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Definition: TDavixFile.cxx:846
Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len)
Definition: TDavixFile.cxx:786
Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len)
Definition: TDavixFile.cxx:826
virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength)
Write a buffer to the file.
Definition: TDavixFile.cxx:684
virtual TString GetNewUrl()
Definition: TDavixFile.cxx:568
Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len)
Definition: TDavixFile.cxx:806
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Definition: TDavixFile.cxx:649
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via HTTP.
Definition: TDavixFile.cxx:612
void enableGridMode()
Enable the grid mode The grid Mode configure automatically all grid-CA path, VOMS authentication and ...
Definition: TDavixFile.cxx:709
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition: TDavixFile.cxx:585
TDavixFileInternal * d_ptr
Definition: TDavixFile.h:68
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:665
void eventStop(Double_t t, Long64_t len, bool read=true)
set TFile state info
Definition: TDavixFile.cxx:767
void setCACheck(Bool_t check)
Enable or disable certificate authority check.
Definition: TDavixFile.cxx:702
Double_t eventStart()
Definition: TDavixFile.cxx:757
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
ERelativeTo
Definition: TFile.h:184
@ kBeg
Definition: TFile.h:184
Basic string class.
Definition: TString.h:131
@ kUseGeneralPurpose
Use the recommended general-purpose setting; moderate read / write speed and compression ratio.
Definition: Compression.h:53