Logo ROOT   6.07/09
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 #ifndef ROOT_TList
28 #include "TList.h"
29 #endif
30 #ifndef ROOT_TNamed
31 #include "TNamed.h"
32 #endif
33 #ifndef ROOT_TUrl
34 #include "TUrl.h"
35 #endif
36 #ifndef ROOT_TString
37 #include "TString.h"
38 #endif
39 #ifndef ROOT_TSystem
40 #include "TSystem.h"
41 #endif
42 
43 class TFileCollection;
44 class TObjString;
45 class TProof;
46 class TProofDesc;
47 class TProofLog;
48 class TProofMgr;
49 class TSignalHandler;
50 
51 typedef TProofMgr *(*TProofMgr_t)(const char *, Int_t, const char *);
52 
53 class TProofMgr : public TNamed {
54 
55 public:
56  enum EServType { kProofd = 0, kXProofd = 1, kProofLite = 2 };
57 
58 private:
59  TProofMgr(const TProofMgr&); // Not implemented
60  TProofMgr& operator=(const TProofMgr&); // Not implemented
61 
62  static TProofMgr_t fgTXProofMgrHook; // Constructor hooks for TXProofMgr
64 
65  static void ReplaceSubdirs(const char *fn, TString &fdst, TList &dirph);
66 
67 protected:
68  TString fMssUrl; // URL for the remote data pool, if any
69  Int_t fRemoteProtocol; // Protocol number run by the daemon server
70  EServType fServType; // Type of server: old-proofd, XrdProofd
71  TList *fSessions; // PROOF session managed by this server
72  TUrl fUrl; // Server URL
73 
74  TSignalHandler *fIntHandler; // Interrupt signal handler (ctrl-c)
75 
76  static TList fgListOfManagers; // Sub-list of TROOT::ListOfProofs for managers
77 
78  TProofMgr() : fRemoteProtocol(-1),
79  fServType(kXProofd), fSessions(0), fUrl(), fIntHandler(0) { }
80 
81 public:
82  TProofMgr(const char *url, Int_t loglevel = -1, const char *alias = "");
83  virtual ~TProofMgr();
84 
85  virtual Bool_t IsLite() const { return (fServType == kProofLite); }
86  virtual Bool_t IsProofd() const { return (fServType == kProofd); }
87  virtual Bool_t IsValid() const { return kTRUE; }
88  virtual void SetInvalid() { }
89  void Close() { SetInvalid(); }
90 
91  virtual TProof *AttachSession(Int_t, Bool_t = kFALSE);
93  virtual TProof *CreateSession(const char * = 0, const char * = 0, Int_t = -1);
94  virtual void DetachSession(Int_t, Option_t * = "");
95  virtual void DetachSession(TProof *, Option_t * = "");
96  virtual void DiscardSession(TProof *p);
97  virtual const char *GetMssUrl(Bool_t = kFALSE) { return fMssUrl.Data(); }
98  virtual TProofDesc *GetProofDesc(Int_t id);
99  virtual TProofDesc *GetProofDesc(TProof *p);
100  virtual Int_t GetRemoteProtocol() const { return fRemoteProtocol; }
101  virtual TProofLog *GetSessionLogs(Int_t = 0, const char * = 0,
102  const char * = "-v \"| SvcMsg\"", Bool_t = kFALSE)
103  { return (TProofLog *)0; }
104  virtual const char *GetUrl() { return fUrl.GetUrl(); }
105  virtual Bool_t MatchUrl(const char *url);
106  virtual TList *QuerySessions(Option_t *opt = "S");
107  virtual TObjString *ReadBuffer(const char *, Long64_t, Int_t)
108  { return (TObjString *)0; }
109  virtual TObjString *ReadBuffer(const char *, const char *)
110  { return (TObjString *)0; }
111  virtual Int_t Reset(Bool_t hard = kFALSE, const char *usr = 0);
112  virtual void ShowWorkers();
113  virtual Int_t SendMsgToUsers(const char *, const char * = 0);
114  virtual void SetAlias(const char *alias="") { TNamed::SetTitle(alias); }
115  virtual void SetMssUrl(const char *mss) { fMssUrl = mss; }
116  virtual Int_t SetROOTVersion(const char *) { return 0; }
117  virtual void ShowROOTVersions() { }
118  virtual void ShutdownSession(Int_t id) { DetachSession(id,"S"); }
119  virtual void ShutdownSession(TProof *p) { DetachSession(p,"S"); }
120 
121  // Remote file system actions
122  virtual Int_t Cp(const char *, const char * = 0, const char * = 0) { return -1; }
123  virtual void Find(const char * = "~/", const char * = 0, const char * = 0) { }
124  virtual void Grep(const char *, const char * = 0, const char * = 0) { }
125  virtual void Ls(const char * = "~/", const char * = 0, const char * = 0) { }
126  virtual void More(const char *, const char * = 0, const char * = 0) { }
127  virtual Int_t Rm(const char *, const char * = 0, const char * = 0);
128  virtual void Tail(const char *, const char * = 0, const char * = 0) { }
129  virtual Int_t Md5sum(const char *, TString &, const char * = 0) { return -1; }
130  virtual Int_t Stat(const char *, FileStat_t &, const char * = 0) { return -1; }
131 
132  virtual Int_t GetFile(const char *, const char *, const char * = 0) { return -1; }
133  virtual Int_t PutFile(const char *, const char *, const char * = 0) { return -1; }
134 
135  static TList *GetListOfManagers();
136 
137  static void SetTXProofMgrHook(TProofMgr_t pmh);
138 
139  static TProofMgr *Create(const char *url, Int_t loglevel = -1,
140  const char *alias = 0, Bool_t xpd = kTRUE);
141  static Int_t Ping(const char *url, Bool_t checkxrd = kFALSE);
142 
143  static TFileCollection *UploadFiles(TList *src, const char *mss, const char *dest = 0);
144  static TFileCollection *UploadFiles(const char *txtfile, const char *mss, const char *dest = 0);
145 
146  ClassDef(TProofMgr,0) // Abstract PROOF manager interface
147 };
148 
149 //
150 // Metaclass describing the essentials of a PROOF session
151 //
152 class TProofDesc : public TNamed {
153 public:
154  enum EStatus { kUnknown = -1, kIdle = 0, kRunning =1, kShutdown = 2};
155 
156 private:
157  TProofDesc(const TProofDesc&); // Not implemented
158  TProofDesc& operator=(const TProofDesc&); // Not implemented
159 
160  Int_t fLocalId; // ID in the local list
161  Int_t fStatus; // Session status (see EStatus)
162  TProof *fProof; // Related instance of TProof
163  Int_t fRemoteId; // Remote ID assigned by the coordinator to the proofserv
164  TString fUrl; // Url of the connection
165 
166 public:
167  TProofDesc(const char *tag = 0, const char *alias = 0, const char *url = 0,
168  Int_t id = -1, Int_t remid = -1, Int_t status = kIdle, TProof *p = 0)
169  : TNamed(tag, alias),
170  fLocalId(id), fStatus(0), fProof(p), fRemoteId(remid), fUrl(url) { SetStatus(status); }
171  virtual ~TProofDesc() { }
172 
173  Int_t GetLocalId() const { return fLocalId; }
174  TProof *GetProof() const { return fProof; }
175  Int_t GetRemoteId() const { return fRemoteId; }
176  Int_t GetStatus() const { return fStatus; }
177  const char *GetUrl() const { return fUrl; }
178 
179  Bool_t IsIdle() const { return (fStatus == kIdle) ? kTRUE : kFALSE; }
180  Bool_t IsRunning() const { return (fStatus == kRunning) ? kTRUE : kFALSE; }
181  Bool_t IsShuttingDown() const { return (fStatus == kShutdown) ? kTRUE : kFALSE; }
182 
183  Bool_t MatchId(Int_t id) const { return (fLocalId == id); }
184 
185  void Print(Option_t *opt = "") const;
186 
187  void SetStatus(Int_t st) { fStatus = (st < kIdle || st > kShutdown) ? -1 : st; }
188 
189  void SetProof(TProof *p) { fProof = p; }
190  void SetRemoteId(Int_t id) { fRemoteId = id; }
191 
192  ClassDef(TProofDesc,1) // Small class describing a proof session
193 };
194 
195 #endif
static TProofMgr_t fgTXProofMgrHook
Definition: TProofMgr.h:62
TList * fSessions
Definition: TProofMgr.h:71
long long Long64_t
Definition: RtypesCore.h:69
virtual Int_t Cp(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:122
Collectable string class.
Definition: TObjString.h:32
Int_t fRemoteProtocol
Definition: TProofMgr.h:69
const char Option_t
Definition: RtypesCore.h:62
virtual ~TProofDesc()
Definition: TProofMgr.h:171
Int_t GetRemoteId() const
Definition: TProofMgr.h:175
virtual void Grep(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:124
Bool_t MatchId(Int_t id) const
Definition: TProofMgr.h:183
This class represents a WWW compatible URL.
Definition: TUrl.h:41
static Int_t Ping(const char *url, Bool_t checkxrd=kFALSE)
Non-blocking check for a PROOF (or Xrootd, if checkxrd) service at &#39;url&#39; Return 0 if a XProofd (or Xr...
Definition: TProofMgr.cxx:630
The PROOF manager interacts with the PROOF server coordinator to create or destroy a PROOF session...
Definition: TProofMgr.h:53
virtual ~TProofMgr()
Destroy a TProofMgr instance.
Definition: TProofMgr.cxx:109
virtual Bool_t IsProofd() const
Definition: TProofMgr.h:86
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t fLocalId
Definition: TProofMgr.h:160
virtual Int_t Md5sum(const char *, TString &, const char *=0)
Definition: TProofMgr.h:129
virtual Bool_t MatchUrl(const char *url)
Checks if &#39;url&#39; refers to the same &#39;user:port&#39; entity as the URL in memory.
Definition: TProofMgr.cxx:430
void SetProof(TProof *p)
Definition: TProofMgr.h:189
virtual Bool_t IsValid() const
Definition: TProofMgr.h:87
virtual void DiscardSession(TProof *p)
Discard TProofDesc of session &#39;p&#39; from the internal list.
Definition: TProofMgr.cxx:366
virtual void DetachSession(Int_t, Option_t *="")
Detach session with &#39;id&#39; from its proofserv.
Definition: TProofMgr.cxx:159
Bool_t IsRunning() const
Definition: TProofMgr.h:180
void SetRemoteId(Int_t id)
Definition: TProofMgr.h:190
const char * Data() const
Definition: TString.h:349
Int_t GetStatus() const
Definition: TProofMgr.h:176
static TList * GetListOfManagers()
Extract pointers to PROOF managers from TROOT::fProofs.
Definition: TProofMgr.cxx:459
#define ClassDef(name, id)
Definition: Rtypes.h:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
virtual void Tail(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:128
Int_t fRemoteId
Definition: TProofMgr.h:163
virtual Int_t Rm(const char *, const char *=0, const char *=0)
Run &#39;rm&#39; on &#39;what&#39;. Locally it is just a call to TSystem::Unlink .
Definition: TProofMgr.cxx:1065
static TProofMgr_t GetXProofMgrHook()
Get the constructor hook fro TXProofMgr.
Definition: TProofMgr.cxx:595
virtual Int_t SetROOTVersion(const char *)
Definition: TProofMgr.h:116
virtual TProofDesc * GetProofDesc(Int_t id)
Get TProofDesc instance corresponding to &#39;id&#39;.
Definition: TProofMgr.cxx:324
XFontStruct * id
Definition: TGX11.cxx:108
TProofMgr()
Definition: TProofMgr.h:78
virtual const char * GetMssUrl(Bool_t=kFALSE)
Definition: TProofMgr.h:97
EServType fServType
Definition: TProofMgr.h:70
virtual Int_t GetFile(const char *, const char *, const char *=0)
Definition: TProofMgr.h:132
virtual TProof * AttachSession(Int_t, Bool_t=kFALSE)
Dummy version provided for completeness.
Definition: TProofMgr.cxx:123
virtual TProofLog * GetSessionLogs(Int_t=0, const char *=0, const char *="-v \"| SvcMsg\"", Bool_t=kFALSE)
Definition: TProofMgr.h:101
A doubly linked list.
Definition: TList.h:47
virtual void ShowROOTVersions()
Definition: TProofMgr.h:117
virtual void SetMssUrl(const char *mss)
Definition: TProofMgr.h:115
virtual void ShutdownSession(TProof *p)
Definition: TProofMgr.h:119
virtual void Ls(const char *="~/", const char *=0, const char *=0)
Definition: TProofMgr.h:125
virtual void Find(const char *="~/", const char *=0, const char *=0)
Definition: TProofMgr.h:123
virtual void SetAlias(const char *alias="")
Definition: TProofMgr.h:114
TSignalHandler * fIntHandler
Definition: TProofMgr.h:74
TProofMgr *(* TProofMgr_t)(const char *, Int_t, const char *)
Definition: TProofMgr.h:51
TString fUrl
Definition: TProofMgr.h:164
#define dest(otri, vertexptr)
Definition: triangle.c:1040
static TFileCollection * UploadFiles(TList *src, const char *mss, const char *dest=0)
Upload files provided via the list &#39;src&#39; (as TFileInfo or TObjString) to &#39;mss&#39;.
Definition: TProofMgr.cxx:801
virtual TProof * CreateSession(const char *=0, const char *=0, Int_t=-1)
Create a new remote session (master and associated workers).
Definition: TProofMgr.cxx:386
virtual void SetInvalid()
Definition: TProofMgr.h:88
TProofMgr & operator=(const TProofMgr &)
void Close()
Definition: TProofMgr.h:89
virtual Int_t Stat(const char *, FileStat_t &, const char *=0)
Definition: TProofMgr.h:130
virtual TObjString * ReadBuffer(const char *, Long64_t, Int_t)
Definition: TProofMgr.h:107
virtual Int_t PutFile(const char *, const char *, const char *=0)
Definition: TProofMgr.h:133
virtual const char * GetUrl()
Definition: TProofMgr.h:104
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:306
virtual void Print(Option_t *option="") const
Print TNamed name and title.
Definition: TNamed.cxx:119
virtual Int_t SendMsgToUsers(const char *, const char *=0)
Send a message to connected users.
Definition: TProofMgr.cxx:294
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:387
virtual void ShowWorkers()
Show available workers.
Definition: TProofMgr.cxx:316
TUrl fUrl
Definition: TProofMgr.h:72
virtual Bool_t IsLite() const
Definition: TProofMgr.h:85
virtual void More(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:126
static TList fgListOfManagers
Definition: TProofMgr.h:76
TProof * fProof
Definition: TProofMgr.h:162
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:346
static void SetTXProofMgrHook(TProofMgr_t pmh)
Set hook to TXProofMgr ctor.
Definition: TProofMgr.cxx:618
virtual Int_t GetRemoteProtocol() const
Definition: TProofMgr.h:100
Bool_t IsShuttingDown() const
Definition: TProofMgr.h:181
TString fMssUrl
Definition: TProofMgr.h:68
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:744
virtual TList * QuerySessions(Option_t *opt="S")
Get list of sessions accessible to this manager.
Definition: TProofMgr.cxx:228
Class that contains a list of TFileInfo&#39;s and accumulated meta data information about its entries...
Int_t fStatus
Definition: TProofMgr.h:161
Bool_t IsIdle() const
Definition: TProofMgr.h:179
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:498
const char * GetUrl() const
Definition: TProofMgr.h:177
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
virtual TObjString * ReadBuffer(const char *, const char *)
Definition: TProofMgr.h:109
Int_t GetLocalId() const
Definition: TProofMgr.h:173
virtual void ShutdownSession(Int_t id)
Definition: TProofMgr.h:118
void SetStatus(Int_t st)
Definition: TProofMgr.h:187
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:167
Implementation of the PROOF session log handler.
Definition: TProofLog.h:38
TProof * GetProof() const
Definition: TProofMgr.h:174