55static const std::string
VERSION =
"0.2.0";
58" TDavixFile/" +
VERSION +
" davix/" + Davix::version();
61#define ENVPFX "Davix."
94 if (!str)
return false;
105 if(
strcmp(str,
"n") == 0 ||
strcmp(str,
"no") == 0 ||
strcmp(str,
"0") == 0 ||
strcmp(str,
"false") == 0)
return false;
106 if(
strcmp(str,
"y") == 0 ||
strcmp(str,
"yes") == 0 ||
strcmp(str,
"1") == 0 ||
strcmp(str,
"true") == 0)
return true;
156 static const std::string
whitespace =
" \t\f\n\v\r";
162 if (begin == std::string::npos) {
199 static const size_t max_size = 16384;
240 std::string
fname =
"/bt_u";
273 Info(
"TDavixFile_http_get_ucert",
"Found proxy in gEnv");
278 if (
getenv(
"X509_USER_PROXY")) {
280 Info(
"TDavixFile_http_get_ucert",
"Found proxy in X509_USER_PROXY");
291 Info(
"TDavixFile_http_get_ucert",
"Found proxy in /tmp");
301 Info(
"TDavixFile_http_get_ucert",
"Found cert and key in gEnv");
309 if (
getenv(
"X509_USER_CERT"))
311 if (
getenv(
"X509_USER_KEY"))
314 if ((
ucert.size() > 0) || (
ukey.size() > 0)) {
316 Info(
"TDavixFile_http_get_ucert",
"Found cert and key in gEnv");
325 Davix::X509Credential *
cert, Davix::DavixError **err)
333 Davix::DavixError::setupError(err,
"TDavixFile",
334 Davix::StatusCode::AuthentificationError,
335 "Could not set the user's proxy or certificate");
389 Error(
"DavixOpen",
"can not open file \"%s\" with davix: %s (%d)",
396 davixPosix->fadvise(fd, 0, 300, Davix::AdviseRandom);
408 Error(
"DavixClose",
"can not to close file with davix: %s (%d)",
421 Info(
"enableGridMode",
" grid mode enabled !");
424 env_var=
"/etc/grid-security/certificates/";
428 Info(
"enableGridMode",
"Adding CAdir %s",
env_var);
441template<
typename TRequestParams = Davix::RequestParams>
443 ->
decltype(parameters->setAwsRegion(
region), void())
445 if (
gDebug > 1)
Info(
"awsRegion",
"Setting S3 Region to '%s' - v4 signature will be used",
region);
446 parameters->setAwsRegion(
region);
449template<
typename TRequestParams = Davix::RequestParams>
451 Warning(
"setAwsRegion",
"Unable to set AWS region, not supported by this version of davix");
455template<
typename TRequestParams = Davix::RequestParams>
457 ->
decltype(parameters->setAwsToken(
token), void())
459 if (
gDebug > 1)
Info(
"awsToken",
"Setting S3 STS temporary credentials");
460 parameters->setAwsToken(
token);
463template<
typename TRequestParams = Davix::RequestParams>
465 Warning(
"awsToken",
"Unable to set AWS token, not supported by this version of davix");
469template<
typename TRequestParams = Davix::RequestParams>
471 ->
decltype(parameters->setAwsAlternate(
option), void())
473 if (
gDebug > 1)
Info(
"awsAlternate",
"Setting S3 path-based bucket option (s3alternate)");
474 parameters->setAwsAlternate(
option);
477template<
typename TRequestParams = Davix::RequestParams>
479 Warning(
"awsAlternate",
"Unable to set AWS path-based bucket option (s3alternate), not supported by this version of davix");
500 const std::string &
region,
const std::string &
token)
503 Info(
"setS3Auth",
" Aws S3 tokens configured");
506 davixParam->setProtocol(RequestProtocol::AwsS3);
518 davixParam->setTransparentRedirectionSupport(
true);
533 Info(
"parseConfig",
"Setting CAcheck to %s", ((
ca_check_local) ? (
"true") : (
"false")));
536 std::string prefix =
"Bearer ";
538 if (!
token.empty()) {
547 Info(
"parseConfig",
"Setting S3 SecretKey and AccessKey. Access Key : %s ",
env_var2);
580 while (std::getline(
ss, item,
' ')) {
632 davixParam->setMetalinkMode(Davix::MetalinkMode::Disable);
646 Error(
"DavixStat",
"can not stat the file with davix: %s (%d)",
659 :
TFile(
url,
strstr(opt,
"_WITHOUT_GLOBALREGISTRATION") != nullptr ?
"WEB_WITHOUT_GLOBALREGISTRATION" :
"WEB"),
696 if(!replicas.empty()) {
697 std::stringstream
ss;
698 for(
size_t i = 0; i < replicas.size(); i++) {
700 if(i != replicas.size()-1)
ss <<
"|";
723 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
729 Info(
"Seek",
" move cursor to %lld"
748 Info(
"ReadBuffer",
"%lld bytes of data read sequentially"
749 " (%d requested)",
ret,
len);
767 Info(
"ReadBuffer",
"%lld bytes of data read from offset"
768 " %lld (%d requested)",
ret, pos,
len);
783 Info(
"ReadBufferAsync",
"%d bytes of data prefected from offset"
801 Info(
"ReadBuffers",
"%lld bytes of data read from a list of %d buffers",
820 Info(
"WriteBuffer",
"%lld bytes of data write"
821 " %d requested",
ret,
len);
844 std::vector<void *>::iterator
f = std::find(
dirdVec.begin(),
dirdVec.end(), fd);
861 std::vector<void *>::iterator
f = std::find(
dirdVec.begin(),
dirdVec.end(), fd);
874 Info(
"GetSize",
"file size requested: %lld", (
Long64_t)
st.st_size);
918 Error(
"DavixReadBuffer",
"can not read data with davix: %s (%d)",
938 Error(
"DavixWriteBuffer",
"can not write data with davix: %s (%d)",
958 Error(
"DavixPReadBuffer",
"can not read data with davix: %s (%d)",
975 auto in = std::make_unique<DavIOVecInput[]>(
nbuf);
976 auto out = std::make_unique<DavIOVecOuput[]>(
nbuf);
980 in[i].diov_buffer = &buf[
lastPos];
981 in[i].diov_offset = pos[i];
982 in[i].diov_size =
len[i];
988 Error(
"DavixReadBuffers",
"can not read data with davix: %s (%d)",
#define R__LOG_ERROR(...)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
const char * s3_seckey_opt
bool normalizeToken(const std::string &input_token, std::string &output_token)
static const std::string VERSION
static void ConfigureDavixLogLevel()
static auto awsRegion(TRequestParams *parameters, const char *region) -> decltype(parameters->setAwsRegion(region), void())
bool findTokenInFile(const std::string &token_file, std::string &output_token)
static auto awsAlternate(TRequestParams *parameters, bool option) -> decltype(parameters->setAwsAlternate(option), void())
std::string DiscoverToken()
static int TDavixFile_http_authn_cert_X509(void *userdata, const Davix::SessionInfo &info, Davix::X509Credential *cert, Davix::DavixError **err)
const char * s3_alternate_opt
static auto awsToken(TRequestParams *parameters, const char *token) -> decltype(parameters->setAwsToken(token), void())
ROOT::RLogChannel & TDavixLogChannel()
const char * s3_token_opt
bool isno(const char *str)
const char * ca_check_opt
const char * open_mode_new
const char * open_mode_update
const char * open_mode_create
const char * s3_acckey_opt
static Context * davix_context_s
const char * grid_mode_opt
int configure_open_flag(const std::string &str, int old_flag)
static void TDavixFile_http_get_ucert(std::string &ucert, std::string &ukey)
static const std::string gUserAgent
bool strToBool(const char *str, bool defvalue)
const char * s3_region_opt
const char * open_mode_read
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
A log configuration for a channel, e.g.
const_iterator begin() const
const_iterator end() const
Davix::RequestParams * davixParam
std::vector< void * > dirdVec
void setAwsToken(const std::string &token)
void setS3Auth(const std::string &secret, const std::string &access, const std::string ®ion, const std::string &token)
void setAwsAlternate(const bool &option)
static Davix::Context * getDavixInstance()
Davix::DavPosix * davixPosix
void parseParams(Option_t *option)
intput params
std::vector< std::string > getReplicas()
Int_t DavixStat(const char *url, struct stat *st)
Davix_fd * getDavixFileInstance()
Davix::Context * davixContext
void setAwsRegion(const std::string ®ion)
std::vector< std::string > replicas
void removeDird(void *fd)
virtual Long64_t GetSize() const
Returns the current file size.
void Init(Bool_t init)
Initialize a TFile object.
Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len)
Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len)
virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength)
Write a buffer to the file.
virtual TString GetNewUrl()
Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len)
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via HTTP.
TDavixFile(const char *url, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Open function for TDavixFile.
void enableGridMode()
Enable the grid mode The grid Mode configure automatically all grid-CA path, VOMS authentication and ...
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
TDavixFileInternal * d_ptr
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.
void eventStop(Double_t t, Long64_t len, bool read=true)
set TFile state info
void setCACheck(Bool_t check)
Enable or disable certificate authority check.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
static void SetFileBytesWritten(Long64_t bytes=0)
Long64_t fBytesRead
Number of bytes read from this file.
static Long64_t GetFileBytesWritten()
Static function returning the total number of bytes written to all files.
static void SetFileBytesRead(Long64_t bytes=0)
static void SetFileReadCalls(Int_t readcalls=0)
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Long64_t fArchiveOffset
!Offset at which file starts in archive
virtual void Init(Bool_t create)
Initialize a TFile object.
Long64_t fBytesWrite
Number of bytes written to this file.
Long64_t fOffset
!Seek offset cache
Long64_t fEND
Last used byte in file.
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
The TTimeStamp encapsulates seconds and ns since EPOCH.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.