Logo ROOT  
Reference Guide
TProofMgr.h
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: G. Ganis, Nov 2005
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_TProofMgr
13 #define ROOT_TProofMgr
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TProofMgr //
19 // //
20 // The PROOF manager interacts with the PROOF server coordinator to //
21 // create or destroy a PROOF session, attach to or detach from //
22 // existing one, and to monitor any client activity on the cluster. //
23 // At most one manager instance per server is allowed. //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
27 #include "TList.h"
28 #include "TNamed.h"
29 #include "TUrl.h"
30 #include "TString.h"
31 #include "TSystem.h"
32 
33 class TFileCollection;
34 class TObjString;
35 class TProof;
36 class TProofDesc;
37 class TProofLog;
38 class TProofMgr;
39 class TSignalHandler;
40 
41 typedef TProofMgr *(*TProofMgr_t)(const char *, Int_t, const char *);
42 
43 class TProofMgr : public TNamed {
44 
45 public:
46  enum EServType { kProofd = 0, kXProofd = 1, kProofLite = 2 };
47 
48 private:
49  TProofMgr(const TProofMgr&); // Not implemented
50  TProofMgr& operator=(const TProofMgr&); // Not implemented
51 
52  static TProofMgr_t fgTXProofMgrHook; // Constructor hooks for TXProofMgr
54 
55  static void ReplaceSubdirs(const char *fn, TString &fdst, TList &dirph);
56 
57 protected:
58  TString fMssUrl; // URL for the remote data pool, if any
59  Int_t fRemoteProtocol; // Protocol number run by the daemon server
60  EServType fServType; // Type of server: old-proofd, XrdProofd
61  TList *fSessions; // PROOF session managed by this server
62  TUrl fUrl; // Server URL
63 
64  TSignalHandler *fIntHandler; // Interrupt signal handler (ctrl-c)
65 
66  static TList fgListOfManagers; // Sub-list of TROOT::ListOfProofs for managers
67 
70 
71 public:
72  TProofMgr(const char *url, Int_t loglevel = -1, const char *alias = "");
73  virtual ~TProofMgr();
74 
75  virtual Bool_t IsLite() const { return (fServType == kProofLite); }
76  virtual Bool_t IsProofd() const { return (fServType == kProofd); }
77  virtual Bool_t IsValid() const { return kTRUE; }
78  virtual void SetInvalid() { }
79  void Close() { SetInvalid(); }
80 
81  virtual TProof *AttachSession(Int_t, Bool_t = kFALSE);
83  virtual TProof *CreateSession(const char * = 0, const char * = 0, Int_t = -1);
84  virtual void DetachSession(Int_t, Option_t * = "");
85  virtual void DetachSession(TProof *, Option_t * = "");
86  virtual void DiscardSession(TProof *p);
87  virtual const char *GetMssUrl(Bool_t = kFALSE) { return fMssUrl.Data(); }
88  virtual TProofDesc *GetProofDesc(Int_t id);
89  virtual TProofDesc *GetProofDesc(TProof *p);
90  virtual Int_t GetRemoteProtocol() const { return fRemoteProtocol; }
91  virtual TProofLog *GetSessionLogs(Int_t = 0, const char * = 0,
92  const char * = "-v \"| SvcMsg\"", Bool_t = kFALSE)
93  { return (TProofLog *)0; }
94  virtual const char *GetUrl() { return fUrl.GetUrl(); }
95  virtual Bool_t MatchUrl(const char *url);
96  virtual TList *QuerySessions(Option_t *opt = "S");
97  virtual TObjString *ReadBuffer(const char *, Long64_t, Int_t)
98  { return (TObjString *)0; }
99  virtual TObjString *ReadBuffer(const char *, const char *)
100  { return (TObjString *)0; }
101  virtual Int_t Reset(Bool_t hard = kFALSE, const char *usr = 0);
102  virtual void ShowWorkers();
103  virtual Int_t SendMsgToUsers(const char *, const char * = 0);
104  virtual void SetAlias(const char *alias="") { TNamed::SetTitle(alias); }
105  virtual void SetMssUrl(const char *mss) { fMssUrl = mss; }
106  virtual Int_t SetROOTVersion(const char *) { return 0; }
107  virtual void ShowROOTVersions() { }
108  virtual void ShutdownSession(Int_t id) { DetachSession(id,"S"); }
109  virtual void ShutdownSession(TProof *p) { DetachSession(p,"S"); }
110 
111  // Remote file system actions
112  virtual Int_t Cp(const char *, const char * = 0, const char * = 0) { return -1; }
113  virtual void Find(const char * = "~/", const char * = 0, const char * = 0) { }
114  virtual void Grep(const char *, const char * = 0, const char * = 0) { }
115  virtual void Ls(const char * = "~/", const char * = 0, const char * = 0) { }
116  virtual void More(const char *, const char * = 0, const char * = 0) { }
117  virtual Int_t Rm(const char *, const char * = 0, const char * = 0);
118  virtual void Tail(const char *, const char * = 0, const char * = 0) { }
119  virtual Int_t Md5sum(const char *, TString &, const char * = 0) { return -1; }
120  virtual Int_t Stat(const char *, FileStat_t &, const char * = 0) { return -1; }
121 
122  virtual Int_t GetFile(const char *, const char *, const char * = 0) { return -1; }
123  virtual Int_t PutFile(const char *, const char *, const char * = 0) { return -1; }
124 
125  static TList *GetListOfManagers();
126 
127  static void SetTXProofMgrHook(TProofMgr_t pmh);
128 
129  static TProofMgr *Create(const char *url, Int_t loglevel = -1,
130  const char *alias = 0, Bool_t xpd = kTRUE);
131  static Int_t Ping(const char *url, Bool_t checkxrd = kFALSE);
132 
133  static TFileCollection *UploadFiles(TList *src, const char *mss, const char *dest = 0);
134  static TFileCollection *UploadFiles(const char *txtfile, const char *mss, const char *dest = 0);
135 
136  ClassDef(TProofMgr,0) // Abstract PROOF manager interface
137 };
138 
139 //
140 // Metaclass describing the essentials of a PROOF session
141 //
142 class TProofDesc : public TNamed {
143 public:
144  enum EStatus { kUnknown = -1, kIdle = 0, kRunning =1, kShutdown = 2};
145 
146 private:
147  TProofDesc(const TProofDesc&); // Not implemented
148  TProofDesc& operator=(const TProofDesc&); // Not implemented
149 
150  Int_t fLocalId; // ID in the local list
151  Int_t fStatus; // Session status (see EStatus)
152  TProof *fProof; // Related instance of TProof
153  Int_t fRemoteId; // Remote ID assigned by the coordinator to the proofserv
154  TString fUrl; // Url of the connection
155 
156 public:
157  TProofDesc(const char *tag = 0, const char *alias = 0, const char *url = 0,
158  Int_t id = -1, Int_t remid = -1, Int_t status = kIdle, TProof *p = 0)
159  : TNamed(tag, alias),
160  fLocalId(id), fStatus(0), fProof(p), fRemoteId(remid), fUrl(url) { SetStatus(status); }
161  virtual ~TProofDesc() { }
162 
163  Int_t GetLocalId() const { return fLocalId; }
164  TProof *GetProof() const { return fProof; }
165  Int_t GetRemoteId() const { return fRemoteId; }
166  Int_t GetStatus() const { return fStatus; }
167  const char *GetUrl() const { return fUrl; }
168 
169  Bool_t IsIdle() const { return (fStatus == kIdle) ? kTRUE : kFALSE; }
170  Bool_t IsRunning() const { return (fStatus == kRunning) ? kTRUE : kFALSE; }
171  Bool_t IsShuttingDown() const { return (fStatus == kShutdown) ? kTRUE : kFALSE; }
172 
173  Bool_t MatchId(Int_t id) const { return (fLocalId == id); }
174 
175  void Print(Option_t *opt = "") const;
176 
177  void SetStatus(Int_t st) { fStatus = (st < kIdle || st > kShutdown) ? -1 : st; }
178 
179  void SetProof(TProof *p) { fProof = p; }
180  void SetRemoteId(Int_t id) { fRemoteId = id; }
181 
182  ClassDef(TProofDesc,1) // Small class describing a proof session
183 };
184 
185 #endif
TProofMgr::ShowWorkers
virtual void ShowWorkers()
Show available workers.
Definition: TProofMgr.cxx:317
TProofMgr::SetMssUrl
virtual void SetMssUrl(const char *mss)
Definition: TProofMgr.h:105
TProofMgr::GetXProofMgrHook
static TProofMgr_t GetXProofMgrHook()
Get the constructor hook fro TXProofMgr.
Definition: TProofMgr.cxx:596
TProofMgr::kProofLite
@ kProofLite
Definition: TProofMgr.h:46
TProofMgr::GetMssUrl
virtual const char * GetMssUrl(Bool_t=kFALSE)
Definition: TProofMgr.h:87
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TProofMgr::SetAlias
virtual void SetAlias(const char *alias="")
Definition: TProofMgr.h:104
TProofMgr::More
virtual void More(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:116
TProofMgr::fRemoteProtocol
Int_t fRemoteProtocol
Definition: TProofMgr.h:59
TProofMgr::Md5sum
virtual Int_t Md5sum(const char *, TString &, const char *=0)
Definition: TProofMgr.h:119
TProofDesc::~TProofDesc
virtual ~TProofDesc()
Definition: TProofMgr.h:161
TProofMgr::UploadFiles
static TFileCollection * UploadFiles(TList *src, const char *mss, const char *dest=0)
Upload files provided via the list 'src' (as TFileInfo or TObjString) to 'mss'.
Definition: TProofMgr.cxx:805
TProofMgr::SetROOTVersion
virtual Int_t SetROOTVersion(const char *)
Definition: TProofMgr.h:106
TProofMgr::SetTXProofMgrHook
static void SetTXProofMgrHook(TProofMgr_t pmh)
Set hook to TXProofMgr ctor.
Definition: TProofMgr.cxx:619
dest
#define dest(otri, vertexptr)
Definition: triangle.c:1040
TProofDesc::kUnknown
@ kUnknown
Definition: TProofMgr.h:144
TProofDesc::operator=
TProofDesc & operator=(const TProofDesc &)
TProofLog
Definition: TProofLog.h:32
TString::Data
const char * Data() const
Definition: TString.h:369
TProofMgr_t
TProofMgr *(* TProofMgr_t)(const char *, Int_t, const char *)
Definition: TProofMgr.h:41
TProofDesc::TProofDesc
TProofDesc(const TProofDesc &)
TSignalHandler
Definition: TSysEvtHandler.h:127
FileStat_t
Definition: TSystem.h:124
TProofMgr::Grep
virtual void Grep(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:114
TProofDesc::GetRemoteId
Int_t GetRemoteId() const
Definition: TProofMgr.h:165
TProofMgr::kXProofd
@ kXProofd
Definition: TProofMgr.h:46
TNamed.h
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TProofMgr::Close
void Close()
Definition: TProofMgr.h:79
TProofDesc::kShutdown
@ kShutdown
Definition: TProofMgr.h:144
TProofMgr::fSessions
TList * fSessions
Definition: TProofMgr.h:61
TProofMgr::fgListOfManagers
static TList fgListOfManagers
Definition: TProofMgr.h:66
Int_t
int Int_t
Definition: RtypesCore.h:45
TProofMgr::fServType
EServType fServType
Definition: TProofMgr.h:60
TProofMgr::GetRemoteProtocol
virtual Int_t GetRemoteProtocol() const
Definition: TProofMgr.h:90
TProofDesc::GetUrl
const char * GetUrl() const
Definition: TProofMgr.h:167
TProofMgr::IsValid
virtual Bool_t IsValid() const
Definition: TProofMgr.h:77
TProofMgr::operator=
TProofMgr & operator=(const TProofMgr &)
TList.h
TProofDesc::EStatus
EStatus
Definition: TProofMgr.h:144
TProofMgr::fIntHandler
TSignalHandler * fIntHandler
Definition: TProofMgr.h:64
TProofDesc::SetRemoteId
void SetRemoteId(Int_t id)
Definition: TProofMgr.h:180
TProofDesc::GetLocalId
Int_t GetLocalId() const
Definition: TProofMgr.h:163
TProofMgr::fMssUrl
TString fMssUrl
Definition: TProofMgr.h:58
TProofDesc::fRemoteId
Int_t fRemoteId
Definition: TProofMgr.h:153
TProofMgr
Definition: TProofMgr.h:43
TProofMgr::ReadBuffer
virtual TObjString * ReadBuffer(const char *, Long64_t, Int_t)
Definition: TProofMgr.h:97
TString
Definition: TString.h:136
TProofMgr::ReadBuffer
virtual TObjString * ReadBuffer(const char *, const char *)
Definition: TProofMgr.h:99
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TString.h
TProofMgr::Stat
virtual Int_t Stat(const char *, FileStat_t &, const char *=0)
Definition: TProofMgr.h:120
TProofDesc::SetProof
void SetProof(TProof *p)
Definition: TProofMgr.h:179
bool
TProofMgr::fUrl
TUrl fUrl
Definition: TProofMgr.h:62
TProofMgr::fgTXProofMgrHook
static TProofMgr_t fgTXProofMgrHook
Definition: TProofMgr.h:52
TProofMgr::GetListOfManagers
static TList * GetListOfManagers()
Extract pointers to PROOF managers from TROOT::fProofs.
Definition: TProofMgr.cxx:460
id
XFontStruct * id
Definition: TGX11.cxx:109
TProofDesc::Print
void Print(Option_t *opt="") const
Dump the content to the screen.
Definition: TProofMgr.cxx:1106
TProofMgr::Reset
virtual Int_t Reset(Bool_t hard=kFALSE, const char *usr=0)
Send a cleanup request for the sessions associated with the current user.
Definition: TProofMgr.cxx:307
TProofDesc::GetStatus
Int_t GetStatus() const
Definition: TProofMgr.h:166
TObjString
Definition: TObjString.h:28
TProofDesc::TProofDesc
TProofDesc(const char *tag=0, const char *alias=0, const char *url=0, Int_t id=-1, Int_t remid=-1, Int_t status=kIdle, TProof *p=0)
Definition: TProofMgr.h:157
TProofMgr::ShutdownSession
virtual void ShutdownSession(TProof *p)
Definition: TProofMgr.h:109
TProofMgr::MatchUrl
virtual Bool_t MatchUrl(const char *url)
Checks if 'url' refers to the same 'user@host:port' entity as the URL in memory.
Definition: TProofMgr.cxx:431
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TProofMgr::Find
virtual void Find(const char *="~/", const char *=0, const char *=0)
Definition: TProofMgr.h:113
TProofDesc::kRunning
@ kRunning
Definition: TProofMgr.h:144
TProofDesc::IsShuttingDown
Bool_t IsShuttingDown() const
Definition: TProofMgr.h:171
TSystem.h
TProofMgr::PutFile
virtual Int_t PutFile(const char *, const char *, const char *=0)
Definition: TProofMgr.h:123
TProofMgr::Tail
virtual void Tail(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:118
TNamed
Definition: TNamed.h:29
TProofDesc::kIdle
@ kIdle
Definition: TProofMgr.h:144
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TProofMgr::Create
static TProofMgr * Create(const char *url, Int_t loglevel=-1, const char *alias=0, Bool_t xpd=kTRUE)
Static method returning the appropriate TProofMgr object using the plugin manager.
Definition: TProofMgr.cxx:499
TProofDesc::fStatus
Int_t fStatus
Definition: TProofMgr.h:151
TProofMgr::IsLite
virtual Bool_t IsLite() const
Definition: TProofMgr.h:75
TProofMgr::EServType
EServType
Definition: TProofMgr.h:46
TProofDesc::IsRunning
Bool_t IsRunning() const
Definition: TProofMgr.h:170
TProofMgr::~TProofMgr
virtual ~TProofMgr()
Destroy a TProofMgr instance.
Definition: TProofMgr.cxx:110
TProofMgr::Rm
virtual Int_t Rm(const char *, const char *=0, const char *=0)
Run 'rm' on 'what'. Locally it is just a call to TSystem::Unlink .
Definition: TProofMgr.cxx:1073
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TProofMgr::ShowROOTVersions
virtual void ShowROOTVersions()
Definition: TProofMgr.h:107
TProofMgr::QuerySessions
virtual TList * QuerySessions(Option_t *opt="S")
Get list of sessions accessible to this manager.
Definition: TProofMgr.cxx:229
TUrl::GetUrl
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:387
TUrl
Definition: TUrl.h:33
TProofMgr::CreateSession
virtual TProof * CreateSession(const char *=0, const char *=0, Int_t=-1)
Create a new remote session (master and associated workers).
Definition: TProofMgr.cxx:387
TProofMgr::GetSessionLogs
virtual TProofLog * GetSessionLogs(Int_t=0, const char *=0, const char *="-v \"| SvcMsg\"", Bool_t=kFALSE)
Definition: TProofMgr.h:91
TProofMgr::TProofMgr
TProofMgr()
Definition: TProofMgr.h:68
TProofMgr::kProofd
@ kProofd
Definition: TProofMgr.h:46
TProofMgr::Cp
virtual Int_t Cp(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:112
TProofDesc::IsIdle
Bool_t IsIdle() const
Definition: TProofMgr.h:169
TProofMgr::SendMsgToUsers
virtual Int_t SendMsgToUsers(const char *, const char *=0)
Send a message to connected users.
Definition: TProofMgr.cxx:295
TProofMgr::GetFile
virtual Int_t GetFile(const char *, const char *, const char *=0)
Definition: TProofMgr.h:122
TProofDesc::fUrl
TString fUrl
Definition: TProofMgr.h:154
TProofMgr::IsProofd
virtual Bool_t IsProofd() const
Definition: TProofMgr.h:76
TProofDesc::MatchId
Bool_t MatchId(Int_t id) const
Definition: TProofMgr.h:173
TProofMgr::Ls
virtual void Ls(const char *="~/", const char *=0, const char *=0)
Definition: TProofMgr.h:115
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TProofMgr::GetProofDesc
virtual TProofDesc * GetProofDesc(Int_t id)
Get TProofDesc instance corresponding to 'id'.
Definition: TProofMgr.cxx:325
TProofDesc::SetStatus
void SetStatus(Int_t st)
Definition: TProofMgr.h:177
TProofDesc::GetProof
TProof * GetProof() const
Definition: TProofMgr.h:164
TProofMgr::ReplaceSubdirs
static void ReplaceSubdirs(const char *fn, TString &fdst, TList &dirph)
Parse file name extracting the directory subcomponents in dirs, stored as TObjStrings.
Definition: TProofMgr.cxx:745
TProofMgr::DiscardSession
virtual void DiscardSession(TProof *p)
Discard TProofDesc of session 'p' from the internal list.
Definition: TProofMgr.cxx:367
TProof
Definition: TProof.h:316
TProofDesc::fLocalId
Int_t fLocalId
Definition: TProofMgr.h:150
TProofDesc::fProof
TProof * fProof
Definition: TProofMgr.h:152
TProofMgr::ShutdownSession
virtual void ShutdownSession(Int_t id)
Definition: TProofMgr.h:108
TProofMgr::GetUrl
virtual const char * GetUrl()
Definition: TProofMgr.h:94
TProofMgr::AttachSession
virtual TProof * AttachSession(Int_t, Bool_t=kFALSE)
Dummy version provided for completeness.
Definition: TProofMgr.cxx:124
TUrl.h
TProofMgr::SetInvalid
virtual void SetInvalid()
Definition: TProofMgr.h:78
TProofDesc
Definition: TProofMgr.h:142
TList
Definition: TList.h:44
TProofMgr::DetachSession
virtual void DetachSession(Int_t, Option_t *="")
Detach session with 'id' from its proofserv.
Definition: TProofMgr.cxx:160
int
TFileCollection
Definition: TFileCollection.h:39
TProofMgr::Ping
static Int_t Ping(const char *url, Bool_t checkxrd=kFALSE)
Non-blocking check for a PROOF (or Xrootd, if checkxrd) service at 'url' Return 0 if a XProofd (or Xr...
Definition: TProofMgr.cxx:631