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");
163 TUrl uut((cadm->GetClientConn()
164 ->GetCurrentUrl()).GetUrl().c_str());
168 Info(
"Connect",
" url: %s",uu.Data());
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());
246 XrdOucString
s(
fDir.Data());
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!");
562 TString *buf = (bufout) ? bufout :
new TString();
569 while ((o = nxt())) {
573 Warning(
"Prepare",
"object is of unexpected type %s - ignoring", o->
ClassName());
579 path.ReplaceAll(
"\n",
"\r");
581 *buf +=
Form(
"%s\n", path.Data());
584 Info(
"Prepare",
"buffer ready: issuing prepare (opt=%d, prio=%d) ...",
586 cg.
ClientAdmin()->Prepare(buf->Data(), (kXR_char)opt, (kXR_char)prio);
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;
666 if (cg.
ClientAdmin()->Locate((kXR_char *)edir.Data(), li)) {
697 if (
gDebug > 0)
Info(
"Locate",
"server not Xrootd: method not implemented!");
707 XrdClientAdmin *ca = 0;
719 ca =
new XrdClientAdmin(url);
const char * GetDirEntry(void *dirp=0)
Get directory entry via rootd. Returns 0 in case no more entries.
TSystem * ROOT_Plugin_TXNetSystem(const char *url, Bool_t owner)
PluginManager creation function.
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
void NotifyLastError()
Print message about last occured error.
void SetRemoteProtocol(Int_t rproto)
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
static TString GetPathName(TObject *o)
Return the path name contained in object 'o' allowing for TUrl, TObjString or TFileInfo.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual int Unlink(const char *path)
Unlink 'path' on the remote server system.
void SetProtocol(const char *proto, Bool_t setDefaultPort=kFALSE)
Set protocol and, optionally, change the port accordingly.
Bool_t IsOnline(const char *path)
Check if the file defined by 'path' is ready to be used.
const char * GetHostName() const
virtual Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
This class represents a WWW compatible URL.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
This class represents an Internet Protocol (IP) address.
Bool_t AccessPathName(const char *path, EAccessMode mode)
Returns FALSE if one can access a file using the specified access mode.
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
R__EXTERN TVirtualMutex * gROOTMutex
static Int_t GetRootdProtocol(TSocket *s)
Find out the remote rootd protocol version.
void Create(const char *url, TSocket *sock=0)
Create a TNetSystem object.
static TString GetKey(const char *url)
Build from uu a unique ID key used in hash tables.
static THashList fgAdminHash
#define NAME_FIRSTCONNECTMAXCNT
TObject * FindObject(const char *name) const
Find object using its name.
Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
static THashList fgAddrFQDN
TXNetSystem(Bool_t owner=kTRUE)
Create system management class without connecting to server.
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
XrdClientVector< XrdOucString > VecString_t
void SetServType(Int_t st)
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.
const char * GetFile() const
TXNetSystemConnectGuard(TXNetSystem *xn, const char *url)
Construct a guard object.
const char * GetHost() const
virtual const char * ClassName() const
Returns name of class to which the object belongs.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
The TNamed class is the base class for all named ROOT classes.
virtual Bool_t ConsistentWith(const char *path, void *dirptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
static XrdClientAdmin * GetClientAdmin(const char *url)
Checks if an admin for 'url' exists already.
#define EnvPutInt(name, val)
virtual ~TXrdClientAdminWrapper()
Destructor: destroy the instance.
virtual Int_t Locate(const char *path, TString &endurl)
Get end-point url of a file.
static void SetEnv()
Set the relevant environment variables.
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
XrdClientAdmin * Connect(const char *url)
Init a connection to the server.
const char * GetUser() const
Bool_t GetPathsInfo(const char *paths, UChar_t *info)
Retrieve status of a ' '-separated list of files in 'paths'.
~TXNetSystemConnectGuard()
Destructor: close the connection.
R__EXTERN TSystem * gSystem
static void FormUrl(TUrl uut, TString &uu)
Form url for rootd socket.
virtual const char * GetDirEntry(void *dirp)
Get directory entry for directory referenced by dirp.
Collection abstract base class.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
void * OpenDirectory(const char *name)
Open a directory via rfiod.
Int_t MakeDirectory(const char *name)
Make a directory via rootd.
virtual void * OpenDirectory(const char *dir)
Open a directory.
XrdClientAdmin * fClientAdmin
Bool_t Prepare(const char *path, UChar_t opt=8, UChar_t prio=0)
Issue a prepare request for file defined by 'path'.
void SetHost(const char *host)
void InitXrdClient()
One-time initialization of some communication variables for xrootd protocol.
static RooMathCoreReg dummy
static constexpr double s
#define R__LOCKGUARD(mutex)
Mother of all ROOT objects.
Bool_t ConsistentWith(const char *path, void *dirptr)
Check consistency of this helper with the one required by 'path' or 'dirptr'.
virtual void FreeDirectory(void *dirp)
Free(Close) the directory referenced by dirp.
virtual void Add(TObject *obj)
virtual Int_t MakeDirectory(const char *dir)
Create a directory. Return 0 on success, -1 otherwise.
virtual Int_t GetPathInfo(const char *path, FileStat_t &buf)
Get info about a file.
void SetUrl(const char *url)
void SetService(const char *service)
virtual Int_t GetSize() const
Abstract base class defining a generic interface to the underlying Operating System.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
void InitRemoteEntity(const char *url)
Parse and save coordinates of the remote entity (user, host, port, ...)
XrdClientAdmin * ClientAdmin() const
void FreeDirectory(void *dirp=0)
Free directory via rootd.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual const char * GetTitle() const
Returns title of object.
Bool_t R_ISOFF(Int_t mode)