Loading [MathJax]/extensions/tex2jax.js
ROOT  6.06/09
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TProofBenchDataSet //
15 // //
16 // Handle operations on datasets used by ProofBench //
17 // //
18 //////////////////////////////////////////////////////////////////////////
19 
20 #include "RConfigure.h"
21 
22 #include "TProofBenchDataSet.h"
23 #include "TClass.h"
24 #include "TFileCollection.h"
25 #include "TList.h"
26 #include "TMap.h"
27 #include "TProof.h"
28 #include "TProofBenchTypes.h"
29 
30 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Constructor
35 
37 {
38  fProof = proof ? proof : gProof;
39 }
40 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Release memory cache for dataset 'dset'
44 /// Return 0 on success, -1 on error
45 
47 {
48  // Clear the cache
50  if (Handle(dset, &type) != 0) {
51  Error("ReleaseCache", "problems clearing cache for '%s'", dset);
52  return -1;
53  }
54  // Done
55  return 0;
56 }
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Physically remove the dataset 'dset', i.e. remove the dataset and the files
60 /// it describes
61 /// Return 0 on success, -1 on error
62 
64 {
65  // Phyically remove the files
67  if (Handle(dset, &type) != 0) {
68  Error("RemoveFiles", "problems removing files for '%s'", dset);
69  return -1;
70  }
71  // Remove the meta information
72  if (!fProof || (fProof && fProof->RemoveDataSet(dset) != 0)) {
73  Error("RemoveFiles", "problems removing meta-information for dataset '%s'", dset);
74  return -1;
75  }
76  // Done
77  return 0;
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Copy the files of dataset 'dset' to another directory
82 /// Return 0 on success, -1 on error
83 
84 Int_t TProofBenchDataSet::CopyFiles(const char *dset, const char *destdir)
85 {
86  // Check input
87  if (!destdir || (destdir && strlen(destdir) <= 0)) {
88  Error("CopyFiles", "specifying a destination dir is mandatory!");
89  return -1;
90  }
91 
92  // Set the destination dir
93  if (fProof) fProof->SetParameter("PROOF_Benchmark_DestDir", destdir);
94 
95  // Copy the files
97  if (Handle(dset, &type) != 0) {
98  Error("CopyFiles", "problems copying files for '%s'", dset);
99  return -1;
100  }
101 
102  // Done
103  return 0;
104 }
105 
106 ////////////////////////////////////////////////////////////////////////////////
107 /// Physically remove the dataset 'dset', i.e. remove the dataset and the files
108 /// it describes
109 /// Return 0 on success, -1 on error
110 
112 {
113  // Check input
114  if (!dset || (dset && strlen(dset) <= 0)) {
115  Error("Handle", "a valid dataset name is mandatory");
116  return -1;
117  }
118 
119  // The dataset must exist
120  if (!fProof || (fProof && !fProof->ExistsDataSet(dset))) {
121  Error("Handle", "dataset '%s' does not exist", dset);
122  return -1;
123  }
124 
125  // Get the dataset
127  if (!fc) {
128  Error("Handle", "TFileCollection object for dataset '%s' could not be retrieved", dset);
129  return -1;
130  }
131 
132  // Get information per server
133 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
134  TMap *fcmap = fc->GetFilesPerServer(fProof->GetMaster(), kTRUE);
135 #else
136  TMap *fcmap = fc->GetFilesPerServer(fProof->GetMaster());
137 #endif
138  if (!fcmap) {
139  Error("Handle", "could not create map with per-server info for dataset '%s'", dset);
140  return -1;
141  }
142  fcmap->Print();
143 
144  // Load the selector, if needed
145  TString selName("TSelHandleDataSet");
146  if (!TClass::GetClass(selName)) {
147  // Load the parfile
148 #ifdef R__HAVE_CONFIG
150 #else
151  TString par = TString::Format("$ROOTSYS/etc/%s%s.par", kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
152 #endif
153  Info("Handle", "Uploading '%s' ...", par.Data());
154  if (fProof->UploadPackage(par) != 0) {
155  Error("Handle", "problems uploading '%s' - cannot continue", par.Data());
156  return -1;
157  }
158  Info("Handle", "Enabling '%s' ...", kPROOF_BenchDataSelPar);
160  Error("Handle", "problems enabling '%s' - cannot continue", kPROOF_BenchDataSelPar);
161  return -1;
162  }
163  // Check
164  if (!TClass::GetClass(selName)) {
165  Error("Handle", "failed to load '%s'", selName.Data());
166  return -1;
167  }
168  }
169 
170  // Add map in the input list
171  fcmap->SetName("PROOF_FilesToProcess");
172  fProof->AddInput(fcmap);
173 
174  // Set parameters for processing
175  TString oldpack;
176  if (TProof::GetParameter(fProof->GetInputList(), "PROOF_Packetizer", oldpack) != 0) oldpack = "";
177  fProof->SetParameter("PROOF_Packetizer", "TPacketizerFile");
178 
179  // Process
180  fProof->AddInput(type);
181  fProof->Process(selName, (Long64_t) fc->GetNFiles());
182  if (fProof->GetInputList()) fProof->GetInputList()->Remove(type);
183 
184  // Restore parameters
185  if (!oldpack.IsNull())
186  fProof->SetParameter("PROOF_Packetizer", oldpack);
187  else
188  fProof->DeleteParameters("PROOF_Packetizer");
189 
190  // Cleanup
191  fProof->GetInputList()->Remove(fcmap);
192  delete fcmap;
193  delete fc;
194 
195  // Done
196  return 0;
197 }
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:11435
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:8632
void SetParameter(const char *par, const char *value)
Set input list parameter.
Definition: TProof.cxx:10389
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:11504
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
const char *const kPROOF_BenchParDir
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:2334
const char * GetMaster() const
Definition: TProof.h:936
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:10485
Int_t UploadPackage(const char *par, EUploadPackageOpt opt=kUntar, TList *workers=0)
Upload a PROOF archive (PAR file).
Definition: TProof.cxx:8898
const char *const kPROOF_BenchDataSelPar
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:674
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:5293
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:10301
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:10320
R__EXTERN TProof * gProof
Definition: TProof.h:1110
void DeleteParameters(const char *wildcard)
Delete the input list parameters specified by a wildcard (e.g.
Definition: TProof.cxx:10500
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
Definition: TProof.h:339
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:2881
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:11558
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...