Logo ROOT  
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
60struct Davix_fd;
61
62class TDavixFile : public TFile {
63private:
65
66 void Init(Bool_t init);
67 Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len);
68 Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len);
69 Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
70 Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len);
71 Int_t DavixStat(struct stat *st) const;
72
73 // perfStats
75 void eventStop(Double_t t, Long64_t len, bool read = true);
76
77public:
78 ///
79 /// Open function for TDavixFile
80 ///
81 /// TDavixFile supports several options :
82 ///
83 /// - GRID_MODE=yes : enable the grid authentication and CA support
84 /// - CA_CHECK=no : remove all the certificate authority check, this option can create a security vulnerability
85 /// - S3_SECKEY=string : Amazon S3 secret token
86 /// - S3_ACCKEY=string : Amazon S3 access token
87 /// - S3_REGION=string : Amazon S3 region. Optional, if provided, davix will use v4 signatures.
88 /// - S3_TOKEN=string : Amazon STS temporary credentials token.
89 ///
90 /// Several parameters can be used if separated with whitespace
91
92 TDavixFile(const char* url, Option_t *option="", const char *ftitle="", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault);
93
95
96 // TFile interface.
97 virtual Long64_t GetSize() const;
98 virtual void Seek(Long64_t offset, ERelativeTo pos = kBeg);
99 virtual Bool_t ReadBuffer(char *buf, Int_t len);
100 virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
101 virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
102 virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
103 virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength);
104 virtual TString GetNewUrl();
105
106 // TDavixFile options
107 /// Enable or disable certificate authority check
108 void setCACheck(Bool_t check);
109
110 /// Enable the grid mode
111 /// The grid Mode configure automatically all grid-CA path, VOMS authentication
112 /// and grid related extension for a grid analysis usage
113 void enableGridMode();
114
116};
117
118#endif
double Double_t
Definition: RtypesCore.h:57
long long Long64_t
Definition: RtypesCore.h:71
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
virtual Long64_t GetSize() const
Returns the current file size.
Definition: TDavixFile.cxx:742
void Init(Bool_t init)
Initialize a TFile object.
Definition: TDavixFile.cxx:551
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:845
Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len)
Definition: TDavixFile.cxx:785
Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len)
Definition: TDavixFile.cxx:825
virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength)
Write a buffer to the file.
Definition: TDavixFile.cxx:683
virtual TString GetNewUrl()
Definition: TDavixFile.cxx:567
Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len)
Definition: TDavixFile.cxx:805
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Definition: TDavixFile.cxx:648
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via HTTP.
Definition: TDavixFile.cxx:611
TDavixFile(const char *url, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Open function for TDavixFile.
Definition: TDavixFile.cxx:533
void enableGridMode()
Enable the grid mode The grid Mode configure automatically all grid-CA path, VOMS authentication and ...
Definition: TDavixFile.cxx:708
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition: TDavixFile.cxx:584
TDavixFileInternal * d_ptr
Definition: TDavixFile.h:64
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:664
void eventStop(Double_t t, Long64_t len, bool read=true)
set TFile state info
Definition: TDavixFile.cxx:766
void setCACheck(Bool_t check)
Enable or disable certificate authority check.
Definition: TDavixFile.cxx:701
Double_t eventStart()
Definition: TDavixFile.cxx:756
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:53
ERelativeTo
Definition: TFile.h:190
@ kBeg
Definition: TFile.h:190
Basic string class.
Definition: TString.h:131
EvaluateInfo init(std::vector< RooRealProxy > parameters, std::vector< ArrayWrapper * > wrappers, std::vector< double * > arrays, size_t begin, size_t batchSize)
@ kUseCompiledDefault
Use the compile-time default setting.
Definition: Compression.h:50