ROOT  6.06/09
Reference Guide
XrdROOT.h
Go to the documentation of this file.
1 // @(#)root/proofd:$Id$
2 // Author: G. Ganis June 2007
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_XrdROOT
13 #define ROOT_XrdROOT
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // XrdProofdProtocol //
18 // //
19 // Authors: G. Ganis, CERN, 2007 //
20 // //
21 // Class describing a ROOT version //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 #include <list>
25 
26 #include "Xrd/XrdProtocol.hh"
27 #include "XProofProtocol.h"
28 #include "XrdOuc/XrdOucString.hh"
29 
30 #include "XrdProofdConfig.h"
31 
32 class XrdProofdManager;
33 class XrdSysLogger;
34 
35 class XrdROOT {
36 friend class XrdROOTMgr;
37 private:
38  int fStatus;
39  XrdOucString fDir;
40  XrdOucString fBinDir;
41  XrdOucString fDataDir;
42  XrdOucString fIncDir;
43  XrdOucString fLibDir;
44  XrdOucString fTag;
45  XrdOucString fExport;
46  XrdOucString fPrgmSrv;
47  kXR_int16 fSrvProtVers;
48 
49  XrdOucString fRelease;
50  XrdOucString fGitCommit;
52 
53  int fVrsMajor;
54  int fVrsMinor;
55  int fVrsPatch;
56 
57  int CheckDir(const char *dir);
59 
60 public:
61  XrdROOT(const char *dir, const char *tag, const char *bindir = 0,
62  const char *incdir = 0, const char *libdir = 0, const char *datadir = 0);
63  ~XrdROOT() { }
64 
65  const char *Dir() const { return fDir.c_str(); }
66  const char *BinDir() const { return fBinDir.c_str(); }
67  const char *DataDir() const { return fDataDir.c_str(); }
68  const char *IncDir() const { return fIncDir.c_str(); }
69  const char *LibDir() const { return fLibDir.c_str(); }
70  const char *Export() const { return fExport.c_str(); }
71  const char *GitCommit() const { return fGitCommit.c_str(); }
72  bool IsParked() const { return ((fStatus == 2) ? 1: 0); }
73  bool IsValid() const { return ((fStatus == 1) ? 1: 0); }
74  bool IsInvalid() const { return ((fStatus == -1) ? 1: 0); }
75  bool Match(const char *dir, const char *tag)
76  { return ((fTag == tag && fDir == dir) ? 1 : 0); }
77  bool MatchTag(const char *tag) { return ((fTag == tag) ? 1 : 0); }
78  void Park() { fStatus = 2; }
79  const char *PrgmSrv() const { return fPrgmSrv.c_str(); }
80  const char *Release() const { return fRelease.c_str(); }
81  void SetValid(kXR_int16 vers = -1);
82  kXR_int16 SrvProtVers() const { return fSrvProtVers; }
83  const char *Tag() const { return fTag.c_str(); }
84  int VersionCode() const { return fVersionCode; }
85  int VrsMajor() const { return fVrsMajor; }
86  int VrsMinor() const { return fVrsMinor; }
87  int VrsPatch() const { return fVrsPatch; }
88 
89  static int GetVersionCode(const char *release);
90  static int GetVersionCode(int maj, int min, int patch);
91  static int ParseReleaseString(const char *release, int &maj, int &min, int &patch);
92 };
93 
94 //
95 // Manage XrdROOT instances
96 
97 class XrdROOTMgr : public XrdProofdConfig {
98 
100  XrdSysLogger *fLogger; // Error logger
101  XrdOucString fLogDir; // Path to dir with validation logs
102 
103  std::list<XrdROOT *> fROOT; // ROOT versions; the first is the default
104 
105  int Validate(XrdROOT *r, XrdScheduler *sched);
106 
107  void RegisterDirectives();
108  int DoDirectiveRootSys(char *, XrdOucStream *, bool);
109 
110 public:
111  XrdROOTMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e);
112  virtual ~XrdROOTMgr() { }
113 
114  int Config(bool rcf = 0);
116  char *val, XrdOucStream *cfg, bool rcf);
117 
118  XrdROOT *DefaultVersion() const { return fROOT.front(); }
119  XrdOucString ExportVersions(XrdROOT *def);
120  XrdROOT *GetVersion(const char *tag);
121  void SetLogDir(const char *d);
122 };
123 
124 
125 #endif
XrdROOT(const char *dir, const char *tag, const char *bindir=0, const char *incdir=0, const char *libdir=0, const char *datadir=0)
Constructor: validates 'dir', gets the version and defines the tag.
Definition: XrdROOT.cxx:40
#define XrdSysLogger
Definition: XpdSysLogger.h:8
void SetLogDir(const char *d)
Set the log dir.
Definition: XrdROOT.cxx:334
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
XrdOucString fRelease
Definition: XrdROOT.h:49
~XrdROOT()
Definition: XrdROOT.h:63
int VersionCode() const
Definition: XrdROOT.h:84
bool IsParked() const
Definition: XrdROOT.h:72
const double pi
XrdROOTMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e)
Constructor.
Definition: XrdROOT.cxx:319
XrdOucString fBinDir
Definition: XrdROOT.h:40
XrdOucString fGitCommit
Definition: XrdROOT.h:50
kXR_int16 SrvProtVers() const
Definition: XrdROOT.h:82
int fVersionCode
Definition: XrdROOT.h:51
const char * Tag() const
Definition: XrdROOT.h:83
virtual ~XrdROOTMgr()
Definition: XrdROOT.h:112
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
Definition: XrdROOT.cxx:433
bool IsInvalid() const
Definition: XrdROOT.h:74
const char * GitCommit() const
Definition: XrdROOT.h:71
XrdOucString fDir
Definition: XrdROOT.h:39
XrdROOT * DefaultVersion() const
Definition: XrdROOT.h:118
static int GetVersionCode(const char *release)
Translate 'release' into a version code integer following the rules in $ROOTSYS/include/RVersion.h.
Definition: XrdROOT.cxx:275
const char * BinDir() const
Definition: XrdROOT.h:66
int fVrsMajor
Definition: XrdROOT.h:53
int VrsMinor() const
Definition: XrdROOT.h:86
int Validate(XrdROOT *r, XrdScheduler *sched)
Start a trial server application to test forking and get the version of the protocol run by the PROOF...
Definition: XrdROOT.cxx:516
void SetValid(kXR_int16 vers=-1)
Set valid, save protocol and finalize the export string.
Definition: XrdROOT.cxx:149
int DoDirectiveRootSys(char *, XrdOucStream *, bool)
Process 'rootsys' directive.
Definition: XrdROOT.cxx:452
void RegisterDirectives()
Register directives for configuration.
Definition: XrdROOT.cxx:425
const char * DataDir() const
Definition: XrdROOT.h:67
XrdOucString fLogDir
Definition: XrdROOT.h:101
XrdOucString fExport
Definition: XrdROOT.h:45
XrdSysLogger * fLogger
Definition: XrdROOT.h:100
std::list< XrdROOT * > fROOT
Definition: XrdROOT.h:103
XrdOucString fTag
Definition: XrdROOT.h:44
int VrsPatch() const
Definition: XrdROOT.h:87
XrdOucString fDataDir
Definition: XrdROOT.h:41
const char * IncDir() const
Definition: XrdROOT.h:68
int fVrsMinor
Definition: XrdROOT.h:54
ROOT::R::TRInterface & r
Definition: Object.C:4
XrdROOT * GetVersion(const char *tag)
Return pointer to the ROOT version corresponding to 'tag' or 0 if not found.
Definition: XrdROOT.cxx:730
XrdOucString ExportVersions(XrdROOT *def)
Return a string describing the available versions, with the default version 'def' markde with a '*'...
Definition: XrdROOT.cxx:706
#define XrdSysError
Definition: XpdSysError.h:8
const char * Dir() const
Definition: XrdROOT.h:65
bool MatchTag(const char *tag)
Definition: XrdROOT.h:77
XrdOucString fLibDir
Definition: XrdROOT.h:43
int fStatus
Definition: XrdROOT.h:38
int VrsMajor() const
Definition: XrdROOT.h:85
int ParseROOTVersionInfo()
Extract ROOT version information associated with 'dir'.
Definition: XrdROOT.cxx:171
kXR_int16 fSrvProtVers
Definition: XrdROOT.h:47
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
Definition: XrdROOT.cxx:356
void Park()
Definition: XrdROOT.h:78
bool IsValid() const
Definition: XrdROOT.h:73
XrdOucString fPrgmSrv
Definition: XrdROOT.h:46
static int ParseReleaseString(const char *release, int &maj, int &min, int &patch)
Extract from 'release' its major, minor and patch numerical components; 'release' must be in the form...
Definition: XrdROOT.cxx:296
XrdProofdManager * fMgr
Definition: XrdROOT.h:99
int CheckDir(const char *dir)
Check if 'dir' exists Return 0 on succes, -1 on failure.
Definition: XrdROOT.cxx:123
const char * Export() const
Definition: XrdROOT.h:70
XrdOucString fIncDir
Definition: XrdROOT.h:42
const char * PrgmSrv() const
Definition: XrdROOT.h:79
int fVrsPatch
Definition: XrdROOT.h:55
const char * LibDir() const
Definition: XrdROOT.h:69
const char * Release() const
Definition: XrdROOT.h:80
bool Match(const char *dir, const char *tag)
Definition: XrdROOT.h:75