Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 : /////////////////////////////////////////////////////////////////////////////////////////////////
17 : // //
18 : // AliCDBLocal //
19 : // access class to a DataBase in a local storage //
20 : // //
21 : /////////////////////////////////////////////////////////////////////////////////////////////////
22 :
23 : #include <cstdlib>
24 : #include <stdexcept>
25 : #include <fstream>
26 :
27 : #include <TSystem.h>
28 : #include <TObjString.h>
29 : #include <TRegexp.h>
30 : #include <TFile.h>
31 : #include <TKey.h>
32 :
33 : #include "AliCDBLocal.h"
34 : #include "AliCDBEntry.h"
35 : #include "AliLog.h"
36 : using namespace std;
37 :
38 128 : ClassImp(AliCDBLocal)
39 :
40 : //_____________________________________________________________________________
41 12 : AliCDBLocal::AliCDBLocal(const char* baseDir):
42 12 : fBaseDirectory(baseDir)
43 60 : {
44 : // constructor
45 :
46 60 : AliDebug(1, Form("fBaseDirectory = %s",fBaseDirectory.Data()));
47 :
48 : // check baseDire: trying to cd to baseDir; if it does not exist, create it
49 12 : void* dir = gSystem->OpenDirectory(baseDir);
50 12 : if (dir == NULL) {
51 0 : if (gSystem->mkdir(baseDir, kTRUE)) {
52 0 : AliError(Form("Can't open directory <%s>!", baseDir)); //!!!!!!!! to be commented out for testing
53 : }
54 :
55 : } else {
56 60 : AliDebug(2,Form("Folder <%s> found",fBaseDirectory.Data()));
57 12 : gSystem->FreeDirectory(dir);
58 : }
59 12 : fType="local";
60 12 : fBaseFolder = fBaseDirectory;
61 24 : }
62 :
63 : //_____________________________________________________________________________
64 0 : AliCDBLocal::~AliCDBLocal() {
65 : // destructor
66 :
67 0 : }
68 :
69 :
70 : //_____________________________________________________________________________
71 : Bool_t AliCDBLocal::FilenameToId(const char* filename, AliCDBRunRange& runRange,
72 : Int_t& version, Int_t& subVersion) {
73 : // build AliCDBId from filename numbers
74 :
75 5850 : Ssiz_t mSize;
76 :
77 : // valid filename: Run#firstRun_#lastRun_v#version_s#subVersion.root
78 2925 : TRegexp keyPattern("^Run[0-9]+_[0-9]+_v[0-9]+_s[0-9]+.root$");
79 8775 : keyPattern.Index(filename, &mSize);
80 2925 : if (!mSize) {
81 25 : AliDebug(2, Form("Bad filename <%s>.", filename));
82 5 : return kFALSE;
83 : }
84 :
85 2920 : TString idString(filename);
86 5840 : idString.Resize(idString.Length() - sizeof(".root") + 1);
87 :
88 8760 : TObjArray* strArray = (TObjArray*) idString.Tokenize("_");
89 :
90 5840 : TString firstRunString(((TObjString*) strArray->At(0))->GetString());
91 8760 : runRange.SetFirstRun(atoi(firstRunString.Data() + 3));
92 14600 : runRange.SetLastRun(atoi(((TObjString*) strArray->At(1))->GetString()));
93 :
94 5840 : TString verString(((TObjString*) strArray->At(2))->GetString());
95 8760 : version = atoi(verString.Data() + 1);
96 :
97 5840 : TString subVerString(((TObjString*) strArray->At(3))->GetString());
98 8760 : subVersion = atoi(subVerString.Data() + 1);
99 :
100 5840 : delete strArray;
101 :
102 : return kTRUE;
103 5845 : }
104 :
105 :
106 : //_____________________________________________________________________________
107 : Bool_t AliCDBLocal::IdToFilename(const AliCDBId& id, TString& filename) const {
108 : // build file name from AliCDBId data (run range, version, subVersion)
109 :
110 2960 : AliDebug(1, Form("fBaseDirectory = %s",fBaseDirectory.Data()));
111 :
112 740 : if (!id.GetAliCDBRunRange().IsValid()) {
113 0 : AliDebug(2,Form("Invalid run range <%d, %d>.",
114 : id.GetFirstRun(), id.GetLastRun()));
115 0 : return kFALSE;
116 : }
117 :
118 740 : if (id.GetVersion() < 0) {
119 0 : AliDebug(2,Form("Invalid version <%d>.", id.GetVersion()));
120 0 : return kFALSE;
121 : }
122 :
123 740 : if (id.GetSubVersion() < 0) {
124 0 : AliDebug(2,Form("Invalid subversion <%d>.", id.GetSubVersion()));
125 0 : return kFALSE;
126 : }
127 :
128 1480 : filename = Form("Run%d_%d_v%d_s%d.root", id.GetFirstRun(), id.GetLastRun(),
129 740 : id.GetVersion(), id.GetSubVersion());
130 :
131 3700 : filename.Prepend(fBaseDirectory +'/' + id.GetPath() + '/');
132 :
133 740 : return kTRUE;
134 740 : }
135 :
136 : //_____________________________________________________________________________
137 : Bool_t AliCDBLocal::PrepareId(AliCDBId& id) {
138 : // prepare id (version, subVersion) of the object that will be stored (called by PutEntry)
139 :
140 2 : TString dirName = Form("%s/%s", fBaseDirectory.Data(), id.GetPath().Data());
141 :
142 : // go to the path; if directory does not exist, create it
143 2 : void* dirPtr = gSystem->OpenDirectory(dirName);
144 1 : if (!dirPtr) {
145 2 : gSystem->mkdir(dirName, kTRUE);
146 2 : dirPtr = gSystem->OpenDirectory(dirName);
147 :
148 1 : if (!dirPtr) {
149 0 : AliError(Form("Can't create directory <%s>!",
150 : dirName.Data()));
151 0 : return kFALSE;
152 : }
153 : }
154 :
155 : const char* filename;
156 1 : AliCDBRunRange aRunRange; // the runRange got from filename
157 1 : AliCDBRunRange lastRunRange(-1,-1); // highest runRange found
158 1 : Int_t aVersion, aSubVersion; // the version subVersion got from filename
159 : Int_t lastVersion = 0, lastSubVersion = -1; // highest version and subVersion found
160 :
161 1 : if (!id.HasVersion()) { // version not specified: look for highest version & subVersion
162 :
163 0 : while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on the files
164 :
165 0 : TString aString(filename);
166 0 : if (aString == "." || aString == "..") continue;
167 :
168 0 : if (!FilenameToId(filename, aRunRange, aVersion,
169 : aSubVersion)) {
170 0 : AliDebug(2,Form(
171 : "Bad filename <%s>! I'll skip it.",
172 : filename));
173 0 : continue;
174 : }
175 :
176 0 : if (!aRunRange.Overlaps(id.GetAliCDBRunRange())) continue;
177 0 : if(aVersion < lastVersion) continue;
178 0 : if(aVersion > lastVersion) lastSubVersion = -1;
179 0 : if(aSubVersion < lastSubVersion) continue;
180 0 : lastVersion = aVersion;
181 : lastSubVersion = aSubVersion;
182 0 : lastRunRange = aRunRange;
183 0 : }
184 :
185 0 : id.SetVersion(lastVersion);
186 0 : id.SetSubVersion(lastSubVersion + 1);
187 :
188 0 : } else { // version specified, look for highest subVersion only
189 :
190 6 : while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on the files
191 :
192 2 : TString aString(filename);
193 6 : if (aString == "." || aString == "..") {
194 2 : continue;
195 : }
196 :
197 0 : if (!FilenameToId(filename, aRunRange, aVersion,
198 : aSubVersion)) {
199 0 : AliDebug(2,Form(
200 : "Bad filename <%s>!I'll skip it.",
201 : filename));
202 0 : continue;
203 : }
204 :
205 0 : if (aRunRange.Overlaps(id.GetAliCDBRunRange())
206 0 : && aVersion == id.GetVersion()
207 0 : && aSubVersion > lastSubVersion) {
208 : lastSubVersion = aSubVersion;
209 0 : lastRunRange = aRunRange;
210 : }
211 :
212 2 : }
213 :
214 1 : id.SetSubVersion(lastSubVersion + 1);
215 : }
216 :
217 1 : gSystem->FreeDirectory(dirPtr);
218 :
219 1 : TString lastStorage = id.GetLastStorage();
220 4 : if(lastStorage.Contains(TString("grid"), TString::kIgnoreCase) &&
221 0 : id.GetSubVersion() > 0 ){
222 0 : AliError(Form("Grid to Local Storage error! local object with version v%d_s%d found:",id.GetVersion(), id.GetSubVersion()-1));
223 0 : AliError(Form("This object has been already transferred from Grid (check v%d_s0)!",id.GetVersion()));
224 0 : return kFALSE;
225 : }
226 :
227 4 : if(lastStorage.Contains(TString("new"), TString::kIgnoreCase) &&
228 1 : id.GetSubVersion() > 0 ){
229 0 : AliDebug(2, Form("A NEW object is being stored with version v%d_s%d",
230 : id.GetVersion(),id.GetSubVersion()));
231 0 : AliDebug(2, Form("and it will hide previously stored object with v%d_s%d!",
232 : id.GetVersion(),id.GetSubVersion()-1));
233 : }
234 :
235 1 : if(!lastRunRange.IsAnyRange() && !(lastRunRange.IsEqual(& id.GetAliCDBRunRange())))
236 0 : AliWarning(Form("Run range modified w.r.t. previous version (Run%d_%d_v%d_s%d)",
237 : lastRunRange.GetFirstRun(), lastRunRange.GetLastRun(),
238 : id.GetVersion(), id.GetSubVersion()-1));
239 :
240 1 : return kTRUE;
241 2 : }
242 :
243 :
244 : //_____________________________________________________________________________
245 : AliCDBId* AliCDBLocal::GetId(const AliCDBId& query) {
246 : // look for filename matching query (called by GetEntryId)
247 :
248 : // if querying for fRun and not specifying a version, look in the fValidFileIds list
249 5104 : if(!AliCDBManager::Instance()->GetCvmfsOcdbTag().IsNull() && query.GetFirstRun() == fRun && !query.HasVersion()) {
250 : //if(query.GetFirstRun() == fRun && !query.HasVersion()) {
251 : // get id from fValidFileIds
252 0 : TIter iter(&fValidFileIds);
253 :
254 : AliCDBId *anIdPtr=0;
255 : AliCDBId* result=0;
256 :
257 0 : while((anIdPtr = dynamic_cast<AliCDBId*> (iter.Next()))){
258 0 : if(anIdPtr->GetPath() == query.GetPath()){
259 0 : result = new AliCDBId(*anIdPtr);
260 0 : break;
261 : }
262 : }
263 : return result;
264 0 : }
265 :
266 : // otherwise browse in the local filesystem CDB storage
267 1276 : TString dirName = Form("%s/%s", fBaseDirectory.Data(), query.GetPath().Data());
268 :
269 2552 : void* dirPtr = gSystem->OpenDirectory(dirName);
270 1276 : if (!dirPtr) {
271 5 : AliDebug(2,Form("Directory <%s> not found", (query.GetPath()).Data()));
272 5 : AliDebug(2,Form("in DB folder %s", fBaseDirectory.Data()));
273 1 : return NULL;
274 : }
275 :
276 : const char* filename;
277 2550 : AliCDBId *result = new AliCDBId();
278 3825 : result->SetPath(query.GetPath());
279 :
280 1275 : AliCDBRunRange aRunRange; // the runRange got from filename
281 1275 : Int_t aVersion, aSubVersion; // the version and subVersion got from filename
282 :
283 1275 : if (!query.HasVersion()) { // neither version and subversion specified -> look for highest version and subVersion
284 :
285 1628 : while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files
286 :
287 611 : TString aString(filename);
288 2239 : if (aString.BeginsWith('.')) continue;
289 :
290 410 : if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue;
291 : // aRunRange, aVersion, aSubVersion filled from filename
292 :
293 411 : if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue;
294 : // aRunRange contains requested run!
295 :
296 1020 : AliDebug(1,Form("Filename %s matches\n",filename));
297 :
298 204 : if (result->GetVersion() < aVersion) {
299 204 : result->SetVersion(aVersion);
300 204 : result->SetSubVersion(aSubVersion);
301 :
302 204 : result->SetFirstRun(
303 204 : aRunRange.GetFirstRun());
304 204 : result->SetLastRun(
305 204 : aRunRange.GetLastRun());
306 :
307 204 : } else if (result->GetVersion() == aVersion
308 0 : && result->GetSubVersion()
309 0 : < aSubVersion) {
310 :
311 0 : result->SetSubVersion(aSubVersion);
312 :
313 0 : result->SetFirstRun(
314 0 : aRunRange.GetFirstRun());
315 0 : result->SetLastRun(
316 0 : aRunRange.GetLastRun());
317 0 : } else if (result->GetVersion() == aVersion
318 0 : && result->GetSubVersion() == aSubVersion){
319 0 : AliError(Form("More than one object valid for run %d, version %d_%d!",
320 : query.GetFirstRun(), aVersion, aSubVersion));
321 0 : gSystem->FreeDirectory(dirPtr);
322 0 : delete result;
323 0 : return NULL;
324 : }
325 815 : }
326 :
327 1072 : } else if (!query.HasSubVersion()) { // version specified but not subversion -> look for highest subVersion
328 0 : result->SetVersion(query.GetVersion());
329 :
330 0 : while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files
331 :
332 0 : TString aString(filename);
333 0 : if (aString.BeginsWith('.')) continue;
334 :
335 0 : if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) continue;
336 : // aRunRange, aVersion, aSubVersion filled from filename
337 :
338 0 : if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue;
339 : // aRunRange contains requested run!
340 :
341 0 : if(query.GetVersion() != aVersion) continue;
342 : // aVersion is requested version!
343 :
344 0 : if(result->GetSubVersion() == aSubVersion){
345 0 : AliError(Form("More than one object valid for run %d, version %d_%d!",
346 : query.GetFirstRun(), aVersion, aSubVersion));
347 0 : gSystem->FreeDirectory(dirPtr);
348 0 : delete result;
349 0 : return NULL;
350 : }
351 0 : if( result->GetSubVersion() < aSubVersion) {
352 :
353 0 : result->SetSubVersion(aSubVersion);
354 :
355 0 : result->SetFirstRun(
356 0 : aRunRange.GetFirstRun());
357 0 : result->SetLastRun(
358 0 : aRunRange.GetLastRun());
359 0 : }
360 0 : }
361 :
362 : } else { // both version and subversion specified
363 :
364 : //AliCDBId dataId(queryId.GetAliCDBPath(), -1, -1, -1, -1);
365 : //Bool_t result;
366 6440 : while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files
367 :
368 3220 : TString aString(filename);
369 11804 : if (aString.BeginsWith('.')) continue;
370 :
371 2152 : if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)){
372 0 : AliDebug(5, Form("Could not make id from file: %s", filename));
373 0 : continue;
374 : }
375 : // aRunRange, aVersion, aSubVersion filled from filename
376 :
377 2152 : if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue;
378 : // aRunRange contains requested run!
379 :
380 2148 : if(query.GetVersion() != aVersion || query.GetSubVersion() != aSubVersion){
381 4 : continue;
382 : }
383 : // aVersion and aSubVersion are requested version and subVersion!
384 :
385 1072 : result->SetVersion(aVersion);
386 1072 : result->SetSubVersion(aSubVersion);
387 1072 : result->SetFirstRun(aRunRange.GetFirstRun());
388 1072 : result->SetLastRun(aRunRange.GetLastRun());
389 1072 : break;
390 3220 : }
391 : }
392 :
393 1275 : gSystem->FreeDirectory(dirPtr);
394 :
395 1275 : return result;
396 3827 : }
397 :
398 : //_____________________________________________________________________________
399 : AliCDBEntry* AliCDBLocal::GetEntry(const AliCDBId& queryId) {
400 : // get AliCDBEntry from the storage (the CDB file matching the query is
401 : // selected by GetEntryId and the contained AliCDBid is passed here)
402 :
403 1480 : AliCDBId* dataId = GetEntryId(queryId);
404 :
405 2221 : TString errMessage(TString::Format("No valid CDB object found! request was: %s", queryId.ToString().Data()));
406 2218 : if (!dataId || !dataId->IsSpecified()){
407 3 : AliError(Form("No file found matching this id!"));
408 3 : throw std::runtime_error(errMessage.Data());
409 : return NULL;
410 : }
411 :
412 739 : TString filename;
413 1478 : if (!IdToFilename(*dataId, filename)) {
414 0 : AliError(Form("Bad data ID encountered!"));
415 0 : delete dataId;
416 0 : throw std::runtime_error(errMessage.Data());
417 : return NULL;
418 : }
419 :
420 1478 : TFile file(filename, "READ"); // open file
421 1478 : if (!file.IsOpen()) {
422 0 : AliError(Form("Can't open file <%s>!", filename.Data()));
423 0 : delete dataId;
424 0 : throw std::runtime_error(errMessage.Data());
425 : return NULL;
426 : }
427 :
428 : // get the only AliCDBEntry object from the file
429 : // the object in the file is an AliCDBEntry entry named "AliCDBEntry"
430 :
431 2956 : AliCDBEntry* anEntry = dynamic_cast<AliCDBEntry*> (file.Get("AliCDBEntry"));
432 739 : if (!anEntry) {
433 0 : AliError(Form("Bad storage data: No AliCDBEntry in file!"));
434 0 : file.Close();
435 0 : delete dataId;
436 0 : throw std::runtime_error(errMessage.Data());
437 : return NULL;
438 : }
439 :
440 739 : AliCDBId& entryId = anEntry->GetId();
441 :
442 : // The object's Id are not reset during storage
443 : // If object's Id runRange or version do not match with filename,
444 : // it means that someone renamed file by hand. In this case a warning msg is issued.
445 :
446 2217 : anEntry-> SetLastStorage("local");
447 :
448 1478 : if(!entryId.IsEqual(dataId)){
449 9 : AliWarning(Form("Mismatch between file name and object's Id!"));
450 18 : AliWarning(Form("File name: %s", dataId->ToString().Data()));
451 18 : AliWarning(Form("Object's Id: %s", entryId.ToString().Data()));
452 3 : }
453 :
454 : // Check whether entry contains a TTree. In case load the tree in memory!
455 739 : LoadTreeFromFile(anEntry);
456 :
457 : // close file, return retrieved entry
458 739 : file.Close();
459 1478 : delete dataId;
460 :
461 : return anEntry;
462 741 : }
463 :
464 : //_____________________________________________________________________________
465 : AliCDBId* AliCDBLocal::GetEntryId(const AliCDBId& queryId) {
466 : // get AliCDBId from the storage
467 : // Via GetId, select the CDB file matching the query and return
468 : // the contained AliCDBId
469 :
470 : AliCDBId* dataId = 0;
471 :
472 : // look for a filename matching query requests (path, runRange, version, subVersion)
473 1480 : if (!queryId.HasVersion()) {
474 : // if version is not specified, first check the selection criteria list
475 204 : AliCDBId selectedId(queryId);
476 204 : GetSelection(&selectedId);
477 204 : dataId = GetId(selectedId);
478 204 : } else {
479 536 : dataId = GetId(queryId);
480 : }
481 :
482 1479 : if (dataId && !dataId->IsSpecified()) {
483 0 : delete dataId;
484 0 : return NULL;
485 : }
486 :
487 740 : return dataId;
488 740 : }
489 :
490 : //_____________________________________________________________________________
491 : void AliCDBLocal::GetEntriesForLevel0(const char* level0,
492 : const AliCDBId& queryId, TList* result) {
493 : // multiple request (AliCDBStorage::GetAll)
494 :
495 0 : TString level0Dir = Form("%s/%s", fBaseDirectory.Data(), level0);
496 :
497 0 : void* level0DirPtr = gSystem->OpenDirectory(level0Dir);
498 0 : if (!level0DirPtr) {
499 0 : AliDebug(2,Form("Can't open level0 directory <%s>!",
500 : level0Dir.Data()));
501 0 : return;
502 : }
503 :
504 : const char* level1;
505 0 : Long_t flag=0;
506 0 : while ((level1 = gSystem->GetDirEntry(level0DirPtr))) {
507 :
508 0 : TString level1Str(level1);
509 : // skip directories starting with a dot (".svn" and similar in old svn working copies)
510 0 : if (level1Str.BeginsWith('.')) {
511 0 : continue;
512 : }
513 :
514 0 : TString fullPath = Form("%s/%s",level0Dir.Data(), level1);
515 :
516 0 : Int_t res=gSystem->GetPathInfo(fullPath.Data(), 0, (Long64_t*) 0, &flag, 0);
517 :
518 0 : if(res){
519 0 : AliDebug(2, Form("Error reading entry %s !",level1Str.Data()));
520 0 : continue;
521 : }
522 0 : if(!(flag&2)) continue; // bit 1 of flag = directory!
523 :
524 0 : if (queryId.GetAliCDBPath().Level1Comprises(level1)) {
525 0 : GetEntriesForLevel1(level0, level1, queryId, result);
526 : }
527 0 : }
528 :
529 0 : gSystem->FreeDirectory(level0DirPtr);
530 0 : }
531 :
532 : //_____________________________________________________________________________
533 : void AliCDBLocal::GetEntriesForLevel1(const char* level0, const char* level1,
534 : const AliCDBId& queryId, TList* result) {
535 : // multiple request (AliCDBStorage::GetAll)
536 :
537 0 : TString level1Dir = Form("%s/%s/%s", fBaseDirectory.Data(), level0,level1);
538 :
539 0 : void* level1DirPtr = gSystem->OpenDirectory(level1Dir);
540 0 : if (!level1DirPtr) {
541 0 : AliDebug(2,Form("Can't open level1 directory <%s>!",
542 : level1Dir.Data()));
543 0 : return;
544 : }
545 :
546 : const char* level2;
547 0 : Long_t flag=0;
548 0 : while ((level2 = gSystem->GetDirEntry(level1DirPtr))) {
549 :
550 0 : TString level2Str(level2);
551 : // skip directories starting with a dot (".svn" and similar in old svn working copies)
552 0 : if (level2Str.BeginsWith('.')) {
553 0 : continue;
554 : }
555 :
556 0 : TString fullPath = Form("%s/%s",level1Dir.Data(), level2);
557 :
558 0 : Int_t res=gSystem->GetPathInfo(fullPath.Data(), 0, (Long64_t*) 0, &flag, 0);
559 :
560 0 : if(res){
561 0 : AliDebug(2, Form("Error reading entry %s !",level2Str.Data()));
562 0 : continue;
563 : }
564 0 : if(!(flag&2)) continue; // skip if not a directory
565 :
566 0 : if (queryId.GetAliCDBPath().Level2Comprises(level2)) {
567 :
568 0 : AliCDBPath entryPath(level0, level1, level2);
569 :
570 0 : AliCDBId entryId(entryPath, queryId.GetAliCDBRunRange(),
571 0 : queryId.GetVersion(), queryId.GetSubVersion());
572 :
573 : // check filenames to see if any includes queryId.GetAliCDBRunRange()
574 0 : void* level2DirPtr = gSystem->OpenDirectory(fullPath);
575 0 : if (!level2DirPtr) {
576 0 : AliDebug(2,Form("Can't open level2 directory <%s>!", fullPath.Data()));
577 0 : return;
578 : }
579 : const char* level3;
580 0 : Long_t file_flag=0;
581 0 : while ((level3 = gSystem->GetDirEntry(level2DirPtr))) {
582 0 : TString fileName(level3);
583 0 : TString fullFileName = Form("%s/%s", fullPath.Data(), level3);
584 :
585 0 : Int_t file_res=gSystem->GetPathInfo(fullFileName.Data(), 0, (Long64_t*) 0, &file_flag, 0);
586 :
587 0 : if(file_res){
588 0 : AliDebug(2, Form("Error reading entry %s !",level2Str.Data()));
589 0 : continue;
590 : }
591 0 : if(file_flag)
592 0 : continue; // it is not a regular file!
593 :
594 : // skip if result already contains an entry for this path
595 : Bool_t alreadyLoaded = kFALSE;
596 0 : Int_t nEntries = result->GetEntries();
597 0 : for(int i=0; i<nEntries; i++){
598 0 : AliCDBEntry *lEntry = (AliCDBEntry*) result->At(i);
599 0 : AliCDBId lId = lEntry->GetId();
600 0 : TString lPath = lId.GetPath();
601 0 : if(lPath.EqualTo(entryPath.GetPath())){
602 : alreadyLoaded = kTRUE;
603 0 : break;
604 : }
605 0 : }
606 0 : if (alreadyLoaded) continue;
607 :
608 : //skip filenames not matching the regex below
609 0 : TRegexp re("^Run[0-9]+_[0-9]+_");
610 0 : if(!fileName.Contains(re))
611 0 : continue;
612 : // Extract first- and last-run and version and subversion.
613 : // This allows to avoid quering for a calibration path if we did not find a filename with
614 : // run-range including the one specified in the query and
615 : // with version, subversion matching the query
616 0 : TString fn = fileName( 3, fileName.Length()-3 );
617 0 : TString firstRunStr = fn( 0, fn.First('_') );
618 0 : fn.Remove( 0, firstRunStr.Length()+1 );
619 0 : TString lastRunStr = fn( 0, fn.First('_') );
620 0 : fn.Remove( 0, lastRunStr.Length()+1 );
621 0 : TString versionStr = fn( 1, fn.First('_')-1 );
622 0 : fn.Remove( 0, versionStr.Length()+2 );
623 0 : TString subvStr = fn(1, fn.First('.')-1);
624 0 : Int_t firstRun = firstRunStr.Atoi();
625 0 : Int_t lastRun = lastRunStr.Atoi();
626 0 : AliCDBRunRange rr(firstRun,lastRun);
627 0 : Int_t version = versionStr.Atoi();
628 0 : Int_t subVersion = subvStr.Atoi();
629 :
630 : AliCDBEntry* anEntry = 0;
631 : Bool_t versionOK = kTRUE, subVersionOK = kTRUE;
632 0 : if ( queryId.HasVersion() && version!=queryId.GetVersion())
633 0 : versionOK = kFALSE;
634 0 : if ( queryId.HasSubVersion() && subVersion!=queryId.GetSubVersion())
635 0 : subVersionOK = kFALSE;
636 0 : if (rr.Comprises(queryId.GetAliCDBRunRange()) && versionOK && subVersionOK )
637 : {
638 0 : anEntry = GetEntry(entryId);
639 0 : result->Add(anEntry);
640 : }
641 0 : }
642 0 : }
643 0 : }
644 :
645 0 : gSystem->FreeDirectory(level1DirPtr);
646 0 : }
647 :
648 : //_____________________________________________________________________________
649 : TList* AliCDBLocal::GetEntries(const AliCDBId& queryId) {
650 : // multiple request (AliCDBStorage::GetAll)
651 :
652 128 : TList* result = new TList();
653 64 : result->SetOwner();
654 :
655 : // if querying for fRun and not specifying a version, look in the fValidFileIds list
656 128 : if(queryId.GetFirstRun() == fRun && !queryId.HasVersion()) {
657 : // get id from fValidFileIds
658 64 : TIter *iter = new TIter(&fValidFileIds);
659 64 : TObjArray selectedIds;
660 64 : selectedIds.SetOwner(1);
661 :
662 : // loop on list of valid Ids to select the right version to get.
663 : // According to query and to the selection criteria list, version can be the highest or exact
664 : AliCDBId* anIdPtr=0;
665 : AliCDBId* dataId=0;
666 64 : AliCDBPath queryPath = queryId.GetAliCDBPath();
667 83136 : while((anIdPtr = dynamic_cast<AliCDBId*> (iter->Next()))){
668 20736 : AliCDBPath thisCDBPath = anIdPtr->GetAliCDBPath();
669 41472 : if(!(queryPath.Comprises(thisCDBPath))){
670 20200 : continue;
671 : }
672 :
673 536 : AliCDBId thisId(*anIdPtr);
674 536 : dataId = GetId(thisId);
675 536 : if(dataId)
676 536 : selectedIds.Add(dataId);
677 21272 : }
678 :
679 128 : delete iter; iter=0;
680 :
681 : // selectedIds contains the Ids of the files matching all requests of query!
682 : // All the objects are now ready to be retrieved
683 128 : iter = new TIter(&selectedIds);
684 2936 : while((anIdPtr = dynamic_cast<AliCDBId*> (iter->Next()))){
685 536 : AliCDBEntry* anEntry = GetEntry(*anIdPtr);
686 1072 : if(anEntry) result->Add(anEntry);
687 : }
688 128 : delete iter; iter=0;
689 : return result;
690 64 : }
691 :
692 0 : void* storageDirPtr = gSystem->OpenDirectory(fBaseDirectory);
693 0 : if (!storageDirPtr) {
694 0 : AliDebug(2,Form("Can't open storage directory <%s>",
695 : fBaseDirectory.Data()));
696 0 : return NULL;
697 : }
698 :
699 : const char* level0;
700 0 : Long_t flag=0;
701 0 : while ((level0 = gSystem->GetDirEntry(storageDirPtr))) {
702 :
703 0 : TString level0Str(level0);
704 : // skip directories starting with a dot (".svn" and similar in old svn working copies)
705 0 : if (level0Str.BeginsWith('.')) {
706 0 : continue;
707 : }
708 :
709 0 : TString fullPath = Form("%s/%s",fBaseDirectory.Data(), level0);
710 :
711 0 : Int_t res=gSystem->GetPathInfo(fullPath.Data(), 0, (Long64_t*) 0, &flag, 0);
712 :
713 0 : if(res){
714 0 : AliDebug(2, Form("Error reading entry %s !",level0Str.Data()));
715 0 : continue;
716 : }
717 :
718 0 : if(!(flag&2)) continue; // bit 1 of flag = directory!
719 :
720 0 : if (queryId.GetAliCDBPath().Level0Comprises(level0)) {
721 0 : GetEntriesForLevel0(level0, queryId, result);
722 : }
723 0 : }
724 :
725 0 : gSystem->FreeDirectory(storageDirPtr);
726 :
727 : return result;
728 64 : }
729 :
730 : //_____________________________________________________________________________
731 : Bool_t AliCDBLocal::PutEntry(AliCDBEntry* entry, const char* mirrors) {
732 : // put an AliCDBEntry object into the database
733 :
734 2 : AliCDBId& id = entry->GetId();
735 :
736 : // set version and subVersion for the entry to be stored
737 1 : if (!PrepareId(id)) return kFALSE;
738 :
739 :
740 : // build filename from entry's id
741 1 : TString filename="";
742 2 : if (!IdToFilename(id, filename)) {
743 :
744 0 : AliDebug(2,Form("Bad ID encountered! Subnormal error!"));
745 0 : return kFALSE;
746 : }
747 :
748 1 : TString mirrorsString(mirrors);
749 2 : if(!mirrorsString.IsNull())
750 0 : AliWarning("AliCDBLocal storage cannot take mirror SEs into account. They will be ignored.");
751 :
752 : // open file
753 2 : TFile file(filename, "CREATE");
754 2 : if (!file.IsOpen()) {
755 0 : AliError(Form("Can't open file <%s>!", filename.Data()));
756 0 : return kFALSE;
757 : }
758 :
759 : //SetTreeToFile(entry, &file);
760 :
761 1 : entry->SetVersion(id.GetVersion());
762 1 : entry->SetSubVersion(id.GetSubVersion());
763 :
764 : // write object (key name: "AliCDBEntry")
765 2 : Bool_t result = file.WriteTObject(entry, "AliCDBEntry");
766 1 : if (!result) AliDebug(2,Form("Can't write entry to file: %s", filename.Data()));
767 :
768 1 : file.Close();
769 1 : if(result) {
770 3 : if(!(id.GetPath().Contains("SHUTTLE/STATUS")))
771 4 : AliInfo(Form("CDB object stored into file %s",filename.Data()));
772 : }
773 :
774 : return result;
775 3 : }
776 :
777 : //_____________________________________________________________________________
778 : TList* AliCDBLocal::GetIdListFromFile(const char* fileName){
779 :
780 0 : TString fullFileName(fileName);
781 0 : fullFileName.Prepend(fBaseDirectory+'/');
782 0 : TFile *file = TFile::Open(fullFileName);
783 0 : if (!file) {
784 0 : AliError(Form("Can't open selection file <%s>!", fullFileName.Data()));
785 0 : return NULL;
786 : }
787 0 : file->cd();
788 :
789 0 : TList *list = new TList();
790 0 : list->SetOwner();
791 : int i=0;
792 0 : TString keycycle;
793 :
794 : AliCDBId *id;
795 0 : while(1){
796 0 : i++;
797 0 : keycycle = "AliCDBId;";
798 0 : keycycle+=i;
799 :
800 0 : id = (AliCDBId*) file->Get(keycycle);
801 0 : if(!id) break;
802 0 : list->AddFirst(id);
803 : }
804 0 : file->Close(); delete file; file=0;
805 : return list;
806 0 : }
807 :
808 : //_____________________________________________________________________________
809 : Bool_t AliCDBLocal::Contains(const char* path) const{
810 : // check for path in storage's fBaseDirectory
811 :
812 0 : TString dirName = Form("%s/%s", fBaseDirectory.Data(), path);
813 : Bool_t result=kFALSE;
814 :
815 0 : void* dirPtr = gSystem->OpenDirectory(dirName);
816 0 : if (dirPtr) result=kTRUE;
817 0 : gSystem->FreeDirectory(dirPtr);
818 :
819 0 : return result;
820 0 : }
821 :
822 : //_____________________________________________________________________________
823 : void AliCDBLocal::QueryValidFiles() {
824 : // Query the CDB for files valid for AliCDBStorage::fRun.
825 : // Fills list fValidFileIds with AliCDBId objects extracted from CDB files
826 : // present in the local storage.
827 : // If fVersion was not set, fValidFileIds is filled with highest versions.
828 : // In the CVMFS case, the fValidFileIds is filled from the file containing
829 : // the filepaths corresponding to the highest versions for the give OCDB tag
830 : // by launching the script which extracts the last versions for the given run.
831 : //
832 :
833 20 : if(fVersion != -1) AliWarning ("Version parameter is not used by local storage query!");
834 10 : if(fMetaDataFilter) {
835 0 : AliWarning ("CDB meta data parameters are not used by local storage query!");
836 0 : delete fMetaDataFilter; fMetaDataFilter=0;
837 0 : }
838 :
839 : // Check if in CVMFS case
840 10 : TString cvmfsOcdbTag(gSystem->Getenv("OCDB_PATH"));
841 20 : if (!cvmfsOcdbTag.IsNull()) {
842 0 : QueryValidCVMFSFiles(cvmfsOcdbTag);
843 0 : return;
844 : }
845 :
846 20 : void* storageDirPtr = gSystem->OpenDirectory(fBaseDirectory);
847 :
848 : const char* level0;
849 1520 : while ((level0 = gSystem->GetDirEntry(storageDirPtr))) {
850 :
851 745 : TString level0Str(level0);
852 1490 : if (level0Str.BeginsWith(".")) {
853 30 : continue;
854 : }
855 :
856 2145 : if (fPathFilter.Level0Comprises(level0)) {
857 372 : TString level0Dir = Form("%s/%s",fBaseDirectory.Data(),level0);
858 248 : void* level0DirPtr = gSystem->OpenDirectory(level0Dir);
859 : const char* level1;
860 1406 : while ((level1 = gSystem->GetDirEntry(level0DirPtr))) {
861 :
862 517 : TString level1Str(level1);
863 1034 : if (level1Str.BeginsWith(".")) {
864 218 : continue;
865 : }
866 :
867 897 : if (fPathFilter.Level1Comprises(level1)) {
868 897 : TString level1Dir = Form("%s/%s/%s",
869 299 : fBaseDirectory.Data(),level0,level1);
870 :
871 598 : void* level1DirPtr = gSystem->OpenDirectory(level1Dir);
872 : const char* level2;
873 5371 : while ((level2 = gSystem->GetDirEntry(level1DirPtr))) {
874 :
875 2237 : TString level2Str(level2);
876 4474 : if (level2Str.BeginsWith(".")) {
877 598 : continue;
878 : }
879 :
880 4917 : if (fPathFilter.Level2Comprises(level2)) {
881 4917 : TString dirName = Form("%s/%s/%s/%s", fBaseDirectory.Data(), level0, level1, level2);
882 :
883 3278 : void* dirPtr = gSystem->OpenDirectory(dirName);
884 :
885 : const char* filename;
886 :
887 1639 : AliCDBRunRange aRunRange; // the runRange got from filename
888 1639 : AliCDBRunRange hvRunRange; // the runRange of the highest version valid file
889 1639 : Int_t aVersion, aSubVersion; // the version and subVersion got from filename
890 : Int_t highestV=-1, highestSubV=-1; // the highest version and subVersion for this calibration type
891 :
892 14721 : while ((filename = gSystem->GetDirEntry(dirPtr))) { // loop on files
893 :
894 4902 : TString aString(filename);
895 13062 : if (aString.BeginsWith(".")) continue;
896 :
897 3288 : if (!FilenameToId(filename, aRunRange, aVersion, aSubVersion)) {
898 5 : continue;
899 : }
900 :
901 1639 : AliCDBRunRange runrg(fRun, fRun);
902 3278 : if (!aRunRange.Comprises(runrg))
903 5 : continue;
904 :
905 : // check to keep the highest version/subversion (in case of more than one)
906 1634 : if (aVersion > highestV) {
907 : highestV = aVersion;
908 1629 : highestSubV = aSubVersion;
909 1629 : hvRunRange = aRunRange;
910 5 : } else if (aVersion == highestV) {
911 5 : if (aSubVersion > highestSubV) {
912 : highestSubV = aSubVersion;
913 5 : hvRunRange = aRunRange;
914 : }
915 : }
916 8175 : }
917 1639 : if(highestV >= 0){
918 1624 : AliCDBPath validPath(level0, level1, level2);
919 3248 : AliCDBId *validId = new AliCDBId(validPath, hvRunRange, highestV, highestSubV);
920 1624 : fValidFileIds.AddLast(validId);
921 1624 : }
922 :
923 1639 : gSystem->FreeDirectory(dirPtr);
924 1639 : }
925 3876 : }
926 299 : gSystem->FreeDirectory(level1DirPtr);
927 299 : }
928 816 : }
929 124 : gSystem->FreeDirectory(level0DirPtr);
930 124 : }
931 1460 : }
932 10 : gSystem->FreeDirectory(storageDirPtr);
933 :
934 20 : }
935 :
936 : //_____________________________________________________________________________
937 : void AliCDBLocal::QueryValidCVMFSFiles(TString& cvmfsOcdbTag) {
938 : // Called in the CVMFS case to fill the fValidFileIds from the file containing
939 : // the filepaths corresponding to the highest versions for the given OCDB tag
940 : // by launching the script which extracts the last versions for the given run.
941 : //
942 :
943 0 : TString command = cvmfsOcdbTag;
944 0 : AliDebug(3, Form("Getting valid files from CVMFS-OCDB tag \"%s\"", cvmfsOcdbTag.Data()));
945 : // CVMFS-OCDB tag. This is the file $OCDB_PATH/catalogue/20??.list.gz
946 : // containing all CDB file paths (for the given AR tag)
947 0 : cvmfsOcdbTag.Strip(TString::kTrailing, '/');
948 0 : cvmfsOcdbTag.Append("/");
949 0 : gSystem->ExpandPathName(cvmfsOcdbTag);
950 0 : if ( gSystem->AccessPathName(cvmfsOcdbTag) )
951 0 : AliFatal(Form("cvmfs OCDB set to an invalid path: %s", cvmfsOcdbTag.Data()));
952 :
953 : // The file containing the list of valid files for the current run has to be generated
954 : // by running the (shell+awk) script on the CVMFS OCDB tag file.
955 :
956 : // the script in cvmfs to extract CDB filepaths for the given run has the following fullpath
957 : // w.r.t. $OCDB_PATH: bin/OCDBperRun.sh
958 0 : command = command.Strip(TString::kTrailing, '/');
959 0 : command.Append("/bin/getOCDBFilesPerRun.sh ");
960 0 : command += cvmfsOcdbTag;
961 : // from URI define the last two levels of the path of the cvmfs ocdb tag (e.g. data/2012.list.gz)
962 0 : TString uri(GetURI());
963 0 : uri.Remove(TString::kTrailing, '/');
964 0 : TObjArray * osArr = uri.Tokenize('/');
965 0 : TObjString* mcdata_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-3));
966 : TObjString* yeartype_os = 0;
967 0 : TString mcdata = mcdata_os->GetString();
968 0 : if( mcdata == TString("data")) {
969 0 : yeartype_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-2));
970 0 : } else {
971 0 : mcdata_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-2));
972 0 : yeartype_os = dynamic_cast<TObjString*>(osArr->At(osArr->GetEntries()-1));
973 : }
974 0 : mcdata = mcdata_os->GetString();
975 0 : TString yeartype = yeartype_os->GetString();
976 0 : command += mcdata;
977 0 : command += '/';
978 0 : command += yeartype;
979 0 : command += ".list.gz cvmfs ";
980 0 : command += TString::Itoa(fRun,10);
981 0 : command += ' ';
982 0 : command += TString::Itoa(fRun,10);
983 0 : command += " -y > ";
984 0 : TString runValidFile(gSystem->WorkingDirectory());
985 0 : runValidFile += '/';
986 0 : runValidFile += mcdata;
987 0 : runValidFile += '_';
988 0 : runValidFile += yeartype;
989 0 : runValidFile += '_';
990 0 : runValidFile += TString::Itoa(fRun,10);
991 0 : command += runValidFile;
992 0 : AliDebug(3, Form("Running command: \"%s\"",command.Data()));
993 0 : Int_t result = gSystem->Exec(command.Data());
994 0 : if(result != 0) {
995 0 : AliError(Form("Was not able to execute \"%s\"", command.Data()));
996 : }
997 :
998 : // We expect the file with valid paths for this run to be generated in the current directory
999 : // and to be named as the CVMFS OCDB tag, without .gz, with '_runnumber' appended
1000 : // Fill fValidFileIds from file
1001 0 : std::ifstream file (runValidFile.Data());
1002 0 : if (!file.is_open()) {
1003 0 : AliFatal(Form("Error opening file \"%s\"!", runValidFile.Data()));
1004 : }
1005 0 : TString filepath;
1006 0 : while (filepath.ReadLine(file)) {
1007 : // skip line in case it is not a root file path
1008 0 : if(! filepath.EndsWith(".root")) {
1009 : continue;
1010 : }
1011 : //extract three-level path and basename
1012 0 : TObjArray *tokens = filepath.Tokenize('/');
1013 0 : if (tokens->GetEntries() < 5) {
1014 0 : AliError(Form("\"%s\" is not a valid cvmfs path for an OCDB object", filepath.Data()));
1015 0 : continue;
1016 : }
1017 0 : TObjString *baseNameOstr = (TObjString*) tokens->At(tokens->GetEntries()-1);
1018 0 : TString baseName(baseNameOstr->String());
1019 0 : TObjString *l0oStr = (TObjString*) tokens->At(tokens->GetEntries()-4);
1020 0 : TObjString *l1oStr = (TObjString*) tokens->At(tokens->GetEntries()-3);
1021 0 : TObjString *l2oStr = (TObjString*) tokens->At(tokens->GetEntries()-2);
1022 0 : TString l0(l0oStr->String());
1023 0 : TString l1(l1oStr->String());
1024 0 : TString l2(l2oStr->String());
1025 0 : TString threeLevels = l0 + '/' + l1 + '/' + l2;
1026 :
1027 0 : AliCDBPath validPath(threeLevels);
1028 : //use basename and three-level path to create Id
1029 0 : AliCDBRunRange aRunRange; // the runRange got from filename
1030 0 : Int_t aVersion, aSubVersion; // the version and subVersion got from filename
1031 0 : if ( !FilenameToId(baseName, aRunRange, aVersion, aSubVersion) )
1032 0 : AliError( Form("Could not create a valid CDB id from path: \"%s\"", filepath.Data()) );
1033 :
1034 0 : AliCDBRunRange runrg(fRun,fRun);
1035 0 : if (!aRunRange.Comprises(runrg)) continue; // should never happen (would mean awk script wrong output)
1036 : // aRunRange contains requested run!
1037 0 : AliCDBId *validId = new AliCDBId(validPath,aRunRange,aVersion,aSubVersion);
1038 0 : fValidFileIds.AddLast(validId);
1039 0 : }
1040 :
1041 0 : file.close();
1042 0 : gSystem->Exec( Form( "rm %s", runValidFile.Data() ) );
1043 : return;
1044 0 : }
1045 :
1046 : /////////////////////////////////////////////////////////////////////////////////////////////////
1047 : // //
1048 : // AliCDBLocal factory //
1049 : // //
1050 : /////////////////////////////////////////////////////////////////////////////////////////////////
1051 :
1052 128 : ClassImp(AliCDBLocalFactory)
1053 :
1054 : //_____________________________________________________________________________
1055 : Bool_t AliCDBLocalFactory::Validate(const char* dbString) {
1056 : // check if the string is valid local URI
1057 :
1058 58 : TRegexp dbPatternLocal("^local://.+$");
1059 :
1060 193 : return (TString(dbString).Contains(dbPatternLocal) || TString(dbString).BeginsWith("snapshot://folder="));
1061 29 : }
1062 :
1063 : //_____________________________________________________________________________
1064 : AliCDBParam* AliCDBLocalFactory::CreateParameter(const char* dbString) {
1065 : // create AliCDBLocalParam class from the URI string
1066 :
1067 58 : if (!Validate(dbString)) {
1068 16 : return NULL;
1069 : }
1070 :
1071 13 : TString checkSS(dbString);
1072 26 : if(checkSS.BeginsWith("snapshot://"))
1073 : {
1074 0 : TString snapshotPath("OCDB");
1075 0 : snapshotPath.Prepend(TString(gSystem->WorkingDirectory()) + '/');
1076 0 : checkSS.Remove(0,checkSS.First(':')+3);
1077 0 : return new AliCDBLocalParam(snapshotPath,checkSS);
1078 0 : }
1079 :
1080 : // if the string argument is not a snapshot URI, than it is a plain local URI
1081 13 : TString pathname(dbString + sizeof("local://") - 1);
1082 :
1083 26 : if(gSystem->ExpandPathName(pathname))
1084 0 : return NULL;
1085 :
1086 26 : if (pathname[0] != '/') {
1087 10 : pathname.Prepend(TString(gSystem->WorkingDirectory()) + '/');
1088 2 : }
1089 : //pathname.Prepend("local://");
1090 :
1091 52 : return new AliCDBLocalParam(pathname);
1092 55 : }
1093 :
1094 : //_____________________________________________________________________________
1095 : AliCDBStorage* AliCDBLocalFactory::Create(const AliCDBParam* param) {
1096 : // create AliCDBLocal storage instance from parameters
1097 :
1098 24 : if (AliCDBLocalParam::Class() == param->IsA()) {
1099 :
1100 : const AliCDBLocalParam* localParam =
1101 12 : (const AliCDBLocalParam*) param;
1102 :
1103 36 : return new AliCDBLocal(localParam->GetPath());
1104 : }
1105 :
1106 0 : return NULL;
1107 12 : }
1108 : //_____________________________________________________________________________
1109 : void AliCDBLocal::SetRetry(Int_t /* nretry */, Int_t /* initsec */) {
1110 :
1111 : // Function to set the exponential retry for putting entries in the OCDB
1112 :
1113 0 : AliInfo("This function sets the exponential retry for putting entries in the OCDB - to be used ONLY for AliCDBGrid --> returning without doing anything");
1114 0 : return;
1115 : }
1116 :
1117 :
1118 :
1119 : /////////////////////////////////////////////////////////////////////////////////////////////////
1120 : // //
1121 : // AliCDBLocal Parameter class // //
1122 : // //
1123 : /////////////////////////////////////////////////////////////////////////////////////////////////
1124 :
1125 128 : ClassImp(AliCDBLocalParam)
1126 :
1127 : //_____________________________________________________________________________
1128 : AliCDBLocalParam::AliCDBLocalParam():
1129 0 : AliCDBParam(),
1130 0 : fDBPath()
1131 0 : {
1132 : // default constructor
1133 :
1134 0 : }
1135 :
1136 : //_____________________________________________________________________________
1137 : AliCDBLocalParam::AliCDBLocalParam(const char* dbPath):
1138 30 : AliCDBParam(),
1139 30 : fDBPath(dbPath)
1140 150 : {
1141 : // constructor
1142 :
1143 30 : SetType("local");
1144 150 : SetURI(TString("local://") + dbPath);
1145 60 : }
1146 :
1147 : //_____________________________________________________________________________
1148 : AliCDBLocalParam::AliCDBLocalParam(const char* dbPath, const char* uri):
1149 0 : AliCDBParam(),
1150 0 : fDBPath(dbPath)
1151 0 : {
1152 : // constructor
1153 :
1154 0 : SetType("local");
1155 0 : SetURI(TString("alien://") + uri);
1156 0 : }
1157 :
1158 : //_____________________________________________________________________________
1159 78 : AliCDBLocalParam::~AliCDBLocalParam() {
1160 : // destructor
1161 :
1162 39 : }
1163 :
1164 : //_____________________________________________________________________________
1165 : AliCDBParam* AliCDBLocalParam::CloneParam() const {
1166 : // clone parameter
1167 :
1168 68 : return new AliCDBLocalParam(fDBPath);
1169 0 : }
1170 :
1171 : //_____________________________________________________________________________
1172 : ULong_t AliCDBLocalParam::Hash() const {
1173 : // return Hash function
1174 :
1175 94 : return fDBPath.Hash();
1176 : }
1177 :
1178 : //_____________________________________________________________________________
1179 : Bool_t AliCDBLocalParam::IsEqual(const TObject* obj) const {
1180 : // check if this object is equal to AliCDBParam obj
1181 :
1182 46 : if (this == obj) {
1183 0 : return kTRUE;
1184 : }
1185 :
1186 23 : if (AliCDBLocalParam::Class() != obj->IsA()) {
1187 0 : return kFALSE;
1188 : }
1189 :
1190 23 : AliCDBLocalParam* other = (AliCDBLocalParam*) obj;
1191 :
1192 23 : return fDBPath == other->fDBPath;
1193 23 : }
1194 :
|