37#include "XrdOuc/XrdOucString.hh"
39#include "XrdClient/XrdClientAdmin.hh"
43#include "XProtocol/XProtocol.hh"
70 SetTitle(
"(x)rootd system administration");
83 SetTitle(
"(x)rootd system administration");
105 Error(
"TXNetSystem",
"fatal error: connection creation failed.");
124 Error(
"Connect",
"fatal error: new object creation failed.");
134 if (cadm->Connect()) {
141 (cadm->GetClientConn()->GetServerType() ==
kSTRootd);
142 Int_t sd = cadm->GetClientConn()->GetOpenSockFD();
143 if (isRootd && sd > -1) {
150 gROOT->GetListOfSockets()->Remove(
s);
157 Error(
"TXNetSystem",
"getting protocol of the rootd server");
162 s->SetRemoteProtocol(rproto);
163 TUrl uut((cadm->GetClientConn()
164 ->GetCurrentUrl()).GetUrl().c_str());
168 Info(
"Connect",
" url: %s",uu.
Data());
170 s->SetUrl(uu.
Data());
171 s->SetService(
"rootd");
192 Error(
"Connect",
"some severe error occurred while opening"
193 " the connection at %s - exit", url);
194 if (cadm && cadm->LastServerError())
195 Printf(
" '%s'", cadm->LastServerError()->errmsg);
197 Printf(
" (error message not available)");
203 "while opening the connection at %s - exit", url);
225 Info(
"TXNetFile",
"(C) 2005 SLAC TXNetSystem (eXtended TNetSystem) %s",
226 gROOT->GetVersion());
250 if (existDirs.GetSize()>0 && existDirs[0])
259 Info(
"OpenDirectory",
"calling TNetSystem::OpenDirectory");
270 Error(
"FreeDirectory",
"invalid directory pointer (%p, %p)", dirp,
fDirp);
285 Info(
"FreeDirectory",
"calling TNetSystem::FreeDirectory");
310 Info(
"MakeDirectory",
"Calling TNetSystem::MakeDirectory");
322 Error(
"GetDirEntry",
"invalid directory pointer");
350 if (
gDebug > 1)
Info(
"GetDirEntry",
"Calling TNetSystem::GetDirEntry");
385 if (flags & kXR_offline) {
388 buf.
fDev = (
id >> 24);
389 buf.
fIno = (
id & 0x00FFFFFF);
413 Info(
"GetPathInfo",
"Calling TNetSystem::GetPathInfo");
424 Info(
"ConsistentWith",
425 "calling for path: %s, dir: %p", path, dirptr);
450 Info(
"AccessPathName",
"calling TNetSystem::AccessPathName");
475 if (ok && !(flags & kXR_offline)) {
476 if (flags & kXR_isDir)
483 return ((ok) ? 0 : -1);
492 Info(
"Unlink",
"calling TNetSystem::Unlink");
505 Info(
"IsOnline",
"path '%s' cannot be stat'ed", path);
510 Info(
"IsOnline",
"path '%s' is offline", path);
526 vs.Push_back(pathname);
527 cg.
ClientAdmin()->Prepare(vs, (kXR_char)option, (kXR_char)priority);
530 Info(
"Prepare",
"Got Status %d for %s",
531 cg.
ClientAdmin()->LastServerResp()->status, pathname.c_str());
532 if (!(cg.
ClientAdmin()->LastServerResp()->status)){
553 Warning(
"Prepare",
"input list is empty!");
569 while ((o = nxt())) {
573 Warning(
"Prepare",
"object is of unexpected type %s - ignoring", o->
ClassName());
584 Info(
"Prepare",
"buffer ready: issuing prepare (opt=%d, prio=%d) ...",
591 Info(
"Prepare",
"Got Status %d",
593 if (!(cg.
ClientAdmin()->LastServerResp()->status)){
611 Warning(
"GetPathsInfo",
"input list is empty!");
620 Info(
"GetPathsInfo",
"Got Status %d",
622 if (!(cg.
ClientAdmin()->LastServerResp()->status)){
663 XrdClientLocate_Info li;
675 if (strlen(
a.GetHostName()) > 0)
697 if (
gDebug > 0)
Info(
"Locate",
"server not Xrootd: method not implemented!");
707 XrdClientAdmin *ca = 0;
719 ca =
new XrdClientAdmin(url);
static RooMathCoreReg dummy
R__EXTERN TVirtualMutex * gROOTMutex
char * Form(const char *fmt,...)
void Printf(const char *fmt,...)
Bool_t R_ISOFF(Int_t mode)
R__EXTERN TSystem * gSystem
#define R__LOCKGUARD(mutex)
TSystem * ROOT_Plugin_TXNetSystem(const char *url, Bool_t owner)
PluginManager creation function.
XrdClientVector< XrdOucString > VecString_t
#define NAME_FIRSTCONNECTMAXCNT
#define EnvPutInt(name, val)
Collection abstract base class.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
static TString GetPathName(TObject *o)
Return the path name contained in object 'o' allowing for TUrl, TObjString or TFileInfo.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
TObject * FindObject(const char *name) const
Find object using its name.
This class represents an Internet Protocol (IP) address.
virtual void Add(TObject *obj)
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
const char * GetDirEntry(void *dirp=0)
Get directory entry via rootd. Returns 0 in case no more entries.
void InitRemoteEntity(const char *url)
Parse and save coordinates of the remote entity (user, host, port, ...)
Int_t MakeDirectory(const char *name)
Make a directory via rootd.
void Create(const char *url, TSocket *sock=0)
Create a TNetSystem object.
void FreeDirectory(void *dirp=0)
Free directory via rootd.
Bool_t ConsistentWith(const char *path, void *dirptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
void * OpenDirectory(const char *name)
Open a directory and return an opaque pointer to a dir structure.
Mother of all ROOT objects.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void Clear()
Clear string without changing its capacity.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Abstract base class defining a generic interface to the underlying Operating System.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
This class represents a WWW compatible URL.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
const char * GetFile() const
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
const char * GetUser() const
const char * GetHost() const
void SetHost(const char *host)
static void SetEnv()
Set the relevant environment variables.
static void FormUrl(TUrl uut, TString &uu)
Form url for rootd socket.
static Int_t GetRootdProtocol(TSocket *s)
Find out the remote rootd protocol version.
~TXNetSystemConnectGuard()
Destructor: close the connection.
XrdClientAdmin * fClientAdmin
TXNetSystemConnectGuard(TXNetSystem *xn, const char *url)
Construct a guard object.
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'.
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
static THashList fgAddrFQDN
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.
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'.
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.
TXNetSystem(Bool_t owner=kTRUE)
Create system management class without connecting to server.
virtual void FreeDirectory(void *dirp)
Free(Close) the directory referenced by dirp.
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
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.
Bool_t Prepare(const char *path, UChar_t opt=8, UChar_t prio=0)
Issue a prepare request for file defined by 'path'.
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.
virtual ~TXrdClientAdminWrapper()
Destructor: destroy the instance.
static constexpr double s