ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TDavixFile.cxx
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 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TDavixFile //
15 // //
16 // A TDavixFile is like a normal TFile except that it uses //
17 // libdavix to read/write remote files. //
18 // It supports HTTP and HTTPS in a number of dialects and options //
19 // e.g. S3 is one of them //
20 // Other caracteristics come from the full support of Davix, //
21 // e.g. full redirection support in any circumstance //
22 // //
23 // Authors: Adrien Devresse (CERN IT/SDC) //
24 // Tigran Mkrtchyan (DESY) //
25 // //
26 // Checks and ROOT5 porting: //
27 // Fabrizio Furano (CERN IT/SDC) //
28 // //
29 // September 2013 //
30 // //
31 //////////////////////////////////////////////////////////////////////////
32 
33 
34 #include "TDavixFile.h"
35 #include "TROOT.h"
36 #include "TSocket.h"
37 #include "Bytes.h"
38 #include "TError.h"
39 #include "TSystem.h"
40 #include "TEnv.h"
41 #include "TBase64.h"
42 #include "TVirtualPerfStats.h"
43 #include "TDavixFileInternal.h"
44 #include "TSocket.h"
45 
46 #include <errno.h>
47 #include <stdlib.h>
48 #include <unistd.h>
49 #include <fcntl.h>
50 #include <davix.hpp>
51 #include <sstream>
52 #include <string>
53 #include <cstring>
54 
55 
56 static const std::string VERSION = "0.2.0";
57 
58 static const std::string gUserAgent = "ROOT/" + std::string(gROOT->GetVersion()) +
59 " TDavixFile/" + VERSION + " davix/" + Davix::version();
60 
61 // The prefix that is used to find the variables in the gEnv
62 #define ENVPFX "Davix."
63 
65 
66 using namespace Davix;
67 
68 const char* grid_mode_opt = "grid_mode=yes";
69 const char* ca_check_opt = "ca_check=no";
70 const char* s3_seckey_opt = "s3seckey=";
71 const char* s3_acckey_opt = "s3acckey=";
72 const char* open_mode_read = "READ";
73 const char* open_mode_create = "CREATE";
74 const char* open_mode_new = "NEW";
75 const char* open_mode_update = "UPDATE";
76 
79 
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 
83 bool isno(const char *str)
84 {
85  if (!str) return false;
86 
87  if (!strcmp(str, "n") || !strcmp(str, "no") || !strcmp(str, "0") || !strcmp(str, "false")) return true;
88 
89  return false;
90 
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 
95 int configure_open_flag(const std::string &str, int old_flag)
96 {
97  if (strcasecmp(str.c_str(), open_mode_read) == 0)
98  old_flag |= O_RDONLY;
99  if ((strcasecmp(str.c_str(), open_mode_create) == 0)
100  || (strcasecmp(str.c_str(), open_mode_new) == 0)) {
101  old_flag |= (O_CREAT | O_WRONLY | O_TRUNC);
102  }
103  if ((strcasecmp(str.c_str(), open_mode_update) == 0)) {
104  old_flag |= (O_RDWR);
105  }
106  return old_flag;
107 }
108 
109 ////////////////////////////////////////////////////////////////////////////////
110 
112 {
113  Int_t log_level = (gEnv) ? gEnv->GetValue("Davix.Debug", 0) : 0;
114 
115  switch (log_level) {
116  case 0:
117  davix_set_log_level(0);
118  break;
119  case 1:
120  davix_set_log_level(DAVIX_LOG_WARNING);
121  break;
122  case 2:
123  davix_set_log_level(DAVIX_LOG_VERBOSE);
124  break;
125  case 3:
126  davix_set_log_level(DAVIX_LOG_DEBUG);
127  break;
128  default:
129  davix_set_log_level(DAVIX_LOG_ALL);
130  break;
131  }
132 }
133 
134 ///////////////////////////////////////////////////////////////////
135 // Authn implementation, Locate and get VOMS cred if exist
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 
139 static void TDavixFile_http_get_ucert(std::string &ucert, std::string &ukey)
140 {
141  char default_proxy[64];
142  const char *genvvar = 0, *genvvar1 = 0;
143  // The gEnv has higher priority, let's look for a proxy cert
144  genvvar = gEnv->GetValue("Davix.GSI.UserProxy", (const char *) NULL);
145  if (genvvar) {
146  ucert = ukey = genvvar;
147  if (gDebug > 0)
148  Info("TDavixFile_http_get_ucert", "Found proxy in gEnv");
149  return;
150  }
151 
152  // Try explicit environment for proxy
153  if (getenv("X509_USER_PROXY")) {
154  if (gDebug > 0)
155  Info("TDavixFile_http_get_ucert", "Found proxy in X509_USER_PROXY");
156  ucert = ukey = getenv("X509_USER_PROXY");
157  return;
158  }
159 
160  // Try with default location
161  snprintf(default_proxy, sizeof(default_proxy), "/tmp/x509up_u%d",
162  geteuid());
163 
164  if (access(default_proxy, R_OK) == 0) {
165  if (gDebug > 0)
166  Info("TDavixFile_http_get_ucert", "Found proxy in /tmp");
167  ucert = ukey = default_proxy;
168  return;
169  }
170 
171  // It seems we got no proxy, let's try to gather the keys
172  genvvar = gEnv->GetValue("Davix.GSI.UserCert", (const char *) NULL);
173  genvvar1 = gEnv->GetValue("Davix.GSI.UserKey", (const char *) NULL);
174  if (genvvar || genvvar1) {
175  if (gDebug > 0)
176  Info("TDavixFile_http_get_ucert", "Found cert and key in gEnv");
177 
178  ucert = genvvar;
179  ukey = genvvar1;
180  return;
181  }
182 
183  // try with X509_* environment
184  if (getenv("X509_USER_CERT"))
185  ucert = getenv("X509_USER_CERT");
186  if (getenv("X509_USER_KEY"))
187  ukey = getenv("X509_USER_KEY");
188 
189  if ((ucert.size() > 0) || (ukey.size() > 0)) {
190  if (gDebug > 0)
191  Info("TDavixFile_http_get_ucert", "Found cert and key in gEnv");
192  }
193  return;
194 
195 }
196 
197 ////////////////////////////////////////////////////////////////////////////////
198 
199 static int TDavixFile_http_authn_cert_X509(void *userdata, const Davix::SessionInfo &info,
200  Davix::X509Credential *cert, Davix::DavixError **err)
201 {
202  (void) userdata; // keep quiete compilation warnings
203  (void) info;
204  std::string ucert, ukey;
205  TDavixFile_http_get_ucert(ucert, ukey);
206 
207  if (ucert.empty() || ukey.empty()) {
208  Davix::DavixError::setupError(err, "TDavixFile",
209  Davix::StatusCode::AuthentificationError,
210  "Could not set the user's proxy or certificate");
211  return -1;
212  }
213  return cert->loadFromFilePEM(ukey, ucert, "", err);
214 }
215 /////////////////////////////////////////////////////////////////////////////////////////////
216 
217 ////////////////////////////////////////////////////////////////////////////////
218 
220 {
221  delete davixPosix;
222  delete davixParam;
223 }
224 
225 ////////////////////////////////////////////////////////////////////////////////
226 
228 {
229  if (davix_context_s == NULL) {
230  TLockGuard guard(&createLock);
231  if (davix_context_s == NULL) {
232  davix_context_s = new Context();
233  }
234  }
235  return davix_context_s;
236 }
237 
238 ////////////////////////////////////////////////////////////////////////////////
239 
241 {
242  DavixError *davixErr = NULL;
243  Davix_fd *fd = davixPosix->open(davixParam, fUrl.GetUrl(), oflags, &davixErr);
244  if (fd == NULL) {
245  Error("DavixOpen", "can not open file with davix: %s (%d)",
246  davixErr->getErrMsg().c_str(), davixErr->getStatus());
247  DavixError::clearError(&davixErr);
248  } else {
249  // setup ROOT style read
250  davixPosix->fadvise(fd, 0, 300, Davix::AdviseRandom);
251  }
252 
253  return fd;
254 }
255 
256 ////////////////////////////////////////////////////////////////////////////////
257 
259 {
260  DavixError *davixErr = NULL;
261  if (davixFd != NULL && davixPosix->close(davixFd, &davixErr)) {
262  Error("DavixClose", "can not to close file with davix: %s (%d)",
263  davixErr->getErrMsg().c_str(), davixErr->getStatus());
264  DavixError::clearError(&davixErr);
265  }
266 }
267 
268 ////////////////////////////////////////////////////////////////////////////////
269 
271 {
272  const char *env_var = NULL;
273 
274  if (gDebug > 1)
275  Info("enableGridMode", " grid mode enabled !");
276 
277  if( ( env_var = getenv("X509_CERT_DIR")) == NULL){
278  env_var= "/etc/grid-security/certificates/";
279  }
280  davixParam->addCertificateAuthorityPath(env_var);
281  if (gDebug > 0)
282  Info("enableGridMode", "Adding CAdir %s", env_var);
283 }
284 
285 ////////////////////////////////////////////////////////////////////////////////
286 
287 void TDavixFileInternal::setS3Auth(const std::string &key, const std::string &token)
288 {
289  if (gDebug > 1)
290  Info("setS3Auth", " Aws S3 tokens configured");
291  davixParam->setAwsAuthorizationKeys(key, token);
292  davixParam->setProtocol(RequestProtocol::AwsS3);
293 }
294 
295 ////////////////////////////////////////////////////////////////////////////////
296 
298 {
299  const char *env_var = NULL, *env_var2 = NULL;
300  // default opts
301  davixParam->setTransparentRedirectionSupport(true);
302  davixParam->setClientCertCallbackX509(&TDavixFile_http_authn_cert_X509, NULL);
303 
304  // setup CADIR
305  env_var = gEnv->GetValue("Davix.GSI.CAdir", (const char *) NULL);
306  if (env_var) {
307  davixParam->addCertificateAuthorityPath(env_var);
308  if (gDebug > 0)
309  Info("parseConfig", "Add CAdir: %s", env_var);
310  }
311  // CA Check
312  bool ca_check_local = !isno(gEnv->GetValue("Davix.GSI.CACheck", (const char *)"y"));
313  davixParam->setSSLCAcheck(ca_check_local);
314  if (gDebug > 0)
315  Info("parseConfig", "Setting CAcheck to %s", ((ca_check_local) ? ("true") : ("false")));
316 
317  // S3 Auth
318  if (((env_var = gEnv->GetValue("Davix.S3.SecretKey", getenv("S3_SECRET_KEY"))) != NULL)
319  && ((env_var2 = gEnv->GetValue("Davix.S3.AccessKey", getenv("S3_ACCESS_KEY"))) != NULL)) {
320  Info("parseConfig", "Setting S3 SecretKey and AccessKey. Access Key : %s ", env_var2);
321  davixParam->setAwsAuthorizationKeys(env_var, env_var2);
322  }
323 
324  env_var = gEnv->GetValue("Davix.GSI.GridMode", (const char *)"y");
325  if (!isno(env_var))
326  enableGridMode();
327 }
328 
329 ////////////////////////////////////////////////////////////////////////////////
330 /// intput params
331 
333 {
334  std::stringstream ss(option);
335  std::string item;
336  std::vector<std::string> parsed_options;
337  // parameters
338  std::string s3seckey, s3acckey;
339 
340  while (std::getline(ss, item, ' ')) {
341  parsed_options.push_back(item);
342  }
343 
344  for (std::vector<std::string>::iterator it = parsed_options.begin(); it < parsed_options.end(); ++it) {
345  // grid mode option
346  if ((strcasecmp(it->c_str(), grid_mode_opt)) == 0) {
347  enableGridMode();
348  }
349  // ca check option
350  if ((strcasecmp(it->c_str(), ca_check_opt)) == 0) {
351  davixParam->setSSLCAcheck(false);
352  }
353  // s3 sec key
354  if (strncasecmp(it->c_str(), s3_seckey_opt, strlen(s3_seckey_opt)) == 0) {
355  s3seckey = std::string(it->c_str() + strlen(s3_seckey_opt));
356  }
357  // s3 access key
358  if (strncasecmp(it->c_str(), s3_acckey_opt, strlen(s3_acckey_opt)) == 0) {
359  s3acckey = std::string(it->c_str() + strlen(s3_acckey_opt));
360  }
361  // open mods
363  }
364 
365  if (s3seckey.size() > 0) {
366  setS3Auth(s3seckey, s3acckey);
367  }
368 
369  if (oflags == 0) // default open mode
370  oflags = O_RDONLY;
371 }
372 
373 ////////////////////////////////////////////////////////////////////////////////
374 
376 {
377  davixPosix = new DavPosix(davixContext);
378  davixParam = new RequestParams();
379  davixParam->setUserAgent(gUserAgent);
381  parseConfig();
382  parseParams(opt);
383 }
384 
385 ////////////////////////////////////////////////////////////////////////////////
386 
387 Int_t TDavixFileInternal::DavixStat(const char *url, struct stat *st)
388 {
389  DavixError *davixErr = NULL;
390 
391  if (davixPosix->stat(davixParam, url, st, &davixErr) < 0) {
392 
393  Error("DavixStat", "can not stat the file with davix: %s (%d)",
394  davixErr->getErrMsg().c_str(), davixErr->getStatus());
395  DavixError::clearError(&davixErr);
396  return 0;
397  }
398  return 1;
399 }
400 
401 /////////////////////////////////////////////////////////////////////////////////////////////
402 
403 ////////////////////////////////////////////////////////////////////////////////
404 
405 TDavixFile::TDavixFile(const char *url, Option_t *opt, const char *ftitle, Int_t compress) : TFile(url, "WEB"),
406  d_ptr(new TDavixFileInternal(fUrl, opt))
407 {
408  (void) ftitle;
409  (void) compress;
410  Init(kFALSE);
411 }
412 
413 ////////////////////////////////////////////////////////////////////////////////
414 
416 {
417  d_ptr->Close();
418  delete d_ptr;
419 }
420 
421 ////////////////////////////////////////////////////////////////////////////////
422 
424 {
425  (void) init;
426  //initialize davix
427  d_ptr->init();
428  // pre-open file
429  if ((d_ptr->getDavixFileInstance()) == NULL){
430  MakeZombie();
431  gDirectory = gROOT;
432  return;
433  }
435  fOffset = 0;
436  fD = -2; // so TFile::IsOpen() will return true when in TFile::~TFi */
437 }
438 
439 ////////////////////////////////////////////////////////////////////////////////
440 /// Set position from where to start reading.
441 
443 {
444  TLockGuard guard(&(d_ptr->positionLock));
445  switch (pos) {
446  case kBeg:
447  fOffset = offset + fArchiveOffset;
448  break;
449  case kCur:
450  fOffset += offset;
451  break;
452  case kEnd:
453  // this option is not used currently in the ROOT code
454  if (fArchiveOffset)
455  Error("Seek", "seeking from end in archive is not (yet) supported");
456  fOffset = fEND - offset; // is fEND really EOF or logical EOF?
457  break;
458  }
459 
460  if (gDebug > 1)
461  Info("Seek", " move cursor to %lld"
462  , fOffset);
463 }
464 
465 ////////////////////////////////////////////////////////////////////////////////
466 /// Read specified byte range from remote file via HTTP.
467 /// Returns kTRUE in case of error.
468 
470 {
471  TLockGuard guard(&(d_ptr->positionLock));
472  Davix_fd *fd;
473  if ((fd = d_ptr->getDavixFileInstance()) == NULL)
474  return kTRUE;
475  Long64_t ret = DavixReadBuffer(fd, buf, len);
476  if (ret < 0)
477  return kTRUE;
478 
479  if (gDebug > 1)
480  Info("ReadBuffer", "%lld bytes of data read sequentially"
481  " (%d requested)", ret, len);
482 
483  return kFALSE;
484 }
485 
486 ////////////////////////////////////////////////////////////////////////////////
487 
489 {
490  Davix_fd *fd;
491  if ((fd = d_ptr->getDavixFileInstance()) == NULL)
492  return kTRUE;
493 
494  Long64_t ret = DavixPReadBuffer(fd, buf, pos, len);
495  if (ret < 0)
496  return kTRUE;
497 
498  if (gDebug > 1)
499  Info("ReadBuffer", "%lld bytes of data read from offset"
500  " %lld (%d requested)", ret, pos, len);
501  return kFALSE;
502 }
503 
504 ////////////////////////////////////////////////////////////////////////////////
505 
507 {
508  Davix_fd *fd;
509  if ((fd = d_ptr->getDavixFileInstance()) == NULL)
510  return kFALSE;
511 
512  d_ptr->davixPosix->fadvise(fd, static_cast<dav_off_t>(offs), static_cast<dav_size_t>(len), Davix::AdviseRandom);
513 
514  if (gDebug > 1)
515  Info("ReadBufferAsync", "%d bytes of data prefected from offset"
516  " %lld ", len, offs);
517  return kFALSE;
518 }
519 
520 ////////////////////////////////////////////////////////////////////////////////
521 
522 Bool_t TDavixFile::ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
523 {
524  Davix_fd *fd;
525  if ((fd = d_ptr->getDavixFileInstance()) == NULL)
526  return kTRUE;
527 
528  Long64_t ret = DavixReadBuffers(fd, buf, pos, len, nbuf);
529  if (ret < 0)
530  return kTRUE;
531 
532  if (gDebug > 1)
533  Info("ReadBuffers", "%lld bytes of data read from a list of %d buffers",
534  ret, nbuf);
535 
536  return kFALSE;
537 }
538 
539 ////////////////////////////////////////////////////////////////////////////////
540 
541 Bool_t TDavixFile::WriteBuffer(const char *buf, Int_t len)
542 {
543  Davix_fd *fd;
544  if ((fd = d_ptr->getDavixFileInstance()) == NULL)
545  return kTRUE;
546 
547  Long64_t ret = DavixWriteBuffer(fd, buf, len);
548  if (ret < 0)
549  return kTRUE;
550 
551  if (gDebug > 1)
552  Info("WriteBuffer", "%lld bytes of data write"
553  " %d requested", ret, len);
554  return kFALSE;
555 }
556 
557 ////////////////////////////////////////////////////////////////////////////////
558 
560 {
561  d_ptr->davixParam->setSSLCAcheck((bool)check);
562 }
563 
564 ////////////////////////////////////////////////////////////////////////////////
565 
567 {
569 }
570 
571 ////////////////////////////////////////////////////////////////////////////////
572 
574 {
575  TLockGuard l(&(openLock));
576  std::vector<void *>::iterator f = std::find(dirdVec.begin(), dirdVec.end(), fd);
577  return (f != dirdVec.end());
578 }
579 
580 ////////////////////////////////////////////////////////////////////////////////
581 
583 {
584  TLockGuard l(&(openLock));
585  dirdVec.push_back(fd);
586 }
587 
588 ////////////////////////////////////////////////////////////////////////////////
589 
591 {
592  TLockGuard l(&(openLock));
593  std::vector<void *>::iterator f = std::find(dirdVec.begin(), dirdVec.end(), fd);
594  if (f != dirdVec.end())
595  dirdVec.erase(f);
596 }
597 
598 ////////////////////////////////////////////////////////////////////////////////
599 
601 {
602  struct stat st;
603  Int_t ret = d_ptr->DavixStat(fUrl.GetUrl(), &st);
604  if (ret) {
605  if (gDebug > 1)
606  Info("GetSize", "file size requested: %lld", (Long64_t)st.st_size);
607  return st.st_size;
608  }
609  return -1;
610 }
611 
612 ////////////////////////////////////////////////////////////////////////////////
613 
615 {
616  if (gPerfStats)
617  return TTimeStamp();
618  return 0;
619 }
620 
621 ////////////////////////////////////////////////////////////////////////////////
622 /// set TFile state info
623 
625 {
626  fBytesRead += len;
627  fReadCalls += 1;
628 
629  if (gPerfStats)
630  gPerfStats->FileReadEvent(this, (Int_t) len, t_start);
631 }
632 
633 ////////////////////////////////////////////////////////////////////////////////
634 
635 Long64_t TDavixFile::DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len)
636 {
637  DavixError *davixErr = NULL;
638  Double_t start_time = eventStart();
639 
640  Long64_t ret = d_ptr->davixPosix->pread(fd, buf, len, fOffset, &davixErr);
641  if (ret < 0) {
642  Error("DavixReadBuffer", "can not read data with davix: %s (%d)",
643  davixErr->getErrMsg().c_str(), davixErr->getStatus());
644  DavixError::clearError(&davixErr);
645  } else {
646  fOffset += ret;
647  eventStop(start_time, ret);
648  }
649 
650  return ret;
651 }
652 
653 ////////////////////////////////////////////////////////////////////////////////
654 
655 Long64_t TDavixFile::DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len)
656 {
657  DavixError *davixErr = NULL;
658  Double_t start_time = eventStart();
659 
660  Long64_t ret = d_ptr->davixPosix->pwrite(fd, buf, len, fOffset, &davixErr);
661  if (ret < 0) {
662  Error("DavixWriteBuffer", "can not write data with davix: %s (%d)",
663  davixErr->getErrMsg().c_str(), davixErr->getStatus());
664  DavixError::clearError(&davixErr);
665  } else {
666  fOffset += ret;
667  eventStop(start_time, ret);
668  }
669 
670  return ret;
671 }
672 
673 ////////////////////////////////////////////////////////////////////////////////
674 
675 Long64_t TDavixFile::DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len)
676 {
677  DavixError *davixErr = NULL;
678  Double_t start_time = eventStart();
679 
680  Long64_t ret = d_ptr->davixPosix->pread(fd, buf, len, pos, &davixErr);
681  if (ret < 0) {
682  Error("DavixPReadBuffer", "can not read data with davix: %s (%d)",
683  davixErr->getErrMsg().c_str(), davixErr->getStatus());
684  DavixError::clearError(&davixErr);
685  } else {
686  eventStop(start_time, ret);
687  }
688 
689 
690  return ret;
691 }
692 
693 ////////////////////////////////////////////////////////////////////////////////
694 
695 Long64_t TDavixFile::DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
696 {
697  DavixError *davixErr = NULL;
698  Double_t start_time = eventStart();
699  DavIOVecInput in[nbuf];
700  DavIOVecOuput out[nbuf];
701 
702  int lastPos = 0;
703  for (Int_t i = 0; i < nbuf; ++i) {
704  in[i].diov_buffer = &buf[lastPos];
705  in[i].diov_offset = pos[i];
706  in[i].diov_size = len[i];
707  lastPos += len[i];
708  }
709 
710  Long64_t ret = d_ptr->davixPosix->preadVec(fd, in, out, nbuf, &davixErr);
711  if (ret < 0) {
712  Error("DavixReadBuffers", "can not read data with davix: %s (%d)",
713  davixErr->getErrMsg().c_str(), davixErr->getStatus());
714  DavixError::clearError(&davixErr);
715  } else {
716  eventStop(start_time, ret);
717  }
718 
719  return ret;
720 }
721 
static void ConfigureDavixLogLevel()
Definition: TDavixFile.cxx:111
Definition: TMutex.h:34
TServerSocket * ss
Definition: hserv2.C:30
static const std::string gUserAgent
Definition: TDavixFile.cxx:58
const char * s3_seckey_opt
Definition: TDavixFile.cxx:70
long long Long64_t
Definition: RtypesCore.h:69
const char * open_mode_read
Definition: TDavixFile.cxx:72
const char * open_mode_update
Definition: TDavixFile.cxx:75
void Init(Bool_t init)
Initialize a TFile object.
Definition: TDavixFile.cxx:423
const char Option_t
Definition: RtypesCore.h:62
static void TDavixFile_http_get_ucert(std::string &ucert, std::string &ukey)
Definition: TDavixFile.cxx:139
tuple offset
Definition: tree.py:93
void setS3Auth(const std::string &key, const std::string &token)
Definition: TDavixFile.cxx:287
Davix::RequestParams * davixParam
Small helper to keep current directory context.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
Davix_fd * Open()
Definition: TDavixFile.cxx:240
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via HTTP.
Definition: TDavixFile.cxx:469
#define gROOT
Definition: TROOT.h:344
void addDird(void *fd)
Definition: TDavixFile.cxx:582
Double_t eventStart()
Definition: TDavixFile.cxx:614
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TDavixFileInternal * d_ptr
Definition: TDavixFile.h:62
const Bool_t kFALSE
Definition: Rtypes.h:92
Long64_t DavixReadBuffer(Davix_fd *fd, char *buf, Int_t len)
Definition: TDavixFile.cxx:635
ERelativeTo
Definition: TFile.h:160
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition: TFile.h:76
virtual Bool_t WriteBuffer(const char *buffer, Int_t bufferLength)
Write a buffer to the file.
Definition: TDavixFile.cxx:541
void eventStop(Double_t t, Long64_t len)
set TFile state info
Definition: TDavixFile.cxx:624
Davix_fd * getDavixFileInstance()
TFile * f
const char * open_mode_create
Definition: TDavixFile.cxx:73
Long64_t DavixReadBuffers(Davix_fd *fd, char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Definition: TDavixFile.cxx:695
TUrl fUrl
!URL of file
Definition: TFile.h:97
Int_t fD
File descriptor.
Definition: TFile.h:69
Davix::DavPosix * davixPosix
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition: TDavixFile.cxx:442
virtual Long64_t GetSize() const
Returns the current file size.
Definition: TDavixFile.cxx:600
void Info(const char *location, const char *msgfmt,...)
static TMutex createLock
Definition: TDavixFile.cxx:77
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
void Error(const char *location, const char *msgfmt,...)
Int_t DavixStat(const char *url, struct stat *st)
Definition: TDavixFile.cxx:387
char * out
Definition: TBase64.cxx:29
ClassImp(TDavixFile) using namespace Davix
static Context * davix_context_s
Definition: TDavixFile.cxx:78
Long64_t DavixWriteBuffer(Davix_fd *fd, const char *buf, Int_t len)
Definition: TDavixFile.cxx:655
Long64_t fEND
Last used byte in file.
Definition: TFile.h:66
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Definition: TDavixFile.cxx:506
static Davix::Context * getDavixInstance()
Definition: TDavixFile.cxx:227
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:494
void removeDird(void *fd)
Definition: TDavixFile.cxx:590
bool isMyDird(void *fd)
Definition: TDavixFile.cxx:573
TLine * l
Definition: textangle.C:4
bool isno(const char *str)
Definition: TDavixFile.cxx:83
virtual void Init(Bool_t create)
Initialize a TFile object.
Definition: TFile.cxx:581
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:522
#define gPerfStats
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:385
std::vector< void * > dirdVec
const char * grid_mode_opt
Definition: TDavixFile.cxx:68
static const std::string VERSION
Definition: TDavixFile.cxx:56
static Int_t init()
double Double_t
Definition: RtypesCore.h:55
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
The TTimeStamp encapsulates seconds and ns since EPOCH.
Definition: TTimeStamp.h:76
const char * s3_acckey_opt
Definition: TDavixFile.cxx:71
int configure_open_flag(const std::string &str, int old_flag)
Definition: TDavixFile.cxx:95
void enableGridMode()
Enable the grid mode The grid Mode configure automatically all grid-CA path, VOMS authentication and ...
Definition: TDavixFile.cxx:566
typedef void((*Func_t)())
const char * ca_check_opt
Definition: TDavixFile.cxx:69
void MakeZombie()
Definition: TObject.h:68
#define NULL
Definition: Rtypes.h:82
static int TDavixFile_http_authn_cert_X509(void *userdata, const Davix::SessionInfo &info, Davix::X509Credential *cert, Davix::DavixError **err)
Definition: TDavixFile.cxx:199
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
Long64_t fArchiveOffset
!Offset at which file starts in archive
Definition: TFile.h:88
#define gDirectory
Definition: TDirectory.h:221
TDavixFile(const char *url, Option_t *option="", const char *ftitle="", Int_t compress=1)
Open function for TDavixFile.
Definition: TDavixFile.cxx:405
Long64_t fOffset
!Seek offset cache
Definition: TFile.h:83
const Bool_t kTRUE
Definition: Rtypes.h:91
Long64_t DavixPReadBuffer(Davix_fd *fd, char *buf, Long64_t pos, Int_t len)
Definition: TDavixFile.cxx:675
void setCACheck(Bool_t check)
Enable or disable certificate authority check.
Definition: TDavixFile.cxx:559
void parseParams(Option_t *option)
intput params
Definition: TDavixFile.cxx:332
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:63
Davix::Context * davixContext
const char * open_mode_new
Definition: TDavixFile.cxx:74