Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
38 class XrdProofdNetMgr : public XrdProofdConfig {
39 
40 private:
41 
42  XrdSysRecMutex fMutex; // Atomize this instance
43 
44  XrdProofdManager *fMgr;
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 DoDirectiveAdminReqTO(char *, XrdOucStream *, bool);
66  int DoDirectiveResource(char *, XrdOucStream *, bool);
67  int DoDirectiveWorker(char *, XrdOucStream *, bool);
68 
69 public:
70  XrdProofdNetMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e);
71  virtual ~XrdProofdNetMgr();
72 
73  int Config(bool rcf = 0);
74  int DoDirective(XrdProofdDirective *d,
75  char *val, XrdOucStream *cfg, bool rcf);
76  void RegisterDirectives();
77 
78  void Dump();
79 
80  const char *PROOFcfg() const { return fPROOFcfg.fName.c_str(); }
81  bool WorkerUsrCfg() const { return fWorkerUsrCfg; }
82 
83  int Broadcast(int type, const char *msg, const char *usr = 0,
84  XrdProofdResponse *r = 0, bool notify = 0, int subtype = -1);
85  int BroadcastCtrlC(const char *usr);
86  XrdProofConn *GetProofConn(const char *url);
87  bool IsLocal(const char *host, bool checkport = 0);
88  XrdClientMessage *Send(const char *url, int type,
89  const char *msg, int srvtype, XrdProofdResponse *r,
90  bool notify = 0, int subtype = -1);
91 
92  int ReadBuffer(XrdProofdProtocol *p);
93  char *ReadBufferLocal(const char *file, kXR_int64 ofs, int &len);
94  char *ReadBufferLocal(const char *file, const char *pat, int &len, int opt);
95  char *ReadBufferRemote(const char *url, const char *file,
96  kXR_int64 ofs, int &len, int grep);
97  char *ReadLogPaths(const char *url, const char *stag, int isess);
98  char *ReadLogPaths(const char *stag, int isess);
99 
100  // List of available and unique workers (on master only)
101  std::list<XrdProofWorker *> *GetActiveWorkers();
102  std::list<XrdProofWorker *> *GetNodes();
103 
104  void BalanceNodesOrder();
105 };
106 
107 // Auxiliary structure to store information for the balancer algorithm.
108 typedef struct BalancerInfo {
109  unsigned int available;
110  unsigned int per_iteration;
111  unsigned int added;
112 } BalancerInfo;
113 
114 #endif