Logo ROOT   6.12/07
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 
68  TProofMgr() : fRemoteProtocol(-1),
69  fServType(kXProofd), fSessions(0), fUrl(), fIntHandler(0) { }
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
static TProofMgr_t fgTXProofMgrHook
Definition: TProofMgr.h:52
Bool_t MatchId(Int_t id) const
Definition: TProofMgr.h:173
TList * fSessions
Definition: TProofMgr.h:61
long long Long64_t
Definition: RtypesCore.h:69
Int_t GetLocalId() const
Definition: TProofMgr.h:163
virtual Int_t Cp(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:112
Collectable string class.
Definition: TObjString.h:28
Int_t fRemoteProtocol
Definition: TProofMgr.h:59
const char Option_t
Definition: RtypesCore.h:62
virtual ~TProofDesc()
Definition: TProofMgr.h:161
virtual void Grep(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:114
This class represents a WWW compatible URL.
Definition: TUrl.h:35
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
const char * GetUrl() const
Definition: TProofMgr.h:167
TProof * GetProof() const
Definition: TProofMgr.h:164
The PROOF manager interacts with the PROOF server coordinator to create or destroy a PROOF session...
Definition: TProofMgr.h:43
virtual ~TProofMgr()
Destroy a TProofMgr instance.
Definition: TProofMgr.cxx:109
Bool_t IsIdle() const
Definition: TProofMgr.h:169
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t fLocalId
Definition: TProofMgr.h:150
Bool_t IsRunning() const
Definition: TProofMgr.h:170
virtual Int_t Md5sum(const char *, TString &, const char *=0)
Definition: TProofMgr.h:119
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
Bool_t IsShuttingDown() const
Definition: TProofMgr.h:171
virtual TProofLog * GetSessionLogs(Int_t=0, const char *=0, const char *="-v \ SvcMsg\, Bool_t=kFALSE)
Definition: TProofMgr.h:91
void SetProof(TProof *p)
Definition: TProofMgr.h:179
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:387
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
void SetRemoteId(Int_t id)
Definition: TProofMgr.h:180
static TList * GetListOfManagers()
Extract pointers to PROOF managers from TROOT::fProofs.
Definition: TProofMgr.cxx:459
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual Bool_t IsProofd() const
Definition: TProofMgr.h:76
virtual Bool_t IsLite() const
Definition: TProofMgr.h:75
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void Tail(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:118
Int_t fRemoteId
Definition: TProofMgr.h:153
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:106
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:68
virtual const char * GetMssUrl(Bool_t=kFALSE)
Definition: TProofMgr.h:87
virtual void Print(Option_t *option="") const
Print TNamed name and title.
Definition: TNamed.cxx:128
EServType fServType
Definition: TProofMgr.h:60
virtual Int_t GetFile(const char *, const char *, const char *=0)
Definition: TProofMgr.h:122
virtual TProof * AttachSession(Int_t, Bool_t=kFALSE)
Dummy version provided for completeness.
Definition: TProofMgr.cxx:123
A doubly linked list.
Definition: TList.h:44
virtual void ShowROOTVersions()
Definition: TProofMgr.h:107
virtual void SetMssUrl(const char *mss)
Definition: TProofMgr.h:105
virtual void ShutdownSession(TProof *p)
Definition: TProofMgr.h:109
virtual void Ls(const char *="~/", const char *=0, const char *=0)
Definition: TProofMgr.h:115
virtual void Find(const char *="~/", const char *=0, const char *=0)
Definition: TProofMgr.h:113
virtual void SetAlias(const char *alias="")
Definition: TProofMgr.h:104
TSignalHandler * fIntHandler
Definition: TProofMgr.h:64
TProofMgr *(* TProofMgr_t)(const char *, Int_t, const char *)
Definition: TProofMgr.h:41
TString fUrl
Definition: TProofMgr.h:154
Int_t GetStatus() const
Definition: TProofMgr.h:166
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:78
TProofMgr & operator=(const TProofMgr &)
void Close()
Definition: TProofMgr.h:79
virtual Int_t Stat(const char *, FileStat_t &, const char *=0)
Definition: TProofMgr.h:120
virtual TObjString * ReadBuffer(const char *, Long64_t, Int_t)
Definition: TProofMgr.h:97
virtual Int_t PutFile(const char *, const char *, const char *=0)
Definition: TProofMgr.h:123
virtual const char * GetUrl()
Definition: TProofMgr.h:94
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 Int_t SendMsgToUsers(const char *, const char *=0)
Send a message to connected users.
Definition: TProofMgr.cxx:294
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual void ShowWorkers()
Show available workers.
Definition: TProofMgr.cxx:316
TUrl fUrl
Definition: TProofMgr.h:62
virtual void More(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:116
static TList fgListOfManagers
Definition: TProofMgr.h:66
TProof * fProof
Definition: TProofMgr.h:152
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:316
virtual Bool_t IsValid() const
Definition: TProofMgr.h:77
static void SetTXProofMgrHook(TProofMgr_t pmh)
Set hook to TXProofMgr ctor.
Definition: TProofMgr.cxx:618
TString fMssUrl
Definition: TProofMgr.h:58
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:151
#define dest(otri, vertexptr)
Definition: triangle.c:1040
virtual Int_t GetRemoteProtocol() const
Definition: TProofMgr.h:90
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
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
const Bool_t kTRUE
Definition: RtypesCore.h:87
Int_t GetRemoteId() const
Definition: TProofMgr.h:165
virtual TObjString * ReadBuffer(const char *, const char *)
Definition: TProofMgr.h:99
virtual void ShutdownSession(Int_t id)
Definition: TProofMgr.h:108
void SetStatus(Int_t st)
Definition: TProofMgr.h:177
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
Implementation of the PROOF session log handler.
Definition: TProofLog.h:32
const char * Data() const
Definition: TString.h:345