51#include <XrdClient/XrdClient.hh>
55#include <XProtocol/XProtocol.hh>
120 Info(
"TXNetFile",
"(eXtended TNetFile) %s",
121 gROOT->GetVersion());
178 if (
uu.GetPort() > 0) {
194 static const char *keys[6] = {
"cachesz=",
"readaheadsz=",
"rmpolicy=",
195 "mxredir=",
"readaheadstrategy=",
"readtrimblksz=" };
200 for (i = 0; i < (
sizeof(keys)/
sizeof(keys[0])); i++) {
207 if (!
TString(val(k++)).IsDigit())
231 Info(
"ParseCacheOptions",
"found: cachesz = %d, readaheadsz = %d, "
232 "rmpolicy = %d, mxredir = %d, rastrategy = %d, readtrimblksz = %d",
262 ::Warning(
"TXNetFile",
"<%s> is not staged - StageOnly flag is set!",
url);
283 Error(
"CreateXClient",
"fatal error: new object creation failed -"
284 " out of system resources.");
296 if (
fClient->GetClientConn()) {
298 Info(
"CreateXClient",
"setting maxredir = %d",
mxredir);
306 Info(
"CreateXClient",
"setting cachesz = %d, readaheadsz = %d, "
330 Info(
"CreateXClient",
"remote file could not be open");
349 Error(
"CreateXClient",
"getting rootd server protocol");
356 ->GetCurrentUrl()).GetUrl().c_str());
361 Info(
"CreateXClient",
" url: %s",
uu.Data());
384 Error(
"CreateXClient",
"rootd: underlying socket undefined");
389 Info(
"CreateXClient",
"rootd: fall back not enabled - closing");
422 ::Error(
"TXNetFile::GetRootdProtocol",
423 "sending %d bytes to rootd server [%s:%d]",
433 ::Error(
"TXNetFile::GetRootdProtocol",
434 "reading %d bytes from rootd server [%s:%d]",
447 ::Error(
"TXNetFile::GetRootdProtocol",
448 "reading %d bytes from rootd server [%s:%d]",
456 ::Info(
"TXNetFile::GetRootdProtocol",
457 "remote rootd: buf1: %d, buf2: %d rproto: %d",
484 Bool_t read = (opt ==
"READ");
515 Error(
"Open",
"no write permission, could not open file %s",
551 Info(
"Open",
"remote file could not be open");
585 Error(
"ReadBuffer",
"ReadBuffer is not possible because object"
586 " is in 'zombie' state");
592 Info(
"ReadBuffer",
"Calling TNetFile::ReadBuffer");
597 Error(
"ReadBuffer",
"The remote file is not open");
642 Error(
"ReadBuffer",
"error reading all requested bytes, got %d of %d",
648 Info(
"ReadBuffer",
"%d bytes of data read from offset"
690 Error(
"ReadBuffer",
"ReadBuffer is not possible because object"
691 " is in 'zombie' state");
697 Error(
"ReadBufferAsync",
"Not supported for rootd");
702 Error(
"ReadBuffer",
"The remote file is not open");
739 Info(
"ReadBufferAsync",
"%d bytes of data read request from offset"
757 Error(
"ReadBuffers",
"ReadBuffers is not possible because object"
758 " is in 'zombie' state");
764 Info(
"ReadBuffers",
"Calling TNetFile::ReadBuffers");
769 Error(
"ReadBuffers",
"The remote file is not open");
799 Info(
"ReadBuffers",
"response from ReadV(%d) nr: %lld",
nbuf,
nr);
804 Info(
"ReadBuffers",
"%lld bytes of data read from a list of %d buffers",
808 Info(
"ReadBuffers",
"%lld bytes of data read with a smaller (%d) TFileCacheRead buffer size?",
835 Info(
"ReadBuffers",
"XrdClient->ReadV failed, executing TFile::ReadBuffers");
854 Error(
"WriteBuffer",
"WriteBuffer is not possible because object"
855 " is in 'zombie' state");
861 Info(
"WriteBuffer",
"file not writable");
867 Info(
"WriteBuffer",
"Calling TNetFile::WriteBuffer");
872 Error(
"WriteBuffer",
"The remote file is not open");
887 "error writing %d bytes of data wrote to offset %lld",
893 Info(
"WriteBuffer",
" %d bytes of data wrote to offset"
916 Info(
"Init",
"TFile::Init already called once");
922 Info(
"Init",
"rootd: calling directly TFile::Init");
953 if (
fClient->GetClientConn() &&
fClient->GetClientConn()->fRedirOpaque.length() <= 0) {
963 Info(
"Init",
"open request failed!");
978 Info(
"IsOpen",
"Calling TNetFile::IsOpen");
995 if (
fClient->IsOpen_inprogress()) {
1017 Info(
"ReOpen",
"Calling TNetFile::ReOpen");
1032 Info(
"Close",
"Calling TNetFile::Close");
1055 Error(
"Flush",
"Flush is not possible because object is"
1056 " in 'zombie' state");
1062 Info(
"Flush",
"file not writable - do nothing");
1068 Info(
"Flush",
"Calling TNetFile::Flush");
1074 Error(
"Flush",
"The remote file is not open");
1084 Info(
"Flush",
"XrdClient::Sync called.");
1094 Error(
"SysStat",
"SysStat is not possible because object is"
1095 " in 'zombie' state");
1102 Info(
"SysStat",
"calling TNetFile::SysStat");
1115 Info(
"SysStat",
"got stats = %ld %lld %ld %ld",
1116 *
id, *
size, *flags, *modtime);
1120 if (!
IsOpen())
Info(
"SysStat",
"could not stat remote file. Not opened.");
1122 Info(
"SysStat",
"could not stat remote file");
1140 Error(
"SysClose",
"SysClose is not possible because object is"
1141 " in 'zombie' state");
1147 Info(
"SysClose",
"Calling TNetFile::SysClose");
1165 Info(
"SysOpen",
"Calling TNetFile::SysOpen");
1288 const char *
cenv = 0;
1316 if (
cadir.Length() > 0)
1328 if (
ucert.Length() > 0)
1332 if (
ukey.Length() > 0)
1336 if (
upxy.Length() > 0)
1344 if (
deplen.Length() > 0 &&
1410 fClient->RemoveAllDataFromCache();
1435 Printf(
"TXNetFile caching information:");
1453 Printf(
" -- No Xrd client instance allocated --\n");
UShort_t net2host(UShort_t x)
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
winID h TVirtualViewer3D TVirtualGLPainter p
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 np
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 result
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
Option_t Option_t TPoint TPoint const char mode
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 bytes
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
R__EXTERN TSystem * gSystem
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
#define NAME_TRANSACTIONTIMEOUT
#define NAME_CONNECTTIMEOUT
#define DFLT_REQUESTTIMEOUT
#define NAME_READCACHESIZE
#define NAME_REQUESTTIMEOUT
#define DFLT_DFLTTCPWINDOWSIZE
#define DFLT_FIRSTCONNECTMAXCNT
#define DFLT_MAXREDIRECTCOUNT
#define NAME_REDIRDOMAINDENY_RE
#define NAME_MAXREDIRECTCOUNT
#define NAME_FIRSTCONNECTMAXCNT
#define DFLT_TRANSACTIONTIMEOUT
#define NAME_RECONNECTWAIT
#define NAME_REDIRDOMAINALLOW_RE
#define DFLT_READAHEADSIZE
#define NAME_DFLTTCPWINDOWSIZE
#define NAME_CONNECTDOMAINDENY_RE
#define NAME_READAHEADSIZE
#define NAME_MULTISTREAMCNT
#define NAME_CONNECTDOMAINALLOW_RE
#define DFLT_READCACHESIZE
#define DFLT_CONNECTTIMEOUT
#define NAME_KEEPSOCKOPENIFNOTXRD
#define DFLT_MULTISTREAMCNT
#define DFLT_RECONNECTWAIT
#define EnvPutInt(name, val)
#define EnvPutString(name, val)
#define XrdSysMutexHelper
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Bool_t fWritable
True if directory is writable.
Int_t GetBufferSize() const override
Return the buffer size to create new TKeys.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
A cache when reading files over the network.
static TFileStager * Open(const char *stager)
Open a stager, after having loaded the relevant plug-in.
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
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 Bool_t GetOnlyStaged()
Returns staged only flag.
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode.
static Long64_t GetFileBytesWritten()
Static function returning the total number of bytes written to all files.
static void SetFileBytesRead(Long64_t bytes=0)
TList * fOpenPhases
!Time info about open phases
static void SetFileReadCalls(Int_t readcalls=0)
void Print(Option_t *option="") const override
Print all objects in the file.
static UInt_t GetOpenTimeout()
Returns open timeout (in ms).
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
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.
Long64_t fArchiveOffset
!Offset at which file starts in archive
virtual void Init(Bool_t create)
Initialize a TFile object.
TString fOption
File options.
EAsyncOpenStatus
Asynchronous open request status.
Bool_t FlushWriteCache()
Flush the write cache if active.
Long64_t fBytesWrite
Number of bytes written to this file.
Bool_t fInitDone
!True if the file has been initialized
Long64_t fOffset
!Seek offset cache
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
EAsyncOpenStatus fAsyncOpenStatus
!Status of an asynchronous open request
void Close(Option_t *option="") override
Close a file.
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
Return a pointer to the current read cache.
A TNetFile is like a normal TFile except that it reads and writes its data via a rootd server (for mo...
void Init(Bool_t create) override
Initialize a TNetFile object.
Bool_t ReadBuffer(char *buf, Int_t len) override
Read specified byte range from remote file via rootd daemon.
Bool_t WriteBuffer(const char *buf, Int_t len) override
Write specified byte range to remote file via rootd daemon.
virtual void Create(const char *url, Option_t *option, Int_t netopt)
Create a NetFile object.
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override
Return file stat information.
Int_t SysClose(Int_t fd) override
Close currently open file.
Bool_t IsOpen() const override
Retruns kTRUE if file is open, kFALSE otherwise.
Int_t ReOpen(Option_t *mode) override
Reopen a file with a different access mode, like from READ to UPDATE or from NEW, CREATE,...
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override
Read a list of buffers given in pos[] and len[] and return it in a single buffer.
void Flush() override
Flush file to disk.
void Close(Option_t *option="") override
Close remote file.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override
Open a remote file. Requires fOption to be set correctly.
R__ALWAYS_INLINE Bool_t IsZombie() const
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
void SetServType(Int_t st)
void SetRemoteProtocol(Int_t rproto)
static Int_t GetClientProtocol()
Static method returning supported client protocol.
void SetService(const char *service)
void SetUrl(const char *url)
TInetAddress GetInetAddress() const
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
Int_t Atoi() const
Return integer value of string.
const char * Data() const
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
void ToUpper()
Change string to upper case.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Remove(Ssiz_t pos)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual const char * Getenv(const char *env)
Get environment variable.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual void IgnoreSignal(ESignals sig, Bool_t ignore=kTRUE)
If ignore is true ignore the specified signal, else restore previous behaviour.
virtual void Setenv(const char *name, const char *value)
Set environment variable.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
virtual void Abort(int code=0)
Abort the application.
The TTimeStamp encapsulates seconds and ns since EPOCH.
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
const char * GetOptions() const
virtual Bool_t SendFileOpenProgress(TFile *, TList *, const char *, Bool_t=kFALSE)
virtual Bool_t SendFileReadProgress(TFile *)
TXNetFile is an extension of TNetFile able to deal with new xrootd server.
Int_t ParseOptions(const char *opts, Int_t &cachesz, Int_t &readaheadsz, Int_t &rmpolicy, Int_t &mxredir, Int_t &rastrategy, Int_t &readtrimblksz)
Parse input options for cache parameters.
virtual void Print(Option_t *option="") const
Print the local statistics.
void SynchronizeCacheSize()
Synchronize the cache size Alternative purging policy.
static TFileStager * fgFileStager
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Override TNetFile::SysStat (see parent's method for more details).
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, where pos[i] is the seek position of block i of...
virtual Int_t ReOpen(const Option_t *mode)
Re-open the file (see TNetFile::ReOpen() or TFile::ReOpen() for more details).
virtual ~TXNetFile()
Destructor.
void Init(Bool_t create)
Initialize the file.
static void SetEnv()
Set the relevant environment variables.
virtual void ResetCache()
Reset the cache.
static void FormUrl(TUrl uut, TString &uu)
Form url for rootd socket.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Override TNetFile::SysOpen (see parent's method for more details).
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Override TNetFile::ReadBuffer to deal with the xrootd server.
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Implementation dealing with the xrootd server.
virtual Bool_t WriteBuffer(const char *buffer, Int_t BufferLength)
Override TNetFile::WriteBuffer to deal with the xrootd server.
virtual void Close(const Option_t *opt="")
Close the file (see TNetFile::Close() or TFile::Close() for more details).
virtual Int_t GetBytesToPrefetch() const
Max number of bytes to prefetch.
void CreateXClient(const char *url, Option_t *option, Int_t netopt, Bool_t parallelopen)
The real creation work is done here.
virtual void Flush()
Flushes un-written data.
Int_t SysClose(Int_t fd)
Override TNetFile::SysClose (see parent's method for more details).
Bool_t Open(Option_t *option, Bool_t parallelopen)
The real creation work is done here.
virtual Bool_t IsOpen() const
Return kTRUE if the file is open, kFALSE otherwise.
static Int_t GetRootdProtocol(TSocket *s)
Find out the remote rootd protocol version.
virtual TFile::EAsyncOpenStatus GetAsyncOpenStatus()
Return status of asynchronous request.