Logo ROOT  
Reference Guide
TXNetSystem.h
Go to the documentation of this file.
1 // @(#)root/netx:$Id$
2 // Author: Frank Winklmeier, Fabrizio Furano
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, 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 #ifndef ROOT_TXNetSystem
13 #define ROOT_TXNetSystem
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TXNetSystem //
18 // //
19 // Authors: Frank Winklmeier, Fabrizio Furano //
20 // INFN Padova, 2005 //
21 // //
22 // TXNetSystem is an extension of TNetSystem able to deal with new //
23 // xrootd servers. The class detects the nature of the server and //
24 // redirects the calls to TNetSystem in case of a rootd server. //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 
28 #include "TNetFile.h"
29 
30 #include "Rtypes.h"
31 
32 #include "TString.h"
33 
34 #include "THashList.h"
35 
36 class XrdClientAdmin;
37 class TCollection;
39 
40 typedef /*XrdClientVector<XrdOucString>*/ void* VecStringVP_t;
41 
43 public:
44  TXrdClientAdminWrapper(const char *key, XrdClientAdmin *ca) : TNamed(key,""), fXCA(ca) { }
45  virtual ~TXrdClientAdminWrapper();
46  XrdClientAdmin *fXCA;
47 };
48 
49 class TXNetSystem : public TNetSystem {
50 
52 
53 private:
54  Bool_t fIsRootd; // Nature of remote file server
55  Bool_t fIsXRootd; // Nature of remote file server
56  TString fDir; // Current directory
57  void *fDirp; // Directory pointer
58  VecStringVP_t fDirList; // Buffer for directory content
59  TString fDirEntry; // Last dir entry
60  TString fUrl; // Initial url
61 
62  static Bool_t fgInitDone; // Avoid initializing more than once
63  static Bool_t fgRootdBC; // Control rootd backward compatibility
64 
65  XrdClientAdmin *Connect(const char *url); // Connect to server
66  void *GetDirPtr() const { return fDirp; }
67  void InitXrdClient();
68 
69  static THashList fgAddrFQDN; // Cross-table address<->FQDN
70  static THashList fgAdminHash; // List of existing XrdClientAdmin
71  static XrdClientAdmin *GetClientAdmin(const char *url);
72  static TString GetKey(const char *url);
73 
74 public:
75  TXNetSystem(Bool_t owner = kTRUE);
76  TXNetSystem(const char *url, Bool_t owner = kTRUE);
77  virtual ~TXNetSystem() { }
78 
79  Bool_t AccessPathName(const char *path, EAccessMode mode);
80  virtual Bool_t ConsistentWith(const char *path, void *dirptr);
81  virtual void FreeDirectory(void *dirp);
82  virtual const char *GetDirEntry(void *dirp);
83  virtual Int_t GetPathInfo(const char* path, FileStat_t &buf);
84  virtual Bool_t IsPathLocal(const char *path);
85  virtual Int_t Locate(const char* path, TString &endurl);
86  virtual Int_t MakeDirectory(const char* dir);
87  virtual void *OpenDirectory(const char* dir);
88  virtual int Unlink(const char *path);
89 
90  // TXNetSystem specific
91  Bool_t GetPathsInfo(const char *paths, UChar_t *info);
92  Bool_t IsOnline(const char *path);
93  Bool_t Prepare(const char *path, UChar_t opt = 8, UChar_t prio = 0);
94  Int_t Prepare(TCollection *paths,
95  UChar_t opt = 8, UChar_t prio = 0, TString *buf = 0);
96 
97  ClassDef(TXNetSystem,0) // System management class for xrootd servers
98 };
99 
100 //
101 // Simple guard class for connections
102 //
104 
105 private:
106  XrdClientAdmin *fClientAdmin; // Handle to the client admin object
107 
108 public:
109  TXNetSystemConnectGuard(TXNetSystem *xn, const char *url);
111 
112  bool IsValid() const { return ((fClientAdmin) ? 1 : 0); }
113 
114  XrdClientAdmin *ClientAdmin() const { return fClientAdmin; }
115 
116  void NotifyLastError();
117 };
118 
119 #endif
TXNetSystemConnectGuard::ClientAdmin
XrdClientAdmin * ClientAdmin() const
Definition: TXNetSystem.h:114
TXNetSystem::GetPathInfo
virtual Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
Definition: TXNetSystem.cxx:360
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TXNetSystemConnectGuard::NotifyLastError
void NotifyLastError()
Print message about last occured error.
Definition: TXNetSystem.cxx:781
TXNetSystem::IsPathLocal
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
Definition: TXNetSystem.cxx:635
TXNetSystem::fgAdminHash
static THashList fgAdminHash
Definition: TXNetSystem.h:70
TXNetSystem::fDirList
VecStringVP_t fDirList
Definition: TXNetSystem.h:58
FileStat_t
Definition: TSystem.h:124
TXNetSystemConnectGuard::TXNetSystemConnectGuard
TXNetSystemConnectGuard(TXNetSystem *xn, const char *url)
Construct a guard object.
Definition: TXNetSystem.cxx:761
TXNetSystem::fUrl
TString fUrl
Definition: TXNetSystem.h:60
TXNetSystem
Definition: TXNetSystem.h:49
TXNetSystem::Unlink
virtual int Unlink(const char *path)
Unlink 'path' on the remote server system.
Definition: TXNetSystem.cxx:457
TXNetSystem::GetClientAdmin
static XrdClientAdmin * GetClientAdmin(const char *url)
Checks if an admin for 'url' exists already.
Definition: TXNetSystem.cxx:704
Int_t
int Int_t
Definition: RtypesCore.h:45
TXNetSystem::TXNetSystem
TXNetSystem(Bool_t owner=kTRUE)
Create system management class without connecting to server.
Definition: TXNetSystem.cxx:67
TXNetSystem::IsOnline
Bool_t IsOnline(const char *path)
Check if the file defined by 'path' is ready to be used.
Definition: TXNetSystem.cxx:498
TXNetSystem::GetDirPtr
void * GetDirPtr() const
Definition: TXNetSystem.h:66
TXrdClientAdminWrapper::~TXrdClientAdminWrapper
virtual ~TXrdClientAdminWrapper()
Destructor: destroy the instance.
Definition: TXNetSystem.cxx:750
TString
Definition: TString.h:136
TXNetSystem::AccessPathName
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
Definition: TXNetSystem.cxx:436
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TString.h
bool
TXNetSystemConnectGuard::~TXNetSystemConnectGuard
~TXNetSystemConnectGuard()
Destructor: close the connection.
Definition: TXNetSystem.cxx:773
TXNetSystem::GetKey
static TString GetKey(const char *url)
Build from uu a unique ID key used in hash tables.
Definition: TXNetSystem.cxx:728
TXNetSystem::GetDirEntry
virtual const char * GetDirEntry(void *dirp)
Get directory entry for directory referenced by dirp.
Definition: TXNetSystem.cxx:317
TXNetSystem::ConsistentWith
virtual Bool_t ConsistentWith(const char *path, void *dirptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
Definition: TXNetSystem.cxx:420
TXrdClientAdminWrapper::fXCA
XrdClientAdmin * fXCA
Definition: TXNetSystem.h:46
TXNetSystem::GetPathsInfo
Bool_t GetPathsInfo(const char *paths, UChar_t *info)
Retrieve status of a ' '-separated list of files in 'paths'.
Definition: TXNetSystem.cxx:607
TXNetSystem::fgAddrFQDN
static THashList fgAddrFQDN
Definition: TXNetSystem.h:69
TXNetSystem::fgRootdBC
static Bool_t fgRootdBC
Definition: TXNetSystem.h:63
TXNetSystem::Locate
virtual Int_t Locate(const char *path, TString &endurl)
Get end-point url of a file.
Definition: TXNetSystem.cxx:655
THashList
Definition: THashList.h:34
TXNetSystem::fDirEntry
TString fDirEntry
Definition: TXNetSystem.h:59
TXNetSystemConnectGuard::IsValid
bool IsValid() const
Definition: TXNetSystem.h:112
TXNetSystem::Connect
XrdClientAdmin * Connect(const char *url)
Init a connection to the server.
Definition: TXNetSystem.cxx:114
TXNetSystem::fDirp
void * fDirp
Definition: TXNetSystem.h:57
TNamed
Definition: TNamed.h:29
VecStringVP_t
void * VecStringVP_t
Definition: TXNetSystem.h:38
TXNetSystem::fIsRootd
Bool_t fIsRootd
Definition: TXNetSystem.h:54
TNetFile.h
TXNetSystem::Prepare
Bool_t Prepare(const char *path, UChar_t opt=8, UChar_t prio=0)
Issue a prepare request for file defined by 'path'.
Definition: TXNetSystem.cxx:519
TXNetSystem::fIsXRootd
Bool_t fIsXRootd
Definition: TXNetSystem.h:55
TNetSystem
Definition: TNetFile.h:85
TXrdClientAdminWrapper
Definition: TXNetSystem.h:42
THashList.h
TXNetSystem::InitXrdClient
void InitXrdClient()
One-time initialization of some communication variables for xrootd protocol.
Definition: TXNetSystem.cxx:214
TXNetSystem::OpenDirectory
virtual void * OpenDirectory(const char *dir)
Open a directory.
Definition: TXNetSystem.cxx:232
EAccessMode
EAccessMode
Definition: TSystem.h:43
TXNetSystemConnectGuard::fClientAdmin
XrdClientAdmin * fClientAdmin
Definition: TXNetSystem.h:106
TXrdClientAdminWrapper::TXrdClientAdminWrapper
TXrdClientAdminWrapper(const char *key, XrdClientAdmin *ca)
Definition: TXNetSystem.h:44
TXNetSystem::fDir
TString fDir
Definition: TXNetSystem.h:56
TXNetSystem::~TXNetSystem
virtual ~TXNetSystem()
Definition: TXNetSystem.h:77
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
TXNetSystem::MakeDirectory
virtual Int_t MakeDirectory(const char *dir)
Create a directory. Return 0 on success, -1 otherwise.
Definition: TXNetSystem.cxx:291
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TXNetSystem::fgInitDone
static Bool_t fgInitDone
Definition: TXNetSystem.h:62
TXNetSystemConnectGuard
Definition: TXNetSystem.h:103
TCollection
Definition: TCollection.h:63
TXNetSystem::FreeDirectory
virtual void FreeDirectory(void *dirp)
Free(Close) the directory referenced by dirp.
Definition: TXNetSystem.cxx:265
Rtypes.h