forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TProofBenchDataSet.cxx
197 lines (167 loc) · 6.3 KB
/
TProofBenchDataSet.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// @(#)root/proof:$Id$
// Author: Sangsu Ryu 22/06/2010
/*************************************************************************
* Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
//////////////////////////////////////////////////////////////////////////
// //
// TProofBenchDataSet //
// //
// Handle operations on datasets used by ProofBench //
// //
//////////////////////////////////////////////////////////////////////////
#include "RConfigure.h"
#include "TProofBenchDataSet.h"
#include "TClass.h"
#include "TFileCollection.h"
#include "TList.h"
#include "TMap.h"
#include "TProof.h"
#include "TProofBenchTypes.h"
ClassImp(TProofBenchDataSet)
//______________________________________________________________________________
TProofBenchDataSet::TProofBenchDataSet(TProof *proof)
{
// Constructor
fProof = proof ? proof : gProof;
}
//______________________________________________________________________________
Int_t TProofBenchDataSet::ReleaseCache(const char *dset)
{
// Release memory cache for dataset 'dset'
// Return 0 on success, -1 on error
// Clear the cache
TPBHandleDSType type(TPBHandleDSType::kReleaseCache);
if (Handle(dset, &type) != 0) {
Error("ReleaseCache", "problems clearing cache for '%s'", dset);
return -1;
}
// Done
return 0;
}
//______________________________________________________________________________
Int_t TProofBenchDataSet::RemoveFiles(const char *dset)
{
// Physically remove the dataset 'dset', i.e. remove the dataset and the files
// it describes
// Return 0 on success, -1 on error
// Phyically remove the files
TPBHandleDSType type(TPBHandleDSType::kRemoveFiles);
if (Handle(dset, &type) != 0) {
Error("RemoveFiles", "problems removing files for '%s'", dset);
return -1;
}
// Remove the meta information
if (!fProof || (fProof && fProof->RemoveDataSet(dset) != 0)) {
Error("RemoveFiles", "problems removing meta-information for dataset '%s'", dset);
return -1;
}
// Done
return 0;
}
//______________________________________________________________________________
Int_t TProofBenchDataSet::CopyFiles(const char *dset, const char *destdir)
{
// Copy the files of dataset 'dset' to another directory
// Return 0 on success, -1 on error
// Check input
if (!destdir || (destdir && strlen(destdir) <= 0)) {
Error("CopyFiles", "specifying a destination dir is mandatory!");
return -1;
}
// Set the destination dir
if (fProof) fProof->SetParameter("PROOF_Benchmark_DestDir", destdir);
// Copy the files
TPBHandleDSType type(TPBHandleDSType::kCopyFiles);
if (Handle(dset, &type) != 0) {
Error("CopyFiles", "problems copying files for '%s'", dset);
return -1;
}
// Done
return 0;
}
//______________________________________________________________________________
Int_t TProofBenchDataSet::Handle(const char *dset, TObject *type)
{
// Physically remove the dataset 'dset', i.e. remove the dataset and the files
// it describes
// Return 0 on success, -1 on error
// Check input
if (!dset || (dset && strlen(dset) <= 0)) {
Error("Handle", "a valid dataset name is mandatory");
return -1;
}
// The dataset must exist
if (!fProof || (fProof && !fProof->ExistsDataSet(dset))) {
Error("Handle", "dataset '%s' does not exist", dset);
return -1;
}
// Get the dataset
TFileCollection *fc = fProof->GetDataSet(dset);
if (!fc) {
Error("Handle", "TFileCollection object for dataset '%s' could not be retrieved", dset);
return -1;
}
// Get information per server
#if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
TMap *fcmap = fc->GetFilesPerServer(fProof->GetMaster(), kTRUE);
#else
TMap *fcmap = fc->GetFilesPerServer(fProof->GetMaster());
#endif
if (!fcmap) {
Error("Handle", "could not create map with per-server info for dataset '%s'", dset);
return -1;
}
fcmap->Print();
// Load the selector, if needed
TString selName("TSelHandleDataSet");
if (!TClass::GetClass(selName)) {
// Load the parfile
#ifdef R__HAVE_CONFIG
TString par = TString::Format("%s/%s%s.par", ROOTETCDIR, kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
#else
TString par = TString::Format("$ROOTSYS/etc/%s%s.par", kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
#endif
Info("Handle", "Uploading '%s' ...", par.Data());
if (fProof->UploadPackage(par) != 0) {
Error("Handle", "problems uploading '%s' - cannot continue", par.Data());
return -1;
}
Info("Handle", "Enabling '%s' ...", kPROOF_BenchDataSelPar);
if (fProof->EnablePackage(kPROOF_BenchDataSelPar) != 0) {
Error("Handle", "problems enabling '%s' - cannot continue", kPROOF_BenchDataSelPar);
return -1;
}
// Check
if (!TClass::GetClass(selName)) {
Error("Handle", "failed to load '%s'", selName.Data());
return -1;
}
}
// Add map in the input list
fcmap->SetName("PROOF_FilesToProcess");
fProof->AddInput(fcmap);
// Set parameters for processing
TString oldpack;
if (TProof::GetParameter(fProof->GetInputList(), "PROOF_Packetizer", oldpack) != 0) oldpack = "";
fProof->SetParameter("PROOF_Packetizer", "TPacketizerFile");
// Process
fProof->AddInput(type);
fProof->Process(selName, (Long64_t) fc->GetNFiles());
if (fProof->GetInputList()) fProof->GetInputList()->Remove(type);
// Restore parameters
if (!oldpack.IsNull())
fProof->SetParameter("PROOF_Packetizer", oldpack);
else
fProof->DeleteParameters("PROOF_Packetizer");
// Cleanup
fProof->GetInputList()->Remove(fcmap);
delete fcmap;
delete fc;
// Done
return 0;
}