1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 // Implementation of AliCDBManager and AliCDBParam classe
17 // Author: Alberto Colla
18 // e-mail: Alberto.Colla@cern.ch
19 //-------------------------------------------------------------------------
21 #include "AliCDBManager.h"
22 #include "AliCDBStorage.h"
24 #include "AliCDBDump.h"
25 #include "AliCDBLocal.h"
26 #include "AliCDBGrid.h"
27 #include "AliCDBEntry.h"
28 #include "AliCDBMetaData.h"
30 #include <TObjString.h>
35 ClassImp(AliCDBManager)
37 //TODO OCDB and Reference folder should not be fully hardcoded but built from run number (or year/LHC period)
38 TString AliCDBManager::fgkCondUri("alien://folder=/alice/cern.ch/user/a/aliprod/testCDB/CDB?user=aliprod");
39 TString AliCDBManager::fgkRefUri("alien://folder=/alice/cern.ch/user/a/aliprod/testCDB/Reference?user=aliprod");
40 AliCDBManager* AliCDBManager::fgInstance = 0x0;
42 //_____________________________________________________________________________
43 AliCDBManager* AliCDBManager::Instance()
45 // returns AliCDBManager instance (singleton)
48 fgInstance = new AliCDBManager();
55 //_____________________________________________________________________________
56 void AliCDBManager::Init() {
57 // factory registering
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());
65 fCondParam = CreateParameter(fgkCondUri);
66 fRefParam = CreateParameter(fgkRefUri);
71 //_____________________________________________________________________________
72 void AliCDBManager::Destroy() {
73 // delete ALCDBManager instance and active storages
76 //fgInstance->Delete();
82 //_____________________________________________________________________________
83 AliCDBManager::AliCDBManager():
90 fDefaultStorage(NULL),
99 fFactories.SetOwner(1);
100 fActiveStorages.SetOwner(1);
101 fSpecificStorages.SetOwner(1);
102 fEntryCache.SetOwner(1);
105 //_____________________________________________________________________________
106 AliCDBManager::~AliCDBManager() {
109 DestroyActiveStorages();
112 fDefaultStorage = 0x0;
113 fRemoteStorage = 0x0;
116 delete fShortLived; fShortLived = 0x0;
119 //_____________________________________________________________________________
120 void AliCDBManager::PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage){
121 // put a storage object into the list of active storages
123 fActiveStorages.Add(param, storage);
124 AliDebug(1, Form("Active storages: %d", fActiveStorages.GetEntries()));
127 //_____________________________________________________________________________
128 void AliCDBManager::RegisterFactory(AliCDBStorageFactory* factory) {
129 // add a storage factory to the list of registerd factories
131 if (!fFactories.Contains(factory)) {
132 fFactories.Add(factory);
136 //_____________________________________________________________________________
137 Bool_t AliCDBManager::HasStorage(const char* dbString) const {
138 // check if dbString is a URI valid for one of the registered factories
140 TIter iter(&fFactories);
142 AliCDBStorageFactory* factory=0;
143 while ((factory = (AliCDBStorageFactory*) iter.Next())) {
145 if (factory->Validate(dbString)) {
153 //_____________________________________________________________________________
154 AliCDBParam* AliCDBManager::CreateParameter(const char* dbString) const {
155 // create AliCDBParam object from URI string
157 TIter iter(&fFactories);
159 AliCDBStorageFactory* factory=0;
160 while ((factory = (AliCDBStorageFactory*) iter.Next())) {
161 AliCDBParam* param = factory->CreateParameter(dbString);
162 if(param) return param;
168 //_____________________________________________________________________________
169 AliCDBStorage* AliCDBManager::GetStorage(const char* dbString) {
170 // get storage object from URI string
172 AliCDBParam* param = CreateParameter(dbString);
174 AliError(Form("Failed to activate requested storage! Check URI: %s", dbString));
178 AliCDBStorage* aStorage = GetStorage(param);
184 //_____________________________________________________________________________
185 AliCDBStorage* AliCDBManager::GetStorage(const AliCDBParam* param) {
186 // get storage object from AliCDBParam object
188 // if the list of active storages already contains
189 // the requested storage, return it
190 AliCDBStorage* aStorage = GetActiveStorage(param);
195 TIter iter(&fFactories);
197 AliCDBStorageFactory* factory=0;
199 // loop on the list of registered factories
200 while ((factory = (AliCDBStorageFactory*) iter.Next())) {
202 // each factory tries to create its storage from the parameter
203 aStorage = factory->Create(param);
205 PutActiveStorage(param->CloneParam(), aStorage);
206 aStorage->SetURI(param->GetURI());
208 if(aStorage->GetType() == "alien"){
209 aStorage->QueryCDB(fRun);
212 "Skipping query for valid files, it is used only in grid...");
219 AliError(Form("Failed to activate requested storage! Check URI: %s", param->GetURI().Data()));
224 //_____________________________________________________________________________
225 AliCDBStorage* AliCDBManager::GetActiveStorage(const AliCDBParam* param) {
226 // get a storage object from the list of active storages
228 return dynamic_cast<AliCDBStorage*> (fActiveStorages.GetValue(param));
231 //_____________________________________________________________________________
232 TList* AliCDBManager::GetActiveStorages() {
233 // return list of active storages
234 // user has responsibility to delete returned object
236 TList* result = new TList();
238 TIter iter(fActiveStorages.GetTable());
240 while ((aPair = (TPair*) iter.Next())) {
241 result->Add(aPair->Value());
247 //_____________________________________________________________________________
248 void AliCDBManager::SetDrain(const char* dbString) {
249 // set drain storage from URI string
251 fDrainStorage = GetStorage(dbString);
254 //_____________________________________________________________________________
255 void AliCDBManager::SetDrain(const AliCDBParam* param) {
256 // set drain storage from AliCDBParam
258 fDrainStorage = GetStorage(param);
261 //_____________________________________________________________________________
262 void AliCDBManager::SetDrain(AliCDBStorage* storage) {
263 // set drain storage from another active storage
265 fDrainStorage = storage;
268 //_____________________________________________________________________________
269 Bool_t AliCDBManager::Drain(AliCDBEntry *entry) {
270 // drain retrieved object to drain storage
272 AliDebug(2, "Draining into drain storage...");
273 return fDrainStorage->Put(entry);
276 //_____________________________________________________________________________
277 void AliCDBManager::SetDefaultStorage(const char* dbString) {
278 // sets default storage from URI string
280 AliInfo(Form("Setting Default storage to: %s",dbString));
281 AliCDBStorage* bckStorage = fDefaultStorage;
283 fDefaultStorage = GetStorage(dbString);
285 if(bckStorage && (fDefaultStorage != bckStorage)){
286 AliWarning("Existing default storage replaced: clearing cache!");
291 //_____________________________________________________________________________
292 void AliCDBManager::SetDefaultStorage(const AliCDBParam* param) {
293 // set default storage from AliCDBParam object
295 AliCDBStorage* bckStorage = fDefaultStorage;
297 fDefaultStorage = GetStorage(param);
299 if(bckStorage && (fDefaultStorage != bckStorage)){
300 AliWarning("Existing default storage replaced: clearing cache!");
305 //_____________________________________________________________________________
306 void AliCDBManager::SetDefaultStorage(AliCDBStorage* storage) {
307 // set default storage from another active storage
309 AliCDBStorage* bckStorage = fDefaultStorage;
311 fDefaultStorage = storage;
313 if(bckStorage && (fDefaultStorage != bckStorage)){
314 AliWarning("Existing default storage replaced: clearing cache!");
318 //_____________________________________________________________________________
319 void AliCDBManager::SetRemoteStorage(const char* dbString) {
320 // sets remote storage from URI string
321 // Remote storage is queried if it is activated and if object was not found in default storage
323 AliInfo(Form("Setting remote storage to: %s",dbString));
324 fRemoteStorage = GetStorage(dbString);
327 //_____________________________________________________________________________
328 void AliCDBManager::SetRemoteStorage(const AliCDBParam* param) {
329 // set remote storage from AliCDBParam object
330 // Remote storage is queried if it is activated and if object was not found in default storage
332 fRemoteStorage = GetStorage(param);
335 //_____________________________________________________________________________
336 void AliCDBManager::SetRemoteStorage(AliCDBStorage* storage) {
337 // set remote storage from another active storage
338 // Remote storage is queried if it is activated and if object was not found in default storage
340 fRemoteStorage = storage;
343 //_____________________________________________________________________________
344 void AliCDBManager::SetSpecificStorage(const char* calibType, const char* dbString) {
345 // sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
347 AliCDBParam *aPar = CreateParameter(dbString);
349 SetSpecificStorage(calibType, aPar);
353 //_____________________________________________________________________________
354 void AliCDBManager::SetSpecificStorage(const char* calibType, AliCDBParam* param) {
355 // sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
356 // Default storage should be defined prior to any specific storages, e.g.:
357 // AliCDBManager::instance()->SetDefaultStorage("alien://");
358 // AliCDBManager::instance()->SetSpecificStorage("TPC/*","local://DB_TPC");
359 // AliCDBManager::instance()->SetSpecificStorage("*/Align/*","local://DB_TPCAlign");
360 // calibType must be a valid CDB path! (3 level folder structure)
362 if(!fDefaultStorage) {
363 AliError("Please activate a default storage first!");
367 AliCDBPath aPath(calibType);
368 if(!aPath.IsValid()){
369 AliError(Form("Not a valid path: %s", calibType));
373 TObjString *objCalibType = new TObjString(aPath.GetPath());
374 if(fSpecificStorages.Contains(objCalibType)){
375 AliWarning(Form("Storage \"%s\" already activated! It will be replaced by the new one",
377 AliCDBParam *checkPar = dynamic_cast<AliCDBParam*> (fSpecificStorages.GetValue(calibType));
378 if(checkPar) delete checkPar;
379 delete fSpecificStorages.Remove(objCalibType);
383 fSpecificStorages.Add(objCalibType, param->CloneParam());
386 //_____________________________________________________________________________
387 AliCDBStorage* AliCDBManager::GetSpecificStorage(const char* calibType) {
388 // get storage specific for detector or calibration type
390 AliCDBPath calibPath(calibType);
391 if(!calibPath.IsValid()) return NULL;
393 AliCDBParam *checkPar = (AliCDBParam*) fSpecificStorages.GetValue(calibPath.GetPath());
395 AliError(Form("%s storage not found!", calibType));
398 return GetStorage(checkPar);
403 //_____________________________________________________________________________
404 AliCDBParam* AliCDBManager::SelectSpecificStorage(const TString& path) {
405 // select storage valid for path from the list of specific storages
407 AliCDBPath aPath(path);
408 if(!aPath.IsValid()) return NULL;
410 TIter iter(&fSpecificStorages);
411 TObjString *aCalibType=0;
412 AliCDBPath tmpPath("null/null/null");
414 while((aCalibType = (TObjString*) iter.Next())){
415 AliCDBPath calibTypePath(aCalibType->GetName());
416 if(calibTypePath.Comprises(aPath)) {
417 if(calibTypePath.Comprises(tmpPath)) continue;
418 aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
419 tmpPath.SetPath(calibTypePath.GetPath());
425 //_____________________________________________________________________________
426 AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path, Int_t runNumber,
427 Int_t version, Int_t subVersion) {
428 // get an AliCDBEntry object from the database
431 // RunNumber is not specified. Try with fRun
433 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
439 return Get(AliCDBId(path, runNumber, runNumber, version, subVersion));
442 //_____________________________________________________________________________
443 AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path,
444 const AliCDBRunRange& runRange, Int_t version,
446 // get an AliCDBEntry object from the database!
448 return Get(AliCDBId(path, runRange, version, subVersion));
451 //_____________________________________________________________________________
452 AliCDBEntry* AliCDBManager::Get(const AliCDBId& query) {
453 // get an AliCDBEntry object from the database
455 if(!fDefaultStorage) {
456 AliError("No storage set!");
460 // check if query's path and runRange are valid
461 // query is invalid also if version is not specified and subversion is!
462 if (!query.IsValid()) {
463 AliError(Form("Invalid query: %s", query.ToString().Data()));
467 // query is not specified if path contains wildcard or run range= [-1,-1]
468 if (!query.IsSpecified()) {
469 AliError(Form("Unspecified query: %s",
470 query.ToString().Data()));
474 if(fCache && query.GetFirstRun() != fRun)
475 AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!");
478 AliCDBEntry *entry=0;
480 // first look into map of cached objects
481 if(fCache && query.GetFirstRun() == fRun)
482 entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath());
485 AliDebug(2, Form("Object %s retrieved from cache !!",query.GetPath().Data()));
489 // Entry is not in cache -> retrieve it from CDB and cache it!!
490 AliCDBStorage *aStorage=0;
491 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
492 Bool_t usedDefStorage=kTRUE;
495 aStorage=GetStorage(aPar);
496 TString str = aPar->GetURI();
497 AliDebug(2,Form("Looking into storage: %s",str.Data()));
498 usedDefStorage=kFALSE;
501 aStorage=GetDefaultStorage();
502 AliDebug(2,"Looking into default storage");
505 entry = aStorage->Get(query);
507 if (!entry && usedDefStorage && IsRemoteStorageSet()) {
508 AliWarning(Form("Object not found in default storage: Looking into remote storage!"));
509 entry = fRemoteStorage->Get(query);
512 if(entry && fCache && (query.GetFirstRun() == fRun)){
513 CacheEntry(query.GetPath(), entry);
520 //_____________________________________________________________________________
521 AliCDBId* AliCDBManager::GetId(const AliCDBPath& path, Int_t runNumber,
522 Int_t version, Int_t subVersion) {
523 // get the AliCDBId of the valid object from the database (does not retrieve the object)
524 // User must delete returned object!
527 // RunNumber is not specified. Try with fRun
529 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
535 return GetId(AliCDBId(path, runNumber, runNumber, version, subVersion));
538 //_____________________________________________________________________________
539 AliCDBId* AliCDBManager::GetId(const AliCDBPath& path,
540 const AliCDBRunRange& runRange, Int_t version,
542 // get the AliCDBId of the valid object from the database (does not retrieve the object)
543 // User must delete returned object!
545 return GetId(AliCDBId(path, runRange, version, subVersion));
548 //_____________________________________________________________________________
549 AliCDBId* AliCDBManager::GetId(const AliCDBId& query) {
550 // get the AliCDBId of the valid object from the database (does not retrieve the object)
551 // User must delete returned object!
553 if(!fDefaultStorage) {
554 AliError("No storage set!");
558 // check if query's path and runRange are valid
559 // query is invalid also if version is not specified and subversion is!
560 if (!query.IsValid()) {
561 AliError(Form("Invalid query: %s", query.ToString().Data()));
565 // query is not specified if path contains wildcard or run range= [-1,-1]
566 if (!query.IsSpecified()) {
567 AliError(Form("Unspecified query: %s",
568 query.ToString().Data()));
572 if(fCache && query.GetFirstRun() != fRun)
573 AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!");
575 AliCDBEntry* entry = 0;
577 // first look into map of cached objects
578 if(fCache && query.GetFirstRun() == fRun)
579 entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath());
582 AliDebug(2, Form("Object %s retrieved from cache !!",query.GetPath().Data()));
583 return dynamic_cast<AliCDBId*> (entry->GetId().Clone());
586 // Entry is not in cache -> retrieve it from CDB and cache it!!
587 AliCDBStorage *aStorage=0;
588 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
591 aStorage=GetStorage(aPar);
592 TString str = aPar->GetURI();
593 AliDebug(2,Form("Looking into storage: %s",str.Data()));
596 aStorage=GetDefaultStorage();
597 AliDebug(2,"Looking into default storage");
600 return aStorage->GetId(query);
604 //_____________________________________________________________________________
605 TList* AliCDBManager::GetAll(const AliCDBPath& path, Int_t runNumber,
606 Int_t version, Int_t subVersion) {
607 // get multiple AliCDBEntry objects from the database
610 // RunNumber is not specified. Try with fRun
612 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
618 return GetAll(AliCDBId(path, runNumber, runNumber, version,
622 //_____________________________________________________________________________
623 TList* AliCDBManager::GetAll(const AliCDBPath& path,
624 const AliCDBRunRange& runRange, Int_t version, Int_t subVersion) {
625 // get multiple AliCDBEntry objects from the database
627 return GetAll(AliCDBId(path, runRange, version, subVersion));
630 //_____________________________________________________________________________
631 TList* AliCDBManager::GetAll(const AliCDBId& query) {
632 // get multiple AliCDBEntry objects from the database
633 // Warning: this method works correctly only for queries of the type "Detector/*"
634 // and not for more specific queries e.g. "Detector/Calib/*" !
635 // Warning #2: Entries are cached, but GetAll will keep on retrieving objects from OCDB!
636 // To get an object from cache use Get() function
638 if(!fDefaultStorage) {
639 AliError("No storage set!");
643 if (!query.IsValid()) {
644 AliError(Form("Invalid query: %s", query.ToString().Data()));
648 if((fSpecificStorages.GetEntries()>0) && query.GetPath().BeginsWith('*')){
649 // if specific storages are active a query with "*" is ambiguous
650 AliError("Query too generic in this context!");
654 if (query.IsAnyRange()) {
655 AliError(Form("Unspecified run or runrange: %s",
656 query.ToString().Data()));
660 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
662 AliCDBStorage *aStorage;
664 aStorage=GetStorage(aPar);
665 AliDebug(2,Form("Looking into storage: %s", aPar->GetURI().Data()));
668 aStorage=GetDefaultStorage();
669 AliDebug(2,"Looking into default storage");
673 if(aStorage) result = aStorage->GetAll(query);
674 if(!result) return 0;
676 // loop on result to check whether entries should be re-queried with specific storages
677 if(fSpecificStorages.GetEntries()>0 && ! (fSpecificStorages.GetEntries() == 1 && aPar)) {
678 AliInfo("Now look into all other specific storages...");
681 AliCDBEntry* chkEntry=0;
683 while((chkEntry = dynamic_cast<AliCDBEntry*> (iter.Next()))){
684 AliCDBId& chkId = chkEntry->GetId();
685 AliDebug(2, Form("Checking id %s ", chkId.GetPath().Data()));
686 AliCDBParam *chkPar=SelectSpecificStorage(chkId.GetPath());
687 if (!chkPar || aPar == chkPar) continue;
688 AliCDBStorage *chkStorage = GetStorage(chkPar);
689 AliDebug(2, Form("Found specific storage! %s", chkPar->GetURI().Data()));
691 AliCDBEntry *newEntry=0;
692 chkId.SetRunRange(query.GetFirstRun(), query.GetLastRun());
693 chkId.SetVersion(query.GetVersion());
694 chkId.SetSubVersion(query.GetSubVersion());
696 if(chkStorage) newEntry = chkStorage->Get(chkId);
697 if(!newEntry) continue;
699 // object is found in specific storage: replace entry in the result list!
700 chkEntry->SetOwner(1);
701 delete result->Remove(chkEntry);
702 result->AddFirst(newEntry);
705 Int_t nEntries = result->GetEntries();
706 AliInfo("After look into other specific storages, result list is:");
707 for(int i=0; i<nEntries;i++){
708 AliCDBEntry *entry = (AliCDBEntry*) result->At(i);
709 AliInfo(Form("%s",entry->GetId().ToString().Data()));
714 if(fCache && (query.GetFirstRun() == fRun)){
717 AliCDBEntry* entry=0;
718 while((entry = dynamic_cast<AliCDBEntry*> (iter.Next()))){
719 CacheEntry(entry->GetId().GetPath(), entry);
726 //_____________________________________________________________________________
727 Bool_t AliCDBManager::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData, DataType type){
728 // store an AliCDBEntry object into the database
730 AliCDBEntry anEntry(object, id, metaData);
731 return Put(&anEntry, type);
736 //_____________________________________________________________________________
737 Bool_t AliCDBManager::Put(AliCDBEntry* entry, DataType type){
738 // store an AliCDBEntry object into the database
740 if(type == kPrivate && !fDefaultStorage) {
741 AliError("No storage set!");
746 AliError("No entry!");
750 if (!entry->GetId().IsValid()) {
751 AliError(Form("Invalid entry ID: %s",
752 entry->GetId().ToString().Data()));
756 if (!entry->GetId().IsSpecified()) {
757 AliError(Form("Unspecified entry ID: %s",
758 entry->GetId().ToString().Data()));
762 AliCDBId id = entry->GetId();
763 AliCDBParam *aPar = SelectSpecificStorage(id.GetPath());
765 AliCDBStorage *aStorage=0;
768 aStorage=GetStorage(aPar);
772 aStorage = GetStorage(fCondParam);
775 aStorage = GetStorage(fRefParam);
778 aStorage = GetDefaultStorage();
783 AliDebug(2,Form("Storing object into storage: %s", aStorage->GetURI().Data()));
785 Bool_t result = aStorage->Put(entry, type);
787 if(fRun >= 0) QueryCDB();
794 //_____________________________________________________________________________
795 void AliCDBManager::CacheEntry(const char* path, AliCDBEntry* entry)
797 // cache AliCDBEntry. Cache is valid until run number is changed.
799 AliCDBEntry *chkEntry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(path));
802 AliDebug(2, Form("Object %s already in cache !!", path));
805 AliDebug(2,Form("Caching entry %s", path));
808 fEntryCache.Add(new TObjString(path), entry);
809 AliDebug(2,Form("Cache entries: %d", fEntryCache.GetEntries()));
813 //_____________________________________________________________________________
814 void AliCDBManager::Print(Option_t* /*option*/) const
816 // Print list of active storages and their URIs
818 TString output=Form("Run number = %d; ",fRun);
819 output += "Cache is ";
820 if(!fCache) output += "NOT ";
821 output += Form("ACTIVE; Number of active storages: %d\n",fActiveStorages.GetEntries());
823 if(fDefaultStorage) {
824 output += Form("\t*** Default Storage URI: \"%s\"\n",fDefaultStorage->GetURI().Data());
825 // AliInfo(output.Data());
827 if(fSpecificStorages.GetEntries()>0) {
828 TIter iter(fSpecificStorages.GetTable());
831 while((aPair = (TPair*) iter.Next())){
832 output += Form("\t*** Specific storage %d: Path \"%s\" -> URI \"%s\"\n",
833 i++, ((TObjString*) aPair->Key())->GetName(),
834 ((AliCDBParam*) aPair->Value())->GetURI().Data());
838 output += Form("*** Drain Storage URI: %s\n",fDrainStorage->GetURI().Data());
840 AliInfo(output.Data());
843 //_____________________________________________________________________________
844 void AliCDBManager::SetRun(Int_t run)
846 // Sets current run number.
847 // When the run number changes the caching is cleared.
857 //_____________________________________________________________________________
858 void AliCDBManager::ClearCache(){
859 // clear AliCDBEntry cache
861 AliDebug(2,Form("Clearing cache!"));
862 fEntryCache.DeleteAll();
863 AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries()));
867 //_____________________________________________________________________________
868 void AliCDBManager::UnloadFromCache(const char* path){
869 // unload cached object
871 AliCDBPath queryPath(path);
872 if(!queryPath.IsValid()) return;
874 if(!queryPath.IsWildcard()) { // path is not wildcard, get it directly from the cache and unload it!
875 if(fEntryCache.Contains(path)){
876 AliInfo(Form("Unloading object \"%s\" from cache", path));
877 TObjString pathStr(path);
878 AliCDBEntry *entry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(&pathStr));
879 if(entry) delete entry;
880 delete fEntryCache.Remove(&pathStr);
882 AliError(Form("Cache does not contain object \"%s\"!", path))
884 AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries()));
888 // path is wildcard: loop on the cache and unload all comprised objects!
889 TIter iter(fEntryCache.GetTable());
892 while((pair = dynamic_cast<TPair*> (iter.Next()))){
893 AliCDBPath entryPath = pair->Key()->GetName();
894 if(queryPath.Comprises(entryPath)) {
895 AliInfo(Form("Unloading object \"%s\" from cache", entryPath.GetPath().Data()));
896 TObjString pathStr(entryPath.GetPath().Data());
897 AliCDBEntry *entry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(&pathStr));
898 if(entry) delete entry;
899 delete fEntryCache.Remove(&pathStr);
902 AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries()));
905 //_____________________________________________________________________________
906 void AliCDBManager::DestroyActiveStorages() {
907 // delete list of active storages
909 fActiveStorages.DeleteAll();
910 fSpecificStorages.DeleteAll();
913 //_____________________________________________________________________________
914 void AliCDBManager::DestroyActiveStorage(AliCDBStorage* /*storage*/) {
915 // destroys active storage
918 TIter iter(fActiveStorages.GetTable());
920 while ((aPair = (TPair*) iter.Next())) {
921 if(storage == (AliCDBStorage*) aPair->Value())
922 delete fActiveStorages.Remove(aPair->Key());
923 storage->Delete(); storage=0x0;
929 //_____________________________________________________________________________
930 void AliCDBManager::QueryCDB() {
931 // query default and specific storages for files valid for fRun. Every storage loads the Ids into its list.
934 AliError("Run number not yet set! Use AliCDBManager::SetRun.");
937 if (!fDefaultStorage){
938 AliError("Default storage is not set! Use AliCDBManager::SetDefaultStorage");
941 if(fDefaultStorage->GetType() == "alien"){
942 fDefaultStorage->QueryCDB(fRun);
944 AliDebug(2,"Skipping query for valid files, it used only in grid...");
947 TIter iter(&fSpecificStorages);
948 TObjString *aCalibType=0;
950 while((aCalibType = dynamic_cast<TObjString*> (iter.Next()))){
951 aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
953 AliDebug(2,Form("Querying specific storage %s",aCalibType->GetName()));
954 AliCDBStorage *aStorage = GetStorage(aPar);
955 if(aStorage->GetType() == "alien"){
956 aStorage->QueryCDB(fRun,aCalibType->GetName());
959 "Skipping query for valid files, it is used only in grid...");
965 //______________________________________________________________________________________________
966 const char* AliCDBManager::GetDataTypeName(DataType type)
968 // returns the name (string) of the data type
971 case kCondition: return "Conditions";
972 case kReference: return "Reference";
973 case kPrivate: return "Private";
979 //______________________________________________________________________________________________
980 void AliCDBManager::InitShortLived()
982 // Init the list of short-lived objects
983 // currently disabled
987 // fShortLived = new TList();
988 // fShortLived->SetOwner(1);
990 // fShortLived->Add(new TObjString("EMCAL/Calib/Data"));
992 // fShortLived->Add(new TObjString("HMPID/Calib/Nmean"));
993 // fShortLived->Add(new TObjString("HMPID/Calib/Qthre"));
995 // fShortLived->Add(new TObjString("ITS/Calib/CalibSPD"));
997 // fShortLived->Add(new TObjString("MUON/Calib/Gains"));
998 // fShortLived->Add(new TObjString("MUON/Calib/HV"));
999 // fShortLived->Add(new TObjString("MUON/Calib/Pedestals"));
1001 // fShortLived->Add(new TObjString("PHOS/Calib/CpvGainPedestals"));
1002 // fShortLived->Add(new TObjString("PHOS/Calib/EmcGainPedestals"));
1004 // fShortLived->Add(new TObjString("PMD/Calib/Data"));
1006 // fShortLived->Add(new TObjString("TRD/Calib/ChamberGainFactor"));
1007 // fShortLived->Add(new TObjString("TRD/Calib/LocalGainFactor"));
1008 // fShortLived->Add(new TObjString("TRD/Calib/ChamberT0"));
1009 // fShortLived->Add(new TObjString("TRD/Calib/LocalT0"));
1010 // fShortLived->Add(new TObjString("TRD/Calib/ChamberVdrift"));
1011 // fShortLived->Add(new TObjString("TRD/Calib/LocalVdrift"));
1013 // fShortLived->Add(new TObjString("ZDC/Calib/Data"));
1017 //______________________________________________________________________________________________
1018 Bool_t AliCDBManager::IsShortLived(const char* path)
1020 // returns the name (string) of the data type
1022 if(!fShortLived) return kFALSE;
1024 AliCDBPath aPath(path);
1025 if(!aPath.IsValid()){
1026 AliError(Form("Not a valid path: %s", path));
1030 return fShortLived->Contains(path);
1034 ///////////////////////////////////////////////////////////
1035 // AliCDBManager Parameter class //
1036 // interface to specific AliCDBParameter class //
1037 // (AliCDBGridParam, AliCDBLocalParam, AliCDBDumpParam) //
1038 ///////////////////////////////////////////////////////////
1040 AliCDBParam::AliCDBParam():
1048 //_____________________________________________________________________________
1049 AliCDBParam::~AliCDBParam() {