library: libNetx #include "TXNetFile.h"

# TXNetFile

class description - source file - inheritance tree (.pdf)

## class TXNetFile : public TNetFile, public TXAbsNetCommon

| Inheritance Chart:
`TObject`
| <- | `TNamed`
| <- | `TDirectory`
| <- | `TFile`
| <- | `TNetFile`
`TXAbsUnsolicitedMsgHandler`
| <- | `TXAbsNetCommon`
| <- | `TXNetFile` |

        private:

                   void CreateTXNf(const char* url, Option_t* option, const char* ftitle, Int_t compress, Int_t netopt)
                 Bool_t LowOpen(const char* file, Option_t* option, const char* ftitle, Int_t compress, Int_t netopt, Bool_t DoInit, Bool_t refresh_open = kFALSE)
          virtual Int_t SysClose(Int_t fd)
          virtual Int_t SysOpen(const char* pathname, Int_t flags, UInt_t mode)
          virtual Int_t SysStat(Int_t fd, Long_t* id, Long64_t* size, Long_t* flags, Long_t* modtime)

        public:

                          TXNetFile(const char* url, Option_t* option = "", const char* fTitle = "", Int_t compress = 1, Int_t netopt = -1)
                  virtual ~TXNetFile()
           static TClass* Class()
             virtual void Close(Option_t* opt = "")
             virtual void Flush()
           virtual Long_t GetRemoteFile(void**)
          virtual TClass* IsA() const
           virtual Bool_t IsOpen() const
                    Int_t LastBytesRecv()
                    Int_t LastBytesSent()
                    Int_t LastDataBytesRecv()
                    Int_t LastDataBytesSent()
                   Bool_t Open(Option_t* option, const char* fTitle, Int_t compress, Int_t netopt, Bool_t DoInit)
           virtual Bool_t OpenFileWhenRedirected(char* newfhandle, Bool_t& wasopen)
           virtual Bool_t ProcessUnsolicitedMsg(TXUnsolicitedMsgSender* sender, TXMessage* unsolmsg)
           virtual Bool_t ReadBuffer(char* buf, Int_t len)
            virtual Int_t ReOpen(Option_t* mode)
             virtual void ShowMembers(TMemberInspector& insp, char* parent)
                 Long64_t Size()
             virtual void Streamer(TBuffer& b)
                     void StreamerNVirtual(TBuffer& b)
           virtual Bool_t WriteBuffer(const char* buffer, Int_t BufferLength)

### Data Members

        private:

                 Bool_t fAlreadyStated
                 Bool_t fAlreadyDetected
             TXNetConn* fConnModule
                 Bool_t fCreateMode
                   char fHandle[4]           The file handle returned by the server,
                 Bool_t fIsROOT
            Params_Open fOpenPars            Just a container for the last parameters
                 Bool_t fOpenWithRefresh
               Long64_t fSize
          static Bool_t fgTagAlreadyPrinted

## Class Description

     TXNetFile

     TXNetFile is an extension of TNetFile able to deal with new xrootd
     server. Its new features are:
      - Automatic server kind recognition (xrootd load balancer, xrootd
        data server, old rootd)
      - Backward compatibility with old rootd server (acts as an old
        TNetFile)
      - Fault tolerance for read/write operations (read/write timeouts
        and retry)
      - Internal connection timeout (tunable indipendently from the OS
        one) handled by threads
      - handling of redirections from server
      - Single TCP physical channel for multiple TXNetFile's instances
        inside the same application
        So, each TXNetFile object client must send messages containing
        its ID (streamid). The server, of course, will respond with
        messages containing the client's ID, in order to make the client
        able to recognize its message by matching its streamid with that
        one contained in the server's response.
      - Tunable log verbosity level (0 = nothing, 3 = dump read/write
        buffers too!)
      - Many parameters configurable via TEnv facility (see SetParm()
        methods)

