Logo ROOT   6.14/05
Reference Guide
XrdProofdNetMgr.h
Go to the documentation of this file.
1 // @(#)root/proofd:$Id$
2 // Author: G. Ganis Jan 2008
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_XrdProofdNetMgr
13 #define ROOT_XrdProofdNetMgr
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // XrdProofdNetMgr //
18 // //
19 // Authors: G. Ganis, CERN, 2008 //
20 // //
21 // Manages connections between PROOF server daemons //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #include "XpdSysPthread.h"
26 
27 #include "XrdOuc/XrdOucHash.hh"
28 
29 #include "XrdProofConn.h"
30 #include "XrdProofdConfig.h"
31 
32 class XrdProofdDirective;
33 class XrdProofdManager;
34 class XrdProofdProtocol;
35 class XrdProofdResponse;
36 class XrdProofWorker;
37 
39 
40 private:
41 
42  XrdSysRecMutex fMutex; // Atomize this instance
43 
45  XrdOucHash<XrdProofConn> fProofConnHash; // Available connections
46  int fNumLocalWrks; // Number of workers to be started locally
47  int fResourceType; // resource type
48  XrdProofdFile fPROOFcfg; // PROOF static configuration
49  bool fReloadPROOFcfg; // Whether the file should regurarl checked for updates
50  bool fDfltFallback; // Whether to fallback to default if file cannot be read
51  bool fWorkerUsrCfg; // user cfg files enabled / disabled
52  int fRequestTO; // Timeout on broadcast request
53 
54  std::list<XrdProofWorker *> fDfltWorkers; // List of possible default workers
55  std::list<XrdProofWorker *> fRegWorkers; // List of all workers registered
56  std::list<XrdProofWorker *> fWorkers; // List of currently available workers
57  std::list<XrdProofWorker *> fNodes; // List of worker unique nodes
58 
59  void CreateDefaultPROOFcfg();
60  int ReadPROOFcfg(bool reset = 1);
61  int FindUniqueNodes();
62 
63  int LocateLocalFile(XrdOucString &file);
64 
65  int DoDirectiveBonjour(char *val, XrdOucStream *cfg, bool);
66  int DoDirectiveAdminReqTO(char *, XrdOucStream *, bool);
67  int DoDirectiveResource(char *, XrdOucStream *, bool);
68  int DoDirectiveWorker(char *, XrdOucStream *, bool);
69 
71 
72 public:
73  XrdProofdNetMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e);
74  virtual ~XrdProofdNetMgr();
75 
76  int Config(bool rcf = 0);
78  char *val, XrdOucStream *cfg, bool rcf);
79  void RegisterDirectives();
80 
81  void Dump();
82 
83  const char *PROOFcfg() const { return fPROOFcfg.fName.c_str(); }
84  bool WorkerUsrCfg() const { return fWorkerUsrCfg; }
85 
86  int Broadcast(int type, const char *msg, const char *usr = 0,
87  XrdProofdResponse *r = 0, bool notify = 0, int subtype = -1);
88  int BroadcastCtrlC(const char *usr);
89  XrdProofConn *GetProofConn(const char *url);
90  bool IsLocal(const char *host, bool checkport = 0);
91  XrdClientMessage *Send(const char *url, int type,
92  const char *msg, int srvtype, XrdProofdResponse *r,
93  bool notify = 0, int subtype = -1);
94 
96  char *ReadBufferLocal(const char *file, kXR_int64 ofs, int &len);
97  char *ReadBufferLocal(const char *file, const char *pat, int &len, int opt);
98  char *ReadBufferRemote(const char *url, const char *file,
99  kXR_int64 ofs, int &len, int grep);
100  char *ReadLogPaths(const char *url, const char *stag, int isess);
101  char *ReadLogPaths(const char *stag, int isess);
102 
103  // List of available and unique workers (on master only)
104  std::list<XrdProofWorker *> *GetActiveWorkers();
105  std::list<XrdProofWorker *> *GetNodes();
106 
107  void BalanceNodesOrder();
108 };
109 
110 // Auxiliary structure to store information for the balancer algorithm.
111 typedef struct BalancerInfo {
112  unsigned int available;
113  unsigned int per_iteration;
114  unsigned int added;
115 } BalancerInfo;
116 
117 #endif
int DoDirectiveBonjour(char *val, XrdOucStream *cfg, bool)
int DoDirectiveAdminReqTO(char *, XrdOucStream *, bool)
Process &#39;adminreqto&#39; directive.
unsigned int added
void RegisterDirectives()
Register config directives.
XrdOucString fName
Definition: XrdProofdAux.h:76
unsigned int available
static constexpr double pi
char * ReadBufferLocal(const char *file, kXR_int64 ofs, int &len)
Read a buffer of length &#39;len&#39; at offset &#39;ofs&#39; of local file &#39;path&#39;; the returned buffer must be freed...
std::list< XrdProofWorker * > fRegWorkers
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
int LocateLocalFile(XrdOucString &file)
Locate the exact file path allowing for wildcards &#39;*&#39; in the file name.
XrdProofdFile fPROOFcfg
int ReadPROOFcfg(bool reset=1)
Read PROOF config file and load the information in fWorkers.
XrdOucHash< XrdProofConn > fProofConnHash
XrdProofConn * GetProofConn(const char *url)
Get a XrdProofConn for url; create a new one if not available.
XrdSysRecMutex fMutex
std::list< XrdProofWorker * > * GetActiveWorkers()
Return the list of workers after having made sure that the info is up-to-date.
int DoDirectiveResource(char *, XrdOucStream *, bool)
Process &#39;resource&#39; directive.
unsigned int per_iteration
XrdProofdManager * fMgr
XrdClientMessage * Send(const char *url, int type, const char *msg, int srvtype, XrdProofdResponse *r, bool notify=0, int subtype=-1)
Broadcast request to known potential sub-nodes.
std::list< XrdProofWorker * > fNodes
int BroadcastCtrlC(const char *usr)
Broadcast a ctrlc interrupt Return 0 on success, -1 on error.
char * ReadLogPaths(const char *url, const char *stag, int isess)
Get log paths from next tier; used in multi-master setups Returns 0 in case of error.
virtual ~XrdProofdNetMgr()
Destructor.
int Broadcast(int type, const char *msg, const char *usr=0, XrdProofdResponse *r=0, bool notify=0, int subtype=-1)
Broadcast request to known potential sub-nodes.
bool WorkerUsrCfg() const
const char * PROOFcfg() const
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
int FindUniqueNodes()
Scan fWorkers for unique nodes (stored in fNodes).
void CreateDefaultPROOFcfg()
Fill-in fWorkers for a localhost based on the number of workers fNumLocalWrks.
ROOT::R::TRInterface & r
Definition: Object.C:4
std::list< XrdProofWorker * > * GetNodes()
Return the list of unique nodes after having made sure that the info is up-to-date.
#define XrdSysError
Definition: XpdSysError.h:8
int DoDirectiveWorker(char *, XrdOucStream *, bool)
Process &#39;worker&#39; directive.
int ReadBuffer(XrdProofdProtocol *p)
Process a readbuf request.
#define d(i)
Definition: RSha256.hxx:102
std::list< XrdProofWorker * > fWorkers
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
std::list< XrdProofWorker * > fDfltWorkers
int type
Definition: TGX11.cxx:120
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
void BalanceNodesOrder()
Indices (this will be used twice).
bool IsLocal(const char *host, bool checkport=0)
Check if &#39;host&#39; is this local host.
Definition: file.py:1
void Dump()
Dump status.
char * ReadBufferRemote(const char *url, const char *file, kXR_int64 ofs, int &len, int grep)
Send a read buffer request of length &#39;len&#39; at offset &#39;ofs&#39; for remote file defined by &#39;url&#39;; the retu...
struct BalancerInfo BalancerInfo
XrdProofdNetMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e)
Constructor.