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
33class TFileCollection;
34class TObjString;
35class TProof;
36class TProofDesc;
37class TProofLog;
38class TProofMgr;
39class TSignalHandler;
40
41typedef TProofMgr *(*TProofMgr_t)(const char *, Int_t, const char *);
42
43class TProofMgr : public TNamed {
44
45public:
46 enum EServType { kProofd = 0, kXProofd = 1, kProofLite = 2 };
47
48private:
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
57protected:
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
71public:
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
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//
142class TProofDesc : public TNamed {
143public:
144 enum EStatus { kUnknown = -1, kIdle = 0, kRunning =1, kShutdown = 2};
145
146private:
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
156public:
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; }
181
182 ClassDef(TProofDesc,1) // Small class describing a proof session
183};
184
185#endif
int Int_t
Definition: RtypesCore.h:45
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:325
XFontStruct * id
Definition: TGX11.cxx:109
TProofMgr *(* TProofMgr_t)(const char *, Int_t, const char *)
Definition: TProofMgr.h:41
Class that contains a list of TFileInfo's and accumulated meta data information about its entries.
A doubly linked list.
Definition: TList.h:44
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
Collectable string class.
Definition: TObjString.h:28
TString fUrl
Definition: TProofMgr.h:154
Int_t GetStatus() const
Definition: TProofMgr.h:166
TProof * GetProof() const
Definition: TProofMgr.h:164
TProofDesc & operator=(const TProofDesc &)
Int_t fStatus
Definition: TProofMgr.h:151
TProofDesc(const TProofDesc &)
Int_t fLocalId
Definition: TProofMgr.h:150
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
Bool_t IsShuttingDown() const
Definition: TProofMgr.h:171
Bool_t IsIdle() const
Definition: TProofMgr.h:169
Bool_t MatchId(Int_t id) const
Definition: TProofMgr.h:173
Int_t GetLocalId() const
Definition: TProofMgr.h:163
void SetRemoteId(Int_t id)
Definition: TProofMgr.h:180
virtual ~TProofDesc()
Definition: TProofMgr.h:161
const char * GetUrl() const
Definition: TProofMgr.h:167
Int_t GetRemoteId() const
Definition: TProofMgr.h:165
Bool_t IsRunning() const
Definition: TProofMgr.h:170
TProof * fProof
Definition: TProofMgr.h:152
void SetStatus(Int_t st)
Definition: TProofMgr.h:177
Int_t fRemoteId
Definition: TProofMgr.h:153
void Print(Option_t *opt="") const
Dump the content to the screen.
Definition: TProofMgr.cxx:1106
void SetProof(TProof *p)
Definition: TProofMgr.h:179
Implementation of the PROOF session log handler.
Definition: TProofLog.h:32
The PROOF manager interacts with the PROOF server coordinator to create or destroy a PROOF session,...
Definition: TProofMgr.h:43
static TProofMgr_t GetXProofMgrHook()
Get the constructor hook fro TXProofMgr.
Definition: TProofMgr.cxx:596
virtual void ShowWorkers()
Show available workers.
Definition: TProofMgr.cxx:317
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
void Close()
Definition: TProofMgr.h:79
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
TProofMgr(const TProofMgr &)
virtual void ShutdownSession(TProof *p)
Definition: TProofMgr.h:109
virtual void Grep(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:114
virtual const char * GetMssUrl(Bool_t=kFALSE)
Definition: TProofMgr.h:87
virtual TList * QuerySessions(Option_t *opt="S")
Get list of sessions accessible to this manager.
Definition: TProofMgr.cxx:229
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
virtual ~TProofMgr()
Destroy a TProofMgr instance.
Definition: TProofMgr.cxx:110
static TList * GetListOfManagers()
Extract pointers to PROOF managers from TROOT::fProofs.
Definition: TProofMgr.cxx:460
virtual const char * GetUrl()
Definition: TProofMgr.h:94
virtual Int_t SendMsgToUsers(const char *, const char *=0)
Send a message to connected users.
Definition: TProofMgr.cxx:295
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
TSignalHandler * fIntHandler
Definition: TProofMgr.h:64
virtual void More(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:116
virtual void Find(const char *="~/", const char *=0, const char *=0)
Definition: TProofMgr.h:113
TUrl fUrl
Definition: TProofMgr.h:62
virtual TProofLog * GetSessionLogs(Int_t=0, const char *=0, const char *="-v \"| SvcMsg\"", Bool_t=kFALSE)
Definition: TProofMgr.h:91
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
virtual Int_t GetRemoteProtocol() const
Definition: TProofMgr.h:90
virtual Int_t SetROOTVersion(const char *)
Definition: TProofMgr.h:106
virtual void Ls(const char *="~/", const char *=0, const char *=0)
Definition: TProofMgr.h:115
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
virtual Bool_t IsValid() const
Definition: TProofMgr.h:77
static TList fgListOfManagers
Definition: TProofMgr.h:66
TProofMgr & operator=(const TProofMgr &)
Int_t fRemoteProtocol
Definition: TProofMgr.h:59
virtual Int_t Md5sum(const char *, TString &, const char *=0)
Definition: TProofMgr.h:119
@ kProofLite
Definition: TProofMgr.h:46
@ kXProofd
Definition: TProofMgr.h:46
virtual TObjString * ReadBuffer(const char *, Long64_t, Int_t)
Definition: TProofMgr.h:97
static void SetTXProofMgrHook(TProofMgr_t pmh)
Set hook to TXProofMgr ctor.
Definition: TProofMgr.cxx:619
virtual void DetachSession(Int_t, Option_t *="")
Detach session with 'id' from its proofserv.
Definition: TProofMgr.cxx:160
virtual TObjString * ReadBuffer(const char *, const char *)
Definition: TProofMgr.h:99
virtual void SetAlias(const char *alias="")
Definition: TProofMgr.h:104
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:124
virtual Int_t PutFile(const char *, const char *, const char *=0)
Definition: TProofMgr.h:123
virtual void SetMssUrl(const char *mss)
Definition: TProofMgr.h:105
virtual Bool_t IsProofd() const
Definition: TProofMgr.h:76
TString fMssUrl
Definition: TProofMgr.h:58
virtual void ShutdownSession(Int_t id)
Definition: TProofMgr.h:108
virtual void Tail(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:118
TProofMgr()
Definition: TProofMgr.h:68
virtual TProofDesc * GetProofDesc(Int_t id)
Get TProofDesc instance corresponding to 'id'.
Definition: TProofMgr.cxx:325
virtual void SetInvalid()
Definition: TProofMgr.h:78
TList * fSessions
Definition: TProofMgr.h:61
virtual Int_t Stat(const char *, FileStat_t &, const char *=0)
Definition: TProofMgr.h:120
virtual void ShowROOTVersions()
Definition: TProofMgr.h:107
virtual Bool_t IsLite() const
Definition: TProofMgr.h:75
static TProofMgr_t fgTXProofMgrHook
Definition: TProofMgr.h:52
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
virtual void DiscardSession(TProof *p)
Discard TProofDesc of session 'p' from the internal list.
Definition: TProofMgr.cxx:367
virtual Int_t Cp(const char *, const char *=0, const char *=0)
Definition: TProofMgr.h:112
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
EServType fServType
Definition: TProofMgr.h:60
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:316
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369
This class represents a WWW compatible URL.
Definition: TUrl.h:33
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:389
#define dest(otri, vertexptr)
Definition: triangle.c:1041