|
xrootd
|
00001 #ifndef __CMS_NODE__H 00002 #define __CMS_NODE__H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s N o d e . h h */ 00006 /* */ 00007 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 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 00033 #include <string.h> 00034 #include <unistd.h> 00035 #include <sys/uio.h> 00036 00037 #include "Xrd/XrdLink.hh" 00038 #include "XrdCms/XrdCmsTypes.hh" 00039 #include "XrdCms/XrdCmsRRQ.hh" 00040 #include "XrdSys/XrdSysPthread.hh" 00041 00042 class XrdCmsBaseFR; 00043 class XrdCmsBaseFS; 00044 class XrdCmsDrop; 00045 class XrdCmsPrepArgs; 00046 class XrdCmsRRData; 00047 class XrdCmsSelected; 00048 class XrdOucProg; 00049 00050 class XrdCmsNode 00051 { 00052 friend class XrdCmsCluster; 00053 public: 00054 char *Ident; // -> role hostname 00055 char isDisable; //0 Set via admin command to temporarily remove node 00056 char isOffline; //1 Set when a link failure occurs 00057 char isNoStage; //2 Set upon a nostage event 00058 char isMan; //3 Set when node acts as manager 00059 char isPeer; //4 Set when node acts as peer manager 00060 char isProxy; //5 Set when node acts as a proxy 00061 char isSuspend; //6 Set upon a suspend event 00062 char isBound; //7 Set when node is in the configuration 00063 char isRW; //0 Set when node can write or stage data 00064 char isKnown; //1 Set when we have recieved a "state" 00065 char isConn; //2 Set when node is network connected 00066 char isGone; //3 Set when node must be deleted 00067 char isPerm; //4 Set when node is permanently bound 00068 char isReserved[2]; 00069 char RoleID; // The converted XrdCmsRole::RoleID 00070 char TimeZone; // Time zone in +UTC- 00071 char TZValid; // Time zone has been set 00072 00073 static const char allowsRW = 0x01; // in isRW -> Server allows r/w access 00074 static const char allowsSS = 0x02; // in isRW -> Server can stage data 00075 00076 unsigned int DiskTotal; // Total disk space in GB 00077 int DiskNums; // Number of file systems 00078 int DiskMinF; // Minimum MB needed for selection 00079 int DiskFree; // Largest free MB 00080 int DiskUtil; // Total disk utilization 00081 unsigned int ConfigID; // Configuration identifier 00082 00083 const char *do_Avail(XrdCmsRRData &Arg); 00084 const char *do_Chmod(XrdCmsRRData &Arg); 00085 const char *do_Disc(XrdCmsRRData &Arg); 00086 const char *do_Gone(XrdCmsRRData &Arg); 00087 const char *do_Have(XrdCmsRRData &Arg); 00088 const char *do_Load(XrdCmsRRData &Arg); 00089 const char *do_Locate(XrdCmsRRData &Arg); 00090 static int do_LocFmt(char *buff, XrdCmsSelected *sP, SMask_t pf, SMask_t wf); 00091 const char *do_Mkdir(XrdCmsRRData &Arg); 00092 const char *do_Mkpath(XrdCmsRRData &Arg); 00093 const char *do_Mv(XrdCmsRRData &Arg); 00094 const char *do_Ping(XrdCmsRRData &Arg); 00095 const char *do_Pong(XrdCmsRRData &Arg); 00096 const char *do_PrepAdd(XrdCmsRRData &Arg); 00097 const char *do_PrepDel(XrdCmsRRData &Arg); 00098 const char *do_Rm(XrdCmsRRData &Arg); 00099 const char *do_Rmdir(XrdCmsRRData &Arg); 00100 const char *do_Select(XrdCmsRRData &Arg); 00101 static int do_SelPrep(XrdCmsPrepArgs &Arg); 00102 const char *do_Space(XrdCmsRRData &Arg); 00103 const char *do_State(XrdCmsRRData &Arg); 00104 static void do_StateDFS(XrdCmsBaseFR *rP, int rc); 00105 int do_StateFWD(XrdCmsRRData &Arg); 00106 const char *do_StatFS(XrdCmsRRData &Arg); 00107 const char *do_Stats(XrdCmsRRData &Arg); 00108 const char *do_Status(XrdCmsRRData &Arg); 00109 const char *do_Trunc(XrdCmsRRData &Arg); 00110 const char *do_Try(XrdCmsRRData &Arg); 00111 const char *do_Update(XrdCmsRRData &Arg); 00112 const char *do_Usage(XrdCmsRRData &Arg); 00113 00114 void Disc(const char *reason=0, int needLock=1); 00115 00116 inline int ID(int &INum) {INum = Instance; return NodeID;} 00117 00118 inline int Inst() {return Instance;} 00119 00120 inline int isNode(SMask_t smask) {return (smask & NodeMask) != 0;} 00121 inline int isNode(const char *hn) 00122 {return Link && !strcmp(Link->Host(), hn);} 00123 inline int isNode(unsigned int ipa) 00124 {return ipa == IPAddr;} 00125 inline int isNode(unsigned int ipa, const char *nid) 00126 {return ipa == IPAddr && (nid ? !strcmp(myNID, nid) : 1);} 00127 inline char *Name() {return (myName ? myName : (char *)"?");} 00128 00129 inline char *Name(int &len, int &port) 00130 {len = myNlen; port = Port; return myName;} 00131 00132 inline SMask_t Mask() {return NodeMask;} 00133 00134 inline void Lock() {myMutex.Lock(); isLocked = 1;} 00135 inline void UnLock() {isLocked = 0; myMutex.UnLock();} 00136 00137 static void Report_Usage(XrdLink *lp); 00138 00139 inline int Send(const char *buff, int blen=0) 00140 {return (isOffline ? -1 : Link->Send(buff, blen));} 00141 inline int Send(const struct iovec *iov, int iovcnt, int iotot=0) 00142 {return (isOffline ? -1 : Link->Send(iov, iovcnt, iotot));} 00143 00144 void setName(XrdLink *lnkp, int port); 00145 00146 void setShare(int shrval) 00147 {if (shrval > 99) Shrem = Shrip = Share = 0; 00148 else {Shrem = Share = shrval; Shrip = 100 - shrval;} 00149 } 00150 00151 int setTZone(int tZone) 00152 {TimeZone = tZone & 0x0f; 00153 if (tZone & 0x10) TimeZone = -TimeZone; 00154 TZValid = (tZone != 0); 00155 return TimeZone; 00156 } 00157 00158 inline void setSlot(short rslot) {RSlot = rslot;} 00159 inline short getSlot() {return RSlot;} 00160 00161 void SyncSpace(); 00162 00163 XrdCmsNode(XrdLink *lnkp, int port=0, 00164 const char *sid=0, int lvl=0, int id=-1); 00165 ~XrdCmsNode(); 00166 00167 private: 00168 static const int fsL2PFail1 = 999991; 00169 static const int fsL2PFail2 = 999992; 00170 00171 int fsExec(XrdOucProg *Prog, char *Arg1, char *Arg2=0); 00172 const char *fsFail(const char *Who, const char *What, const char *Path, int rc); 00173 int getMode(const char *theMode, mode_t &Mode); 00174 int getSize(const char *theSize, long long &Size); 00175 00176 XrdSysMutex myMutex; 00177 XrdLink *Link; 00178 unsigned int IPAddr; 00179 XrdCmsNode *Next; 00180 time_t DropTime; 00181 XrdCmsDrop *DropJob; 00182 int IPV6Len; // 12345678901234567890123456 00183 char IPV6[28]; // [::123.123.123.123]:123456 00184 00185 SMask_t NodeMask; 00186 int NodeID; 00187 int Instance; 00188 int Port; 00189 int myLevel; 00190 int myCNUM; 00191 char *myCID; 00192 char *myNID; 00193 char *myName; 00194 int myNlen; 00195 00196 int logload; 00197 int myCost; // Overall cost (determined by location) 00198 int myLoad; // Overall load 00199 int myMass; // Overall load including space utilization 00200 int RefW; // Number of times used for writing 00201 int RefTotW; 00202 int RefR; // Number of times used for redirection 00203 int RefTotR; 00204 short RSlot; 00205 char isLocked; 00206 char Share; // Share of requests for this node (0 -> n/a) 00207 char Shrem; // Share of requests left 00208 char Shrip; // Share of requests to skip 00209 char Rsvd[2]; 00210 int Shrin; // Share intervals used 00211 00212 // The following fields are used to keep the supervisor's free space value 00213 // 00214 static XrdSysMutex mlMutex; 00215 static int LastFree; 00216 }; 00217 #endif
1.7.6.1