Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
36class XrdClientAdmin;
37class TCollection;
39
40typedef /*XrdClientVector<XrdOucString>*/ void* VecStringVP_t;
41
43public:
44 TXrdClientAdminWrapper(const char *key, XrdClientAdmin *ca) : TNamed(key,""), fXCA(ca) { }
46 XrdClientAdmin *fXCA;
47};
48
49class TXNetSystem : public TNetSystem {
50
52
53private:
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
74public:
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);
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
105private:
106 XrdClientAdmin *fClientAdmin; // Handle to the client admin object
107
108public:
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
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned char UChar_t
Definition RtypesCore.h:38
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassDef(name, id)
Definition Rtypes.h:337
Option_t Option_t TPoint TPoint const char mode
EAccessMode
Definition TSystem.h:41
void * VecStringVP_t
Definition TXNetSystem.h:40
Collection abstract base class.
Definition TCollection.h:65
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Basic string class.
Definition TString.h:139
~TXNetSystemConnectGuard()
Destructor: close the connection.
XrdClientAdmin * fClientAdmin
void NotifyLastError()
Print message about last occured error.
XrdClientAdmin * ClientAdmin() const
virtual Bool_t ConsistentWith(const char *path, void *dirptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
static Bool_t fgRootdBC
Definition TXNetSystem.h:63
virtual ~TXNetSystem()
Definition TXNetSystem.h:77
void * fDirp
Definition TXNetSystem.h:57
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
static THashList fgAddrFQDN
Definition TXNetSystem.h:69
static XrdClientAdmin * GetClientAdmin(const char *url)
Checks if an admin for 'url' exists already.
virtual int Unlink(const char *path)
Unlink 'path' on the remote server system.
void * GetDirPtr() const
Definition TXNetSystem.h:66
virtual Int_t MakeDirectory(const char *dir)
Create a directory. Return 0 on success, -1 otherwise.
Bool_t GetPathsInfo(const char *paths, UChar_t *info)
Retrieve status of a ' '-separated list of files in 'paths'.
Bool_t fIsRootd
Definition TXNetSystem.h:54
TString fDir
Definition TXNetSystem.h:56
TString fDirEntry
Definition TXNetSystem.h:59
Bool_t fIsXRootd
Definition TXNetSystem.h:55
void InitXrdClient()
One-time initialization of some communication variables for xrootd protocol.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual void FreeDirectory(void *dirp)
Free(Close) the directory referenced by dirp.
VecStringVP_t fDirList
Definition TXNetSystem.h:58
virtual void * OpenDirectory(const char *dir)
Open a directory.
virtual Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
static THashList fgAdminHash
Definition TXNetSystem.h:70
Bool_t IsOnline(const char *path)
Check if the file defined by 'path' is ready to be used.
virtual const char * GetDirEntry(void *dirp)
Get directory entry for directory referenced by dirp.
static Bool_t fgInitDone
Definition TXNetSystem.h:62
Bool_t Prepare(const char *path, UChar_t opt=8, UChar_t prio=0)
Issue a prepare request for file defined by 'path'.
TString fUrl
Definition TXNetSystem.h:60
static TString GetKey(const char *url)
Build from uu a unique ID key used in hash tables.
virtual Int_t Locate(const char *path, TString &endurl)
Get end-point url of a file.
XrdClientAdmin * Connect(const char *url)
Init a connection to the server.
XrdClientAdmin * fXCA
Definition TXNetSystem.h:46
virtual ~TXrdClientAdminWrapper()
Destructor: destroy the instance.
TXrdClientAdminWrapper(const char *key, XrdClientAdmin *ca)
Definition TXNetSystem.h:44