56static const std::string
VERSION =
"0.2.0";
59" TDavixFile/" +
VERSION +
" davix/" + Davix::version();
62#define ENVPFX "Davix."
96 if(
strcmp(str,
"n") == 0 ||
strcmp(str,
"no") == 0 ||
strcmp(str,
"0") == 0 ||
strcmp(str,
"false") == 0)
return false;
97 if(
strcmp(str,
"y") == 0 ||
strcmp(str,
"yes") == 0 ||
strcmp(str,
"1") == 0 ||
strcmp(str,
"true") == 0)
return true;
147 static const std::string
whitespace =
" \t\f\n\v\r";
153 if (begin == std::string::npos) {
190 static const size_t max_size = 16384;
231 std::string
fname =
"/bt_u";
264 Info(
"TDavixFile_http_get_ucert",
"Found proxy in gEnv");
269 if (
getenv(
"X509_USER_PROXY")) {
271 Info(
"TDavixFile_http_get_ucert",
"Found proxy in X509_USER_PROXY");
282 Info(
"TDavixFile_http_get_ucert",
"Found proxy in /tmp");
292 Info(
"TDavixFile_http_get_ucert",
"Found cert and key in gEnv");
300 if (
getenv(
"X509_USER_CERT"))
302 if (
getenv(
"X509_USER_KEY"))
305 if ((
ucert.size() > 0) || (
ukey.size() > 0)) {
307 Info(
"TDavixFile_http_get_ucert",
"Found cert and key in gEnv");
316 Davix::X509Credential *
cert, Davix::DavixError **err)
324 Davix::DavixError::setupError(err,
"TDavixFile",
325 Davix::StatusCode::AuthentificationError,
326 "Could not set the user's proxy or certificate");
380 Error(
"DavixOpen",
"can not open file \"%s\" with davix: %s (%d)",
387 davixPosix->fadvise(fd, 0, 300, Davix::AdviseRandom);
399 Error(
"DavixClose",
"can not to close file with davix: %s (%d)",
412 Info(
"enableGridMode",
" grid mode enabled !");
415 env_var=
"/etc/grid-security/certificates/";
419 Info(
"enableGridMode",
"Adding CAdir %s",
env_var);
432template<
typename TRequestParams = Davix::RequestParams>
434 ->
decltype(parameters->setAwsRegion(
region), void())
436 if (
gDebug > 1)
Info(
"awsRegion",
"Setting S3 Region to '%s' - v4 signature will be used",
region);
437 parameters->setAwsRegion(
region);
440template<
typename TRequestParams = Davix::RequestParams>
442 Warning(
"setAwsRegion",
"Unable to set AWS region, not supported by this version of davix");
446template<
typename TRequestParams = Davix::RequestParams>
448 ->
decltype(parameters->setAwsToken(
token), void())
450 if (
gDebug > 1)
Info(
"awsToken",
"Setting S3 STS temporary credentials");
451 parameters->setAwsToken(
token);
454template<
typename TRequestParams = Davix::RequestParams>
456 Warning(
"awsToken",
"Unable to set AWS token, not supported by this version of davix");
460template<
typename TRequestParams = Davix::RequestParams>
462 ->
decltype(parameters->setAwsAlternate(
option), void())
464 if (
gDebug > 1)
Info(
"awsAlternate",
"Setting S3 path-based bucket option (s3alternate)");
465 parameters->setAwsAlternate(
option);
468template<
typename TRequestParams = Davix::RequestParams>
470 Warning(
"awsAlternate",
"Unable to set AWS path-based bucket option (s3alternate), not supported by this version of davix");
491 const std::string &
region,
const std::string &
token)
494 Info(
"setS3Auth",
" Aws S3 tokens configured");
497 davixParam->setProtocol(RequestProtocol::AwsS3);
509 davixParam->setTransparentRedirectionSupport(
true);
524 Info(
"parseConfig",
"Setting CAcheck to %s", ((
ca_check_local) ? (
"true") : (
"false")));
527 std::string prefix =
"Bearer ";
529 if (!
token.empty()) {
538 Info(
"parseConfig",
"Setting S3 SecretKey and AccessKey. Access Key : %s ",
env_var2);
571 while (std::getline(
ss, item,
' ')) {
623 davixParam->setMetalinkMode(Davix::MetalinkMode::Disable);
637 Error(
"DavixStat",
"can not stat the file with davix: %s (%d)",
650 :
TFile(
url,
strstr(opt,
"_WITHOUT_GLOBALREGISTRATION") != nullptr ?
"WEB_WITHOUT_GLOBALREGISTRATION" :
"WEB"),
687 if(!replicas.empty()) {
688 std::stringstream
ss;
689 for(
size_t i = 0; i < replicas.size(); i++) {
691 if(i != replicas.size()-1)
ss <<
"|";
714 Error(
"Seek",
"seeking from end in archive is not (yet) supported");
720 Info(
"Seek",
" move cursor to %lld"
739 Info(
"ReadBuffer",
"%lld bytes of data read sequentially"
740 " (%d requested)",
ret,
len);
758 Info(
"ReadBuffer",
"%lld bytes of data read from offset"
759 " %lld (%d requested)",
ret, pos,
len);
774 Info(
"ReadBufferAsync",
"%d bytes of data prefected from offset"
775 " %lld ",
len, offs);
792 Info(
"ReadBuffers",
"%lld bytes of data read from a list of %d buffers",
811 Info(
"WriteBuffer",
"%lld bytes of data write"
812 " %d requested",
ret,
len);
835 std::vector<void *>::iterator
f = std::find(
dirdVec.begin(),
dirdVec.end(), fd);
852 std::vector<void *>::iterator
f = std::find(
dirdVec.begin(),
dirdVec.end(), fd);
865 Info(
"GetSize",
"file size requested: %lld", (
Long64_t)
st.st_size);
909 Error(
"DavixReadBuffer",
"can not read data with davix: %s (%d)",
929 Error(
"DavixWriteBuffer",
"can not write data with davix: %s (%d)",
949 Error(
"DavixPReadBuffer",
"can not read data with davix: %s (%d)",
971 in[i].diov_buffer = &buf[
lastPos];
972 in[i].diov_offset = pos[i];
973 in[i].diov_size =
len[i];
979 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())
const char * s3_token_opt
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
ROOT::Experimental::RLogChannel & TDavixLogChannel()
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
ROOT::Experimental::RLogChannel & TDavixLogChannel()
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
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.
bool isno(const char *str)