Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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
53  static TProofMgr_t GetXProofMgrHook();
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);
82  virtual TProof *AttachSession(TProofDesc *, 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