ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TDCacheFile.cxx
Go to the documentation of this file.
1 // @(#)root/dcache:$Id$
2 // Author: Grzegorz Mazur 20/01/2002
3 // Modified: William Tanenbaum 01/12/2003
4 // Modified: Tigran Mkrtchyan 29/06/2004
5 // Modified: Tigran Mkrtchyan 06/07/2007
6 
7 /*************************************************************************
8  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
9  * All rights reserved. *
10  * *
11  * For the licensing terms see $ROOTSYS/LICENSE. *
12  * For the list of contributors see $ROOTSYS/README/CREDITS. *
13  *************************************************************************/
14 
15 /**
16 \class TDCacheFile
17 \ingroup IO
18 A TDCacheFile is like a normal TFile except that it may read and
19 write its data via a dCache server (for more on the dCache daemon
20 see http://www-dcache.desy.de/. Given a path which doesn't belong
21 to the dCache managed filesystem, it falls back to the ordinary
22 TFile behaviour.
23 */
24 
25 #include "TDCacheFile.h"
26 #include "TError.h"
27 #include "TSystem.h"
28 #include "TROOT.h"
29 
30 #include <cstdlib>
31 #include <errno.h>
32 #include <sys/stat.h>
33 #include <sys/types.h>
34 
35 #include <dcap.h>
36 #ifndef R__WIN32
37 #include <unistd.h>
38 #if defined(R__SUN) || defined(R__HPUX) || \
39  defined(R__AIX) || defined(R__LINUX) || defined(R__SOLARIS) || \
40  defined(R__HIUX) || defined(R__FBSD) || defined(R__MACOSX) || \
41  defined(R__HURD) || defined(R__OBSD)
42 #define HAS_DIRENT
43 #endif
44 #endif
45 
46 #ifdef HAS_DIRENT
47 #include <dirent.h>
48 #endif
49 
50 static const char* const DCACHE_PREFIX = "dcache:";
51 static const size_t DCACHE_PREFIX_LEN = strlen(DCACHE_PREFIX);
52 static const char* const DCAP_PREFIX = "dcap:";
53 static const size_t DCAP_PREFIX_LEN = strlen(DCAP_PREFIX);
54 
55 
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Create a dCache file object.
60 ///
61 /// A dCache file is the same as a TFile
62 /// except that it is being accessed via a dCache server. The url
63 /// argument must be of the form: \a dcache:/pnfs/<path>/<file>.root or
64 /// \a dcap://<nodename.org>/<path>/<file>.root. If the file specified in the
65 /// URL does not exist, is not accessable or can not be created the kZombie
66 /// bit will be set in the TDCacheFile object. Use IsZombie() to see if the
67 /// file is accessable. For a description of the option and other arguments
68 /// see the TFile ctor. The preferred interface to this constructor is
69 /// via TFile::Open().
70 
71 TDCacheFile::TDCacheFile(const char *path, Option_t *option,
72  const char *ftitle, Int_t compress):
73  TFile(path, "NET", ftitle, compress)
74 {
75  TString pathString = GetDcapPath(path);
76  path = pathString.Data();
77 
78  fOption = option;
79  fOption.ToUpper();
80  fStatCached = kFALSE;
81 
82  if (fOption == "NEW")
83  fOption = "CREATE";
84 
85  Bool_t create = (fOption == "CREATE") ? kTRUE : kFALSE;
86  Bool_t recreate = (fOption == "RECREATE") ? kTRUE : kFALSE;
87  Bool_t update = (fOption == "UPDATE") ? kTRUE : kFALSE;
88  Bool_t read = (fOption == "READ") ? kTRUE : kFALSE;
89  if (!create && !recreate && !update && !read) {
90  read = kTRUE;
91  fOption = "READ";
92  }
93 
94  TString stmp;
95  TString stmp2;
96  const char *fname;
97  const char *fnameWithPrefix;
98 
99  if (!strncmp(path, DCAP_PREFIX, DCAP_PREFIX_LEN)) {
100  fnameWithPrefix = fname = path;
101  } else {
102  // Metadata provided by PNFS
103  char *tname;
104  if ((tname = gSystem->ExpandPathName(path))) {
105  stmp = tname;
106  stmp2 = DCACHE_PREFIX;
107  stmp2 += tname;
108  delete [] tname;
109  fname = stmp;
110  fnameWithPrefix = stmp2;
111  } else {
112  Error("TDCacheFile", "error expanding path %s", path);
113  goto zombie;
114  }
115  }
116 
117  if (recreate) {
118  if (!gSystem->AccessPathName(fnameWithPrefix, kFileExists))
119  dc_unlink(fname);
120  recreate = kFALSE;
121  create = kTRUE;
122  fOption = "CREATE";
123  }
124  if (create && !gSystem->AccessPathName(fnameWithPrefix, kFileExists)) {
125  Error("TDCacheFile", "file %s already exists", fname);
126  goto zombie;
127  }
128  if (update) {
129  if (gSystem->AccessPathName(fnameWithPrefix, kFileExists)) {
130  update = kFALSE;
131  create = kTRUE;
132  }
133  if (update && gSystem->AccessPathName(fnameWithPrefix, kWritePermission)) {
134  Error("TDCacheFile", "no write permission, could not open file %s", fname);
135  goto zombie;
136  }
137  }
138 
139  // Connect to file system stream
140  fRealName = fname;
141 
142  if (create || update) {
143 #ifndef WIN32
144  fD = SysOpen(fname, O_RDWR | O_CREAT, 0644);
145 #else
146  fD = SysOpen(fname, O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
147 #endif
148  if (fD == -1) {
149  SysError("TDCacheFile", "file %s can not be opened", fname);
150  goto zombie;
151  }
152  fWritable = kTRUE;
153  } else {
154 #ifndef WIN32
155  fD = SysOpen(fname, O_RDONLY, 0644);
156 #else
157  fD = SysOpen(fname, O_RDONLY | O_BINARY, S_IREAD | S_IWRITE);
158 #endif
159  if (fD == -1) {
160  if (gSystem->AccessPathName(fnameWithPrefix, kFileExists)) {
161  Error("TDCacheFile", "file %s does not exist", fname);
162  goto zombie;
163  }
164  if (gSystem->AccessPathName(fnameWithPrefix, kReadPermission)) {
165  Error("TDCacheFile", "no read permission, could not open file %s", fname);
166  goto zombie;
167  }
168  SysError("TDCacheFile", "file %s can not be opened for reading", fname);
169  goto zombie;
170  }
171  fWritable = kFALSE;
172  }
173 
174  // use 128K ( default ) read-ahead buffer to get file header,
175  // the buffer size can be overriden by env var "DCACHE_RA_BUFFER",
176  // vector read are not affected by read-ahead buffer
177  if (read) {
178  int dcache_RAHEAD_SIZE = RAHEAD_BUFFER_SIZE;
179  const char *DCACHE_RA_BUFFER = gSystem->Getenv("DCACHE_RA_BUFFER");
180  if (DCACHE_RA_BUFFER) {
181  int ra_buffer = atoi(DCACHE_RA_BUFFER);
182  dcache_RAHEAD_SIZE = ra_buffer<=0 ? dcache_RAHEAD_SIZE : ra_buffer;
183  }
184  dc_setBufferSize(fD, dcache_RAHEAD_SIZE);
185  } else {
186  dc_noBuffering(fD);
187  }
188 
189  Init(create);
190 
191  return;
192 
193 zombie:
194  // error in file opening occured, make this object a zombie
195  MakeZombie();
196  gDirectory = gROOT;
197 }
198 
199 ////////////////////////////////////////////////////////////////////////////////
200 /// Close and cleanup dCache file.
201 
203 {
204  Close();
205 }
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 /// Read specified byte range from remote file via dCache daemon.
209 /// Returns kTRUE in case of error.
210 
212 {
213  Int_t st;
214  if ((st = ReadBufferViaCache(buf, len))) {
215  if (st == 2)
216  return kTRUE;
217  return kFALSE;
218  }
219 
220  return TFile::ReadBuffer(buf, len);
221 }
222 
223 ////////////////////////////////////////////////////////////////////////////////
224 /// Read specified byte range from remote file via dCache daemon.
225 /// Returns kTRUE in case of error.
226 
228 {
229  SetOffset(pos);
230  Int_t st;
231  if ((st = ReadBufferViaCache(buf, len))) {
232  if (st == 2)
233  return kTRUE;
234  return kFALSE;
235  }
236 
237  return TFile::ReadBuffer(buf, pos, len);
238 }
239 
240 ////////////////////////////////////////////////////////////////////////////////
241 /// Read the nbuf blocks described in arrays pos and len,
242 /// where pos[i] is the seek position of block i of length len[i].
243 /// Note that for nbuf=1, this call is equivalent to TFile::ReafBuffer.
244 /// This function is overloaded by TNetFile, TWebFile, etc.
245 /// Returns kTRUE in case of failure.
246 
247 Bool_t TDCacheFile::ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
248 {
249 #ifdef _IOVEC2_
250 
251  iovec2 *vector;
252 
253  vector = (iovec2 *)malloc(sizeof(iovec2)*nbuf);
254 
255  Int_t total_len = 0;
256  for (Int_t i = 0; i < nbuf; i++) {
257  vector[i].buf = &buf[total_len];
258  vector[i].offset = pos[i] + fArchiveOffset;
259  vector[i].len = len[i];
260  total_len += len[i];
261  }
262 
263  Int_t rc = dc_readv2(fD, vector, nbuf);
264  free(vector);
265 
266  if (rc == 0) {
267  fBytesRead += total_len;
268  SetFileBytesRead(GetFileBytesRead() + total_len);
269  return kFALSE;
270  }
271 
272 #endif
273 
274  // if we failed to get with dc_readv2 (old server), try to loop over
275 
276  Int_t k = 0;
277  Bool_t result = kTRUE;
278  TFileCacheRead *old = fCacheRead;
279  fCacheRead = 0;
280 
281  Long64_t low = pos[0];
282  Long64_t high = pos[nbuf-1] + len[nbuf-1] - pos[0];
283 
284  Long64_t total = 0;
285  for(Int_t j=0; j < nbuf; j++) {
286  total += len[j];
287  }
288 
289  if ( total && high / total < 10 ) {
290 
291  char *temp = new char[high];
292  Seek(low);
293  result = ReadBuffer(temp,high);
294 
295  if (result==0) {
296  for (Int_t i = 0; i < nbuf; i++) {
297  memcpy(&buf[k], &(temp[pos[i]-pos[0]]), len[i]);
298  k += len[i];
299  }
300  }
301 
302  delete [] temp;
303 
304  } else {
305 
306  for (Int_t i = 0; i < nbuf; i++) {
307  Seek(pos[i]);
308  result = ReadBuffer(&buf[k], len[i]);
309  if (result) break;
310  k += len[i];
311  }
312 
313  }
314 
315  fCacheRead = old;
316  return result;
317 }
318 
319 ////////////////////////////////////////////////////////////////////////////////
320 /// Write specified byte range to remote file via dCache daemon.
321 /// Returns kTRUE in case of error.
322 
323 Bool_t TDCacheFile::WriteBuffer(const char *buf, Int_t len)
324 {
325  if (!IsOpen() || !fWritable) return kTRUE;
326 
327  Int_t st;
328  if ((st = WriteBufferViaCache(buf, len))) {
329  if (st == 2)
330  return kTRUE;
331  return kFALSE;
332  }
333 
334  return TFile::WriteBuffer(buf, len);
335 }
336 
337 ////////////////////////////////////////////////////////////////////////////////
338 /// Stage() returns kTRUE on success and kFALSE on failure.
339 
340 Bool_t TDCacheFile::Stage(const char *path, UInt_t after, const char *location)
341 {
342  TString pathString = GetDcapPath(path);
343  path = pathString.Data();
344 
345  dc_errno = 0;
346 
347  if (dc_stage(path, after, location) == 0)
348  return kTRUE;
349 
350  if (dc_errno != 0)
351  gSystem->SetErrorStr(dc_strerror(dc_errno));
352 
353  return kFALSE;
354 }
355 
356 ////////////////////////////////////////////////////////////////////////////////
357 /// CheckFile() returns kTRUE on success and kFALSE on failure. In
358 /// case the file exists but is not cached, CheckFile() returns
359 /// kFALSE and errno is set to EAGAIN.
360 
361 Bool_t TDCacheFile::CheckFile(const char *path, const char *location)
362 {
363  TString pathString = GetDcapPath(path);
364  path = pathString.Data();
365 
366  dc_errno = 0;
367 
368  if (dc_check(path, location) == 0)
369  return kTRUE;
370 
371  if (dc_errno != 0)
372  gSystem->SetErrorStr(dc_strerror(dc_errno));
373 
374  return kFALSE;
375 }
376 
377 ////////////////////////////////////////////////////////////////////////////////
378 /// Set file open timeout.
379 
381 {
382  dc_setOpenTimeout(n);
383 }
384 
385 ////////////////////////////////////////////////////////////////////////////////
386 /// Set on error handler.
387 
389 {
390  dc_setOnError(a);
391 }
392 
393 ////////////////////////////////////////////////////////////////////////////////
394 /// Set reply host name.
395 
396 void TDCacheFile::SetReplyHostName(const char *host_name)
397 {
398  dc_setReplyHostName((char*)host_name);
399 }
400 
401 ////////////////////////////////////////////////////////////////////////////////
402 /// Return dCache version string.
403 
405 {
406  return getDcapVersion();
407 }
408 
409 ////////////////////////////////////////////////////////////////////////////////
410 /// Interface to system open. All arguments like in POSIX open.
411 
412 Int_t TDCacheFile::SysOpen(const char *pathname, Int_t flags, UInt_t mode)
413 {
414  // often there is a filewall on front of storage system.
415  // let clients connect to the data servers
416  // if it's an old dCache version, pool will try to connect to the client
417  // (if it's fine with firewall)
418 
419  dc_setClientActive();
420 
421  dc_errno = 0;
422 
423  Int_t rc = dc_open(pathname, flags, (Int_t) mode);
424 
425  if (rc < 0) {
426  if (dc_errno != 0)
427  gSystem->SetErrorStr(dc_strerror(dc_errno));
428  }
429 
430  return rc;
431 }
432 
433 ////////////////////////////////////////////////////////////////////////////////
434 /// Interface to system close. All arguments like in POSIX close.
435 
437 {
438  dc_errno = 0;
439 
440  Int_t rc = dc_close(fd);
441 
442  if (rc < 0) {
443  if (dc_errno != 0)
444  gSystem->SetErrorStr(dc_strerror(dc_errno));
445  }
446 
447  return rc;
448 }
449 
450 ////////////////////////////////////////////////////////////////////////////////
451 /// Interface to system read. All arguments like in POSIX read.
452 
454 {
455  dc_errno = 0;
456 
457  Int_t rc = dc_read(fd, buf, len);
458 
459  if (rc < 0) {
460  if (dc_errno != 0)
461  gSystem->SetErrorStr(dc_strerror(dc_errno));
462  }
463 
464  return rc;
465 }
466 
467 ////////////////////////////////////////////////////////////////////////////////
468 /// Interface to system write. All arguments like in POSIX write.
469 
470 Int_t TDCacheFile::SysWrite(Int_t fd, const void *buf, Int_t len)
471 {
472  dc_errno = 0;
473 
474  Int_t rc = dc_write(fd, (char *)buf, len);
475 
476  if (rc < 0) {
477  if (dc_errno != 0)
478  gSystem->SetErrorStr(dc_strerror(dc_errno));
479  }
480 
481  return rc;
482 }
483 
484 ////////////////////////////////////////////////////////////////////////////////
485 /// Interface to system seek. All arguments like in POSIX lseek.
486 
488 {
489  dc_errno = 0;
490 
491  Long64_t rc = dc_lseek64(fd, offset, whence);
492 
493  if (rc < 0) {
494  if (dc_errno != 0)
495  gSystem->SetErrorStr(dc_strerror(dc_errno));
496  }
497 
498  return rc;
499 }
500 
501 ////////////////////////////////////////////////////////////////////////////////
502 /// Interface to system sync. All arguments like in POSIX fsync.
503 /// dCache always keep it's files sync'ed, so there's no need to
504 /// sync() them manually.
505 
507 {
508  Int_t rc;
509  dc_errno = 0;
510 
511  rc = dc_fsync(fd);
512  if (rc < 0) {
513  if (dc_errno != 0)
514  gSystem->SetErrorStr(dc_strerror(dc_errno));
515  }
516 
517  return rc;
518 }
519 
520 ////////////////////////////////////////////////////////////////////////////////
521 /// Get info about a file: id, size, flags, modification time.
522 ///
523 /// \param[in] id (statbuf.st_dev << 24) + statbuf.st_ino
524 /// \param[in] size The file size
525 /// \param[in] flags File type: 0 is regular file, bit 0 set executable, bit 1 set directory, bit 2 set special file (socket, fifo, pipe, etc.)
526 /// \param[in] modtime Modification time.
527 /// The function returns 0 in case of success and 1 if the file could
528 /// not be stat'ed.
529 
531  Long_t *flags, Long_t *modtime)
532 {
533  // If in read mode, uses the cached file status, if available, to avoid
534  // costly dc_stat() call.
535 
536  struct stat64 & statbuf = fStatBuffer; // reference the cache
537 
538  if (fOption != "READ" || !fStatCached) {
539  // We are not in read mode, or the file status information is not yet
540  // in the cache. Update or read the status information with dc_stat().
541 
542  const char *path = GetName();
543  TString pathString = GetDcapPath(path);
544  path = pathString.Data();
545 
546  if (path && (dc_stat64(path, &statbuf) >= 0)) {
547  fStatCached = kTRUE;
548  }
549  }
550 
551  if (fStatCached) {
552  if (id)
553  *id = (statbuf.st_dev << 24) + statbuf.st_ino;
554  if (size)
555  *size = statbuf.st_size;
556  if (modtime)
557  *modtime = statbuf.st_mtime;
558  if (flags) {
559  *flags = 0;
560  if (statbuf.st_mode & ((S_IEXEC)|(S_IEXEC>>3)|(S_IEXEC>>6)))
561  *flags |= 1;
562  if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
563  *flags |= 2;
564  if ((statbuf.st_mode & S_IFMT) != S_IFREG &&
565  (statbuf.st_mode & S_IFMT) != S_IFDIR)
566  *flags |= 4;
567  }
568  return 0;
569  }
570  return 1;
571 }
572 
573 ////////////////////////////////////////////////////////////////////////////////
574 /// Method resetting the dc_errno and errno.
575 
577 {
578  dc_errno = 0;
580 }
581 
582 ////////////////////////////////////////////////////////////////////////////////
583 /// Transform the input path into a path usuable by the dcap C library,
584 /// i.e either \a dcap://nodename.org/where/filename.root or
585 /// \a /pnfs/where/filename.root
586 
588 {
589  // eat all 'dcache:' prefixes
590  while (!strncmp(path, DCACHE_PREFIX, DCACHE_PREFIX_LEN)) {
591  path += DCACHE_PREFIX_LEN;
592  }
593 
594  TUrl url(path);
595  TString pathString(url.GetUrl());
596 
597  // convert file://path url and dcap:///path to /path
598  if(!strncmp(url.GetProtocol(), "file", 4) || !strcmp(url.GetHost(),"")){
599  pathString = url.GetFile();
600  }
601 
602  return pathString;
603 }
604 
605 
606 ////////////////////////////////////////////////////////////////////////////////
607 /// Create helper class that allows directory access via dCache.
608 
609 TDCacheSystem::TDCacheSystem() : TSystem("-DCache", "DCache Helper System")
610 {
611  // name must start with '-' to bypass the TSystem singleton check
612  SetName("DCache");
613 
614  fDirp = 0;
615 }
616 
617 ////////////////////////////////////////////////////////////////////////////////
618 /// Create a directory.
619 
620 int TDCacheSystem::MakeDirectory(const char *path)
621 {
622  Int_t rc;
623  dc_errno = 0;
624  TString pathString = TDCacheFile::GetDcapPath(path);
625  path = pathString.Data();
626 
627  rc = dc_mkdir(path, 0755);
628  if (rc < 0) {
629  if (dc_errno != 0)
630  gSystem->SetErrorStr(dc_strerror(dc_errno));
631  }
632 
633  return rc;
634 }
635 
636 ////////////////////////////////////////////////////////////////////////////////
637 /// Open a directory.
638 
639 void *TDCacheSystem::OpenDirectory(const char *path)
640 {
641  dc_errno = 0;
642  TString pathString = TDCacheFile::GetDcapPath(path);
643  path = pathString.Data();
644 
645  fDirp = dc_opendir(path);
646  if (fDirp == 0) {
647  if (dc_errno != 0)
648  gSystem->SetErrorStr(dc_strerror(dc_errno));
649  }
650 
651  return fDirp;
652 }
653 
654 ////////////////////////////////////////////////////////////////////////////////
655 /// Close a directory.
656 
658 {
659  Int_t rc;
660  dc_errno = 0;
661 
662  rc = dc_closedir((DIR *)dirp);
663  if (rc < 0) {
664  if (dc_errno != 0)
665  gSystem->SetErrorStr(dc_strerror(dc_errno));
666  }
667 
668  fDirp = 0;
669  return;
670 }
671 
672 ////////////////////////////////////////////////////////////////////////////////
673 /// Get a directory entry.
674 
675 const char *TDCacheSystem::GetDirEntry(void * dirp)
676 {
677  struct dirent *ent;
678  dc_errno = 0;
679 
680  ent = dc_readdir((DIR *)dirp);
681  if (ent == 0) {
682  if (dc_errno != 0)
683  gSystem->SetErrorStr(dc_strerror(dc_errno));
684  }
685 
686  return !ent ? 0 : ent->d_name;
687 }
688 
689 ////////////////////////////////////////////////////////////////////////////////
690 /// Returns FALSE if one can access a file using the specified access mode.
691 /// Mode is the same as for the Unix access(2) function.
692 /// Attention, bizarre convention of return value!!
693 
695 {
696  TString pathString = TDCacheFile::GetDcapPath(path);
697  path = pathString.Data();
698 
699  return dc_access(path, mode);
700 }
701 
702 ////////////////////////////////////////////////////////////////////////////////
703 /// Get info about a file. Info is returned in the form of a FileStat_t
704 /// structure (see TSystem.h).
705 /// The function returns 0 in case of success and 1 if the file could
706 /// not be stat'ed.
707 
708 int TDCacheSystem::GetPathInfo(const char *path, FileStat_t &buf)
709 {
710  TString pathString = TDCacheFile::GetDcapPath(path);
711  path = pathString.Data();
712 
713  struct stat64 sbuf;
714 
715  if (path && (dc_stat64(path, &sbuf) >= 0)) {
716 
717  buf.fDev = sbuf.st_dev;
718  buf.fIno = sbuf.st_ino;
719  buf.fMode = sbuf.st_mode;
720  buf.fUid = sbuf.st_uid;
721  buf.fGid = sbuf.st_gid;
722  buf.fSize = sbuf.st_size;
723  buf.fMtime = sbuf.st_mtime;
724  buf.fIsLink = kFALSE;
725 
726  return 0;
727  }
728  return 1;
729 }
const char * GetHost() const
Definition: TUrl.h:76
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition: TSystem.cxx:1213
double read(const std::string &file_name)
reading
A TDCacheFile is like a normal TFile except that it may read and write its data via a dCache server (...
Definition: TDCacheFile.h:31
void FreeDirectory(void *dirp)
Close a directory.
TFileCacheRead * fCacheRead
!Pointer to the read cache (if any)
Definition: TFile.h:85
Long64_t SysSeek(Int_t fd, Long64_t offset, Int_t whence)
Interface to system seek. All arguments like in POSIX lseek.
static const char *const DCAP_PREFIX
Definition: TDCacheFile.cxx:52
long long Long64_t
Definition: RtypesCore.h:69
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Int_t SysSync(Int_t fd)
Interface to system sync.
A cache when reading files over the network.
const char Option_t
Definition: RtypesCore.h:62
tuple offset
Definition: tree.py:93
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition: TFile.cxx:2064
This class represents a WWW compatible URL.
Definition: TUrl.h:41
Int_t fUid
Definition: TSystem.h:139
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
const char * GetProtocol() const
Definition: TUrl.h:73
virtual void Seek(Long64_t offset, ERelativeTo pos=kBeg)
Seek to a specific position in the file. Pos it either kBeg, kCur or kEnd.
Definition: TFile.cxx:2085
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Definition: TFile.cxx:1596
#define gROOT
Definition: TROOT.h:344
#define O_BINARY
Definition: civetweb.c:273
Bool_t fStatCached
! (transient) is file status cached?
Definition: TDCacheFile.h:34
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
Definition: TFile.cxx:2331
Long_t fMtime
Definition: TSystem.h:142
static void SetOnError(EOnErrorAction=kOnErrorDefault)
Set on error handler.
Long64_t fSize
Definition: TSystem.h:141
Int_t SysWrite(Int_t fd, const void *buf, Int_t len)
Interface to system write. All arguments like in POSIX write.
void SysError(const char *location, const char *msgfmt,...)
static void SetOpenTimeout(UInt_t secs)
Set file open timeout.
Int_t fMode
Definition: TSystem.h:138
Bool_t WriteBuffer(const char *buf, Int_t len)
Write specified byte range to remote file via dCache daemon.
const char * Data() const
Definition: TString.h:349
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
Definition: TFile.cxx:1373
Int_t fD
File descriptor.
Definition: TFile.h:69
static const char * GetDcapVersion()
Return dCache version string.
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Definition: TFile.cxx:4319
void * OpenDirectory(const char *name)
Open a directory.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:118
static const size_t DCACHE_PREFIX_LEN
Definition: TDCacheFile.cxx:51
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1575
if(pyself &&pyself!=Py_None)
void ResetErrno() const
Method resetting the dc_errno and errno.
void * fDirp
directory handler
Definition: TDCacheFile.h:88
void Error(const char *location, const char *msgfmt,...)
Int_t fGid
Definition: TSystem.h:140
static Bool_t CheckFile(const char *path, const char *location=0)
CheckFile() returns kTRUE on success and kFALSE on failure.
Int_t SysRead(Int_t fd, void *buf, Int_t len)
Interface to system read. All arguments like in POSIX read.
Bool_t fIsLink
Definition: TSystem.h:143
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
static TString GetDcapPath(const char *path)
Transform the input path into a path usuable by the dcap C library, i.e either dcap://nodename.org/where/filename.root or /pnfs/where/filename.root.
virtual Bool_t WriteBuffer(const char *buf, Int_t len)
Write a buffer to the file.
Definition: TFile.cxx:2288
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
unsigned int UInt_t
Definition: RtypesCore.h:42
static void SetReplyHostName(const char *host_name)
Set reply host name.
const char * GetDirEntry(void *dirp)
Get a directory entry.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len, where pos[i] is the seek position of block i of...
static const size_t DCAP_PREFIX_LEN
Definition: TDCacheFile.cxx:53
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Definition: TFile.cxx:1715
tuple free
Definition: fildir.py:30
Bool_t fWritable
True if directory is writable.
TH1F * total
Definition: threadsh2.C:15
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:385
long Long_t
Definition: RtypesCore.h:50
static const char *const DCACHE_PREFIX
Definition: TDCacheFile.cxx:50
ClassImp(TDCacheFile) TDCacheFile
Create a dCache file object.
Definition: TDCacheFile.cxx:56
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Interface to system open. All arguments like in POSIX open.
Int_t MakeDirectory(const char *name)
Create a directory.
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
TString fOption
File options.
Definition: TFile.h:78
EAccessMode
Definition: TSystem.h:54
struct stat64 fStatBuffer
! (transient) Cached file status buffer (for performance)
Definition: TDCacheFile.h:35
Bool_t ReadBuffer(char *buf, Int_t len)
Read specified byte range from remote file via dCache daemon.
Int_t SysClose(Int_t fd)
Interface to system close. All arguments like in POSIX close.
EOnErrorAction
Note: This must be kept in sync with values #defined in dcap.h.
Definition: TDCacheFile.h:67
Long_t fIno
Definition: TSystem.h:137
#define RAHEAD_BUFFER_SIZE
Definition: TDCacheFile.h:29
Long64_t fArchiveOffset
!Offset at which file starts in archive
Definition: TFile.h:88
static void ResetErrno()
Static function resetting system error number.
Definition: TSystem.cxx:280
#define gDirectory
Definition: TDirectory.h:221
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
double result[121]
TDCacheSystem()
Create helper class that allows directory access via dCache.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1191
void SetErrorStr(const char *errstr)
Set the system error string.
Definition: TSystem.cxx:245
Long_t fDev
Definition: TSystem.h:136
static void SetFileBytesRead(Long64_t bytes=0)
Definition: TFile.cxx:4353
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:258
const Bool_t kTRUE
Definition: Rtypes.h:91
~TDCacheFile()
Close and cleanup dCache file.
Vc_ALWAYS_INLINE_L T *Vc_ALWAYS_INLINE_R malloc(size_t n)
Allocates memory on the Heap with alignment and padding suitable for vectorized access.
Definition: memory.h:67
const Int_t n
Definition: legend1.C:16
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:63
const char * GetFile() const
Definition: TUrl.h:78
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:898
static Bool_t Stage(const char *path, UInt_t secs, const char *location=0)
Stage() returns kTRUE on success and kFALSE on failure.