xrootd
|
00001 #ifndef __XRDCMSMANTREE_HH_ 00002 #define __XRDCMSMANTREE_HH_ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s M a n T r e 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$ 00014 00015 #include "XrdCms/XrdCmsManager.hh" 00016 #include "XrdSys/XrdSysPthread.hh" 00017 00018 class XrdCmsNode; 00019 00020 class XrdCmsManTree 00021 { 00022 public: 00023 00024 int Connect(int nID, XrdCmsNode *nP); 00025 00026 void Disc(int nID); 00027 00028 int Register(); 00029 00030 void setMaxCon(int i); 00031 00032 int Trying(int nID, int Lvl); 00033 00034 enum connStat {Active, Connected, None, Pending, Waiting}; 00035 00036 XrdCmsManTree() : maxTMI(0), numConn(0), maxConn(0), atRoot(0), 00037 conLevel(0), conNID(-1), numWaiting(0), 00038 myStatus(Active) {}; 00039 ~XrdCmsManTree() {}; 00040 00041 private: 00042 00043 void Redrive(int nID) {tmInfo[nID].Status = Active; 00044 tmInfo[nID].theSem.Post(); 00045 numWaiting--; 00046 } 00047 void Pause(int nID) {tmInfo[nID].Status = Waiting; 00048 numWaiting++; 00049 myMutex.UnLock(); 00050 tmInfo[nID].theSem.Wait(); 00051 } 00052 00053 XrdSysMutex myMutex; 00054 00055 00056 struct TreeInfo 00057 {XrdSysSemaphore theSem; 00058 XrdCmsNode *nodeP; 00059 connStat Status; 00060 int Level; 00061 00062 TreeInfo() : theSem(0), nodeP(0), Status(None), Level(0) {}; 00063 ~TreeInfo() {}; 00064 00065 } tmInfo[XrdCmsManager::MTMax]; 00066 00067 char buff[8]; 00068 int maxTMI; 00069 int numConn; 00070 int maxConn; 00071 int atRoot; 00072 int conLevel; 00073 int conNID; 00074 int numWaiting; 00075 connStat myStatus; 00076 }; 00077 00078 namespace XrdCms 00079 { 00080 extern XrdCmsManTree ManTree; 00081 } 00082 #endif