ROOT  6.06/08
Reference Guide
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 #include "TROOT.h"
30 
31 
33 
34 ////////////////////////////////////////////////////////////////////////////////
35 /// Constructor
36 
38 {
39  fProof = proof ? proof : gProof;
40 }
41 
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// Release memory cache for dataset 'dset'
45 /// Return 0 on success, -1 on error
46 
48 {
49  // Clear the cache
51  if (Handle(dset, &type) != 0) {
52  Error("ReleaseCache", "problems clearing cache for '%s'", dset);
53  return -1;
54  }
55  // Done
56  return 0;
57 }
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// Physically remove the dataset 'dset', i.e. remove the dataset and the files
61 /// it describes
62 /// Return 0 on success, -1 on error
63 
65 {
66  // Phyically remove the files
68  if (Handle(dset, &type) != 0) {
69  Error("RemoveFiles", "problems removing files for '%s'", dset);
70  return -1;
71  }
72  // Remove the meta information
73  if (!fProof || (fProof && fProof->RemoveDataSet(dset) != 0)) {
74  Error("RemoveFiles", "problems removing meta-information for dataset '%s'", dset);
75  return -1;
76  }
77  // Done
78  return 0;
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Copy the files of dataset 'dset' to another directory
83 /// Return 0 on success, -1 on error
84 
85 Int_t TProofBenchDataSet::CopyFiles(const char *dset, const char *destdir)
86 {
87  // Check input
88  if (!destdir || (destdir && strlen(destdir) <= 0)) {
89  Error("CopyFiles", "specifying a destination dir is mandatory!");
90  return -1;
91  }
92 
93  // Set the destination dir
94  if (fProof) fProof->SetParameter("PROOF_Benchmark_DestDir", destdir);
95 
96  // Copy the files
98  if (Handle(dset, &type) != 0) {
99  Error("CopyFiles", "problems copying files for '%s'", dset);
100  return -1;
101  }
102 
103  // Done
104  return 0;
105 }
106 
107 ////////////////////////////////////////////////////////////////////////////////
108 /// Physically remove the dataset 'dset', i.e. remove the dataset and the files
109 /// it describes
110 /// Return 0 on success, -1 on error
111 
113 {
114  // Check input
115  if (!dset || (dset && strlen(dset) <= 0)) {
116  Error("Handle", "a valid dataset name is mandatory");
117  return -1;
118  }
119 
120  // The dataset must exist
121  if (!fProof || (fProof && !fProof->ExistsDataSet(dset))) {
122  Error("Handle", "dataset '%s' does not exist", dset);
123  return -1;
124  }
125 
126  // Get the dataset
128  if (!fc) {
129  Error("Handle", "TFileCollection object for dataset '%s' could not be retrieved", dset);
130  return -1;
131  }
132 
133  // Get information per server
134 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
135  TMap *fcmap = fc->GetFilesPerServer(fProof->GetMaster(), kTRUE);
136 #else
137  TMap *fcmap = fc->GetFilesPerServer(fProof->GetMaster());
138 #endif
139  if (!fcmap) {
140  Error("Handle", "could not create map with per-server info for dataset '%s'", dset);
141  return -1;
142  }
143  fcmap->Print();
144 
145  // Load the selector, if needed
146  TString selName("TSelHandleDataSet");
147  if (!TClass::GetClass(selName)) {
148  // Load the parfile
150  Info("Handle", "Uploading '%s' ...", par.Data());
151  if (fProof->UploadPackage(par) != 0) {
152  Error("Handle", "problems uploading '%s' - cannot continue", par.Data());
153  return -1;
154  }
155  Info("Handle", "Enabling '%s' ...", kPROOF_BenchDataSelPar);
157  Error("Handle", "problems enabling '%s' - cannot continue", kPROOF_BenchDataSelPar);
158  return -1;
159  }
160  // Check
161  if (!TClass::GetClass(selName)) {
162  Error("Handle", "failed to load '%s'", selName.Data());
163  return -1;
164  }
165  }
166 
167  // Add map in the input list
168  fcmap->SetName("PROOF_FilesToProcess");
169  fProof->AddInput(fcmap);
170 
171  // Set parameters for processing
172  TString oldpack;
173  if (TProof::GetParameter(fProof->GetInputList(), "PROOF_Packetizer", oldpack) != 0) oldpack = "";
174  fProof->SetParameter("PROOF_Packetizer", "TPacketizerFile");
175 
176  // Process
177  fProof->AddInput(type);
178  fProof->Process(selName, (Long64_t) fc->GetNFiles());
179  if (fProof->GetInputList()) fProof->GetInputList()->Remove(type);
180 
181  // Restore parameters
182  if (!oldpack.IsNull())
183  fProof->SetParameter("PROOF_Packetizer", oldpack);
184  else
185  fProof->DeleteParameters("PROOF_Packetizer");
186 
187  // Cleanup
188  fProof->GetInputList()->Remove(fcmap);
189  delete fcmap;
190  delete fc;
191 
192  // Done
193  return 0;
194 }
double par[1]
Definition: unuranDistr.cxx:38
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
long long Long64_t
Definition: RtypesCore.h:69
virtual Bool_t ExistsDataSet(const char *dataset)
Returns kTRUE if &#39;dataset&#39; exists, kFALSE otherwise.
Definition: TProof.cxx:11435
Int_t CopyFiles(const char *dset, const char *destdir)
Copy the files of dataset &#39;dset&#39; 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
TObject * GetParameter(const char *par) const
Get specified parameter.
Definition: TProof.cxx:10485
void SetParameter(const char *par, const char *value)
Set input list parameter.
Definition: TProof.cxx:10389
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
static struct mg_connection * fc(struct mg_context *ctx)
Definition: civetweb.c:839
Int_t RemoveFiles(const char *dset)
Physically remove the dataset &#39;dset&#39;, 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
std::vector< std::vector< double > > Data
Int_t ReleaseCache(const char *dset)
Release memory cache for dataset &#39;dset&#39; Return 0 on success, -1 on error.
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
Long64_t GetNFiles() const
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:674
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
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
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
Int_t Handle(const char *dset, TObject *type)
Physically remove the dataset &#39;dset&#39;, i.e.
TList * GetInputList()
Get input list.
Definition: TProof.cxx:10320
R__EXTERN TProof * gProof
Definition: TProof.h:1110
#define ClassImp(name)
Definition: Rtypes.h:279
void DeleteParameters(const char *wildcard)
Delete the input list parameters specified by a wildcard (e.g.
Definition: TProof.cxx:10500
const char * GetMaster() const
Definition: TProof.h:936
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
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition: TROOT.cxx:2601
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:2871
Bool_t IsNull() const
Definition: TString.h:387
Mother of all ROOT objects.
Definition: TObject.h:58
Class that contains a list of TFileInfo&#39;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
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
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...
const char * Data() const
Definition: TString.h:349