Logo ROOT   6.10/09
Reference Guide
TSlave.h
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: Fons Rademakers 14/02/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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_TSlave
13 #define ROOT_TSlave
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TSlave //
19 // //
20 // This class describes a PROOF slave server. //
21 // It contains information like the slaves host name, ordinal number, //
22 // performance index, socket, etc. Objects of this class can only be //
23 // created via TProof member functions. //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
27 #include "TObject.h"
28 #include "TString.h"
29 
30 class TFileHandler;
31 class TObjString;
32 class TProof;
33 class TSlave;
34 class TSocket;
35 
36 // Special type for the hook to external function setting up authentication
37 // related stuff for old versions. For backward compatibility.
39 
40 // Special type for the hook to the TSlave constructor, needed to avoid
41 // using the plugin manager
42 typedef TSlave *(*TSlave_t)(const char *url, const char *ord, Int_t perf,
43  const char *image, TProof *proof, Int_t stype,
44  const char *workdir, const char *msd, Int_t nwk);
45 
46 class TSlave : public TObject {
47 
48 friend class TProof;
49 friend class TProofLite;
50 friend class TSlaveLite;
51 friend class TXSlave;
52 
53 public:
54 
57  enum EStatusBits {
58  kOutputRequested = BIT(15) // If output has been requested
59  };
60 
61 private:
62 
64 
65  TSlave(const TSlave &s) : TObject(s) { }
66  TSlave(const char *host, const char *ord, Int_t perf,
67  const char *image, TProof *proof, Int_t stype,
68  const char *workdir, const char *msd, Int_t = 1);
69 
70  Int_t OldAuthSetup(Bool_t master, TString wconf);
71  void Init(const char *host, Int_t port, Int_t stype);
72  void operator=(const TSlave &) { }
73 
74  static TSlave *Create(const char *url, const char *ord, Int_t perf,
75  const char *image, TProof *proof, Int_t stype,
76  const char *workdir, const char *msd, Int_t nwk = 1);
77 
78 protected:
79  TString fName; //slave's hostname
80  TString fImage; //slave's image name
81  TString fProofWorkDir; //base proofserv working directory (info obtained from slave)
82  TString fWorkDir; //slave's working directory (info obtained from slave)
83  TString fUser; //slave's user id
84  TString fGroup; //slave's group id
85  Int_t fPort; //slave's port number
86  TString fOrdinal; //slave's ordinal number
87  Int_t fPerfIdx; //relative CPU performance index
88  Int_t fProtocol; //slave's protocol level
89  TSocket *fSocket; //socket to slave
90  TProof *fProof; //proof cluster to which slave belongs
91  TFileHandler *fInput; //input handler related to this slave
92  Long64_t fBytesRead; //bytes read by slave (info is obtained from slave)
93  Float_t fRealTime; //real time spent executing commands (info obtained from slave)
94  Float_t fCpuTime; //CPU time spent executing commands (info obtained from slave)
95  ESlaveType fSlaveType; //type of slave (either kMaster or kSlave)
96  Int_t fStatus; //remote return status
97  Int_t fParallel; //number of active slaves
98  TString fMsd; //mass storage domain of slave
99  TString fSessionTag;//unique tag for ths worker process
100 
101  TString fROOTVers; //ROOT version run by worker
102  TString fArchComp; //Build architecture, compiler on worker (e.g. linux-gcc345)
103 
104  TSlave();
105  virtual void FlushSocket() { }
106  void Init(TSocket *s, Int_t stype);
107  virtual void Interrupt(Int_t type);
108  virtual Int_t Ping();
109  virtual TObjString *SendCoordinator(Int_t kind, const char *msg = 0, Int_t int2 = 0);
110  virtual Int_t SendGroupPriority(const char * /*grp*/, Int_t /*priority*/) { return 0; }
111  virtual void SetAlias(const char *alias);
112  void SetSocket(TSocket *s) { fSocket = s; }
113  virtual void SetStatus(Int_t st) { fStatus = st; }
114  virtual void StopProcess(Bool_t abort, Int_t timeout);
115 
116 public:
117  virtual ~TSlave();
118 
119  virtual void Close(Option_t *opt = "");
120 
121  Int_t Compare(const TObject *obj) const;
122  Bool_t IsSortable() const { return kTRUE; }
123 
124  const char *GetName() const { return fName; }
125  const char *GetImage() const { return fImage; }
126  const char *GetProofWorkDir() const { return fProofWorkDir; }
127  const char *GetWorkDir() const { return fWorkDir; }
128  const char *GetUser() const { return fUser; }
129  const char *GetGroup() const { return fGroup; }
130  Int_t GetPort() const { return fPort; }
131  const char *GetOrdinal() const { return fOrdinal; }
132  Int_t GetPerfIdx() const { return fPerfIdx; }
133  Int_t GetProtocol() const { return fProtocol; }
134  TSocket *GetSocket() const { return fSocket; }
135  TProof *GetProof() const { return fProof; }
136  Long64_t GetBytesRead() const { return fBytesRead; }
137  Float_t GetRealTime() const { return fRealTime; }
138  Float_t GetCpuTime() const { return fCpuTime; }
139  Int_t GetSlaveType() const { return (Int_t)fSlaveType; }
140  Int_t GetStatus() const { return fStatus; }
141  Int_t GetParallel() const { return fParallel; }
142  const char *GetMsd() const { return fMsd; }
143  const char *GetSessionTag() const { return fSessionTag; }
144  TFileHandler *GetInputHandler() const { return fInput; }
145  void SetInputHandler(TFileHandler *ih);
146 
147  const char *GetArchCompiler() const { return fArchComp; }
148  const char *GetROOTVersion() const { return fROOTVers; }
149 
150  virtual Bool_t IsValid() const { return fSocket ? kTRUE : kFALSE; }
151 
152  virtual void Print(Option_t *option="") const;
153 
154  virtual Int_t SetupServ(Int_t stype, const char *conffile);
155 
156  virtual void SetInterruptHandler(Bool_t /* on */) { }
157 
158  void SetArchCompiler(const char *ac) { fArchComp = ac; }
159  void SetROOTVersion(const char *rv) { fROOTVers = rv; }
160 
161  void SetSessionTag(const char *st) { fSessionTag = st; }
162 
163  static void SetTXSlaveHook(TSlave_t xslavehook);
164 
165  virtual void Touch() { }
166 
167  ClassDef(TSlave,0) //PROOF slave server
168 };
169 
170 #endif
Int_t GetSlaveType() const
Definition: TSlave.h:139
Int_t GetStatus() const
Definition: TSlave.h:140
TString fUser
Definition: TSlave.h:83
This class starts a PROOF session on the local machine: no daemons, client and master merged...
Definition: TProofLite.h:40
void SetSessionTag(const char *st)
Definition: TSlave.h:161
virtual Int_t SendGroupPriority(const char *, Int_t)
Definition: TSlave.h:110
long long Long64_t
Definition: RtypesCore.h:69
virtual void FlushSocket()
Definition: TSlave.h:105
Collectable string class.
Definition: TObjString.h:28
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
Int_t GetParallel() const
Definition: TSlave.h:141
Long64_t fBytesRead
Definition: TSlave.h:92
virtual TObjString * SendCoordinator(Int_t kind, const char *msg=0, Int_t int2=0)
Send message to intermediate coordinator.
Definition: TSlave.cxx:644
TString fArchComp
Definition: TSlave.h:102
Float_t GetCpuTime() const
Definition: TSlave.h:138
#define BIT(n)
Definition: Rtypes.h:75
void SetROOTVersion(const char *rv)
Definition: TSlave.h:159
const char * GetROOTVersion() const
Definition: TSlave.h:148
const char * GetMsd() const
Definition: TSlave.h:142
void SetArchCompiler(const char *ac)
Definition: TSlave.h:158
void SetSocket(TSocket *s)
Definition: TSlave.h:112
virtual void StopProcess(Bool_t abort, Int_t timeout)
Sent stop/abort request to PROOF server.
Definition: TSlave.cxx:630
const char * GetOrdinal() const
Definition: TSlave.h:131
Basic string class.
Definition: TString.h:129
virtual void Touch()
Definition: TSlave.h:165
virtual void Print(Option_t *option="") const
Printf info about slave.
Definition: TSlave.cxx:341
virtual void SetInterruptHandler(Bool_t)
Definition: TSlave.h:156
Version of TSlave for local worker servers.
Definition: TSlaveLite.h:31
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TFileHandler * GetInputHandler() const
Definition: TSlave.h:144
const char * GetName() const
Returns name of object.
Definition: TSlave.h:124
This is the version of TSlave for workers servers based on XProofD.
Definition: TXSlave.h:32
Int_t GetProtocol() const
Definition: TSlave.h:133
static TSlave_t fgTXSlaveHook
Definition: TSlave.h:63
const char * GetImage() const
Definition: TSlave.h:125
virtual ~TSlave()
Destroy slave.
Definition: TSlave.cxx:269
TSlave(const TSlave &s)
Definition: TSlave.h:65
TString fSessionTag
Definition: TSlave.h:99
virtual Bool_t IsValid() const
Definition: TSlave.h:150
#define ClassDef(name, id)
Definition: Rtypes.h:297
Int_t GetPerfIdx() const
Definition: TSlave.h:132
Int_t(* OldSlaveAuthSetup_t)(TSocket *, Bool_t, TString, TString)
Definition: TSlave.h:38
TSocket * GetSocket() const
Definition: TSlave.h:134
static void SetTXSlaveHook(TSlave_t xslavehook)
Set hook to TXSlave ctor.
Definition: TSlave.cxx:666
Int_t fParallel
Definition: TSlave.h:97
TString fOrdinal
Definition: TSlave.h:86
const char * GetProofWorkDir() const
Definition: TSlave.h:126
virtual void Interrupt(Int_t type)
Send interrupt OOB byte to master or slave servers.
Definition: TSlave.cxx:511
TString fROOTVers
Definition: TSlave.h:101
virtual void Close(Option_t *opt="")
Close slave socket.
Definition: TSlave.cxx:277
virtual void SetStatus(Int_t st)
Definition: TSlave.h:113
Int_t GetPort() const
Definition: TSlave.h:130
const char * GetSessionTag() const
Definition: TSlave.h:143
TSlave()
Default constructor used by derived classes.
Definition: TSlave.cxx:66
virtual Int_t Ping()
Ping the remote master or slave servers.
Definition: TSlave.cxx:494
TString fWorkDir
Definition: TSlave.h:82
const char * GetGroup() const
Definition: TSlave.h:129
TSocket * fSocket
Definition: TSlave.h:89
Float_t GetRealTime() const
Definition: TSlave.h:137
Int_t fProtocol
Definition: TSlave.h:88
TFileHandler * fInput
Definition: TSlave.h:91
const Bool_t kFALSE
Definition: RtypesCore.h:92
static TSlave * Create(const char *url, const char *ord, Int_t perf, const char *image, TProof *proof, Int_t stype, const char *workdir, const char *msd, Int_t nwk=1)
Static method returning the appropriate TSlave object for the remote server.
Definition: TSlave.cxx:442
virtual void SetAlias(const char *alias)
Set an alias for this session.
Definition: TSlave.cxx:656
TString fName
Definition: TSlave.h:79
TProof * fProof
Definition: TSlave.h:90
EStatusBits
Definition: TObject.h:57
TString fMsd
Definition: TSlave.h:98
int type
Definition: TGX11.cxx:120
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:320
void Init(const char *host, Int_t port, Int_t stype)
Init a PROOF slave object.
Definition: TSlave.cxx:88
Bool_t IsSortable() const
Definition: TSlave.h:122
const char * GetWorkDir() const
Definition: TSlave.h:127
Float_t fRealTime
Definition: TSlave.h:93
TString fImage
Definition: TSlave.h:80
Mother of all ROOT objects.
Definition: TObject.h:37
Int_t fStatus
Definition: TSlave.h:96
const char * GetArchCompiler() const
Definition: TSlave.h:147
TSlave *(* TSlave_t)(const char *url, const char *ord, Int_t perf, const char *image, TProof *proof, Int_t stype, const char *workdir, const char *msd, Int_t nwk)
Definition: TSlave.h:42
Int_t fPort
Definition: TSlave.h:85
void operator=(const TSlave &)
Definition: TSlave.h:72
ESlaveStatus
Definition: TSlave.h:56
const char * GetUser() const
Definition: TSlave.h:128
Int_t OldAuthSetup(Bool_t master, TString wconf)
Setup authentication related stuff for old versions.
Definition: TSlave.cxx:404
Float_t fCpuTime
Definition: TSlave.h:94
Class describing a PROOF worker server.
Definition: TSlave.h:46
ESlaveType
Definition: TSlave.h:55
Long64_t GetBytesRead() const
Definition: TSlave.h:136
const Bool_t kTRUE
Definition: RtypesCore.h:91
ESlaveType fSlaveType
Definition: TSlave.h:95
virtual Int_t SetupServ(Int_t stype, const char *conffile)
Init a PROOF slave object.
Definition: TSlave.cxx:179
TString fProofWorkDir
Definition: TSlave.h:81
TString fGroup
Definition: TSlave.h:84
Int_t Compare(const TObject *obj) const
Used to sort slaves by performance index.
Definition: TSlave.cxx:310
TProof * GetProof() const
Definition: TSlave.h:135
Int_t fPerfIdx
Definition: TSlave.h:87
void SetInputHandler(TFileHandler *ih)
Adopt and register input handler for this slave.
Definition: TSlave.cxx:394