00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_XrdProofdNetMgr
00013 #define ROOT_XrdProofdNetMgr
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef OLDXRDOUC
00026 # include "XrdSysToOuc.h"
00027 # include "XrdOuc/XrdOucPthread.hh"
00028 #else
00029 # include "XrdSys/XrdSysPthread.hh"
00030 #endif
00031
00032 #if defined(BUILD_BONJOUR)
00033 #include "XrdOuc/XrdOucBonjour.hh"
00034 #endif
00035 #include "XrdOuc/XrdOucHash.hh"
00036
00037 #include "XrdProofConn.h"
00038 #include "XrdProofdConfig.h"
00039
00040 class XrdProofdDirective;
00041 class XrdProofdManager;
00042 class XrdProofdProtocol;
00043 class XrdProofdResponse;
00044 class XrdProofWorker;
00045
00046 class XrdProofdNetMgr : public XrdProofdConfig {
00047
00048 private:
00049
00050 XrdSysRecMutex fMutex;
00051
00052 XrdProofdManager *fMgr;
00053 XrdOucHash<XrdProofConn> fProofConnHash;
00054 int fNumLocalWrks;
00055 int fResourceType;
00056 XrdProofdFile fPROOFcfg;
00057 bool fReloadPROOFcfg;
00058 bool fDfltFallback;
00059 bool fWorkerUsrCfg;
00060 int fRequestTO;
00061
00062 std::list<XrdProofWorker *> fDfltWorkers;
00063 std::list<XrdProofWorker *> fRegWorkers;
00064 std::list<XrdProofWorker *> fWorkers;
00065 std::list<XrdProofWorker *> fNodes;
00066
00067 void CreateDefaultPROOFcfg();
00068 int ReadPROOFcfg(bool reset = 1);
00069 int FindUniqueNodes();
00070
00071 int LocateLocalFile(XrdOucString &file);
00072
00073 int DoDirectiveBonjour(char *val, XrdOucStream *cfg, bool);
00074 int DoDirectiveAdminReqTO(char *, XrdOucStream *, bool);
00075 int DoDirectiveResource(char *, XrdOucStream *, bool);
00076 int DoDirectiveWorker(char *, XrdOucStream *, bool);
00077
00078 bool fBonjourEnabled;
00079 #if defined(BUILD_BONJOUR)
00080 int fBonjourRequestedSrvType;
00081 XrdOucBonjour *fBonjourManager;
00082 XrdOucString fBonjourServiceType;
00083 XrdOucString fBonjourName;
00084 XrdOucString fBonjourDomain;
00085 int fBonjourCores;
00086 int LoadBonjourModule(int srvtype);
00087 static void * ProcessBonjourUpdate(void * context);
00088 #endif
00089
00090 public:
00091 XrdProofdNetMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e);
00092 virtual ~XrdProofdNetMgr();
00093
00094 int Config(bool rcf = 0);
00095 int DoDirective(XrdProofdDirective *d,
00096 char *val, XrdOucStream *cfg, bool rcf);
00097 void RegisterDirectives();
00098
00099 void Dump();
00100
00101 const char *PROOFcfg() const { return fPROOFcfg.fName.c_str(); }
00102 bool WorkerUsrCfg() const { return fWorkerUsrCfg; }
00103
00104 int Broadcast(int type, const char *msg, const char *usr = 0,
00105 XrdProofdResponse *r = 0, bool notify = 0, int subtype = -1);
00106 int BroadcastCtrlC(const char *usr);
00107 XrdProofConn *GetProofConn(const char *url);
00108 bool IsLocal(const char *host, bool checkport = 0);
00109 XrdClientMessage *Send(const char *url, int type,
00110 const char *msg, int srvtype, XrdProofdResponse *r,
00111 bool notify = 0, int subtype = -1);
00112
00113 int ReadBuffer(XrdProofdProtocol *p);
00114 char *ReadBufferLocal(const char *file, kXR_int64 ofs, int &len);
00115 char *ReadBufferLocal(const char *file, const char *pat, int &len, int opt);
00116 char *ReadBufferRemote(const char *url, const char *file,
00117 kXR_int64 ofs, int &len, int grep);
00118 char *ReadLogPaths(const char *url, const char *stag, int isess);
00119
00120
00121 std::list<XrdProofWorker *> *GetActiveWorkers();
00122 std::list<XrdProofWorker *> *GetNodes();
00123
00124 #if defined(BUILD_BONJOUR)
00125
00126 int GetBonjourRequestedServiceType() const { return fBonjourRequestedSrvType; }
00127 const char *GetBonjourServiceType() const { return (fBonjourServiceType.length()) ? fBonjourServiceType.c_str() : "_proof._tcp."; }
00128 const char *GetBonjourName() const { return (fBonjourName.length()) ? fBonjourName.c_str() : NULL; }
00129 const char *GetBonjourDomain() const { return (fBonjourDomain.length()) ? fBonjourDomain.c_str() : NULL; }
00130 int GetBonjourCores() const { return fBonjourCores; }
00131 static bool CheckBonjourRoleCoherence(int role, int bonjourSrvType);
00132 #endif
00133 void BalanceNodesOrder();
00134 };
00135
00136
00137 typedef struct BalancerInfo {
00138 unsigned int available;
00139 unsigned int per_iteration;
00140 unsigned int added;
00141 } BalancerInfo;
00142
00143 #endif