Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TDavixFile.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/net:$Id$
0002 // Author: Adrien Devresse and Tigran Mkrtchyan
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TDavixFile
0013 #define ROOT_TDavixFile
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TDavixFile                                                           //
0018 //                                                                      //
0019 // A TDavixFile is like a normal TFile except that it uses              //
0020 // libdavix to read/write remote files.                                 //
0021 // It supports HTTP and HTTPS in a number of dialects and options       //
0022 //  e.g. S3 is one of them                                              //
0023 // Other caracteristics come from the full support of Davix,            //
0024 //  e.g. full redirection support in any circumstance                   //
0025 //                                                                      //
0026 // Authors:     Adrien Devresse (CERN IT/SDC)                           //
0027 //              Tigran Mkrtchyan (DESY)                                 //
0028 //                                                                      //
0029 // Checks, refactoring and ROOT5 porting:                               //
0030 //              Fabrizio Furano (CERN IT/SDC)                           //
0031 //                                                                      //
0032 // September 2013                                                       //
0033 //                                                                      //
0034 //////////////////////////////////////////////////////////////////////////
0035 
0036 //
0037 // Parameters that influence the behavior of TDavixFile/TDavixSystem. The names should be self-explanatory
0038 //
0039 //Davix.Debug
0040 //Davix.GSI.UserProxy
0041 //Davix.GSI.UserCert
0042 //Davix.GSI.UserKey
0043 
0044 //Davix.GSI.CAdir
0045 //Davix.GSI.CACheck
0046 //Davix.GSI.GridMode
0047 //
0048 //Davix.S3.AccessKey
0049 //Davix.S3.SecretKey
0050 //Davix.S3.Region
0051 //Davix.S3.Token
0052 //
0053 // Environment variables:
0054 // X509_USER_CERT, X509_USER_KEY, X509_USER_PROXY ... usual meaning for the X509 Grid things. gEnv vars have higher priority.
0055 // S3_ACCESS_KEY, S3_SECRET_KEY, S3_REGION, S3_TOKEN. gEnv vars have higher priority.
0056 
0057 #include "TFile.h"
0058 
0059 class TDavixFileInternal;
0060 struct Davix_fd;
0061 
0062 namespace ROOT {
0063 namespace Experimental {
0064 class RLogChannel;
0065 }
0066 }
0067 
0068 ROOT::Experimental::RLogChannel &TDavixLogChannel();
0069 
0070 class TDavixFile : public TFile {
0071 private:
0072     TDavixFileInternal* d_ptr;
0073 
0074     void Init(Bool_t init);
0075     Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len);
0076     Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len);
0077     Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
0078     Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len);
0079     Int_t DavixStat(struct stat *st) const;
0080 
0081     // perfStats
0082     Double_t eventStart();
0083     void eventStop(Double_t t, Long64_t len, bool read = true);
0084 
0085 public:
0086     ///
0087     ///  Open function for TDavixFile
0088     ///
0089     /// TDavixFile supports several options :
0090     ///
0091     ///  - GRID_MODE=yes   : enable the grid authentication and CA support
0092     ///  - CA_CHECK=no     : remove all the certificate authority check, this option can create a security vulnerability
0093     ///  - S3SECKEY=string : Amazon S3 secret token
0094     ///  - S3ACCKEY=string : Amazon S3 access token
0095     ///  - S3REGION=string : Amazon S3 region. Optional, if provided, davix will use v4 signatures.
0096     ///  - S3TOKEN=string  : Amazon STS temporary credentials token.
0097     ///
0098     /// Several parameters can be used if separated with whitespace
0099 
0100    TDavixFile(const char* url, Option_t *option="", const char *ftitle="", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault);
0101 
0102    ~TDavixFile();
0103 
0104     // TFile interface.
0105     virtual Long64_t GetSize() const;
0106     virtual void  Seek(Long64_t offset, ERelativeTo pos = kBeg);
0107     virtual Bool_t ReadBuffer(char *buf, Int_t len);
0108     virtual Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len);
0109     virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf);
0110     virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len);
0111     virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength);
0112     virtual TString GetNewUrl();
0113 
0114     // TDavixFile options
0115     /// Enable or disable certificate authority check
0116     void setCACheck(Bool_t check);
0117 
0118     // Determine the value of the current token from the process's environment.
0119     // Follows the WLCG Bearer Token Discovery schema.
0120     // On error or no token discovered, returns the empty string.
0121     std::string DiscoverToken();
0122 
0123     /// Enable the grid mode
0124     /// The grid Mode configure automatically all grid-CA path, VOMS authentication
0125     /// and grid related extension for a grid analysis usage
0126     void enableGridMode();
0127 
0128     ClassDef(TDavixFile, 0)
0129 };
0130 
0131 #endif