Logo ROOT   6.08/07
Reference Guide
TProofLite.h
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: G. Ganis March 2008
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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_TProofLite
13 #define ROOT_TProofLite
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TProofLite //
19 // //
20 // This class starts a PROOF session on the local machine: no daemons, //
21 // client and master merged, communications via UNIX-like sockets. //
22 // By default the number of workers started is NumberOfCores+1; a //
23 // different number can be forced on construction. //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
27 #ifndef ROOT_TProof
28 #include "TProof.h"
29 #endif
30 
31 class TDSet;
32 class TList;
34 class TDataSetManager;
35 class TProofLockPath;
36 class TProofMgr;
37 class TProofQueryResult;
38 class TServerSocket;
39 class TSelector;
40 class TPMERegexp;
41 
42 class TProofLite : public TProof {
43 
44 friend class TProofPlayerLite;
45 
46 private:
47  Int_t fNWorkers; // Number of workers
48  TString fSandbox; // PROOF sandbox root dir
49  TString fCacheDir; // Directory containing cache of user files
50  TString fQueryDir; // Directory containing query results and status
51  TString fDataSetDir; // Directory containing info about known data sets
52  TString fSockPath; // UNIX socket path for communication with workers
53  TServerSocket *fServSock; // Server socket to accept call backs
54  Bool_t fForkStartup; // Startup N-1 workers forking the first worker
55 
56  Int_t fDynamicStartupStep; // Dyn Startup simulation: increment at each call
57  Int_t fDynamicStartupNMax; // Dyn Startup simulation: max number of workers
58 
59  TString fVarExp; // Internal variable to pass drawing options
60  TString fSelection; // Internal variable to pass drawing options
61 
62  TProofLockPath *fCacheLock; // Cache dir locker
63  TProofLockPath *fQueryLock; // Query dir locker
64  TQueryResultManager *fQMgr; // Query-result manager
65 
66  TDataSetManager *fDataSetManager; // Dataset manager
67  TDataSetManagerFile *fDataSetStgRepo; // Dataset manager for staging requests
68 
69  TPMERegexp *fReInvalid; // Regular expression matching invalid dataset URIs
70 
71  static Int_t fgWrksMax; // Max number of workers
72 
73  TProofLite(const TProofLite &); // not implemented
74  void operator=(const TProofLite &); // idem
75 
78  void FindUniqueSlaves();
79  void NotifyStartUp(const char *action, Int_t done, Int_t tot);
80  Int_t SetProofServEnv(const char *ord);
82 
83  void ResolveKeywords(TString &s, const char *ord, const char *logfile);
84 
85  void SendInputDataFile();
86  void ShowDataDir(const char *dirname);
87 
88 protected:
89  TProofLite() : TProof() { } // For derived classes to use
90 
91  Int_t Init(const char *masterurl, const char *conffile,
92  const char *confdir, Int_t loglevel,
93  const char *alias = 0);
94  TProofQueryResult *MakeQueryResult(Long64_t nent, const char *opt,
95  Long64_t fst, TDSet *dset,
96  const char *selec);
98  Int_t SetupWorkers(Int_t opt = 0, TList *wrks = 0);
99  Int_t CopyMacroToCache(const char *macro, Int_t headerRequired = 0,
100  TSelector **selector = 0, Int_t opt = 0, TList *wrks = 0);
101 
103 
104 public:
105  TProofLite(const char *masterurl, const char *conffile = kPROOF_ConfFile,
106  const char *confdir = kPROOF_ConfDir, Int_t loglevel = 0,
107  const char *alias = 0, TProofMgr *mgr = 0);
108  virtual ~TProofLite();
109 
110  void Print(Option_t *option="") const;
111 
112  Long64_t DrawSelect(TDSet *dset, const char *varexp,
113  const char *selection = "",
114  Option_t *option = "", Long64_t nentries = -1,
115  Long64_t firstentry = 0);
116  Long64_t Process(TDSet *dset, const char *sel, Option_t *o = "",
117  Long64_t nent = -1, Long64_t fst = 0);
118  Long64_t Process(TFileCollection *fc, const char *sel, Option_t *o = "",
119  Long64_t nent = -1, Long64_t fst = 0)
120  { return TProof::Process(fc, sel, o, nent, fst); }
121  Long64_t Process(const char *dsname, const char *sel, Option_t *o = "",
122  Long64_t nent = -1, Long64_t fst = 0, TObject *enl = 0)
123  { return TProof::Process(dsname, sel, o, nent, fst, enl); }
124  Long64_t Process(const char *sel, Long64_t nent, Option_t *o = "")
125  { return TProof::Process(sel, nent, o); }
126  // Process via TSelector
127  Long64_t Process(TDSet *dset, TSelector *sel, Option_t *o = "",
128  Long64_t nent = -1, Long64_t fst = 0)
129  { return TProof::Process(dset, sel, o, nent, fst); }
131  Long64_t nent = -1, Long64_t fst = 0)
132  { return TProof::Process(fc, sel, o, nent, fst); }
133  Long64_t Process(const char *dsname, TSelector *sel, Option_t *o = "",
134  Long64_t nent = -1, Long64_t fst = 0, TObject *enl = 0)
135  { return TProof::Process(dsname, sel, o, nent, fst, enl); }
137  { return TProof::Process(sel, nent, o); }
138 
139  // Cache management
140  void ShowCache(Bool_t all = kFALSE);
141  void ClearCache(const char *file = 0);
142  Int_t Load(const char *macro, Bool_t notOnClient = kFALSE, Bool_t uniqueOnly = kTRUE,
143  TList *wrks = 0);
144 
145  // Data management
146  void ShowData();
147 
148  // Query management
149  TList *GetListOfQueries(Option_t *opt = "");
150  Int_t Remove(const char *ref, Bool_t all);
151 
152  // Dataset handling
153  Bool_t RegisterDataSet(const char *dsName, TFileCollection *ds, const char *opt = "");
154  Bool_t ExistsDataSet(const char *uri);
155  TMap *GetDataSets(const char *uri = "", const char * = 0);
156  void ShowDataSets(const char *uri = "", const char * = 0);
157  TFileCollection *GetDataSet(const char *uri, const char * = 0);
158  Int_t RemoveDataSet(const char *uri, const char * = 0);
159  Bool_t RequestStagingDataSet(const char *dataset);
160  Bool_t CancelStagingDataSet(const char *dataset);
161  TFileCollection *GetStagingStatusDataSet(const char *dataset);
162  Int_t VerifyDataSet(const char *uri, const char * = 0);
163  Int_t SetDataSetTreeName( const char *dataset, const char *treename);
164  void ShowDataSetCache(const char *dataset = 0);
165  void ClearDataSetCache(const char *dataset = 0);
166 
167  // Browsing
168  TTree *GetTreeHeader(TDSet *tdset);
169 
170  static Int_t GetNumberOfWorkers(const char *url = 0);
171 
172  ClassDef(TProofLite,0) //PROOF-Lite control class
173 };
174 
175 #endif
Int_t SetProofServEnv(const char *ord)
Create environment files for worker 'ord'.
Definition: TProofLite.cxx:694
void SetQueryRunning(TProofQueryResult *pq)
Set query in running state.
Long64_t Process(const char *sel, Long64_t nent, Option_t *o="")
Generic (non-data based) selector processing: the Process() method of the specified selector (...
Definition: TProofLite.h:124
Long64_t Process(TDSet *dset, TSelector *sel, Option_t *o="", Long64_t nent=-1, Long64_t fst=0)
Process a data set (TDSet) using the specified selector object.
Definition: TProofLite.h:127
Int_t VerifyDataSet(const char *uri, const char *=0)
Verify if all files in the specified dataset are available.
This class starts a PROOF session on the local machine: no daemons, client and master merged...
Definition: TProofLite.h:42
Bool_t RequestStagingDataSet(const char *dataset)
Allows users to request staging of a particular dataset.
TQueryResultManager * fQMgr
Definition: TProofLite.h:64
TPMERegexp * fReInvalid
Definition: TProofLite.h:69
void ShowDataSetCache(const char *dataset=0)
Display the content of the dataset cache, if any (matching 'dataset', if defined).
long long Long64_t
Definition: RtypesCore.h:69
TFileCollection * GetDataSet(const char *uri, const char *=0)
Get a list of TFileInfo objects describing the files of the specified dataset.
Int_t Load(const char *macro, Bool_t notOnClient=kFALSE, Bool_t uniqueOnly=kTRUE, TList *wrks=0)
Copy the specified macro in the cache directory.
Bool_t ExistsDataSet(const char *uri)
Returns kTRUE if 'dataset' described by 'uri' exists, kFALSE otherwise.
Long64_t Process(TSelector *sel, Long64_t nent, Option_t *o="")
Generic (non-data based) selector processing: the Process() method of the specified selector is calle...
Definition: TProofLite.h:136
const char Option_t
Definition: RtypesCore.h:62
virtual ~TProofLite()
Destructor.
Definition: TProofLite.cxx:375
Long64_t Process(const char *dsname, TSelector *sel, Option_t *o="", Long64_t nent=-1, Long64_t fst=0, TObject *enl=0)
Process with name of dataset and TSelector object.
Definition: TProofLite.h:133
Bool_t RegisterDataSet(const char *dsName, TFileCollection *ds, const char *opt="")
Register the 'dataSet' on the cluster under the current user, group and the given 'dataSetName'...
TFileCollection * GetStagingStatusDataSet(const char *dataset)
Obtains a TFileCollection showing the staging status of the specified dataset.
void SendInputDataFile()
Make sure that the input data objects are available to the workers in a dedicated file in the cache; ...
This class implements a data set to be used for PROOF processing.
Definition: TDSet.h:153
The PROOF manager interacts with the PROOF server coordinator to create or destroy a PROOF session...
Definition: TProofMgr.h:53
TString fSelection
Definition: TProofLite.h:60
Int_t PollForNewWorkers()
Simulate dynamic addition, for test purposes.
TProofLockPath * fCacheLock
Definition: TProofLite.h:62
Basic string class.
Definition: TString.h:137
void ClearDataSetCache(const char *dataset=0)
Clear the content of the dataset cache, if any (matching 'dataset', if defined).
Int_t SetDataSetTreeName(const char *dataset, const char *treename)
Set/Change the name of the default tree.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void NotifyStartUp(const char *action, Int_t done, Int_t tot)
Notify setting-up operation message.
Definition: TProofLite.cxx:677
const Bool_t kFALSE
Definition: Rtypes.h:92
static Int_t fgWrksMax
Definition: TProofLite.h:71
Long64_t Process(TFileCollection *fc, TSelector *sel, Option_t *o="", Long64_t nent=-1, Long64_t fst=0)
Process a data set (TFileCollection) using the specified selector object The default tree is analyzed...
Definition: TProofLite.h:130
void ShowData()
List contents of the data directory in the sandbox.
void ShowDataDir(const char *dirname)
List contents of the data directory 'dirname'.
void ResolveKeywords(TString &s, const char *ord, const char *logfile)
Resolve some keywords in &#39;s&#39; <logfilewrk>, <user>, <rootsys>, <cpupin>
Definition: TProofLite.cxx:819
Bool_t fForkStartup
Definition: TProofLite.h:54
TDataSetManagerFile * fDataSetStgRepo
Definition: TProofLite.h:67
static struct mg_connection * fc(struct mg_context *ctx)
Definition: civetweb.c:1956
TString fDataSetDir
Definition: TProofLite.h:51
#define ClassDef(name, id)
Definition: Rtypes.h:254
TDataSetManager * fDataSetManager
Definition: TProofLite.h:66
TString fCacheDir
Definition: TProofLite.h:49
Long64_t Process(TDSet *dset, const char *sel, Option_t *o="", Long64_t nent=-1, Long64_t fst=0)
Process a data set (TDSet) using the specified selector (.C) file.
Int_t Init(const char *masterurl, const char *conffile, const char *confdir, Int_t loglevel, const char *alias=0)
Start the PROOF environment.
Definition: TProofLite.cxx:154
Bool_t CancelStagingDataSet(const char *dataset)
Cancels a dataset staging request.
Version of TProofPlayerRemote merges the functionality needed by clients and masters.
Int_t fDynamicStartupNMax
Definition: TProofLite.h:57
TString fQueryDir
Definition: TProofLite.h:50
TString fSandbox
Definition: TProofLite.h:48
A doubly linked list.
Definition: TList.h:47
const char *const kPROOF_ConfFile
Definition: TProof.h:152
Int_t RemoveDataSet(const char *uri, const char *=0)
Remove the specified dataset from the PROOF cluster.
void ShowDataSets(const char *uri="", const char *=0)
Shows datasets in locations that match the uri By default shows the user&#39;s datasets and global ones...
void operator=(const TProofLite &)
Long64_t DrawSelect(TDSet *dset, const char *varexp, const char *selection="", Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0)
Execute the specified drawing action on a data set (TDSet).
Int_t fNWorkers
Definition: TProofLite.h:47
Class managing the query-result area.
Int_t SetupWorkers(Int_t opt=0, TList *wrks=0)
Start up PROOF workers.
Definition: TProofLite.cxx:499
const char *const kPROOF_ConfDir
Definition: TProof.h:153
void ClearCache(const char *file=0)
Remove files from all file caches.
Int_t fDynamicStartupStep
Definition: TProofLite.h:56
TServerSocket * fServSock
Definition: TProofLite.h:53
TList * GetListOfQueries(Option_t *opt="")
Get the list of queries.
virtual Long64_t Process(TDSet *dset, const char *selector, Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0)
Process a data set (TDSet) using the specified selector (.C) file or Tselector object Entry- or event...
Definition: TProof.cxx:5275
static Int_t GetNumberOfWorkers(const char *url=0)
Static method to determine the number of workers giving priority to users request.
Definition: TProofLite.cxx:406
TMap * GetDataSets(const char *uri="", const char *=0)
lists all datasets that match given uri
Int_t CreateSandbox()
Create the sandbox for this session.
Definition: TProofLite.cxx:898
TString fSockPath
Definition: TProofLite.h:52
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
Int_t CleanupSandbox()
Remove old sessions dirs keep at most &#39;Proof.MaxOldSessions&#39; (default 10)
Long64_t Process(TFileCollection *fc, const char *sel, Option_t *o="", Long64_t nent=-1, Long64_t fst=0)
Process a data set (TFileCollection) using the specified selector (.C) file or TSelector object...
Definition: TProofLite.h:118
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:346
int nentries
Definition: THbookFile.cxx:89
TQueryResult version adapted to PROOF neeeds.
Mother of all ROOT objects.
Definition: TObject.h:37
TString fVarExp
Definition: TProofLite.h:59
Int_t InitDataSetManager()
Initialize the dataset manager from directives or from defaults Return 0 on success, -1 on failure.
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Definition: TPRegexp.h:103
Class that contains a list of TFileInfo&#39;s and accumulated meta data information about its entries...
Definition: file.py:1
TProofLockPath * fQueryLock
Definition: TProofLite.h:63
TTree * GetTreeHeader(TDSet *tdset)
Creates a tree header (a tree with nonexisting files) object for the DataSet.
A TTree object has a header with a name and a title.
Definition: TTree.h:98
TProofQueryResult * MakeQueryResult(Long64_t nent, const char *opt, Long64_t fst, TDSet *dset, const char *selec)
Create a TProofQueryResult instance for this query.
Int_t Remove(const char *ref, Bool_t all)
Handle remove request.
void FindUniqueSlaves()
Add to the fUniqueSlave list the active slaves that have a unique (user) file system image...
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:39
const Bool_t kTRUE
Definition: Rtypes.h:91
void ShowCache(Bool_t all=kFALSE)
List contents of file cache.
void Print(Option_t *option="") const
Print status of PROOF-Lite cluster.
Definition: TProofLite.cxx:967
Long64_t Process(const char *dsname, const char *sel, Option_t *o="", Long64_t nent=-1, Long64_t fst=0, TObject *enl=0)
Process a dataset which is stored on the master with name &#39;dsetname&#39;.
Definition: TProofLite.h:121
Int_t CopyMacroToCache(const char *macro, Int_t headerRequired=0, TSelector **selector=0, Int_t opt=0, TList *wrks=0)
Copy a macro, and its possible associated .h[h] file, to the cache directory, from where the workers ...