|
xrootd
|
00001 #ifndef XRD_CLIENT_ADMIN_H 00002 #define XRD_CLIENT_ADMIN_H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C l i e n t A d m i n . h h */ 00006 /* */ 00007 /* Author: Fabrizio Furano (INFN Padova, 2004) */ 00008 /* Adapted from TXNetFile (root.cern.ch) originally done by */ 00009 /* Alvise Dorigo, Fabrizio Furano */ 00010 /* INFN Padova, 2003 */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00034 // // 00035 // A UNIX reference admin client for xrootd. // 00036 // // 00038 00039 #include "XrdClient/XrdClientAbs.hh" 00040 #include "XrdClient/XrdClientVector.hh" 00041 #include "XrdOuc/XrdOucHash.hh" 00042 #include "XrdOuc/XrdOucString.hh" 00043 00044 typedef XrdClientVector<XrdOucString> vecString; 00045 typedef XrdClientVector<bool> vecBool; 00046 00047 void joinStrings(XrdOucString &buf, vecString &vs, int startidx = 0, int endidx=-1); 00048 00049 struct XrdClientLocate_Info { 00050 enum { 00051 kXrdcLocNone, 00052 kXrdcLocDataServer, 00053 kXrdcLocDataServerPending, 00054 kXrdcLocManager, 00055 kXrdcLocManagerPending 00056 } Infotype; 00057 00058 bool CanWrite; 00059 00060 kXR_char Location[256]; 00061 }; 00062 00063 class XrdClientAdmin : public XrdClientAbs { 00064 00065 XrdOucString fInitialUrl; 00066 bool DirList_low(const char *dir, vecString &entries); 00067 int LocalLocate(kXR_char *path, 00068 XrdClientVector<XrdClientLocate_Info> &res, 00069 bool writable, int opts, bool all = false); 00070 protected: 00071 00072 bool CanRedirOnError() { 00073 // We deny any redir on error 00074 return false; 00075 } 00076 00077 // To be called after a redirection 00078 bool OpenFileWhenRedirected(char *, bool &); 00079 00080 public: 00081 XrdClientAdmin(const char *url); 00082 virtual ~XrdClientAdmin(); 00083 00084 bool Connect(); 00085 00086 // Some administration functions, see the protocol specs for details 00087 bool SysStatX(const char *paths_list, 00088 kXR_char *binInfo); 00089 00090 bool Stat(const char *fname, 00091 long &id, 00092 long long &size, 00093 long &flags, 00094 long &modtime); 00095 00096 00097 bool Stat_vfs(const char *fname, 00098 int &rwservers, 00099 long long &rwfree, 00100 int &rwutil, 00101 int &stagingservers, 00102 long long &stagingfree, 00103 int &stagingutil); 00104 00105 bool DirList(const char *dir, 00106 vecString &entries, bool askallservers=false); 00107 00108 struct DirListInfo { 00109 XrdOucString fullpath; 00110 XrdOucString host; 00111 long long size; 00112 long id; 00113 long flags; 00114 long modtime; 00115 }; 00116 bool DirList(const char *dir, 00117 XrdClientVector<DirListInfo> &dirlistinfo, 00118 bool askallservers=false); 00119 00120 bool ExistFiles(vecString&, 00121 vecBool&); 00122 00123 bool ExistDirs(vecString&, 00124 vecBool&); 00125 00126 // Compute an estimation of the available free space in the given cachefs partition 00127 // The estimation can be fooled if multiple servers mount the same network storage 00128 bool GetSpaceInfo(const char *logicalname, 00129 long long &totspace, 00130 long long &totfree, 00131 long long &totused, 00132 long long &largestchunk); 00133 00134 long GetChecksum(kXR_char *path, 00135 kXR_char **chksum); 00136 00137 // Quickly jump to the former redirector. Useful after having been redirected. 00138 void GoBackToRedirector(); 00139 00140 bool IsFileOnline(vecString&, 00141 vecBool&); 00142 00143 bool Mv(const char *fileSrc, 00144 const char *fileDest); 00145 00146 bool Mkdir(const char *dir, 00147 int user, 00148 int group, 00149 int other); 00150 00151 bool Chmod(const char *file, 00152 int user, 00153 int group, 00154 int other); 00155 00156 bool Rm(const char *file); 00157 00158 bool Rmdir(const char *path); 00159 00160 bool Protocol(kXR_int32 &proto, 00161 kXR_int32 &kind); 00162 00163 bool Prepare(vecString vs, 00164 kXR_char opts, 00165 kXR_char prty); 00166 bool Prepare(const char *paths, 00167 kXR_char opts, 00168 kXR_char prty); 00169 00170 // Gives ONE location of a particular file... if present 00171 // if writable is true only a writable location is searched 00172 // but, if no writable locations are found, the result is negative but may 00173 // propose a non writable one as a bonus 00174 bool Locate(kXR_char *path, XrdClientLocate_Info &resp, 00175 bool writable=false); 00176 00177 // Gives ALL the locations of a particular file... if present 00178 bool Locate(kXR_char *path, 00179 XrdClientVector<XrdClientLocate_Info> &hosts) 00180 { 00181 return Locate( path, hosts, 0 ); 00182 } 00183 00184 bool Locate(kXR_char *path, 00185 XrdClientVector<XrdClientLocate_Info> &hosts, 00186 int opts ); 00187 00188 00189 bool Truncate(const char *path, long long newsize); 00190 00191 UnsolRespProcResult ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *sender, 00192 XrdClientMessage *unsolmsg); 00193 00194 }; 00195 #endif
1.7.6.1