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 fDefaultStorage = GetStorage(dbString);
284 //_____________________________________________________________________________
285 void AliCDBManager::SetDefaultStorage(const AliCDBParam* param) {
286 // set default storage from AliCDBParam object
288 fDefaultStorage = GetStorage(param);
291 //_____________________________________________________________________________
292 void AliCDBManager::SetDefaultStorage(AliCDBStorage* storage) {
293 // set default storage from another active storage
295 fDefaultStorage = storage;
297 //_____________________________________________________________________________
298 void AliCDBManager::SetRemoteStorage(const char* dbString) {
299 // sets remote storage from URI string
300 // Remote storage is queried if it is activated and if object was not found in default storage
302 AliInfo(Form("Setting Default storage to: %s",dbString));
303 fRemoteStorage = GetStorage(dbString);
306 //_____________________________________________________________________________
307 void AliCDBManager::SetRemoteStorage(const AliCDBParam* param) {
308 // set remote storage from AliCDBParam object
309 // Remote storage is queried if it is activated and if object was not found in default storage
311 fRemoteStorage = GetStorage(param);
314 //_____________________________________________________________________________
315 void AliCDBManager::SetRemoteStorage(AliCDBStorage* storage) {
316 // set remote storage from another active storage
317 // Remote storage is queried if it is activated and if object was not found in default storage
319 fRemoteStorage = storage;
322 //_____________________________________________________________________________
323 void AliCDBManager::SetSpecificStorage(const char* calibType, const char* dbString) {
324 // sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
326 AliCDBParam *aPar = CreateParameter(dbString);
328 SetSpecificStorage(calibType, aPar);
332 //_____________________________________________________________________________
333 void AliCDBManager::SetSpecificStorage(const char* calibType, AliCDBParam* param) {
334 // sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
335 // Default storage should be defined prior to any specific storages, e.g.:
336 // AliCDBManager::instance()->SetDefaultStorage("alien://");
337 // AliCDBManager::instance()->SetSpecificStorage("TPC/*","local://DB_TPC");
338 // AliCDBManager::instance()->SetSpecificStorage("*/Align/*","local://DB_TPCAlign");
339 // calibType must be a valid CDB path! (3 level folder structure)
341 if(!fDefaultStorage) {
342 AliError("Please activate a default storage first!");
346 AliCDBPath aPath(calibType);
347 if(!aPath.IsValid()){
348 AliError(Form("Not a valid path: %s", calibType));
352 TObjString *objCalibType = new TObjString(aPath.GetPath());
353 if(fSpecificStorages.Contains(objCalibType)){
354 AliWarning(Form("Storage \"%s\" already activated! It will be replaced by the new one",
356 AliCDBParam *checkPar = dynamic_cast<AliCDBParam*> (fSpecificStorages.GetValue(calibType));
357 if(checkPar) delete checkPar;
358 delete fSpecificStorages.Remove(objCalibType);
362 fSpecificStorages.Add(objCalibType, param->CloneParam());
365 //_____________________________________________________________________________
366 AliCDBStorage* AliCDBManager::GetSpecificStorage(const char* calibType) {
367 // get storage specific for detector or calibration type
369 AliCDBPath calibPath(calibType);
370 if(!calibPath.IsValid()) return NULL;
372 AliCDBParam *checkPar = (AliCDBParam*) fSpecificStorages.GetValue(calibPath.GetPath());
374 AliError(Form("%s storage not found!", calibType));
377 return GetStorage(checkPar);
382 //_____________________________________________________________________________
383 AliCDBParam* AliCDBManager::SelectSpecificStorage(const TString& path) {
384 // select storage valid for path from the list of specific storages
386 AliCDBPath aPath(path);
387 if(!aPath.IsValid()) return NULL;
389 TIter iter(&fSpecificStorages);
390 TObjString *aCalibType=0;
391 AliCDBPath tmpPath("null/null/null");
393 while((aCalibType = (TObjString*) iter.Next())){
394 AliCDBPath calibTypePath(aCalibType->GetName());
395 if(calibTypePath.Comprises(aPath)) {
396 if(calibTypePath.Comprises(tmpPath)) continue;
397 aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
398 tmpPath.SetPath(calibTypePath.GetPath());
404 //_____________________________________________________________________________
405 AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path, Int_t runNumber,
406 Int_t version, Int_t subVersion) {
407 // get an AliCDBEntry object from the database
410 // RunNumber is not specified. Try with fRun
412 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
418 return Get(AliCDBId(path, runNumber, runNumber, version, subVersion));
421 //_____________________________________________________________________________
422 AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path,
423 const AliCDBRunRange& runRange, Int_t version,
425 // get an AliCDBEntry object from the database!
427 return Get(AliCDBId(path, runRange, version, subVersion));
430 //_____________________________________________________________________________
431 AliCDBEntry* AliCDBManager::Get(const AliCDBId& query) {
432 // get an AliCDBEntry object from the database
434 if(!fDefaultStorage) {
435 AliError("No storage set!");
439 // check if query's path and runRange are valid
440 // query is invalid also if version is not specified and subversion is!
441 if (!query.IsValid()) {
442 AliError(Form("Invalid query: %s", query.ToString().Data()));
446 // query is not specified if path contains wildcard or run range= [-1,-1]
447 if (!query.IsSpecified()) {
448 AliError(Form("Unspecified query: %s",
449 query.ToString().Data()));
453 if(fCache && query.GetFirstRun() != fRun)
454 AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!");
457 AliCDBEntry *entry=0;
459 // first look into map of cached objects
460 if(fCache && query.GetFirstRun() == fRun)
461 entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath());
464 AliDebug(2, Form("Object %s retrieved from cache !!",query.GetPath().Data()));
468 // Entry is not in cache -> retrieve it from CDB and cache it!!
469 AliCDBStorage *aStorage=0;
470 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
471 Bool_t usedDefStorage=kTRUE;
474 aStorage=GetStorage(aPar);
475 TString str = aPar->GetURI();
476 AliDebug(2,Form("Looking into storage: %s",str.Data()));
477 usedDefStorage=kFALSE;
480 aStorage=GetDefaultStorage();
481 AliDebug(2,"Looking into default storage");
484 entry = aStorage->Get(query);
486 if (!entry && usedDefStorage && IsRemoteStorageSet()) {
487 AliWarning(Form("Object not found in default storage: Looking into remote storage!"));
488 entry = fRemoteStorage->Get(query);
491 if(entry && fCache && (query.GetFirstRun() == fRun)){
492 CacheEntry(query.GetPath(), entry);
499 //_____________________________________________________________________________
500 AliCDBId* AliCDBManager::GetId(const AliCDBPath& path, Int_t runNumber,
501 Int_t version, Int_t subVersion) {
502 // get the AliCDBId of the valid object from the database (does not retrieve the object)
503 // User must delete returned object!
506 // RunNumber is not specified. Try with fRun
508 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
514 return GetId(AliCDBId(path, runNumber, runNumber, version, subVersion));
517 //_____________________________________________________________________________
518 AliCDBId* AliCDBManager::GetId(const AliCDBPath& path,
519 const AliCDBRunRange& runRange, Int_t version,
521 // get the AliCDBId of the valid object from the database (does not retrieve the object)
522 // User must delete returned object!
524 return GetId(AliCDBId(path, runRange, version, subVersion));
527 //_____________________________________________________________________________
528 AliCDBId* AliCDBManager::GetId(const AliCDBId& query) {
529 // get the AliCDBId of the valid object from the database (does not retrieve the object)
530 // User must delete returned object!
532 if(!fDefaultStorage) {
533 AliError("No storage set!");
537 // check if query's path and runRange are valid
538 // query is invalid also if version is not specified and subversion is!
539 if (!query.IsValid()) {
540 AliError(Form("Invalid query: %s", query.ToString().Data()));
544 // query is not specified if path contains wildcard or run range= [-1,-1]
545 if (!query.IsSpecified()) {
546 AliError(Form("Unspecified query: %s",
547 query.ToString().Data()));
551 if(fCache && query.GetFirstRun() != fRun)
552 AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!");
554 AliCDBEntry* entry = 0;
556 // first look into map of cached objects
557 if(fCache && query.GetFirstRun() == fRun)
558 entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath());
561 AliDebug(2, Form("Object %s retrieved from cache !!",query.GetPath().Data()));
562 return dynamic_cast<AliCDBId*> (entry->GetId().Clone());
565 // Entry is not in cache -> retrieve it from CDB and cache it!!
566 AliCDBStorage *aStorage=0;
567 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
570 aStorage=GetStorage(aPar);
571 TString str = aPar->GetURI();
572 AliDebug(2,Form("Looking into storage: %s",str.Data()));
575 aStorage=GetDefaultStorage();
576 AliDebug(2,"Looking into default storage");
579 return aStorage->GetId(query);
583 //_____________________________________________________________________________
584 TList* AliCDBManager::GetAll(const AliCDBPath& path, Int_t runNumber,
585 Int_t version, Int_t subVersion) {
586 // get multiple AliCDBEntry objects from the database
589 // RunNumber is not specified. Try with fRun
591 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
597 return GetAll(AliCDBId(path, runNumber, runNumber, version,
601 //_____________________________________________________________________________
602 TList* AliCDBManager::GetAll(const AliCDBPath& path,
603 const AliCDBRunRange& runRange, Int_t version, Int_t subVersion) {
604 // get multiple AliCDBEntry objects from the database
606 return GetAll(AliCDBId(path, runRange, version, subVersion));
609 //_____________________________________________________________________________
610 TList* AliCDBManager::GetAll(const AliCDBId& query) {
611 // get multiple AliCDBEntry objects from the database
612 // Warning: this method works correctly only for queries of the type "Detector/*"
613 // and not for more specific queries e.g. "Detector/Calib/*" !
614 // Warning #2: Entries are cached, but GetAll will keep on retrieving objects from OCDB!
615 // To get an object from cache use Get() function
617 if(!fDefaultStorage) {
618 AliError("No storage set!");
622 if (!query.IsValid()) {
623 AliError(Form("Invalid query: %s", query.ToString().Data()));
627 if((fSpecificStorages.GetEntries()>0) && query.GetPath().BeginsWith('*')){
628 // if specific storages are active a query with "*" is ambiguous
629 AliError("Query too generic in this context!");
633 if (query.IsAnyRange()) {
634 AliError(Form("Unspecified run or runrange: %s",
635 query.ToString().Data()));
639 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
641 AliCDBStorage *aStorage;
643 aStorage=GetStorage(aPar);
644 AliDebug(2,Form("Looking into storage: %s", aPar->GetURI().Data()));
647 aStorage=GetDefaultStorage();
648 AliDebug(2,"Looking into default storage");
652 if(aStorage) result = aStorage->GetAll(query);
653 if(!result) return 0;
655 // loop on result to check whether entries should be re-queried with specific storages
656 if(fSpecificStorages.GetEntries()>0 && ! (fSpecificStorages.GetEntries() == 1 && aPar)) {
657 AliInfo("Now look into all other specific storages...");
660 AliCDBEntry* chkEntry=0;
662 while((chkEntry = dynamic_cast<AliCDBEntry*> (iter.Next()))){
663 AliCDBId& chkId = chkEntry->GetId();
664 AliDebug(2, Form("Checking id %s ", chkId.GetPath().Data()));
665 AliCDBParam *chkPar=SelectSpecificStorage(chkId.GetPath());
666 if (!chkPar || aPar == chkPar) continue;
667 AliCDBStorage *chkStorage = GetStorage(chkPar);
668 AliDebug(2, Form("Found specific storage! %s", chkPar->GetURI().Data()));
670 AliCDBEntry *newEntry=0;
671 chkId.SetRunRange(query.GetFirstRun(), query.GetLastRun());
672 chkId.SetVersion(query.GetVersion());
673 chkId.SetSubVersion(query.GetSubVersion());
675 if(chkStorage) newEntry = chkStorage->Get(chkId);
676 if(!newEntry) continue;
678 // object is found in specific storage: replace entry in the result list!
679 chkEntry->SetOwner(1);
680 delete result->Remove(chkEntry);
681 result->AddFirst(newEntry);
684 Int_t nEntries = result->GetEntries();
685 AliInfo("After look into other specific storages, result list is:");
686 for(int i=0; i<nEntries;i++){
687 AliCDBEntry *entry = (AliCDBEntry*) result->At(i);
688 AliInfo(Form("%s",entry->GetId().ToString().Data()));
693 if(fCache && (query.GetFirstRun() == fRun)){
696 AliCDBEntry* entry=0;
697 while((entry = dynamic_cast<AliCDBEntry*> (iter.Next()))){
698 CacheEntry(entry->GetId().GetPath(), entry);
705 //_____________________________________________________________________________
706 Bool_t AliCDBManager::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData, DataType type){
707 // store an AliCDBEntry object into the database
709 AliCDBEntry anEntry(object, id, metaData);
710 return Put(&anEntry, type);
715 //_____________________________________________________________________________
716 Bool_t AliCDBManager::Put(AliCDBEntry* entry, DataType type){
717 // store an AliCDBEntry object into the database
719 if(type == kPrivate && !fDefaultStorage) {
720 AliError("No storage set!");
725 AliError("No entry!");
729 if (!entry->GetId().IsValid()) {
730 AliError(Form("Invalid entry ID: %s",
731 entry->GetId().ToString().Data()));
735 if (!entry->GetId().IsSpecified()) {
736 AliError(Form("Unspecified entry ID: %s",
737 entry->GetId().ToString().Data()));
741 AliCDBId id = entry->GetId();
742 AliCDBParam *aPar = SelectSpecificStorage(id.GetPath());
744 AliCDBStorage *aStorage=0;
747 aStorage=GetStorage(aPar);
751 aStorage = GetStorage(fCondParam);
754 aStorage = GetStorage(fRefParam);
757 aStorage = GetDefaultStorage();
762 AliDebug(2,Form("Storing object into storage: %s", aStorage->GetURI().Data()));
764 Bool_t result = aStorage->Put(entry, type);
766 if(fRun >= 0) QueryCDB();
773 //_____________________________________________________________________________
774 void AliCDBManager::CacheEntry(const char* path, AliCDBEntry* entry)
776 // cache AliCDBEntry. Cache is valid until run number is changed.
778 AliCDBEntry *chkEntry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(path));
781 AliDebug(2, Form("Object %s already in cache !!", path));
784 AliDebug(2,Form("Caching entry %s", path));
787 fEntryCache.Add(new TObjString(path), entry);
788 AliDebug(2,Form("Cache entries: %d", fEntryCache.GetEntries()));
792 //_____________________________________________________________________________
793 void AliCDBManager::Print(Option_t* /*option*/) const
795 // Print list of active storages and their URIs
797 TString output=Form("Run number = %d; ",fRun);
798 output += "Cache is ";
799 if(!fCache) output += "NOT ";
800 output += Form("ACTIVE; Number of active storages: %d\n",fActiveStorages.GetEntries());
802 if(fDefaultStorage) {
803 output += Form("\t*** Default Storage URI: \"%s\"\n",fDefaultStorage->GetURI().Data());
804 // AliInfo(output.Data());
806 if(fSpecificStorages.GetEntries()>0) {
807 TIter iter(fSpecificStorages.GetTable());
810 while((aPair = (TPair*) iter.Next())){
811 output += Form("\t*** Specific storage %d: Path \"%s\" -> URI \"%s\"\n",
812 i++, ((TObjString*) aPair->Key())->GetName(),
813 ((AliCDBParam*) aPair->Value())->GetURI().Data());
817 output += Form("*** Drain Storage URI: %s\n",fDrainStorage->GetURI().Data());
819 AliInfo(output.Data());
822 //_____________________________________________________________________________
823 void AliCDBManager::SetRun(Int_t run)
825 // Sets current run number.
826 // When the run number changes the caching is cleared.
836 //_____________________________________________________________________________
837 void AliCDBManager::ClearCache(){
838 // clear AliCDBEntry cache
840 AliDebug(2,Form("Clearing cache!"));
841 fEntryCache.DeleteAll();
842 AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries()));
846 //_____________________________________________________________________________
847 void AliCDBManager::UnloadFromCache(const char* path){
848 // unload cached object
850 AliCDBPath queryPath(path);
851 if(!queryPath.IsValid()) return;
853 if(!queryPath.IsWildcard()) { // path is not wildcard, get it directly from the cache and unload it!
854 if(fEntryCache.Contains(path)){
855 AliInfo(Form("Unloading object \"%s\" from cache", path));
856 TObjString pathStr(path);
857 AliCDBEntry *entry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(&pathStr));
858 if(entry) delete entry;
859 delete fEntryCache.Remove(&pathStr);
861 AliError(Form("Cache does not contain object \"%s\"!", path))
863 AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries()));
867 // path is wildcard: loop on the cache and unload all comprised objects!
868 TIter iter(fEntryCache.GetTable());
871 while((pair = dynamic_cast<TPair*> (iter.Next()))){
872 AliCDBPath entryPath = pair->Key()->GetName();
873 if(queryPath.Comprises(entryPath)) {
874 AliInfo(Form("Unloading object \"%s\" from cache", entryPath.GetPath().Data()));
875 TObjString pathStr(entryPath.GetPath().Data());
876 AliCDBEntry *entry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(&pathStr));
877 if(entry) delete entry;
878 delete fEntryCache.Remove(&pathStr);
881 AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries()));
884 //_____________________________________________________________________________
885 void AliCDBManager::DestroyActiveStorages() {
886 // delete list of active storages
888 fActiveStorages.DeleteAll();
889 fSpecificStorages.DeleteAll();
892 //_____________________________________________________________________________
893 void AliCDBManager::DestroyActiveStorage(AliCDBStorage* /*storage*/) {
894 // destroys active storage
897 TIter iter(fActiveStorages.GetTable());
899 while ((aPair = (TPair*) iter.Next())) {
900 if(storage == (AliCDBStorage*) aPair->Value())
901 delete fActiveStorages.Remove(aPair->Key());
902 storage->Delete(); storage=0x0;
908 //_____________________________________________________________________________
909 void AliCDBManager::QueryCDB() {
910 // query default and specific storages for files valid for fRun. Every storage loads the Ids into its list.
913 AliError("Run number not yet set! Use AliCDBManager::SetRun.");
916 if (!fDefaultStorage){
917 AliError("Default storage is not set! Use AliCDBManager::SetDefaultStorage");
920 if(fDefaultStorage->GetType() == "alien"){
921 fDefaultStorage->QueryCDB(fRun);
923 AliDebug(2,"Skipping query for valid files, it used only in grid...");
926 TIter iter(&fSpecificStorages);
927 TObjString *aCalibType=0;
929 while((aCalibType = dynamic_cast<TObjString*> (iter.Next()))){
930 aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
932 AliDebug(2,Form("Querying specific storage %s",aCalibType->GetName()));
933 AliCDBStorage *aStorage = GetStorage(aPar);
934 if(aStorage->GetType() == "alien"){
935 aStorage->QueryCDB(fRun,aCalibType->GetName());
938 "Skipping query for valid files, it is used only in grid...");
944 //______________________________________________________________________________________________
945 const char* AliCDBManager::GetDataTypeName(DataType type)
947 // returns the name (string) of the data type
950 case kCondition: return "Conditions";
951 case kReference: return "Reference";
952 case kPrivate: return "Private";
958 //______________________________________________________________________________________________
959 void AliCDBManager::InitShortLived()
961 // Init the list of short-lived objects
962 // currently disabled
966 // fShortLived = new TList();
967 // fShortLived->SetOwner(1);
969 // fShortLived->Add(new TObjString("EMCAL/Calib/Data"));
971 // fShortLived->Add(new TObjString("HMPID/Calib/Nmean"));
972 // fShortLived->Add(new TObjString("HMPID/Calib/Qthre"));
974 // fShortLived->Add(new TObjString("ITS/Calib/CalibSPD"));
976 // fShortLived->Add(new TObjString("MUON/Calib/Gains"));
977 // fShortLived->Add(new TObjString("MUON/Calib/HV"));
978 // fShortLived->Add(new TObjString("MUON/Calib/Pedestals"));
980 // fShortLived->Add(new TObjString("PHOS/Calib/CpvGainPedestals"));
981 // fShortLived->Add(new TObjString("PHOS/Calib/EmcGainPedestals"));
983 // fShortLived->Add(new TObjString("PMD/Calib/Data"));
985 // fShortLived->Add(new TObjString("TRD/Calib/ChamberGainFactor"));
986 // fShortLived->Add(new TObjString("TRD/Calib/LocalGainFactor"));
987 // fShortLived->Add(new TObjString("TRD/Calib/ChamberT0"));
988 // fShortLived->Add(new TObjString("TRD/Calib/LocalT0"));
989 // fShortLived->Add(new TObjString("TRD/Calib/ChamberVdrift"));
990 // fShortLived->Add(new TObjString("TRD/Calib/LocalVdrift"));
992 // fShortLived->Add(new TObjString("ZDC/Calib/Data"));
996 //______________________________________________________________________________________________
997 Bool_t AliCDBManager::IsShortLived(const char* path)
999 // returns the name (string) of the data type
1001 if(!fShortLived) return kFALSE;
1003 AliCDBPath aPath(path);
1004 if(!aPath.IsValid()){
1005 AliError(Form("Not a valid path: %s", path));
1009 return fShortLived->Contains(path);
1013 ///////////////////////////////////////////////////////////
1014 // AliCDBManager Parameter class //
1015 // interface to specific AliCDBParameter class //
1016 // (AliCDBGridParam, AliCDBLocalParam, AliCDBDumpParam) //
1017 ///////////////////////////////////////////////////////////
1019 AliCDBParam::AliCDBParam():
1027 //_____________________________________________________________________________
1028 AliCDBParam::~AliCDBParam() {