TXNetFile(const char *url, Option_t *option, const char* ftitle, Int_t compress, Int_t netopt) : TNetFile(url, ftitle, compress, kFALSE)

     Create a TXNetFile object. A TXNetFile object is the same as a TNetFile
     (from which the former derives) except that the protocol is extended to
     support dealing with new xrootd data server or xrootd load balancer
     server.

     The "url" argument must be of the form

       root://server1:port1[,server2:port2,...,serverN:portN]/pathfile,

     Note that this means that multiple servers (>= 1) can be specified in
     the url. The connection will try to connect to the first server:port
     and if that does not succeed, it will try the second one, and so on
     until it finds a server that will respond.

     See the TNetFile documentation for the description of the other arguments.

     The creation consists of internal variable settings (most important is
     the client's domain), creation of a TXUrl array containing all specified
     urls (a single url is serverX:portX/pathfile), trying to connect to the
     servers calling Connect() method, getting a valid access to the remote
     server the client is connected to using GetAccessToSrv() method,
     recognizing the remote server (if an old rootd the TNetFile's Create
     method will be called)

~TXNetFile()

     Destructor

void CreateTXNf(const char *url, Option_t *option, const char* ftitle, Int_t compress, Int_t netopt)

Bool_t ReadBuffer(char *buffer, Int_t BufferLength)

     Override TNetFile::ReadBuffer to deal with the xrootd server.
     Returns kTRUE in case of errors.

Bool_t WriteBuffer(const char *buffer, Int_t BufferLength)

     Override TNetFile::WriteBuffer to deal with the xrootd server.
     Returns kTRUE in case of errors.

Bool_t IsOpen() const

     Return kTRUE if the file is open, kFALSE otherwise

Int_t ReOpen(const Option_t *Mode)

     Re-open the file (see TNetFile::ReOpen() or TFile::ReOpen()
     for more details)

void Close(const Option_t *opt)

     Close the file (see TNetFile::Close() or TFile::Close()
     for more details)

void Flush()

     Flushes un-written data

Bool_t Open(Option_t *option, const char* ftitle, Int_t compress, Int_t netopt, Bool_t DoInit)

     High level open routine; if the remote server is an old rootd the file
     has been already opened by the TNetFile's Create() method

Bool_t LowOpen(const char* file, Option_t *option, const char* title, Int_t compress, Int_t netopt, Bool_t DoInit, Bool_t refresh_open)

     Low level Open method; deals with xrootd server

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)

Int_t SysClose(Int_t fd)

     Override TNetFile::SysClose (see parent's method for more details)

Int_t SysOpen(const char* pathname, Int_t flags, UInt_t mode)

     Override TNetFile::SysOpen (see parent's method for more details)

void Streamer(TBuffer &R__b)

     Stream an object of class TXNetFile.
     Dummy Streamer: rootcint chokes trying to generate one, but ROOT wants
     one to load the shared library.

Bool_t OpenFileWhenRedirected(char *newfhandle, Bool_t &wasopen)

     Called by the comm module when it needs to reopen a file
     after a redir

Long_t GetRemoteFile(void **bufFile)

     Retrieve a remote file a store it in memory

Bool_t ProcessUnsolicitedMsg(TXUnsolicitedMsgSender *, TXMessage *)

     We are here if an unsolicited response comes from a logical conn
     The response comes in the form of an TXMessage *, that must NOT be
     destroyed after processing. It is destroyed by the first sender.
     Remember that we are in a separate thread, since unsolicited
     responses are asynchronous by nature.

Int_t LastBytesSent(void)

     Return number of bytes last sent

Int_t LastBytesRecv(void)

     Return number of bytes last received

Int_t LastDataBytesSent(void)

     Return number of data bytes last sent

Int_t LastDataBytesRecv(void)

     Return number of data bytes last received

Long64_t Size(void)

     Return file size

### Inline Functions

                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void StreamerNVirtual(TBuffer& b)

Author: Alvise Dorigo, Fabrizio Furano
Last update: root/netx:$Name: $:$Id: TXNetFile.cxx,v 1.9 2005/05/12 12:25:26 rdm Exp $
Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *