XrdProofdNetMgr.h

Go to the documentation of this file.
00001 // @(#)root/proofd:$Id: XrdProofdNetMgr.h 36940 2010-11-25 14:25:10Z rdm $
00002 // Author: G. Ganis  Jan 2008
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_XrdProofdNetMgr
00013 #define ROOT_XrdProofdNetMgr
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // XrdProofdNetMgr                                                     //
00018 //                                                                      //
00019 // Authors: G. Ganis, CERN, 2008                                        //
00020 //                                                                      //
00021 // Manages connections between PROOF server daemons                     //
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;          // Atomize this instance
00051 
00052    XrdProofdManager  *fMgr;
00053    XrdOucHash<XrdProofConn> fProofConnHash;            // Available connections
00054    int                fNumLocalWrks;   // Number of workers to be started locally
00055    int                fResourceType;   // resource type
00056    XrdProofdFile      fPROOFcfg;       // PROOF static configuration
00057    bool               fReloadPROOFcfg; // Whether the file should regurarl checked for updates
00058    bool               fDfltFallback;   // Whether to fallback to default if file cannot be read
00059    bool               fWorkerUsrCfg;   // user cfg files enabled / disabled
00060    int                fRequestTO;      // Timeout on broadcast request
00061 
00062    std::list<XrdProofWorker *> fDfltWorkers; // List of possible default workers
00063    std::list<XrdProofWorker *> fRegWorkers;  // List of all workers registered
00064    std::list<XrdProofWorker *> fWorkers;     // List of currently available workers
00065    std::list<XrdProofWorker *> fNodes;       // List of worker unique nodes
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; // Register, Discover or Both.
00081    XrdOucBonjour     *fBonjourManager; // A reference to the Bonjour manager.
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    // List of available and unique workers (on master only)
00121    std::list<XrdProofWorker *> *GetActiveWorkers();
00122    std::list<XrdProofWorker *> *GetNodes();
00123 
00124 #if defined(BUILD_BONJOUR)
00125    // Interface of Bonjour services.
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 // Auxiliary structure to store information for the balancer algorithm.
00137 typedef struct BalancerInfo {
00138    unsigned int available;
00139    unsigned int per_iteration;
00140    unsigned int added;
00141 } BalancerInfo;
00142 
00143 #endif

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