Logo ROOT  
Reference Guide
TNetXNGFile.h
Go to the documentation of this file.
1 
2 /*************************************************************************
3  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
4  * All rights reserved. *
5  * *
6  * For the licensing terms see $ROOTSYS/LICENSE. *
7  * For the list of contributors see $ROOTSYS/README/CREDITS. *
8  *************************************************************************/
9 
10 #ifndef ROOT_TNetXNGFile
11 #define ROOT_TNetXNGFile
12 
13 ////////////////////////////////////////////////////////////////////////////////
14 // //
15 // TNetXNGFile //
16 // //
17 // Authors: Justin Salmon, Lukasz Janyst //
18 // CERN, 2013 //
19 // //
20 // Enables access to XRootD files using the new client. //
21 // //
22 ////////////////////////////////////////////////////////////////////////////////
23 
24 #include "TFile.h"
25 #include "TSemaphore.h"
26 #ifndef __CLING__
27 #include <XrdCl/XrdClFileSystem.hh>
28 #endif
29 
30 namespace XrdCl {
31  class File;
32  class URL;
33 }
34 class XrdSysCondVar;
35 
36 #ifdef __CLING__
37 namespace XrdCl {
38  struct OpenFlags {
39  enum Flags {None = 0};
40  };
41 }
42 #endif
43 
44 class TNetXNGFile: public TFile {
45 private:
46  XrdCl::File *fFile; // Underlying XRootD file
47  XrdCl::URL *fUrl; // URL of the current file
48  XrdCl::OpenFlags::Flags fMode; // Open mode of the current file
49  XrdSysCondVar *fInitCondVar; // Used to block an async open request
50  // if requested
51  Int_t fReadvIorMax; // Max size of a single readv chunk
52  Int_t fReadvIovMax; // Max number of readv chunks
55 
56 public:
58  fFile(0), fUrl(0), fMode(XrdCl::OpenFlags::None), fInitCondVar(0),
59  fReadvIorMax(0), fReadvIovMax(0) {}
60  TNetXNGFile(const char *url, const char *lurl, Option_t *mode , const char *title ,
61  Int_t compress , Int_t netopt , Bool_t parallelopen );
62  TNetXNGFile(const char *url, Option_t *mode = "", const char *title = "",
63  Int_t compress = 1, Int_t netopt = 0, Bool_t parallelopen = kFALSE);
64 
65  virtual ~TNetXNGFile();
66 
67  virtual void Init(Bool_t create);
68  virtual void Close(const Option_t *option = "");
69  virtual void Seek(Long64_t offset, ERelativeTo position = kBeg);
70  virtual void SetAsyncOpenStatus(EAsyncOpenStatus status);
71  virtual Long64_t GetSize() const;
72  virtual Int_t ReOpen(Option_t *modestr);
73  virtual Bool_t IsOpen() const;
74  virtual Bool_t WriteBuffer(const char *buffer, Int_t length);
75  virtual void Flush();
76  virtual Bool_t ReadBuffer(char *buffer, Int_t length);
77  virtual Bool_t ReadBuffer(char *buffer, Long64_t position, Int_t length);
78  virtual Bool_t ReadBuffers(char *buffer, Long64_t *position, Int_t *length,
79  Int_t nbuffs);
80  virtual TString GetNewUrl() { return fNewUrl; }
81 
82 private:
83  virtual Bool_t IsUseable() const;
84  virtual Bool_t GetVectorReadLimits();
85  virtual void SetEnv();
86  Int_t ParseOpenMode(Option_t *in, TString &modestr,
87  XrdCl::OpenFlags::Flags &mode, Bool_t assumeRead);
88 
89  TNetXNGFile(const TNetXNGFile &other); // Not implemented
90  TNetXNGFile &operator =(const TNetXNGFile &other); // Not implemented
91 
92  ClassDef(TNetXNGFile, 0) // ROOT class definition
93 };
94 
95 #endif // ROOT_TNetXNGFile
Option_t
const char Option_t
Definition: RtypesCore.h:66
TNetXNGFile::IsUseable
virtual Bool_t IsUseable() const
Check the file is open and isn't a zombie.
Definition: TNetXNGFile.cxx:712
TFile::kBeg
@ kBeg
Definition: TFile.h:191
TNetXNGFile::fReadvIorMax
Int_t fReadvIorMax
Definition: TNetXNGFile.h:51
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TFile::ERelativeTo
ERelativeTo
Definition: TFile.h:191
TNetXNGFile::Init
virtual void Init(Bool_t create)
Initialize the file.
Definition: TNetXNGFile.cxx:242
Int_t
int Int_t
Definition: RtypesCore.h:45
TNetXNGFile::IsOpen
virtual Bool_t IsOpen() const
Check if the file is open.
Definition: TNetXNGFile.cxx:304
TNetXNGFile::SetEnv
virtual void SetEnv()
Map ROOT and xrootd environment variables.
Definition: TNetXNGFile.cxx:803
TString
Basic string class.
Definition: TString.h:136
TNetXNGFile::Close
virtual void Close(const Option_t *option="")
Close the file.
Definition: TNetXNGFile.cxx:325
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TFile.h
TNetXNGFile::GetSize
virtual Long64_t GetSize() const
Get the file size.
Definition: TNetXNGFile.cxx:277
TSemaphore.h
TNetXNGFile::ParseOpenMode
Int_t ParseOpenMode(Option_t *in, TString &modestr, XrdCl::OpenFlags::Flags &mode, Bool_t assumeRead)
Parse a file open mode given as a string into a canonically formatted output mode string and an integ...
Definition: TNetXNGFile.cxx:687
TNetXNGFile::fReadvIovMax
Int_t fReadvIovMax
Definition: TNetXNGFile.h:52
TNetXNGFile::Seek
virtual void Seek(Long64_t offset, ERelativeTo position=kBeg)
Set the position within the file.
Definition: TNetXNGFile.cxx:671
TNetXNGFile::TNetXNGFile
TNetXNGFile()
Definition: TNetXNGFile.h:57
TNetXNGFile::ReadBuffers
virtual Bool_t ReadBuffers(char *buffer, Long64_t *position, Int_t *length, Int_t nbuffs)
Read scattered data chunks in one operation.
Definition: TNetXNGFile.cxx:469
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TNetXNGFile::operator=
TNetXNGFile & operator=(const TNetXNGFile &other)
TNetXNGFile::fUrl
XrdCl::URL * fUrl
Definition: TNetXNGFile.h:47
TNetXNGFile::fInitCondVar
XrdSysCondVar * fInitCondVar
Definition: TNetXNGFile.h:49
TNetXNGFile::fFile
XrdCl::File * fFile
Definition: TNetXNGFile.h:46
TNetXNGFile::ReOpen
virtual Int_t ReOpen(Option_t *modestr)
Reopen the file with the new access mode.
Definition: TNetXNGFile.cxx:345
TNetXNGFile::ReadBuffer
virtual Bool_t ReadBuffer(char *buffer, Int_t length)
Read a data chunk of the given size.
Definition: TNetXNGFile.cxx:389
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
TNetXNGFile::GetVectorReadLimits
virtual Bool_t GetVectorReadLimits()
Find the server-specific readv config params.
Definition: TNetXNGFile.cxx:731
XrdCl
Definition: TNetXNGFile.h:30
TNetXNGFile::fMode
XrdCl::OpenFlags::Flags fMode
Definition: TNetXNGFile.h:48
TNetXNGFile::~TNetXNGFile
virtual ~TNetXNGFile()
Destructor.
Definition: TNetXNGFile.cxx:229
TNetXNGFile::SetAsyncOpenStatus
virtual void SetAsyncOpenStatus(EAsyncOpenStatus status)
Set the status of an asynchronous file open.
Definition: TNetXNGFile.cxx:312
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TNetXNGFile::Flush
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
Definition: TNetXNGFile.cxx:642
TNetXNGFile::GetNewUrl
virtual TString GetNewUrl()
Definition: TNetXNGFile.h:80
TNetXNGFile::TNetXNGFile
TNetXNGFile(const TNetXNGFile &other)
TNetXNGFile
Definition: TNetXNGFile.h:44
TNetXNGFile::fNewUrl
TString fNewUrl
Definition: TNetXNGFile.h:54
TNetXNGFile::fQueryReadVParams
Int_t fQueryReadVParams
Definition: TNetXNGFile.h:53
TFile::EAsyncOpenStatus
EAsyncOpenStatus
Asynchronous open request status.
Definition: TFile.h:65
TNetXNGFile::WriteBuffer
virtual Bool_t WriteBuffer(const char *buffer, Int_t length)
Write a data chunk.
Definition: TNetXNGFile.cxx:603
int