00001 #ifndef __XRDCMSSTATE_H_ 00002 #define __XRDCMSSTATE_H_ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s S t a t 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 "XrdSys/XrdSysPthread.hh" 00034 #include "XrdCms/XrdCmsTypes.hh" 00035 00036 class XrdLink; 00037 00038 class XrdCmsState 00039 { 00040 public: 00041 00042 int Suspended; 00043 int NoStaging; 00044 00045 void Enable(); 00046 00047 void *Monitor(); 00048 00049 int Port(); 00050 00051 void sendState(XrdLink *Link); 00052 00053 void Set(int ncount); 00054 void Set(int ncount, int isman, const char *AdminPath); 00055 00056 enum StateType {Active = 0, Counts, FrontEnd, Space, Stage}; 00057 00058 void Update(StateType StateT, int ActivVal, int StageVal=0); 00059 00060 XrdCmsState(); 00061 ~XrdCmsState() {} 00062 00063 static const char SRV_Suspend = 1; 00064 static const char FES_Suspend = 2; 00065 static const char All_Suspend = 3; 00066 static const char All_NoStage = 4; 00067 00068 private: 00069 unsigned char Status(int Changes, int theState); 00070 00071 XrdSysSemaphore mySemaphore; 00072 XrdSysMutex myMutex; 00073 00074 const char *NoStageFile; 00075 const char *SuspendFile; 00076 00077 int minNodeCnt; // Minimum number of needed subscribers 00078 int numActive; // Number of active subscribers 00079 int numStaging; // Number of subscribers that can stage 00080 int dataPort; // Current data port number 00081 00082 char currState; // Current state 00083 char prevState; // Previous state 00084 char feOK; // Front end functioning 00085 char noSpace; // We don't have enough space 00086 char adminSuspend; // Admin asked for suspension 00087 char adminNoStage; // Admin asked for no staging 00088 char isMan; // We are a manager (i.e., have redirectors) 00089 char Enabled; // We are now enabled for reporting 00090 }; 00091 00092 namespace XrdCms 00093 { 00094 extern XrdCmsState CmsState; 00095 } 00096 #endif