]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliCDBManager.cxx
I've tried to make some output messages lighter (and moved others
[u/mrichter/AliRoot.git] / STEER / AliCDBManager.cxx
CommitLineData
9e1ceb13 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 **************************************************************************/
fdf65bb5 15//-------------------------------------------------------------------------
16// Implementation of AliCDBManager and AliCDBParam classe
17// Author: Alberto Colla
18// e-mail: Alberto.Colla@cern.ch
19//-------------------------------------------------------------------------
9e1ceb13 20
21#include "AliCDBManager.h"
22#include "AliCDBStorage.h"
23#include "AliLog.h"
24#include "AliCDBDump.h"
25#include "AliCDBLocal.h"
26#include "AliCDBGrid.h"
02c4845e 27#include "AliCDBEntry.h"
28#include "AliCDBMetaData.h"
9e1ceb13 29
02c4845e 30#include <TObjString.h>
9e1ceb13 31#include <TSystem.h>
32
33ClassImp(AliCDBParam)
34
35ClassImp(AliCDBManager)
36
b8ec52f6 37//TODO OCDB and Reference folder should not be fully hardcoded but built from run number (or year/LHC period)
38TString AliCDBManager::fgkCondUri("alien://folder=/alice/cern.ch/user/a/aliprod/testCDB/CDB?user=aliprod");
39TString AliCDBManager::fgkRefUri("alien://folder=/alice/cern.ch/user/a/aliprod/testCDB/Reference?user=aliprod");
9e1ceb13 40AliCDBManager* AliCDBManager::fgInstance = 0x0;
41
42//_____________________________________________________________________________
b8ec52f6 43AliCDBManager* AliCDBManager::Instance()
44{
9e1ceb13 45// returns AliCDBManager instance (singleton)
46
47 if (!fgInstance) {
48 fgInstance = new AliCDBManager();
49 fgInstance->Init();
50 }
51
52 return fgInstance;
53}
54
55//_____________________________________________________________________________
56void AliCDBManager::Init() {
57// factory registering
58
59 RegisterFactory(new AliCDBDumpFactory());
60 RegisterFactory(new AliCDBLocalFactory());
61 // AliCDBGridFactory is registered only if AliEn libraries are enabled in Root
62 if(!gSystem->Exec("root-config --has-alien |grep yes 2>&1 > /dev/null")){ // returns 0 if yes
63 AliInfo("AliEn classes enabled in Root. AliCDBGrid factory registered.");
64 RegisterFactory(new AliCDBGridFactory());
b8ec52f6 65 fCondParam = CreateParameter(fgkCondUri);
66 fRefParam = CreateParameter(fgkRefUri);
9e1ceb13 67 }
68}
69//_____________________________________________________________________________
70void AliCDBManager::Destroy() {
71// delete ALCDBManager instance and active storages
72
73 if (fgInstance) {
4b5e0dce 74 //fgInstance->Delete();
9e1ceb13 75 delete fgInstance;
76 fgInstance = 0x0;
77 }
78}
79
80//_____________________________________________________________________________
81AliCDBManager::AliCDBManager():
fe12e09c 82 TObject(),
b8ec52f6 83 fCondParam(0),
84 fRefParam(0),
fe12e09c 85 fFactories(),
86 fActiveStorages(),
87 fSpecificStorages(),
88 fDefaultStorage(NULL),
89 fDrainStorage(NULL),
90 fEntryCache(),
91 fCache(kTRUE),
92 fRun(-1)
9e1ceb13 93{
94// default constuctor
4b5e0dce 95 fFactories.SetOwner(1);
62032124 96 fActiveStorages.SetOwner(1);
97 fSpecificStorages.SetOwner(1);
98 fEntryCache.SetOwner(1);
9e1ceb13 99}
100
101//_____________________________________________________________________________
102AliCDBManager::~AliCDBManager() {
103// destructor
4b5e0dce 104 ClearCache();
9e1ceb13 105 DestroyActiveStorages();
62032124 106 fFactories.Delete();
b05400be 107 fDrainStorage = 0x0;
108 fDefaultStorage = 0x0;
b8ec52f6 109 delete fCondParam;
110 delete fRefParam;
9e1ceb13 111}
112
9e1ceb13 113//_____________________________________________________________________________
114void AliCDBManager::PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage){
115// put a storage object into the list of active storages
116
117 fActiveStorages.Add(param, storage);
118 AliDebug(1, Form("Active storages: %d", fActiveStorages.GetEntries()));
119}
120
121//_____________________________________________________________________________
122void AliCDBManager::RegisterFactory(AliCDBStorageFactory* factory) {
123// add a storage factory to the list of registerd factories
124
125 if (!fFactories.Contains(factory)) {
126 fFactories.Add(factory);
127 }
128}
129
130//_____________________________________________________________________________
fdf65bb5 131Bool_t AliCDBManager::HasStorage(const char* dbString) const {
9e1ceb13 132// check if dbString is a URI valid for one of the registered factories
133
134 TIter iter(&fFactories);
135
62032124 136 AliCDBStorageFactory* factory=0;
9e1ceb13 137 while ((factory = (AliCDBStorageFactory*) iter.Next())) {
138
139 if (factory->Validate(dbString)) {
140 return kTRUE;
141 }
142 }
143
144 return kFALSE;
145}
146
147//_____________________________________________________________________________
fdf65bb5 148AliCDBParam* AliCDBManager::CreateParameter(const char* dbString) const {
9e1ceb13 149// create AliCDBParam object from URI string
150
151 TIter iter(&fFactories);
152
62032124 153 AliCDBStorageFactory* factory=0;
9e1ceb13 154 while ((factory = (AliCDBStorageFactory*) iter.Next())) {
9e1ceb13 155 AliCDBParam* param = factory->CreateParameter(dbString);
62032124 156 if(param) return param;
9e1ceb13 157 }
158
159 return NULL;
160}
161
162//_____________________________________________________________________________
163AliCDBStorage* AliCDBManager::GetStorage(const char* dbString) {
164// get storage object from URI string
165
166 AliCDBParam* param = CreateParameter(dbString);
167 if (!param) {
c3a7b59a 168 AliError(Form("Failed to activate requested storage! Check URI: %s", dbString));
9e1ceb13 169 return NULL;
82096dfc 170 }
9e1ceb13 171
172 AliCDBStorage* aStorage = GetStorage(param);
173
174 delete param;
9e1ceb13 175 return aStorage;
176}
177
178//_____________________________________________________________________________
179AliCDBStorage* AliCDBManager::GetStorage(const AliCDBParam* param) {
180// get storage object from AliCDBParam object
181
82096dfc 182 // if the list of active storages already contains
9e1ceb13 183 // the requested storage, return it
184 AliCDBStorage* aStorage = GetActiveStorage(param);
185 if (aStorage) {
186 return aStorage;
187 }
188
189 TIter iter(&fFactories);
190
62032124 191 AliCDBStorageFactory* factory=0;
917a098b 192
9e1ceb13 193 // loop on the list of registered factories
194 while ((factory = (AliCDBStorageFactory*) iter.Next())) {
195
196 // each factory tries to create its storage from the parameter
197 aStorage = factory->Create(param);
198 if (aStorage) {
199 PutActiveStorage(param->CloneParam(), aStorage);
917a098b 200 aStorage->SetURI(param->GetURI());
6dc56e97 201 if(fRun >= 0) {
c3a7b59a 202 aStorage->QueryCDB(fRun);
203 }
9e1ceb13 204 return aStorage;
205 }
206 }
207
c3a7b59a 208 AliError(Form("Failed to activate requested storage! Check URI: %s", param->GetURI().Data()));
209
9e1ceb13 210 return NULL;
211}
212
62032124 213//_____________________________________________________________________________
214AliCDBStorage* AliCDBManager::GetActiveStorage(const AliCDBParam* param) {
215// get a storage object from the list of active storages
216
217 return dynamic_cast<AliCDBStorage*> (fActiveStorages.GetValue(param));
218}
219
9e1ceb13 220//_____________________________________________________________________________
221TList* AliCDBManager::GetActiveStorages() {
222// return list of active storages
62032124 223// user has responsibility to delete returned object
9e1ceb13 224
225 TList* result = new TList();
226
917a098b 227 TIter iter(fActiveStorages.GetTable());
62032124 228 TPair* aPair=0;
9e1ceb13 229 while ((aPair = (TPair*) iter.Next())) {
230 result->Add(aPair->Value());
231 }
232
233 return result;
234}
235
236//_____________________________________________________________________________
237void AliCDBManager::SetDrain(const char* dbString) {
238// set drain storage from URI string
239
240 fDrainStorage = GetStorage(dbString);
241}
242
243//_____________________________________________________________________________
244void AliCDBManager::SetDrain(const AliCDBParam* param) {
245// set drain storage from AliCDBParam
b8ec52f6 246
9e1ceb13 247 fDrainStorage = GetStorage(param);
248}
249
250//_____________________________________________________________________________
251void AliCDBManager::SetDrain(AliCDBStorage* storage) {
252// set drain storage from another active storage
253
254 fDrainStorage = storage;
255}
256
257//_____________________________________________________________________________
258Bool_t AliCDBManager::Drain(AliCDBEntry *entry) {
259// drain retrieved object to drain storage
260
b8ec52f6 261 AliDebug(2, "Draining into drain storage...");
9e1ceb13 262 return fDrainStorage->Put(entry);
263}
264
9e1ceb13 265//_____________________________________________________________________________
266void AliCDBManager::SetDefaultStorage(const char* dbString) {
267// sets default storage from URI string
268
82096dfc 269 AliInfo(Form("Setting Default storage to: %s",dbString));
270 fDefaultStorage = GetStorage(dbString);
9e1ceb13 271}
272
273//_____________________________________________________________________________
274void AliCDBManager::SetDefaultStorage(const AliCDBParam* param) {
275// set default storage from AliCDBParam object
276
b8ec52f6 277 fDefaultStorage = GetStorage(param);
9e1ceb13 278}
279
280//_____________________________________________________________________________
281void AliCDBManager::SetDefaultStorage(AliCDBStorage* storage) {
282// set default storage from another active storage
283
9e1ceb13 284 fDefaultStorage = storage;
285}
286
02c4845e 287//_____________________________________________________________________________
024cf675 288void AliCDBManager::SetSpecificStorage(const char* calibType, const char* dbString) {
289// sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
02c4845e 290
291 AliCDBParam *aPar = CreateParameter(dbString);
292 if(!aPar) return;
024cf675 293 SetSpecificStorage(calibType, aPar);
02c4845e 294 delete aPar;
295}
296
297//_____________________________________________________________________________
024cf675 298void AliCDBManager::SetSpecificStorage(const char* calibType, AliCDBParam* param) {
299// sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
300// Default storage should be defined prior to any specific storages, e.g.:
301// AliCDBManager::instance()->SetDefaultStorage("alien://");
c3a7b59a 302// AliCDBManager::instance()->SetSpecificStorage("TPC/*","local://DB_TPC");
303// AliCDBManager::instance()->SetSpecificStorage("*/Align/*","local://DB_TPCAlign");
304// calibType must be a valid CDB path! (3 level folder structure)
02c4845e 305
306 if(!fDefaultStorage) {
c3a7b59a 307 AliError("Please activate a default storage first!");
02c4845e 308 return;
309 }
310
62032124 311 AliCDBPath aPath(calibType);
312 if(!aPath.IsValid()){
313 AliError(Form("Not a valid path: %s", calibType));
314 return;
315 }
316
317 TObjString *objCalibType = new TObjString(aPath.GetPath());
024cf675 318 if(fSpecificStorages.Contains(objCalibType)){
62032124 319 AliWarning(Form("Storage \"%s\" already activated! It will be replaced by the new one",
024cf675 320 calibType));
62032124 321 fSpecificStorages.Remove(objCalibType);
02c4845e 322 }
323 GetStorage(param);
024cf675 324 fSpecificStorages.Add(objCalibType, param->CloneParam());
02c4845e 325}
326
327//_____________________________________________________________________________
024cf675 328AliCDBStorage* AliCDBManager::GetSpecificStorage(const char* calibType) {
329// get storage specific for detector or calibration type
4b5e0dce 330
024cf675 331 AliCDBParam *checkPar = (AliCDBParam*) fSpecificStorages.GetValue(calibType);
02c4845e 332 if(!checkPar){
b8ec52f6 333 AliError(Form("%s storage not found!", calibType));
02c4845e 334 return NULL;
335 } else {
336 return GetStorage(checkPar);
337 }
338
339}
340
024cf675 341//_____________________________________________________________________________
342AliCDBParam* AliCDBManager::SelectSpecificStorage(const TString& path) {
82096dfc 343// select storage valid for path from the list of specific storages
024cf675 344
62032124 345 AliCDBPath aPath(path);
346 if(!aPath.IsValid()){
347 AliError(Form("Not a valid path: %s", path.Data()));
348 return NULL;
349 }
350
024cf675 351 TIter iter(&fSpecificStorages);
62032124 352 TObjString *aCalibType=0;
024cf675 353 AliCDBParam* aPar=0;
354 while((aCalibType = (TObjString*) iter.Next())){
62032124 355 AliCDBPath calibTypePath(aCalibType->GetName());
356 if(calibTypePath.Comprises(aPath)) {
024cf675 357 aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
358 break;
359 }
360 }
361 return aPar;
362}
363
02c4845e 364//_____________________________________________________________________________
365AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path, Int_t runNumber,
366 Int_t version, Int_t subVersion) {
367// get an AliCDBEntry object from the database
368
024cf675 369 if(runNumber < 0){
370 // RunNumber is not specified. Try with fRun
371 if (fRun < 0){
372 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
373 return NULL;
374 }
375 runNumber = fRun;
376 }
377
02c4845e 378 return Get(AliCDBId(path, runNumber, runNumber, version, subVersion));
379}
380
381//_____________________________________________________________________________
382AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path,
383 const AliCDBRunRange& runRange, Int_t version,
384 Int_t subVersion) {
385// get an AliCDBEntry object from the database!
386
387 return Get(AliCDBId(path, runRange, version, subVersion));
388}
389
390//_____________________________________________________________________________
391AliCDBEntry* AliCDBManager::Get(const AliCDBId& query) {
392// get an AliCDBEntry object from the database
393
394 if(!fDefaultStorage) {
395 AliError("No storage set!");
396 return NULL;
397 }
398
399 // check if query's path and runRange are valid
400 // query is invalid also if version is not specified and subversion is!
401 if (!query.IsValid()) {
402 AliError(Form("Invalid query: %s", query.ToString().Data()));
403 return NULL;
404 }
024cf675 405
406 // query is not specified if path contains wildcard or run range= [-1,-1]
407 if (!query.IsSpecified()) {
02c4845e 408 AliError(Form("Unspecified query: %s",
409 query.ToString().Data()));
410 return NULL;
411 }
412
6dc56e97 413 if(fCache && query.GetFirstRun() != fRun)
024cf675 414 AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!");
415
416
417 AliCDBEntry *entry=0;
418
024cf675 419 // first look into map of cached objects
62032124 420 if(fCache && query.GetFirstRun() == fRun)
024cf675 421 entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath());
422
423 if(entry) {
b8ec52f6 424 AliDebug(2, Form("Object %s retrieved from cache !!",query.GetPath().Data()));
024cf675 425 return entry;
426 }
427
428 // Entry is not in cache -> retrieve it from CDB and cache it!!
429 AliCDBStorage *aStorage=0;
430 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
62032124 431
02c4845e 432 if(aPar) {
433 aStorage=GetStorage(aPar);
434 TString str = aPar->GetURI();
435 AliDebug(2,Form("Looking into storage: %s",str.Data()));
436
437 } else {
438 aStorage=GetDefaultStorage();
439 AliDebug(2,"Looking into default storage");
440 }
441
024cf675 442 entry = aStorage->Get(query);
443 if (!entry) return NULL;
444
445 if(fCache && (query.GetFirstRun() == fRun)){
6a63c2e2 446 AliDebug(2,Form("Caching entry %s !",query.GetPath().Data()));
024cf675 447 CacheEntry(query.GetPath(), entry);
448 }
449
450 return entry;
451
02c4845e 452}
453
454//_____________________________________________________________________________
62032124 455TList* AliCDBManager::GetAll(const AliCDBPath& path, Int_t runNumber,
02c4845e 456 Int_t version, Int_t subVersion) {
457// get multiple AliCDBEntry objects from the database
458
afd8dbf4 459 if(runNumber < 0){
460 // RunNumber is not specified. Try with fRun
461 if (fRun < 0){
462 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
463 return NULL;
464 }
465 runNumber = fRun;
466 }
467
02c4845e 468 return GetAll(AliCDBId(path, runNumber, runNumber, version,
469 subVersion));
470}
471
472//_____________________________________________________________________________
473TList* AliCDBManager::GetAll(const AliCDBPath& path,
474 const AliCDBRunRange& runRange, Int_t version, Int_t subVersion) {
475// get multiple AliCDBEntry objects from the database
476
477 return GetAll(AliCDBId(path, runRange, version, subVersion));
478}
479
480//_____________________________________________________________________________
481TList* AliCDBManager::GetAll(const AliCDBId& query) {
482// get multiple AliCDBEntry objects from the database
024cf675 483// Warning: this method works correctly only for queries of the type "Detector/*"
484// and not for more specific queries e.g. "Detector/Calib/*" !
02c4845e 485
486 if(!fDefaultStorage) {
487 AliError("No storage set!");
488 return NULL;
489 }
490
491 if (!query.IsValid()) {
492 AliError(Form("Invalid query: %s", query.ToString().Data()));
493 return NULL;
494 }
495
afd8dbf4 496 if((fSpecificStorages.GetEntries()>0) && query.GetPath().BeginsWith('*')){
497 // if specific storages are active a query with "*" is ambiguous
498 AliError("Query too generic in this context!");
02c4845e 499 return NULL;
500 }
501
502 if (query.IsAnyRange()) {
503 AliError(Form("Unspecified run or runrange: %s",
504 query.ToString().Data()));
505 return NULL;
506 }
507
508 TObjString objStrLev0(query.GetLevel0());
6dc56e97 509 //AliCDBParam *aPar = (AliCDBParam*) fSpecificStorages.GetValue(&objStrLev0);
510 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
024cf675 511
512 AliCDBStorage *aStorage;
02c4845e 513 if(aPar) {
514 aStorage=GetStorage(aPar);
515 TString str = aPar->GetURI();
516 AliDebug(2,Form("Looking into storage: %s",str.Data()));
517
518 } else {
519 aStorage=GetDefaultStorage();
520 AliDebug(2,"Looking into default storage");
521 }
522
523 TList *result = aStorage->GetAll(query);
524
525 return result;
526}
527
528//_____________________________________________________________________________
b8ec52f6 529Bool_t AliCDBManager::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData, DataType type){
02c4845e 530// store an AliCDBEntry object into the database
531
532 AliCDBEntry anEntry(object, id, metaData);
b8ec52f6 533 return Put(&anEntry, type);
02c4845e 534
535}
536
537
538//_____________________________________________________________________________
b8ec52f6 539Bool_t AliCDBManager::Put(AliCDBEntry* entry, DataType type){
02c4845e 540// store an AliCDBEntry object into the database
541
b8ec52f6 542 if(type == kPrivate && !fDefaultStorage) {
02c4845e 543 AliError("No storage set!");
544 return kFALSE;
545 }
546
547 if (!entry){
548 AliError("No entry!");
549 return kFALSE;
550 }
551
552 if (!entry->GetId().IsValid()) {
553 AliError(Form("Invalid entry ID: %s",
554 entry->GetId().ToString().Data()));
555 return kFALSE;
556 }
557
558 if (!entry->GetId().IsSpecified()) {
559 AliError(Form("Unspecified entry ID: %s",
560 entry->GetId().ToString().Data()));
561 return kFALSE;
562 }
563
564 AliCDBId id = entry->GetId();
024cf675 565 AliCDBParam *aPar = SelectSpecificStorage(id.GetPath());
566
02c4845e 567 AliCDBStorage *aStorage;
568
569 if(aPar) {
570 aStorage=GetStorage(aPar);
02c4845e 571 } else {
b8ec52f6 572 switch(type){
573 case kCondition:
574 aStorage = GetStorage(fCondParam);
575 break;
576 case kReference:
577 aStorage = GetStorage(fRefParam);
578 break;
579 case kPrivate:
580 aStorage = GetDefaultStorage();
581 break;
582 }
02c4845e 583 }
584
b8ec52f6 585 AliDebug(2,Form("Storing object into storage: %s", aStorage->GetURI().Data()));
586
587 return aStorage->Put(entry, type);
02c4845e 588
589
590}
9e1ceb13 591
4b5e0dce 592//_____________________________________________________________________________
593void AliCDBManager::CacheEntry(const char* path, AliCDBEntry* entry)
594{
595// cache AliCDBEntry. Cache is valid until run number is changed.
596
597 AliDebug(2,Form("Filling cache with entry %s",path));
598 fEntryCache.Add(new TObjString(path), entry);
599 AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries()));
600
601}
602
917a098b 603//_____________________________________________________________________________
604void AliCDBManager::Print(Option_t* /*option*/) const
605{
606// Print list of active storages and their URIs
917a098b 607
b8ec52f6 608 TString output=Form("Run number = %d; ",fRun);
609 output += "Cache is ";
917a098b 610 if(!fCache) output += "NOT ";
b8ec52f6 611 output += Form("ACTIVE; Number of active storages: %d\n",fActiveStorages.GetEntries());
917a098b 612
613 if(fDefaultStorage) {
b8ec52f6 614 output += Form("\t*** Default Storage URI: \"%s\"\n",fDefaultStorage->GetURI().Data());
615// AliInfo(output.Data());
917a098b 616 }
617 if(fSpecificStorages.GetEntries()>0) {
917a098b 618 TIter iter(fSpecificStorages.GetTable());
62032124 619 TPair *aPair=0;
b8ec52f6 620 Int_t i=1;
917a098b 621 while((aPair = (TPair*) iter.Next())){
b8ec52f6 622 output += Form("\t*** Specific storage %d: Path \"%s\" -> URI \"%s\"\n",
623 i++, ((TObjString*) aPair->Key())->GetName(),
917a098b 624 ((AliCDBParam*) aPair->Value())->GetURI().Data());
917a098b 625 }
917a098b 626 }
627 if(fDrainStorage) {
b8ec52f6 628 output += Form("*** Drain Storage URI: %s\n",fDrainStorage->GetURI().Data());
917a098b 629 }
b8ec52f6 630 AliInfo(output.Data());
917a098b 631}
632
4b5e0dce 633//_____________________________________________________________________________
c3a7b59a 634void AliCDBManager::SetRun(Int_t run)
4b5e0dce 635{
917a098b 636// Sets current run number.
4b5e0dce 637// When the run number changes the caching is cleared.
4b5e0dce 638
639 if (fRun == run)
640 return;
641
642 fRun = run;
643 ClearCache();
62032124 644 QueryCDB();
4b5e0dce 645}
646
647//_____________________________________________________________________________
648void AliCDBManager::ClearCache(){
649// clear AliCDBEntry cache
650
651 AliDebug(2,Form("Clearing cache!"));
652 fEntryCache.DeleteAll();
653 AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries()));
654
655}
656
9e1ceb13 657//_____________________________________________________________________________
658void AliCDBManager::DestroyActiveStorages() {
659// delete list of active storages
660
661 fActiveStorages.DeleteAll();
02c4845e 662 fSpecificStorages.DeleteAll();
9e1ceb13 663}
664
665//_____________________________________________________________________________
666void AliCDBManager::DestroyActiveStorage(AliCDBStorage* /*storage*/) {
b05400be 667// destroys active storage
668
669/*
917a098b 670 TIter iter(fActiveStorages.GetTable());
b05400be 671 TPair* aPair;
672 while ((aPair = (TPair*) iter.Next())) {
673 if(storage == (AliCDBStorage*) aPair->Value())
674 delete fActiveStorages.Remove(aPair->Key());
675 storage->Delete(); storage=0x0;
676 }
6dc56e97 677*/
9e1ceb13 678
679}
680
62032124 681//_____________________________________________________________________________
682void AliCDBManager::QueryCDB() {
683// query default and specific storages for files valid for fRun. Every storage loads the Ids into its list.
684
685 if (fRun < 0){
686 AliError("Run number not yet set! Use AliCDBManager::SetRun.");
687 return;
688 }
6dc56e97 689 if (!fDefaultStorage){
690 AliError("Default storage is not set! Use AliCDBManager::SetDefaultStorage");
691 return;
692 }
693 if(fDefaultStorage->GetType() == "alien"){
694 fDefaultStorage->QueryCDB(fRun);
695 } else {
696 AliDebug(2,"Skipping query for valid files, it used only in grid...");
697 }
62032124 698
699 TIter iter(&fSpecificStorages);
700 TObjString *aCalibType=0;
701 AliCDBParam* aPar=0;
702 while((aCalibType = dynamic_cast<TObjString*> (iter.Next()))){
703 aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
704 if(aPar) {
c3a7b59a 705 AliDebug(2,Form("Querying specific storage %s",aCalibType->GetName()));
6dc56e97 706 AliCDBStorage *aStorage = GetStorage(aPar);
707 if(aStorage->GetType() == "alien"){
708 aStorage->QueryCDB(fRun,aCalibType->GetName());
709 } else {
710 AliDebug(2,
711 "Skipping query for valid files, it is used only in grid...");
712 }
62032124 713 }
714 }
62032124 715}
716
b8ec52f6 717//______________________________________________________________________________________________
718const char* AliCDBManager::GetDataTypeName(DataType type)
719{
720 // returns the name (string) of the data type
721
722 switch (type){
723 case kCondition: return "Conditions";
724 case kReference: return "Reference";
725 case kPrivate: return "Private";
726 }
727 return 0;
728
729}
62032124 730
9e1ceb13 731///////////////////////////////////////////////////////////
732// AliCDBManager Parameter class //
733// interface to specific AliCDBParameter class //
734// (AliCDBGridParam, AliCDBLocalParam, AliCDBDumpParam) //
735///////////////////////////////////////////////////////////
736
62032124 737AliCDBParam::AliCDBParam():
fe12e09c 738 fType(),
739 fURI()
62032124 740{
9e1ceb13 741// constructor
742
743}
744
745//_____________________________________________________________________________
746AliCDBParam::~AliCDBParam() {
747// destructor
748
749}
750