xrootd
XrdClientAdmin.hh
Go to the documentation of this file.
1 #ifndef XRD_CLIENT_ADMIN_H
2 #define XRD_CLIENT_ADMIN_H
3 /******************************************************************************/
4 /* */
5 /* X r d C l i e n t A d m i n . h h */
6 /* */
7 /* Author: Fabrizio Furano (INFN Padova, 2004) */
8 /* Adapted from TXNetFile (root.cern.ch) originally done by */
9 /* Alvise Dorigo, Fabrizio Furano */
10 /* INFN Padova, 2003 */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
34 // //
35 // A UNIX reference admin client for xrootd. //
36 // //
38 
41 #include "XrdOuc/XrdOucHash.hh"
42 #include "XrdOuc/XrdOucString.hh"
43 
46 
47 void joinStrings(XrdOucString &buf, vecString &vs, int startidx = 0, int endidx=-1);
48 
50  enum {
56  } Infotype;
57 
58  bool CanWrite;
59 
61 };
62 
63 class XrdClientAdmin : public XrdClientAbs {
64 
66  bool DirList_low(const char *dir, vecString &entries);
67  int LocalLocate(kXR_char *path,
69  bool writable, int opts, bool all = false);
70  protected:
71 
72  bool CanRedirOnError() {
73  // We deny any redir on error
74  return false;
75  }
76 
77  // To be called after a redirection
78  bool OpenFileWhenRedirected(char *, bool &);
79 
80  public:
81  XrdClientAdmin(const char *url);
82  virtual ~XrdClientAdmin();
83 
84  bool Connect();
85 
86  // Some administration functions, see the protocol specs for details
87  bool SysStatX(const char *paths_list,
88  kXR_char *binInfo);
89 
90  bool Stat(const char *fname,
91  long &id,
92  long long &size,
93  long &flags,
94  long &modtime);
95 
96 
97  bool Stat_vfs(const char *fname,
98  int &rwservers,
99  long long &rwfree,
100  int &rwutil,
101  int &stagingservers,
102  long long &stagingfree,
103  int &stagingutil);
104 
105  bool DirList(const char *dir,
106  vecString &entries, bool askallservers=false);
107 
108  struct DirListInfo {
111  long long size;
112  long id;
113  long flags;
114  long modtime;
115  };
116  bool DirList(const char *dir,
117  XrdClientVector<DirListInfo> &dirlistinfo,
118  bool askallservers=false);
119 
120  bool ExistFiles(vecString&,
121  vecBool&);
122 
123  bool ExistDirs(vecString&,
124  vecBool&);
125 
126  // Compute an estimation of the available free space in the given cachefs partition
127  // The estimation can be fooled if multiple servers mount the same network storage
128  bool GetSpaceInfo(const char *logicalname,
129  long long &totspace,
130  long long &totfree,
131  long long &totused,
132  long long &largestchunk);
133 
134  long GetChecksum(kXR_char *path,
135  kXR_char **chksum);
136 
137  // Quickly jump to the former redirector. Useful after having been redirected.
138  void GoBackToRedirector();
139 
140  bool IsFileOnline(vecString&,
141  vecBool&);
142 
143  bool Mv(const char *fileSrc,
144  const char *fileDest);
145 
146  bool Mkdir(const char *dir,
147  int user,
148  int group,
149  int other);
150 
151  bool Chmod(const char *file,
152  int user,
153  int group,
154  int other);
155 
156  bool Rm(const char *file);
157 
158  bool Rmdir(const char *path);
159 
160  bool Protocol(kXR_int32 &proto,
161  kXR_int32 &kind);
162 
163  bool Prepare(vecString vs,
164  kXR_char opts,
165  kXR_char prty);
166  bool Prepare(const char *paths,
167  kXR_char opts,
168  kXR_char prty);
169 
170  // Gives ONE location of a particular file... if present
171  // if writable is true only a writable location is searched
172  // but, if no writable locations are found, the result is negative but may
173  // propose a non writable one as a bonus
174  bool Locate(kXR_char *path, XrdClientLocate_Info &resp,
175  bool writable=false);
176 
177  // Gives ALL the locations of a particular file... if present
178  bool Locate(kXR_char *path,
180  {
181  return Locate( path, hosts, 0 );
182  }
183 
184  bool Locate(kXR_char *path,
186  int opts );
187 
188 
189  bool Truncate(const char *path, long long newsize);
190 
192  XrdClientMessage *unsolmsg);
193 
194 };
195 #endif
unsigned char kXR_char
Definition: XPtypes.hh:38
bool Chmod(const char *file, int user, int group, int other)
bool GetSpaceInfo(const char *logicalname, long long &totspace, long long &totfree, long long &totused, long long &largestchunk)
bool Protocol(kXR_int32 &proto, kXR_int32 &kind)
long modtime
Definition: XrdClientAdmin.hh:114
long id
Definition: XrdClientAdmin.hh:112
bool Stat_vfs(const char *fname, int &rwservers, long long &rwfree, int &rwutil, int &stagingservers, long long &stagingfree, int &stagingutil)
bool CanRedirOnError()
Definition: XrdClientAdmin.hh:72
virtual ~XrdClientAdmin()
int LocalLocate(kXR_char *path, XrdClientVector< XrdClientLocate_Info > &res, bool writable, int opts, bool all=false)
XrdOucString fInitialUrl
Definition: XrdClientAdmin.hh:65
enum XrdClientLocate_Info::@13 Infotype
bool Locate(kXR_char *path, XrdClientVector< XrdClientLocate_Info > &hosts)
Definition: XrdClientAdmin.hh:178
long long size
Definition: XrdClientAdmin.hh:111
Definition: XrdClientAdmin.hh:63
bool Stat(const char *fname, long &id, long long &size, long &flags, long &modtime)
Definition: XrdClientAdmin.hh:51
UnsolRespProcResult ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *sender, XrdClientMessage *unsolmsg)
bool Rm(const char *file)
bool SysStatX(const char *paths_list, kXR_char *binInfo)
bool IsFileOnline(vecString &, vecBool &)
Definition: XrdClientUnsolMsg.hh:63
kXR_char Location[256]
Definition: XrdClientAdmin.hh:60
bool Prepare(vecString vs, kXR_char opts, kXR_char prty)
XrdClientVector< bool > vecBool
Definition: XrdClientAdmin.hh:45
bool OpenFileWhenRedirected(char *, bool &)
bool DirList(const char *dir, vecString &entries, bool askallservers=false)
long GetChecksum(kXR_char *path, kXR_char **chksum)
Definition: XrdClientAdmin.hh:54
bool Mv(const char *fileSrc, const char *fileDest)
UnsolRespProcResult
Definition: XrdClientUnsolMsg.hh:43
Definition: XrdClientAdmin.hh:55
bool ExistDirs(vecString &, vecBool &)
XrdOucString fullpath
Definition: XrdClientAdmin.hh:109
bool Mkdir(const char *dir, int user, int group, int other)
Definition: XrdClientVector.hh:49
XrdClientVector< XrdOucString > vecString
Definition: XrdClientAdmin.hh:44
XrdOucString host
Definition: XrdClientAdmin.hh:110
bool Locate(kXR_char *path, XrdClientLocate_Info &resp, bool writable=false)
bool CanWrite
Definition: XrdClientAdmin.hh:58
void joinStrings(XrdOucString &buf, vecString &vs, int startidx=0, int endidx=-1)
Definition: XrdClientAdmin.hh:52
XrdClientAdmin(const char *url)
bool Rmdir(const char *path)
int kXR_int32
Definition: XPtypes.hh:62
void GoBackToRedirector()
Definition: XrdClientAdmin.hh:49
bool Truncate(const char *path, long long newsize)
long flags
Definition: XrdClientAdmin.hh:113
Definition: XrdClientAdmin.hh:108
Definition: XrdClientAbs.hh:49
bool ExistFiles(vecString &, vecBool &)
Definition: XrdOucString.hh:254
Definition: XrdClientAdmin.hh:53
bool DirList_low(const char *dir, vecString &entries)