XrdCmsNode.hh

Go to the documentation of this file.
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 
00013 //         $Id: XrdCmsNode.hh 31508 2009-12-02 19:11:01Z brun $
00014 
00015 #include <string.h>
00016 #include <unistd.h>
00017 #include <sys/uio.h>
00018   
00019 #include "Xrd/XrdLink.hh"
00020 #include "XrdCms/XrdCmsTypes.hh"
00021 #include "XrdCms/XrdCmsRRQ.hh"
00022 #include "XrdSys/XrdSysPthread.hh"
00023 
00024 class XrdCmsDrop;
00025 class XrdCmsPrepArgs;
00026 class XrdCmsRRData;
00027 class XrdCmsSelected;
00028 class XrdOucProg;
00029 
00030 class XrdCmsNode
00031 {
00032 friend class XrdCmsCluster;
00033 public:
00034        char  *Ident;        // -> role hostname
00035        char   isDisable;    //0 Set via admin command to temporarily remove node
00036        char   isOffline;    //1 Set when a link failure occurs
00037        char   isNoStage;    //2 Set upon a nostage event
00038        char   isMan;        //3 Set when node acts as manager
00039        char   isPeer;       //4 Set when node acts as peer manager
00040        char   isProxy;      //5 Set when node acts as a proxy
00041        char   isSuspend;    //6 Set upon a suspend event
00042        char   isBound;      //7 Set when node is in the configuration
00043        char   isRW;         //0 Set when node can write or stage data
00044        char   isKnown;      //1 Set when we have recieved a "state"
00045        char   isConn;       //2 Set when node is network connected
00046        char   isGone;       //3 Set when node must be deleted
00047        char   isPerm;       //4 Set when node is permanently bound
00048        char   isReserved[3];
00049 
00050 static const char allowsRW = 0x01; // in isRW -> Server allows r/w access
00051 static const char allowsSS = 0x02; // in isRW -> Server can stage data
00052 
00053 unsigned int    DiskTotal;    // Total disk space in GB
00054          int    DiskNums;     // Number of file systems
00055          int    DiskMinF;     // Minimum MB needed for selection
00056          int    DiskFree;     // Largest free MB
00057          int    DiskUtil;     // Total disk utilization
00058 unsigned int    ConfigID;     // Configuration identifier
00059 
00060 const  char  *do_Avail(XrdCmsRRData &Arg);
00061 const  char  *do_Chmod(XrdCmsRRData &Arg);
00062 const  char  *do_Disc(XrdCmsRRData &Arg);
00063 const  char  *do_Gone(XrdCmsRRData &Arg);
00064 const  char  *do_Have(XrdCmsRRData &Arg);
00065 const  char  *do_Load(XrdCmsRRData &Arg);
00066 const  char  *do_Locate(XrdCmsRRData &Arg);
00067 static int    do_LocFmt(char *buff, XrdCmsSelected *sP, SMask_t pf, SMask_t wf);
00068 const  char  *do_Mkdir(XrdCmsRRData &Arg);
00069 const  char  *do_Mkpath(XrdCmsRRData &Arg);
00070 const  char  *do_Mv(XrdCmsRRData &Arg);
00071 const  char  *do_Ping(XrdCmsRRData &Arg);
00072 const  char  *do_Pong(XrdCmsRRData &Arg);
00073 const  char  *do_PrepAdd(XrdCmsRRData &Arg);
00074 const  char  *do_PrepDel(XrdCmsRRData &Arg);
00075 const  char  *do_Rm(XrdCmsRRData &Arg);
00076 const  char  *do_Rmdir(XrdCmsRRData &Arg);
00077 const  char  *do_Select(XrdCmsRRData &Arg);
00078 static int    do_SelPrep(XrdCmsPrepArgs &Arg);
00079 const  char  *do_Space(XrdCmsRRData &Arg);
00080 const  char  *do_State(XrdCmsRRData &Arg);
00081        int    do_StateFWD(XrdCmsRRData &Arg);
00082 const  char  *do_StatFS(XrdCmsRRData &Arg);
00083 const  char  *do_Stats(XrdCmsRRData &Arg);
00084 const  char  *do_Status(XrdCmsRRData &Arg);
00085 const  char  *do_Trunc(XrdCmsRRData &Arg);
00086 const  char  *do_Try(XrdCmsRRData &Arg);
00087 const  char  *do_Update(XrdCmsRRData &Arg);
00088 const  char  *do_Usage(XrdCmsRRData &Arg);
00089 
00090        void   Disc(const char *reason=0, int needLock=1);
00091 
00092 inline int    ID(int &INum) {INum = Instance; return NodeID;}
00093 
00094 inline int    Inst() {return Instance;}
00095 
00096 inline int    isNode(SMask_t smask) {return (smask & NodeMask) != 0;}
00097 inline int    isNode(const char *hn)
00098                     {return Link && !strcmp(Link->Host(), hn);}
00099 inline int    isNode(unsigned int ipa)
00100                     {return ipa == IPAddr;}
00101 inline int    isNode(unsigned int ipa, const char *nid)
00102                     {return ipa == IPAddr && (nid ? !strcmp(myNID, nid) : 1);}
00103 inline char  *Name()   {return (myName ? myName : (char *)"?");}
00104 
00105 inline char  *Name(int &len, int &port)
00106                        {len = myNlen; port = Port; return myName;}
00107 
00108 inline SMask_t Mask() {return NodeMask;}
00109 
00110 inline void    Lock() {myMutex.Lock(); isLocked = 1;}
00111 inline void  UnLock() {isLocked = 0; myMutex.UnLock();}
00112 
00113 static void  Report_Usage(XrdLink *lp);
00114 
00115 inline int   Send(const char *buff, int blen=0)
00116                  {return (isOffline ? -1 : Link->Send(buff, blen));}
00117 inline int   Send(const struct iovec *iov, int iovcnt, int iotot=0)
00118                  {return (isOffline ? -1 : Link->Send(iov, iovcnt, iotot));}
00119 
00120        void  setName(XrdLink *lnkp, int port);
00121 
00122 inline void  setSlot(short rslot) {RSlot = rslot;}
00123 inline short getSlot() {return RSlot;}
00124 
00125        void  SyncSpace();
00126 
00127              XrdCmsNode(XrdLink *lnkp, int port=0,
00128                         const char *sid=0, int lvl=0, int id=-1);
00129             ~XrdCmsNode();
00130 
00131 private:
00132 static const int fsL2PFail1 = 999991;
00133 static const int fsL2PFail2 = 999992;
00134 
00135        int   fsExec(XrdOucProg *Prog, char *Arg1, char *Arg2=0);
00136 const  char *fsFail(const char *Who, const char *What, const char *Path, int rc);
00137        int   getMode(const char *theMode, mode_t &Mode);
00138        int   getSize(const char *theSize, long long &Size);
00139 static int   isOnline(char *path, int upt=1);
00140 
00141 XrdSysMutex        myMutex;
00142 XrdLink           *Link;
00143 unsigned int       IPAddr;
00144 XrdCmsNode        *Next;
00145 time_t             DropTime;
00146 XrdCmsDrop        *DropJob;  
00147 int                IPV6Len;  // 12345678901234567890123456
00148 char               IPV6[28]; // [::123.123.123.123]:123456
00149 
00150 SMask_t            NodeMask;
00151 int                NodeID;
00152 int                Instance;
00153 int                Port;
00154 int                myLevel;
00155 int                myCNUM;
00156 char              *myCID;
00157 char              *myNID;
00158 char              *myName;
00159 int                myNlen;
00160 
00161 int                logload;
00162 int                myCost;       // Overall cost (determined by location)
00163 int                myLoad;       // Overall load
00164 int                myMass;       // Overall load including space utilization
00165 int                RefA;         // Number of times used for allocation
00166 int                RefTotA;
00167 int                RefR;         // Number of times used for redirection
00168 int                RefTotR;
00169 short              RSlot;
00170 char               isLocked;
00171 char               RSVD;
00172 
00173 // The following fields are used to keep the supervisor's free space value
00174 //
00175 static XrdSysMutex mlMutex;
00176 static int         LastFree;
00177 };
00178 #endif

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