xrootd
XrdClientAdmin.hh
Go to the documentation of this file.
1 
2 // //
3 // XrdClientAdmin //
4 // //
5 // Author: Fabrizio Furano (INFN Padova, 2004) //
6 // Adapted from TXNetFile (root.cern.ch) originally done by //
7 // Alvise Dorigo, Fabrizio Furano //
8 // INFN Padova, 2003 //
9 // //
10 // A UNIX reference admin client for xrootd. //
11 // //
13 
14 // $Id$
15 
16 #ifndef XRD_CLIENT_ADMIN_H
17 #define XRD_CLIENT_ADMIN_H
18 
19 
22 #include "XrdOuc/XrdOucHash.hh"
23 #include "XrdOuc/XrdOucString.hh"
24 
25 
28 
29 void joinStrings(XrdOucString &buf, vecString &vs, int startidx = 0, int endidx=-1);
30 
32  enum {
38  } Infotype;
39 
40  bool CanWrite;
41 
43 };
44 
45 class XrdClientAdmin : public XrdClientAbs {
46 
48  bool DirList_low(const char *dir, vecString &entries);
49  int LocalLocate(kXR_char *path,
51  bool writable, int opts, bool all = false);
52  protected:
53 
54  bool CanRedirOnError() {
55  // We deny any redir on error
56  return false;
57  }
58 
59  // To be called after a redirection
60  bool OpenFileWhenRedirected(char *, bool &);
61 
62  public:
63  XrdClientAdmin(const char *url);
64  virtual ~XrdClientAdmin();
65 
66  bool Connect();
67 
68  // Some administration functions, see the protocol specs for details
69  bool SysStatX(const char *paths_list,
70  kXR_char *binInfo);
71 
72  bool Stat(const char *fname,
73  long &id,
74  long long &size,
75  long &flags,
76  long &modtime);
77 
78 
79  bool Stat_vfs(const char *fname,
80  int &rwservers,
81  long long &rwfree,
82  int &rwutil,
83  int &stagingservers,
84  long long &stagingfree,
85  int &stagingutil);
86 
87  bool DirList(const char *dir,
88  vecString &entries, bool askallservers=false);
89 
90  struct DirListInfo {
93  long long size;
94  long id;
95  long flags;
96  long modtime;
97  };
98  bool DirList(const char *dir,
99  XrdClientVector<DirListInfo> &dirlistinfo,
100  bool askallservers=false);
101 
102  bool ExistFiles(vecString&,
103  vecBool&);
104 
105  bool ExistDirs(vecString&,
106  vecBool&);
107 
108  // Compute an estimation of the available free space in the given cachefs partition
109  // The estimation can be fooled if multiple servers mount the same network storage
110  bool GetSpaceInfo(const char *logicalname,
111  long long &totspace,
112  long long &totfree,
113  long long &totused,
114  long long &largestchunk);
115 
116  long GetChecksum(kXR_char *path,
117  kXR_char **chksum);
118 
119  // Quickly jump to the former redirector. Useful after having been redirected.
120  void GoBackToRedirector();
121 
122  bool IsFileOnline(vecString&,
123  vecBool&);
124 
125  bool Mv(const char *fileSrc,
126  const char *fileDest);
127 
128  bool Mkdir(const char *dir,
129  int user,
130  int group,
131  int other);
132 
133  bool Chmod(const char *file,
134  int user,
135  int group,
136  int other);
137 
138  bool Rm(const char *file);
139 
140  bool Rmdir(const char *path);
141 
142  bool Protocol(kXR_int32 &proto,
143  kXR_int32 &kind);
144 
145  bool Prepare(vecString vs,
146  kXR_char opts,
147  kXR_char prty);
148  bool Prepare(const char *paths,
149  kXR_char opts,
150  kXR_char prty);
151 
152  // Gives ONE location of a particular file... if present
153  // if writable is true only a writable location is searched
154  // but, if no writable locations are found, the result is negative but may
155  // propose a non writable one as a bonus
156  bool Locate(kXR_char *path, XrdClientLocate_Info &resp,
157  bool writable=false);
158 
159  // Gives ALL the locations of a particular file... if present
160  bool Locate(kXR_char *path,
162  {
163  return Locate( path, hosts, 0 );
164  }
165 
166  bool Locate(kXR_char *path,
168  int opts );
169 
170 
171  bool Truncate(const char *path, long long newsize);
172 
174  XrdClientMessage *unsolmsg);
175 
176 };
177 
178 #endif
179 
180 
181 
182 
183