XrdClientAdmin.hh

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //                                                                      //
00003 // XrdClientAdmin                                                       //
00004 //                                                                      //
00005 // Author: Fabrizio Furano (INFN Padova, 2004)                          //
00006 // Adapted from TXNetFile (root.cern.ch) originally done by             //
00007 //  Alvise Dorigo, Fabrizio Furano                                      //
00008 //          INFN Padova, 2003                                           //
00009 //                                                                      //
00010 // A UNIX reference admin client for xrootd.                            //
00011 //                                                                      //
00012 //////////////////////////////////////////////////////////////////////////
00013 
00014 //       $Id: XrdClientAdmin.hh 38011 2011-02-08 18:35:57Z ganis $
00015 
00016 #ifndef XRD_CLIENT_ADMIN_H
00017 #define XRD_CLIENT_ADMIN_H
00018 
00019 
00020 #include "XrdClient/XrdClientAbs.hh"
00021 #include "XrdClient/XrdClientVector.hh"
00022 #include "XrdOuc/XrdOucHash.hh"
00023 #include "XrdOuc/XrdOucString.hh"
00024 
00025 
00026 typedef XrdClientVector<XrdOucString> vecString;
00027 typedef XrdClientVector<bool> vecBool;
00028 
00029 void joinStrings(XrdOucString &buf, vecString &vs, int startidx = 0, int endidx=-1);
00030 
00031 struct XrdClientLocate_Info {
00032   enum {
00033     kXrdcLocNone,
00034     kXrdcLocDataServer,
00035     kXrdcLocDataServerPending,
00036     kXrdcLocManager,
00037     kXrdcLocManagerPending
00038   } Infotype;
00039 
00040   bool CanWrite;
00041 
00042   kXR_char Location[256];
00043 };
00044 
00045 class XrdClientAdmin : public XrdClientAbs {
00046 
00047    XrdOucString                    fInitialUrl;
00048    bool                            DirList_low(const char *dir, vecString &entries);
00049    int                             LocalLocate(kXR_char *path,
00050                                                XrdClientVector<XrdClientLocate_Info> &res,
00051                                                bool writable, int opts, bool all = false);
00052  protected:
00053 
00054    bool                            CanRedirOnError() {
00055      // We deny any redir on error
00056      return false;
00057    }
00058 
00059    // To be called after a redirection
00060    bool                            OpenFileWhenRedirected(char *, bool &);
00061 
00062  public:
00063    XrdClientAdmin(const char *url);
00064    virtual ~XrdClientAdmin();
00065 
00066    bool                            Connect();
00067 
00068    // Some administration functions, see the protocol specs for details
00069    bool                            SysStatX(const char *paths_list,
00070                                             kXR_char *binInfo);
00071 
00072    bool                            Stat(const char *fname,
00073                                         long &id,
00074                                         long long &size,
00075                                         long &flags,
00076                                         long &modtime);
00077 
00078 
00079    bool                            Stat_vfs(const char *fname,
00080                                             int &rwservers,
00081                                             long long &rwfree,
00082                                             int &rwutil,
00083                                             int &stagingservers,
00084                                             long long &stagingfree,
00085                                             int &stagingutil);
00086 
00087    bool                            DirList(const char *dir,
00088                                            vecString &entries, bool askallservers=false);
00089 
00090    struct DirListInfo {
00091       XrdOucString fullpath;
00092       XrdOucString host;
00093       long long size;
00094       long id;
00095       long flags;
00096       long modtime;
00097    };
00098    bool                            DirList(const char *dir,
00099                                            XrdClientVector<DirListInfo> &dirlistinfo,
00100                                            bool askallservers=false);
00101 
00102    bool                            ExistFiles(vecString&,
00103                                               vecBool&);
00104 
00105    bool                            ExistDirs(vecString&,
00106                                              vecBool&);
00107 
00108    // Compute an estimation of the available free space in the given cachefs partition
00109    // The estimation can be fooled if multiple servers mount the same network storage
00110    bool                            GetSpaceInfo(const char *logicalname,
00111                                                 long long &totspace,
00112                                                 long long &totfree,
00113                                                 long long &totused,
00114                                                 long long &largestchunk);
00115    
00116    long                            GetChecksum(kXR_char *path,
00117                                                kXR_char **chksum);
00118 
00119    // Quickly jump to the former redirector. Useful after having been redirected.
00120    void                            GoBackToRedirector();
00121 
00122    bool                            IsFileOnline(vecString&,
00123                                                 vecBool&);
00124 
00125    bool                            Mv(const char *fileSrc,
00126                                       const char *fileDest);
00127 
00128    bool                            Mkdir(const char *dir,
00129                                          int user,
00130                                          int group,
00131                                          int other);
00132 
00133    bool                            Chmod(const char *file,
00134                                          int user,
00135                                          int group,
00136                                          int other);
00137 
00138    bool                            Rm(const char *file);
00139 
00140    bool                            Rmdir(const char *path);
00141 
00142    bool                            Protocol(kXR_int32 &proto,
00143                                             kXR_int32 &kind);
00144 
00145    bool                            Prepare(vecString vs,
00146                                            kXR_char opts,
00147                                            kXR_char prty);
00148    bool                            Prepare(const char *paths,
00149                                            kXR_char opts,
00150                                            kXR_char prty);
00151 
00152    // Gives ONE location of a particular file... if present
00153    //  if writable is true only a writable location is searched
00154    //  but, if no writable locations are found, the result is negative but may
00155    //  propose a non writable one as a bonus
00156    bool                            Locate(kXR_char *path, XrdClientLocate_Info &resp,
00157                                           bool writable=false);
00158 
00159    // Gives ALL the locations of a particular file... if present
00160    bool                            Locate(kXR_char *path,
00161                                           XrdClientVector<XrdClientLocate_Info> &hosts)
00162    {
00163       return Locate( path, hosts, 0 );
00164    }
00165 
00166    bool                            Locate(kXR_char *path,
00167                                           XrdClientVector<XrdClientLocate_Info> &hosts,
00168                                           int opts );
00169 
00170 
00171    bool                            Truncate(const char *path, long long newsize);
00172    
00173    UnsolRespProcResult             ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *sender,
00174                                                          XrdClientMessage *unsolmsg);
00175 
00176 };
00177 
00178 #endif
00179 
00180 
00181 
00182 
00183 

Generated on Tue Jul 5 14:46:17 2011 for ROOT_528-00b_version by  doxygen 1.5.1