ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TProofBenchDataSet.cxx
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: Sangsu Ryu 22/06/2010
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 /** \class TProofBenchDataSet
13 \ingroup proofbench
14 
15 Handle operations on datasets used by ProofBench
16 
17 */
18 
19 #include "RConfigure.h"
20 
21 #include "TProofBenchDataSet.h"
22 #include "TClass.h"
23 #include "TFileCollection.h"
24 #include "TList.h"
25 #include "TMap.h"
26 #include "TProof.h"
27 #include "TProofBenchTypes.h"
28 
29 
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Constructor
34 
36 {
37  fProof = proof ? proof : gProof;
38 }
39 
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// Release memory cache for dataset 'dset'
43 /// Return 0 on success, -1 on error
44 
46 {
47  // Clear the cache
49  if (Handle(dset, &type) != 0) {
50  Error("ReleaseCache", "problems clearing cache for '%s'", dset);
51  return -1;
52  }
53  // Done
54  return 0;
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Physically remove the dataset 'dset', i.e. remove the dataset and the files
59 /// it describes
60 /// Return 0 on success, -1 on error
61 
63 {
64  // Phyically remove the files
66  if (Handle(dset, &type) != 0) {
67  Error("RemoveFiles", "problems removing files for '%s'", dset);
68  return -1;
69  }
70  // Remove the meta information
71  if (!fProof || (fProof && fProof->RemoveDataSet(dset) != 0)) {
72  Error("RemoveFiles", "problems removing meta-information for dataset '%s'", dset);
73  return -1;
74  }
75  // Done
76  return 0;
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Copy the files of dataset 'dset' to another directory
81 /// Return 0 on success, -1 on error
82 
83 Int_t TProofBenchDataSet::CopyFiles(const char *dset, const char *destdir)
84 {
85  // Check input
86  if (!destdir || (destdir && strlen(destdir) <= 0)) {
87  Error("CopyFiles", "specifying a destination dir is mandatory!");
88  return -1;
89  }
90 
91  // Set the destination dir
92  if (fProof) fProof->SetParameter("PROOF_Benchmark_DestDir", destdir);
93 
94  // Copy the files
96  if (Handle(dset, &type) != 0) {
97  Error("CopyFiles", "problems copying files for '%s'", dset);
98  return -1;
99  }
100 
101  // Done
102  return 0;
103 }
104 
105 ////////////////////////////////////////////////////////////////////////////////
106 /// Physically remove the dataset 'dset', i.e. remove the dataset and the files
107 /// it describes
108 /// Return 0 on success, -1 on error
109 
111 {
112  // Check input
113  if (!dset || (dset && strlen(dset) <= 0)) {
114  Error("Handle", "a valid dataset name is mandatory");
115  return -1;
116  }
117 
118  // The dataset must exist
119  if (!fProof || (fProof && !fProof->ExistsDataSet(dset))) {
120  Error("Handle", "dataset '%s' does not exist", dset);
121  return -1;
122  }
123 
124  // Get the dataset
126  if (!fc) {
127  Error("Handle", "TFileCollection object for dataset '%s' could not be retrieved", dset);
128  return -1;
129  }
130 
131  // Get information per server
132 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
133  TMap *fcmap = fc->GetFilesPerServer(fProof->GetMaster(), kTRUE);
134 #else
135  TMap *fcmap = fc->GetFilesPerServer(fProof->GetMaster());
136 #endif
137  if (!fcmap) {
138  Error("Handle", "could not create map with per-server info for dataset '%s'", dset);
139  return -1;
140  }
141  fcmap->Print();
142 
143  // Load the selector, if needed
144  TString selName("TSelHandleDataSet");
145  if (!TClass::GetClass(selName)) {
146  // Load the parfile
147 #ifdef R__HAVE_CONFIG
149 #else
150  TString par = TString::Format("$ROOTSYS/etc/%s%s.par", kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
151 #endif
152  Info("Handle", "Uploading '%s' ...", par.Data());
153  if (fProof->UploadPackage(par) != 0) {
154  Error("Handle", "problems uploading '%s' - cannot continue", par.Data());
155  return -1;
156  }
157  Info("Handle", "Enabling '%s' ...", kPROOF_BenchDataSelPar);
159  Error("Handle", "problems enabling '%s' - cannot continue", kPROOF_BenchDataSelPar);
160  return -1;
161  }
162  // Check
163  if (!TClass::GetClass(selName)) {
164  Error("Handle", "failed to load '%s'", selName.Data());
165  return -1;
166  }
167  }
168 
169  // Add map in the input list
170  fcmap->SetName("PROOF_FilesToProcess");
171  fProof->AddInput(fcmap);
172 
173  // Set parameters for processing
174  TString oldpack;
175  if (TProof::GetParameter(fProof->GetInputList(), "PROOF_Packetizer", oldpack) != 0) oldpack = "";
176  fProof->SetParameter("PROOF_Packetizer", "TPacketizerFile");
177 
178  // Process
179  fProof->AddInput(type);
180  fProof->Process(selName, (Long64_t) fc->GetNFiles());
181  if (fProof->GetInputList()) fProof->GetInputList()->Remove(type);
182 
183  // Restore parameters
184  if (!oldpack.IsNull())
185  fProof->SetParameter("PROOF_Packetizer", oldpack);
186  else
187  fProof->DeleteParameters("PROOF_Packetizer");
188 
189  // Cleanup
190  fProof->GetInputList()->Remove(fcmap);
191  delete fcmap;
192  delete fc;
193 
194  // Done
195  return 0;
196 }
double par[1]
Definition: unuranDistr.cxx:38
Long64_t GetNFiles() const
long long Long64_t
Definition: RtypesCore.h:69
virtual Bool_t ExistsDataSet(const char *dataset)
Returns kTRUE if 'dataset' exists, kFALSE otherwise.
Definition: TProof.cxx:11446
Int_t CopyFiles(const char *dset, const char *destdir)
Copy the files of dataset 'dset' to another directory Return 0 on success, -1 on error.
Int_t EnablePackage(const char *package, Bool_t notOnClient=kFALSE, TList *workers=0)
Enable specified package.
Definition: TProof.cxx:8643
void SetParameter(const char *par, const char *value)
Set input list parameter.
Definition: TProof.cxx:10400
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
virtual TFileCollection * GetDataSet(const char *dataset, const char *optStr="")
Get a list of TFileInfo objects describing the files of the specified dataset.
Definition: TProof.cxx:11515
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
const char *const kPROOF_BenchParDir
Handle operations on datasets used by ProofBench.
const char * Data() const
Definition: TString.h:349
static struct mg_connection * fc(struct mg_context *ctx)
Definition: civetweb.c:839
Int_t RemoveFiles(const char *dset)
Physically remove the dataset 'dset', i.e.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2321
const char * GetMaster() const
Definition: TProof.h:939
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
Int_t ReleaseCache(const char *dset)
Release memory cache for dataset 'dset' Return 0 on success, -1 on error.
TObject * GetParameter(const char *par) const
Get specified parameter.
Definition: TProof.cxx:10496
Int_t UploadPackage(const char *par, EUploadPackageOpt opt=kUntar, TList *workers=0)
Upload a PROOF archive (PAR file).
Definition: TProof.cxx:8909
const char *const kPROOF_BenchDataSelPar
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:675
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:5304
Bool_t IsNull() const
Definition: TString.h:387
void SetName(const char *name)
Definition: TCollection.h:116
void AddInput(TObject *obj)
Add objects that might be needed during the processing of the selector (see Process()).
Definition: TProof.cxx:10312
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
Int_t Handle(const char *dset, TObject *type)
Physically remove the dataset 'dset', i.e.
TList * GetInputList()
Get input list.
Definition: TProof.cxx:10331
R__EXTERN TProof * gProof
Definition: TProof.h:1113
void DeleteParameters(const char *wildcard)
Delete the input list parameters specified by a wildcard (e.g.
Definition: TProof.cxx:10511
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
int type
Definition: TGX11.cxx:120
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:342
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2801
ClassImp(TProofBenchDataSet) TProofBenchDataSet
Constructor.
Mother of all ROOT objects.
Definition: TObject.h:58
const char Int_t const char TProof * proof
Definition: TXSlave.cxx:46
Class that contains a list of TFileInfo's and accumulated meta data information about its entries...
virtual Int_t RemoveDataSet(const char *dataset, const char *optStr="")
Remove the specified dataset from the PROOF cluster.
Definition: TProof.cxx:11569
const Bool_t kTRUE
Definition: Rtypes.h:91
TMap * GetFilesPerServer(const char *exclude=0, Bool_t curronly=kFALSE)
Return a map of TFileCollections with the files on each data server, excluding servers in the comma-s...