Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSlaveLite.cxx
Go to the documentation of this file.
1// @(#)root/proof:$Id$
2// Author: Gerardo Ganis March 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/** \class TSlaveLite
13\ingroup proofkernel
14
15Version of TSlave for local worker servers.
16See TSlave for details.
17
18*/
19
20
21
22//////////////////////////////////////////////////////////////////////////
23// //
24// TSlaveLite //
25// //
26// This is the version of TSlave for local worker servers. //
27// See TSlave for details. //
28// //
29//////////////////////////////////////////////////////////////////////////
30
31#include "RConfigure.h"
32#include "TSlaveLite.h"
33#include "TProof.h"
34#include "TProofServ.h"
35#include "TSystem.h"
36#include "TROOT.h"
37#include "TUrl.h"
38#include "TMessage.h"
39#include "TMonitor.h"
40#include "TError.h"
41#include "TSocket.h"
42#include "TSysEvtHandler.h"
43#include "TVirtualMutex.h"
44
46
47//______________________________________________________________________________
48//---- error handling ----------------------------------------------------------
49//---- Needed to avoid blocking on the CINT mutex in printouts -----------------
50
51////////////////////////////////////////////////////////////////////////////////
52/// Interface to ErrorHandler (protected).
53
54void TSlaveLite::DoError(int level, const char *location,
55 const char *fmt, va_list va) const
56{
57 ::ErrorHandler(level, Form("TSlaveLite::%s", location), fmt, va);
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// Create a PROOF slave object. Called via the TProof ctor.
62
63TSlaveLite::TSlaveLite(const char *ord, Int_t perf,
64 const char *image, TProof *proof, Int_t stype,
65 const char *workdir, const char *msd, Int_t) : TSlave()
66{
67 fName = ord; // Need this during the setup phase; see end of SetupServ
68 fImage = image;
69 fProofWorkDir = workdir;
70 fWorkDir = workdir;
71 fOrdinal = ord;
72 fPerfIdx = perf;
73 fProof = proof;
74 fSlaveType = (ESlaveType)stype;
75 fMsd = msd;
76 fIntHandler = 0;
77 fValid = kFALSE;
79
80 if (fPerfIdx > 0) Init();
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Init a PROOF worker object. Called via the TSlaveLite ctor.
85
87{
88 // Command to be executed
89 TString cmd;
90 cmd.Form(". %s/worker-%s.env; export ROOTBINDIR=\"%s\"; %s/proofserv proofslave lite %d %d 0&",
93 // Execute
94 if (gSystem->Exec(cmd) != 0) {
95 Error("Init", "an error occured while executing 'proofserv'");
97 return;
98 }
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Init a PROOF slave object. Called via the TSlaveLite ctor.
103/// The Init method is technology specific and is overwritten by derived
104/// classes.
105
107{
108 // Get back startup message of proofserv (we are now talking with
109 // the real proofserver and not anymore with the proofd front-end)
110 Int_t what;
111 char buf[512];
112 if (fSocket->Recv(buf, sizeof(buf), what) <= 0) {
113 Error("SetupServ", "failed to receive slave startup message");
114 Close("S");
116 fValid = kFALSE;
117 return -1;
118 }
119
120 if (what == kMESS_NOTOK) {
122 fValid = kFALSE;
123 return -1;
124 }
125
126 // Receive the unique tag and save it as name of this object
127 TMessage *msg = 0;
128 if (fSocket->Recv(msg) <= 0 || !msg || msg->What() != kPROOF_SESSIONTAG) {
129 Error("SetupServ", "failed to receive unique session tag");
130 Close("S");
132 fValid = kFALSE;
133 return -1;
134 }
135 // Extract the unique tag
136 (*msg) >> fSessionTag;
137
138 // Set the real name (temporarly set to ordinal for the setup)
140
141 // We are done
142 return 0;
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Destroy slave.
147
149{
150 Close();
151}
152
153////////////////////////////////////////////////////////////////////////////////
154/// Close slave socket.
155
157{
158 if (fSocket)
159 // Closing socket ...
160 fSocket->Close(opt);
161
164}
165
166////////////////////////////////////////////////////////////////////////////////
167/// Printf info about slave.
168
170{
171 const char *sst[] = { "invalid" , "valid", "inactive" };
172 Int_t st = fSocket ? ((fStatus == kInactive) ? 2 : 1) : 0;
173
174 Printf("*** Worker %s (%s)", fOrdinal.Data(), sst[st]);
175 Printf(" Worker session tag: %s", GetSessionTag());
176 Printf(" ROOT version|rev|tag: %s", GetROOTVersion());
177 Printf(" Architecture-Compiler: %s", GetArchCompiler());
178 if (fSocket) {
179 Printf(" Working directory: %s", GetWorkDir());
180 Printf(" MB's processed: %.2f", float(GetBytesRead())/(1024*1024));
181 Printf(" MB's sent: %.2f", float(fSocket->GetBytesRecv())/(1024*1024));
182 Printf(" MB's received: %.2f", float(fSocket->GetBytesSent())/(1024*1024));
183 Printf(" Real time used (s): %.3f", GetRealTime());
184 Printf(" CPU time used (s): %.3f", GetCpuTime());
185 }
186}
@ kMESS_NOTOK
@ kPROOF_SESSIONTAG
#define SafeDelete(p)
Definition RConfig.hxx:525
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
void ErrorHandler(int level, const char *location, const char *fmt, std::va_list va)
General error handler function. It calls the user set error handler.
Definition TError.cxx:109
const Int_t kPROOF_Protocol
Definition TProof.h:120
Int_t gDebug
Definition TROOT.cxx:597
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2503
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
UInt_t What() const
Definition TMessage.h:75
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:786
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:993
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition TObject.h:72
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition TProof.h:316
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition TROOT.cxx:2993
Version of TSlave for local worker servers.
Definition TSlaveLite.h:31
void Close(Option_t *opt="") override
Close slave socket.
void DoError(int level, const char *location, const char *fmt, va_list va) const override
Interface to ErrorHandler (protected).
void Print(Option_t *option="") const override
Printf info about slave.
~TSlaveLite() override
Destroy slave.
Int_t SetupServ(Int_t stype, const char *conffile) override
Init a PROOF slave object.
Bool_t fValid
Definition TSlaveLite.h:36
void Init()
Init a PROOF worker object. Called via the TSlaveLite ctor.
TSignalHandler * fIntHandler
Definition TSlaveLite.h:37
Class describing a PROOF worker server.
Definition TSlave.h:46
Int_t fStatus
Definition TSlave.h:96
TString fImage
Definition TSlave.h:80
TSocket * fSocket
Definition TSlave.h:89
const char * GetWorkDir() const
Definition TSlave.h:127
TProof * fProof
Definition TSlave.h:90
ESlaveType fSlaveType
Definition TSlave.h:95
Float_t GetRealTime() const
Definition TSlave.h:137
ESlaveType
Definition TSlave.h:55
Long64_t GetBytesRead() const
Definition TSlave.h:136
TString fSessionTag
Definition TSlave.h:99
TString fWorkDir
Definition TSlave.h:82
@ kInactive
Definition TSlave.h:56
TString fOrdinal
Definition TSlave.h:86
friend class TSlaveLite
Definition TSlave.h:50
TFileHandler * fInput
Definition TSlave.h:91
TString fProofWorkDir
Definition TSlave.h:81
const char * GetSessionTag() const
Definition TSlave.h:143
Int_t fPerfIdx
Definition TSlave.h:87
Int_t fProtocol
Definition TSlave.h:88
const char * GetArchCompiler() const
Definition TSlave.h:147
const char * GetROOTVersion() const
Definition TSlave.h:148
Float_t GetCpuTime() const
Definition TSlave.h:138
TString fName
Definition TSlave.h:79
TString fMsd
Definition TSlave.h:98
UInt_t GetBytesRecv() const
Definition TSocket.h:120
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition TSocket.cxx:818
UInt_t GetBytesSent() const
Definition TSocket.h:119
virtual void Close(Option_t *opt="")
Close the socket.
Definition TSocket.cxx:389
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356
virtual int GetPid()
Get process id.
Definition TSystem.cxx:707
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:653
virtual const char * HostName()
Return the system's host name.
Definition TSystem.cxx:303
static const char * what
Definition stlLoader.cc:5