00001 // @(#)root/proofd:$Id: XrdProofWorker.h 36936 2010-11-25 13:52:27Z rdm $ 00002 // Author: Gerardo Ganis June 2007 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #ifndef ROOT_XrdProofWorker 00013 #define ROOT_XrdProofWorker 00014 00015 ////////////////////////////////////////////////////////////////////////// 00016 // // 00017 // XrdProofWorker // 00018 // // 00019 // Authors: G. Ganis, CERN, 2007 // 00020 // // 00021 // Class with information about a potential worker. // 00022 // A list of instances of this class is built using the config file or // 00023 // or the information collected from the resource discoverers. // 00024 // // 00025 ////////////////////////////////////////////////////////////////////////// 00026 #include <list> 00027 00028 #ifdef OLDXRDOUC 00029 # include "XrdSysToOuc.h" 00030 # include "XrdOuc/XrdOucPthread.hh" 00031 #else 00032 # include "XrdSys/XrdSysPthread.hh" 00033 #endif 00034 #include "XrdOuc/XrdOucString.hh" 00035 00036 00037 class XrdProofdProofServ; 00038 00039 class XrdProofWorker { 00040 00041 public: 00042 XrdProofWorker(const char *str = 0); 00043 virtual ~XrdProofWorker(); 00044 00045 void Reset(const char *str); // Set from 'str' 00046 00047 const char *Export(const char *ord = 0); 00048 00049 bool Matches(const char *host); 00050 bool Matches(XrdProofWorker *wrk); 00051 int GetNActiveSessions(); 00052 00053 static void Sort(std::list<XrdProofWorker *> *lst, 00054 bool (*f)(XrdProofWorker *&lhs, 00055 XrdProofWorker *&rhs)); 00056 00057 inline int Active() const { 00058 XrdSysMutexHelper mhp(fMutex); 00059 return fProofServs.size(); 00060 } 00061 inline void AddProofServ(XrdProofdProofServ *xps) { 00062 XrdSysMutexHelper mhp(fMutex); 00063 return fProofServs.push_back(xps); 00064 } 00065 inline void RemoveProofServ(XrdProofdProofServ *xps) { 00066 XrdSysMutexHelper mhp(fMutex); 00067 return fProofServs.remove(xps); 00068 } 00069 // Allows to copy the session objects from other worker. 00070 void MergeProofServs(const XrdProofWorker &other); 00071 00072 std::list<XrdProofdProofServ *> fProofServs; // ProofServ sessions using 00073 // this worker 00074 00075 // Worker definitions 00076 XrdOucString fExport; // export string 00077 char fType; // type: worker ('W') or submaster ('S') 00078 XrdOucString fUser; // user 00079 XrdOucString fHost; // host FQDN 00080 int fPort; // port 00081 int fPerfIdx; // performance index 00082 XrdOucString fImage; // image name 00083 XrdOucString fWorkDir; // work directory 00084 XrdOucString fMsd; // mass storage domain 00085 XrdOucString fId; // ID string 00086 00087 bool fActive; // TRUE if available 00088 00089 private: 00090 XrdSysRecMutex *fMutex; // Local mutex 00091 }; 00092 00093 #endif