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 //-------------------------------------------------------------------------
23 #include "AliCDBManager.h"
24 #include "AliCDBStorage.h"
26 #include "AliCDBDump.h"
27 #include "AliCDBLocal.h"
28 #include "AliCDBGrid.h"
29 #include "AliCDBEntry.h"
30 #include "AliCDBHandler.h"
32 #include <TObjString.h>
33 #include <TSAXParser.h>
43 ClassImp(AliCDBManager)
45 //TODO OCDB and Reference folder should not be fully hardcoded but built from run number (or year/LHC period)
46 TString AliCDBManager::fgkCondUri("alien://folder=/alice/cern.ch/user/a/aliprod/testCDB/CDB?user=aliprod");
47 TString AliCDBManager::fgkRefUri("alien://folder=/alice/cern.ch/user/a/aliprod/testCDB/Reference?user=aliprod");
48 TString AliCDBManager::fgkMCIdealStorage("alien://folder=/alice/simulation/2008/v4-15-Release/Ideal");
49 TString AliCDBManager::fgkMCFullStorage("alien://folder=/alice/simulation/2008/v4-15-Release/Full");
50 TString AliCDBManager::fgkMCResidualStorage("alien://folder=/alice/simulation/2008/v4-15-Release/Residual");
51 TString AliCDBManager::fgkOCDBFolderXMLfile("alien:///alice/data/OCDBFoldervsRunRange.xml");
52 AliCDBManager* AliCDBManager::fgInstance = 0x0;
54 //_____________________________________________________________________________
55 AliCDBManager* AliCDBManager::Instance(TMap *entryCache, Int_t run)
57 // returns AliCDBManager instance (singleton)
60 fgInstance = new AliCDBManager();
64 fgInstance->InitFromCache(entryCache,run);
70 //_____________________________________________________________________________
71 void AliCDBManager::Init() {
72 // factory registering
74 RegisterFactory(new AliCDBDumpFactory());
75 RegisterFactory(new AliCDBLocalFactory());
76 // AliCDBGridFactory is registered only if AliEn libraries are enabled in Root
77 if(!gSystem->Exec("root-config --has-alien 2>/dev/null |grep yes 2>&1 > /dev/null")){ // returns 0 if yes
78 AliInfo("AliEn classes enabled in Root. AliCDBGrid factory registered.");
79 RegisterFactory(new AliCDBGridFactory());
80 fCondParam = CreateParameter(fgkCondUri);
81 fRefParam = CreateParameter(fgkRefUri);
87 //_____________________________________________________________________________
88 void AliCDBManager::InitFromCache(TMap *entryCache, Int_t run) {
89 // initialize manager from existing cache
90 // used on the slaves in case of parallel reconstruction
93 TIter iter(entryCache->GetTable());
96 while((pair = dynamic_cast<TPair*> (iter.Next()))){
97 fEntryCache.Add(pair->Key(),pair->Value());
99 // fEntry is the new owner of the cache
100 fEntryCache.SetOwnerKeyValue(kTRUE,kTRUE);
101 entryCache->SetOwnerKeyValue(kFALSE,kFALSE);
102 AliInfo(Form("%d cache entries have been loaded",fEntryCache.GetEntries()));
105 //_____________________________________________________________________________
106 void AliCDBManager::DumpToSnapshotFile(const char* snapshotFileName, Bool_t singleKeys){
108 // dump the entries map and the ids list to
112 TFile *f = TFile::Open(snapshotFileName,"RECREATE");
113 if (!f || f->IsZombie()){
114 AliError(Form("Cannot open file %s",snapshotFileName));
118 AliInfo(Form("Dumping entriesMap (entries'cache) with %d entries!\n", fEntryCache.GetEntries()));
119 AliInfo(Form("Dumping entriesList with %d entries!\n", fIds->GetEntries()));
124 f->WriteObject(&fEntryCache,"CDBentriesMap");
125 f->WriteObject(fIds,"CDBidsList");
127 // We write the entries one by one named by their calibration path
129 fEntryCache.Write("CDBentriesMap");
130 fIds->Write("CDBidsList");
132 TIter iter(fEntryCache.GetTable());
134 while((pair = dynamic_cast<TPair*> (iter.Next()))){
135 TObjString *os = dynamic_cast<TObjString*>(pair->Key());
137 TString path = os->GetString();
138 AliCDBEntry *entry = dynamic_cast<AliCDBEntry*>(pair->Value());
139 if (!entry) continue;
140 path.ReplaceAll("/","*");
141 entry->Write(path.Data());
150 //_____________________________________________________________________________
151 Bool_t AliCDBManager::InitFromSnapshot(const char* snapshotFileName, Bool_t overwrite){
152 // initialize manager from a CDB snapshot, that is add the entries
153 // to the entries map and the ids to the ids list taking them from
154 // the map and the list found in the input file
156 // if the manager is locked it cannot initialize from a snapshot
158 AliError("Being locked I cannot initialize from the snapshot!");
163 TString snapshotFile(snapshotFileName);
164 if(snapshotFile.BeginsWith("alien://")){
166 TGrid::Connect("alien://","");
168 AliError("Connection to alien failed!");
174 TFile *f = TFile::Open(snapshotFileName);
175 if (!f || f->IsZombie()){
176 AliError(Form("Cannot open file %s",snapshotFileName));
180 // retrieve entries' map from snapshot file
181 TMap *entriesMap = 0;
182 TIter next(f->GetListOfKeys());
184 while ((key = (TKey*)next())) {
185 if (strcmp(key->GetClassName(),"TMap") != 0) continue;
186 entriesMap = (TMap*)key->ReadObj();
189 if (!entriesMap || entriesMap->GetEntries()==0){
190 AliError("Cannot get valid map of CDB entries from snapshot file");
194 // retrieve ids' list from snapshot file
196 TIter nextKey(f->GetListOfKeys());
198 while ((keyN = (TKey*)nextKey())) {
199 if (strcmp(keyN->GetClassName(),"TList") != 0) continue;
200 idsList = (TList*)keyN->ReadObj();
203 if (!idsList || idsList->GetEntries()==0){
204 AliError("Cannot get valid list of CDB entries from snapshot file");
208 // Add each (entry,id) from the snapshot to the memory: entry to the cache, id to the list of ids.
209 // If "overwrite" is false: add the entry to the cache and its id to the list of ids
210 // only if neither of them is already there.
211 // If "overwrite" is true: write the snapshot entry,id in any case. If something
212 // was already there for that calibration type, remove it and issue a warning
213 TIter iterObj(entriesMap->GetTable());
216 while((pair = dynamic_cast<TPair*> (iterObj.Next()))){
217 TObjString* os = (TObjString*) pair->Key();
218 TString path = os->GetString();
219 TIter iterId(idsList);
221 AliCDBId* correspondingId=0;
222 while((id = dynamic_cast<AliCDBId*> (iterId.Next()))){
223 TString idpath(id->GetPath());
229 if(!correspondingId){
230 AliError(Form("id for \"%s\" not found in the snapshot (while entry was). This entry is skipped!",path.Data()));
233 Bool_t cached = fEntryCache.Contains(path.Data());
234 Bool_t registeredId = kFALSE;
237 while((idT = dynamic_cast<AliCDBId*> (iter.Next()))){
238 if(idT->GetPath()==path){
239 registeredId = kTRUE;
245 if(cached || registeredId){
246 AliWarning(Form("An entry was already cached for \"%s\". Removing it before caching from snapshot",path.Data()));
247 UnloadFromCache(path.Data());
249 fEntryCache.Add(pair->Key(),pair->Value());
253 if(cached || registeredId){
254 AliWarning(Form("An entry was already cached for \"%s\". Not adding this object from snapshot",path.Data()));
256 fEntryCache.Add(pair->Key(),pair->Value());
263 // fEntry is the new owner of the cache
264 fEntryCache.SetOwnerKeyValue(kTRUE,kTRUE);
265 entriesMap->SetOwnerKeyValue(kFALSE,kFALSE);
266 fIds->SetOwner(kTRUE);
267 idsList->SetOwner(kFALSE);
268 AliInfo(Form("%d new (entry,id) cached. Total number %d",nAdded,fEntryCache.GetEntries()));
276 //_____________________________________________________________________________
277 void AliCDBManager::Destroy() {
278 // delete ALCDBManager instance and active storages
281 //fgInstance->Delete();
287 //_____________________________________________________________________________
288 AliCDBManager::AliCDBManager():
297 fDefaultStorage(NULL),
304 fSnapshotMode(kFALSE),
307 fStartRunLHCPeriod(-1),
308 fEndRunLHCPeriod(-1),
312 // default constuctor
313 fFactories.SetOwner(1);
314 fActiveStorages.SetOwner(1);
315 fSpecificStorages.SetOwner(1);
316 fEntryCache.SetName("CDBEntryCache");
317 fEntryCache.SetOwnerKeyValue(kTRUE,kTRUE);
319 fStorageMap = new TMap();
320 fStorageMap->SetOwner(1);
325 //_____________________________________________________________________________
326 AliCDBManager::~AliCDBManager() {
329 DestroyActiveStorages();
332 fDefaultStorage = 0x0;
333 delete fStorageMap; fStorageMap = 0;
334 delete fIds; fIds = 0;
337 delete fShortLived; fShortLived = 0x0;
338 //fSnapshotCache = 0;
339 //fSnapshotIdsList = 0;
341 fSnapshotFile->Close();
346 //_____________________________________________________________________________
347 void AliCDBManager::PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage){
348 // put a storage object into the list of active storages
350 fActiveStorages.Add(param, storage);
351 AliDebug(1, Form("Active storages: %d", fActiveStorages.GetEntries()));
354 //_____________________________________________________________________________
355 void AliCDBManager::RegisterFactory(AliCDBStorageFactory* factory) {
356 // add a storage factory to the list of registerd factories
358 if (!fFactories.Contains(factory)) {
359 fFactories.Add(factory);
363 //_____________________________________________________________________________
364 Bool_t AliCDBManager::HasStorage(const char* dbString) const {
365 // check if dbString is a URI valid for one of the registered factories
367 TIter iter(&fFactories);
369 AliCDBStorageFactory* factory=0;
370 while ((factory = (AliCDBStorageFactory*) iter.Next())) {
372 if (factory->Validate(dbString)) {
380 //_____________________________________________________________________________
381 AliCDBParam* AliCDBManager::CreateParameter(const char* dbString) const {
382 // create AliCDBParam object from URI string
384 TIter iter(&fFactories);
386 AliCDBStorageFactory* factory=0;
387 while ((factory = (AliCDBStorageFactory*) iter.Next())) {
388 AliCDBParam* param = factory->CreateParameter(dbString);
389 if(param) return param;
395 //_____________________________________________________________________________
396 AliCDBStorage* AliCDBManager::GetStorage(const char* dbString) {
397 // get storage object from URI string
399 AliCDBParam* param = CreateParameter(dbString);
401 AliError(Form("Failed to activate requested storage! Check URI: %s", dbString));
405 AliCDBStorage* aStorage = GetStorage(param);
411 //_____________________________________________________________________________
412 AliCDBStorage* AliCDBManager::GetStorage(const AliCDBParam* param) {
413 // get storage object from AliCDBParam object
415 // if the list of active storages already contains
416 // the requested storage, return it
417 AliCDBStorage* aStorage = GetActiveStorage(param);
422 // if lock is ON, cannot activate more storages!
424 if (fDefaultStorage) {
425 AliFatal("Lock is ON, and default storage is already set: "
426 "cannot reset it or activate more storages!");
430 TIter iter(&fFactories);
432 AliCDBStorageFactory* factory=0;
434 // loop on the list of registered factories
435 while ((factory = (AliCDBStorageFactory*) iter.Next())) {
437 // each factory tries to create its storage from the parameter
438 aStorage = factory->Create(param);
440 PutActiveStorage(param->CloneParam(), aStorage);
441 aStorage->SetURI(param->GetURI());
443 if(aStorage->GetType() == "alien"){
444 aStorage->QueryCDB(fRun);
447 "Skipping query for valid files, it is used only in grid...");
454 AliError(Form("Failed to activate requested storage! Check URI: %s", param->GetURI().Data()));
459 //_____________________________________________________________________________
460 AliCDBStorage* AliCDBManager::GetActiveStorage(const AliCDBParam* param) {
461 // get a storage object from the list of active storages
463 return dynamic_cast<AliCDBStorage*> (fActiveStorages.GetValue(param));
466 //_____________________________________________________________________________
467 TList* AliCDBManager::GetActiveStorages() {
468 // return list of active storages
469 // user has responsibility to delete returned object
471 TList* result = new TList();
473 TIter iter(fActiveStorages.GetTable());
475 while ((aPair = (TPair*) iter.Next())) {
476 result->Add(aPair->Value());
482 //_____________________________________________________________________________
483 void AliCDBManager::SetDrain(const char* dbString) {
484 // set drain storage from URI string
486 fDrainStorage = GetStorage(dbString);
489 //_____________________________________________________________________________
490 void AliCDBManager::SetDrain(const AliCDBParam* param) {
491 // set drain storage from AliCDBParam
493 fDrainStorage = GetStorage(param);
496 //_____________________________________________________________________________
497 void AliCDBManager::SetDrain(AliCDBStorage* storage) {
498 // set drain storage from another active storage
500 fDrainStorage = storage;
503 //_____________________________________________________________________________
504 Bool_t AliCDBManager::Drain(AliCDBEntry *entry) {
505 // drain retrieved object to drain storage
507 AliDebug(2, "Draining into drain storage...");
508 return fDrainStorage->Put(entry);
511 //____________________________________________________________________________
512 void AliCDBManager::SetDefaultStorage(const char* dbString) {
513 // sets default storage from URI string
515 // checking whether we are in the raw case
516 TString dbStringTemp(dbString);
517 if (dbStringTemp == "raw://")
520 AliInfo("Setting the run-number will set the corresponding OCDB for raw data reconstruction.");
521 AliInfo("Connecting to the grid...");
523 TGrid::Connect("alien://","");
525 AliError("Connection to alien failed!");
532 AliCDBStorage* bckStorage = fDefaultStorage;
534 fDefaultStorage = GetStorage(dbString);
536 if(!fDefaultStorage) return;
538 if(bckStorage && (fDefaultStorage != bckStorage)){
539 AliWarning("Existing default storage replaced: clearing cache!");
543 if (fStorageMap->Contains("default")) {
544 delete fStorageMap->Remove(((TPair*)fStorageMap->FindObject("default"))->Key());
546 fStorageMap->Add(new TObjString("default"), new TObjString(fDefaultStorage->GetURI()));
548 //_____________________________________________________________________________
549 void AliCDBManager::SetDefaultStorage(const AliCDBParam* param) {
550 // set default storage from AliCDBParam object
552 AliCDBStorage* bckStorage = fDefaultStorage;
554 fDefaultStorage = GetStorage(param);
556 if(!fDefaultStorage) return;
558 if(bckStorage && (fDefaultStorage != bckStorage)){
559 AliWarning("Existing default storage replaced: clearing cache!");
563 if (fStorageMap->Contains("default")) {
564 delete fStorageMap->Remove(((TPair*)fStorageMap->FindObject("default"))->Key());
566 fStorageMap->Add(new TObjString("default"), new TObjString(fDefaultStorage->GetURI()));
569 //_____________________________________________________________________________
570 void AliCDBManager::SetDefaultStorage(AliCDBStorage* storage) {
571 // set default storage from another active storage
573 // if lock is ON, cannot activate more storages!
575 if (fDefaultStorage) {
576 AliFatal("Lock is ON, and default storage is already set: "
577 "cannot reset it or activate more storages!");
582 UnsetDefaultStorage();
586 AliCDBStorage* bckStorage = fDefaultStorage;
588 fDefaultStorage = storage;
590 if(bckStorage && (fDefaultStorage != bckStorage)){
591 AliWarning("Existing default storage replaced: clearing cache!");
595 if (fStorageMap->Contains("default")) {
596 delete fStorageMap->Remove(((TPair*)fStorageMap->FindObject("default"))->Key());
598 fStorageMap->Add(new TObjString("default"), new TObjString(fDefaultStorage->GetURI()));
601 //_____________________________________________________________________________
602 void AliCDBManager::SetDefaultStorage(const char* mcString, const char* simType) {
603 // sets default storage for MC data
604 // mcString MUST be "MC",
605 // simType can be "Ideal","Residual","Full"
607 TString strmcString(mcString);
608 TString strsimType(simType);
610 if (strmcString != "MC"){
611 AliFatal("Method requires first string to be MC!");
614 if (strsimType == "Ideal"){
615 dbString = fgkMCIdealStorage;
617 else if (strsimType == "Full"){
618 dbString = fgkMCFullStorage;
620 else if (strsimType == "Residual"){
621 dbString = fgkMCResidualStorage;
624 AliFatal("Error in setting the storage for MC data, second argument MUST be either \"Ideal\" or \"Full\" or \"Residual\".");
627 SetDefaultStorage(dbString.Data());
628 fStartRunLHCPeriod=0;
629 fEndRunLHCPeriod=AliCDBRunRange::Infinity();
630 if(!fDefaultStorage) AliFatal(Form("%s storage not there! Please check!",dbString.Data()));
633 //_____________________________________________________________________________
634 void AliCDBManager::SetDefaultStorageFromRun(Int_t run) {
635 // set default storage from the run number - to be used only with raw data
637 // if lock is ON, cannot activate more storages!
639 if (fDefaultStorage) {
640 AliFatal("Lock is ON, and default storage is already set: "
641 "cannot activate default storage from run number");
645 // retrieve XML file from alien
647 TGrid::Connect("alien://","");
649 AliError("Connection to alien failed!");
654 TString rndname = "/tmp/";
655 rndname += "OCDBFolderXML.";
656 rndname += uuid.AsString();
658 AliDebug(2, Form("file to be copied = %s", fgkOCDBFolderXMLfile.Data()));
659 if (!TFile::Cp(fgkOCDBFolderXMLfile.Data(), rndname.Data())) {
660 AliFatal(Form("Cannot make a local copy of OCDBFolder xml file in %s",rndname.Data()));
662 AliCDBHandler* saxcdb = new AliCDBHandler();
664 TSAXParser *saxParser = new TSAXParser();
665 saxParser->ConnectToHandler("AliCDBHandler", saxcdb);
666 saxParser->ParseFile(rndname.Data());
667 AliInfo(Form(" LHC folder = %s", saxcdb->GetOCDBFolder().Data()));
668 AliInfo(Form(" LHC period start run = %d", saxcdb->GetStartRunRange()));
669 AliInfo(Form(" LHC period end run = %d", saxcdb->GetEndRunRange()));
670 fLHCPeriod = saxcdb->GetOCDBFolder();
671 fStartRunLHCPeriod = saxcdb->GetStartRunRange();
672 fEndRunLHCPeriod = saxcdb->GetEndRunRange();
674 SetDefaultStorage(fLHCPeriod.Data());
675 if(!fDefaultStorage) AliFatal(Form("%s storage not there! Please check!",fLHCPeriod.Data()));
679 //_____________________________________________________________________________
680 void AliCDBManager::UnsetDefaultStorage() {
681 // Unset default storage
683 // if lock is ON, action is forbidden!
685 if (fDefaultStorage) {
686 AliFatal("Lock is ON: cannot unset default storage!");
690 if (fDefaultStorage) {
691 AliWarning("Clearing cache!");
695 fRun = fStartRunLHCPeriod = fEndRunLHCPeriod = -1;
698 fDefaultStorage = 0x0;
701 //_____________________________________________________________________________
702 void AliCDBManager::SetSpecificStorage(const char* calibType, const char* dbString) {
703 // sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
705 AliCDBParam *aPar = CreateParameter(dbString);
707 SetSpecificStorage(calibType, aPar);
711 //_____________________________________________________________________________
712 void AliCDBManager::SetSpecificStorage(const char* calibType, const AliCDBParam* param) {
713 // sets storage specific for detector or calibration type (works with AliCDBManager::Get(...))
714 // Default storage should be defined prior to any specific storages, e.g.:
715 // AliCDBManager::instance()->SetDefaultStorage("alien://");
716 // AliCDBManager::instance()->SetSpecificStorage("TPC/*","local://DB_TPC");
717 // AliCDBManager::instance()->SetSpecificStorage("*/Align/*","local://DB_TPCAlign");
718 // calibType must be a valid CDB path! (3 level folder structure)
721 if(!fDefaultStorage && !fRaw) {
722 AliError("Please activate a default storage first!");
727 AliCDBPath aPath(calibType);
728 if(!aPath.IsValid()){
729 AliError(Form("Not a valid path: %s", calibType));
733 TObjString *objCalibType = new TObjString(aPath.GetPath());
734 if(fSpecificStorages.Contains(objCalibType)){
735 AliWarning(Form("Storage \"%s\" already activated! It will be replaced by the new one",
737 AliCDBParam *checkPar = dynamic_cast<AliCDBParam*> (fSpecificStorages.GetValue(calibType));
738 if(checkPar) delete checkPar;
739 delete fSpecificStorages.Remove(objCalibType);
741 AliCDBStorage *aStorage = GetStorage(param);
742 if(!aStorage) return;
744 fSpecificStorages.Add(objCalibType, param->CloneParam());
746 if(fStorageMap->Contains(objCalibType)){
747 delete fStorageMap->Remove(objCalibType);
749 fStorageMap->Add(objCalibType->Clone(), new TObjString(param->GetURI()));
753 //_____________________________________________________________________________
754 AliCDBStorage* AliCDBManager::GetSpecificStorage(const char* calibType) {
755 // get storage specific for detector or calibration type
757 AliCDBPath calibPath(calibType);
758 if(!calibPath.IsValid()) return NULL;
760 AliCDBParam *checkPar = (AliCDBParam*) fSpecificStorages.GetValue(calibPath.GetPath());
762 AliError(Form("%s storage not found!", calibType));
765 return GetStorage(checkPar);
770 //_____________________________________________________________________________
771 AliCDBParam* AliCDBManager::SelectSpecificStorage(const TString& path) {
772 // select storage valid for path from the list of specific storages
774 AliCDBPath aPath(path);
775 if(!aPath.IsValid()) return NULL;
777 TIter iter(&fSpecificStorages);
778 TObjString *aCalibType=0;
779 AliCDBPath tmpPath("null/null/null");
781 while((aCalibType = (TObjString*) iter.Next())){
782 AliCDBPath calibTypePath(aCalibType->GetName());
783 if(calibTypePath.Comprises(aPath)) {
784 if(calibTypePath.Comprises(tmpPath)) continue;
785 aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
786 tmpPath.SetPath(calibTypePath.GetPath());
792 //_____________________________________________________________________________
793 AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path, Int_t runNumber,
794 Int_t version, Int_t subVersion) {
795 // get an AliCDBEntry object from the database
798 // RunNumber is not specified. Try with fRun
800 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
806 return Get(AliCDBId(path, runNumber, runNumber, version, subVersion));
809 //_____________________________________________________________________________
810 AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path,
811 const AliCDBRunRange& runRange, Int_t version,
813 // get an AliCDBEntry object from the database!
815 return Get(AliCDBId(path, runRange, version, subVersion));
818 //_____________________________________________________________________________
819 AliCDBEntry* AliCDBManager::Get(const AliCDBId& query, Bool_t forceCaching) {
820 // get an AliCDBEntry object from the database
822 // check if query's path and runRange are valid
823 // query is invalid also if version is not specified and subversion is!
824 if (!query.IsValid()) {
825 AliError(Form("Invalid query: %s", query.ToString().Data()));
829 // query is not specified if path contains wildcard or run range= [-1,-1]
830 if (!query.IsSpecified()) {
831 AliError(Form("Unspecified query: %s",
832 query.ToString().Data()));
836 if(fLock && !(fRun >= query.GetFirstRun() && fRun <= query.GetLastRun()))
837 AliFatal("Lock is ON: cannot use different run number than the internal one!");
839 if(fCache && !(fRun >= query.GetFirstRun() && fRun <= query.GetLastRun()))
840 AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!");
842 AliCDBEntry *entry=0;
844 // first look into map of cached objects
845 if(fCache && query.GetFirstRun() == fRun)
846 entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath());
848 AliDebug(2, Form("Object %s retrieved from cache !!",query.GetPath().Data()));
852 // if snapshot flag is set, try getting from the snapshot
853 // but in the case a specific storage is specified for this path
854 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
856 if(fSnapshotMode && query.GetFirstRun() == fRun)
858 entry = GetEntryFromSnapshot(query.GetPath());
860 AliInfo(Form("Object \"%s\" retrieved from the snapshot.",query.GetPath().Data()));
861 if(query.GetFirstRun() == fRun) // no need to check fCache, fSnapshotMode not possible otherwise
862 CacheEntry(query.GetPath(), entry);
864 if(!fIds->Contains(&entry->GetId()))
865 fIds->Add(entry->GetId().Clone());
872 // Entry is not in cache (and, in case we are in snapshot mode, not in the snapshot either)
873 // => retrieve it from the storage and cache it!!
874 if(!fDefaultStorage) {
875 AliError("No storage set!");
879 AliCDBStorage *aStorage=0;
881 aStorage=GetStorage(aPar);
882 TString str = aPar->GetURI();
883 AliDebug(2,Form("Looking into storage: %s",str.Data()));
885 aStorage=GetDefaultStorage();
886 AliDebug(2,"Looking into default storage");
889 entry = aStorage->Get(query);
891 if(entry && fCache && (query.GetFirstRun()==fRun || forceCaching)){
892 CacheEntry(query.GetPath(), entry);
895 if(entry && !fIds->Contains(&entry->GetId())){
896 fIds->Add(entry->GetId().Clone());
904 //_____________________________________________________________________________
905 AliCDBEntry* AliCDBManager::GetEntryFromSnapshot(const char* path) {
906 // get the entry from the open snapshot file
909 sPath.ReplaceAll("/","*");
911 AliError("No snapshot file is open!");
914 AliCDBEntry *entry = dynamic_cast<AliCDBEntry*>(fSnapshotFile->Get(sPath.Data()));
916 AliDebug(2,Form("Cannot get a CDB entry for \"%s\" from snapshot file",path));
923 //_____________________________________________________________________________
924 Bool_t AliCDBManager::SetSnapshotMode(const char* snapshotFileName) {
925 // set the manager in snapshot mode
928 AliError("Cannot set the CDB manage in snapshot mode if the cache is not active!");
933 TString snapshotFile(snapshotFileName);
934 if(snapshotFile.BeginsWith("alien://")){
936 TGrid::Connect("alien://","");
938 AliError("Connection to alien failed!");
944 fSnapshotFile = TFile::Open(snapshotFileName);
945 if (!fSnapshotFile || fSnapshotFile->IsZombie()){
946 AliError(Form("Cannot open file %s",snapshotFileName));
950 AliInfo("The CDB manager is set in snapshot mode!");
951 fSnapshotMode = kTRUE;
956 //_____________________________________________________________________________
957 const char* AliCDBManager::GetURI(const char* path) {
958 // return the URI of the storage where to look for path
960 if(!IsDefaultStorageSet()) return 0;
962 AliCDBParam *aPar=SelectSpecificStorage(path);
965 return aPar->GetURI().Data();
968 return GetDefaultStorage()->GetURI().Data();
974 //_____________________________________________________________________________
975 Int_t AliCDBManager::GetStartRunLHCPeriod(){
976 // get the first run of validity
977 // for the current period
979 if(fStartRunLHCPeriod==-1)
980 AliWarning("Run-range not yet set for the current LHC period.");
981 return fStartRunLHCPeriod;
984 //_____________________________________________________________________________
985 Int_t AliCDBManager::GetEndRunLHCPeriod(){
986 // get the last run of validity
987 // for the current period
989 if(fEndRunLHCPeriod==-1)
990 AliWarning("Run-range not yet set for the current LHC period.");
991 return fEndRunLHCPeriod;
994 //_____________________________________________________________________________
995 TString AliCDBManager::GetLHCPeriod(){
996 // get the current LHC period string
998 if(fLHCPeriod.IsWhitespace() || fLHCPeriod.IsNull())
999 AliWarning("LHC period (OCDB folder) not yet set");
1003 //_____________________________________________________________________________
1004 AliCDBId* AliCDBManager::GetId(const AliCDBPath& path, Int_t runNumber,
1005 Int_t version, Int_t subVersion) {
1006 // get the AliCDBId of the valid object from the database (does not retrieve the object)
1007 // User must delete returned object!
1010 // RunNumber is not specified. Try with fRun
1012 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
1018 return GetId(AliCDBId(path, runNumber, runNumber, version, subVersion));
1021 //_____________________________________________________________________________
1022 AliCDBId* AliCDBManager::GetId(const AliCDBPath& path,
1023 const AliCDBRunRange& runRange, Int_t version,
1025 // get the AliCDBId of the valid object from the database (does not retrieve the object)
1026 // User must delete returned object!
1028 return GetId(AliCDBId(path, runRange, version, subVersion));
1031 //_____________________________________________________________________________
1032 AliCDBId* AliCDBManager::GetId(const AliCDBId& query) {
1033 // get the AliCDBId of the valid object from the database (does not retrieve the object)
1034 // User must delete returned object!
1036 if(!fDefaultStorage) {
1037 AliError("No storage set!");
1041 // check if query's path and runRange are valid
1042 // query is invalid also if version is not specified and subversion is!
1043 if (!query.IsValid()) {
1044 AliError(Form("Invalid query: %s", query.ToString().Data()));
1048 // query is not specified if path contains wildcard or run range= [-1,-1]
1049 if (!query.IsSpecified()) {
1050 AliError(Form("Unspecified query: %s",
1051 query.ToString().Data()));
1055 if(fCache && query.GetFirstRun() != fRun)
1056 AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!");
1058 AliCDBEntry* entry = 0;
1060 // first look into map of cached objects
1061 if(fCache && query.GetFirstRun() == fRun)
1062 entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath());
1065 AliDebug(2, Form("Object %s retrieved from cache !!",query.GetPath().Data()));
1066 return dynamic_cast<AliCDBId*> (entry->GetId().Clone());
1069 // Entry is not in cache -> retrieve it from CDB and cache it!!
1070 AliCDBStorage *aStorage=0;
1071 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
1074 aStorage=GetStorage(aPar);
1075 TString str = aPar->GetURI();
1076 AliDebug(2,Form("Looking into storage: %s",str.Data()));
1079 aStorage=GetDefaultStorage();
1080 AliDebug(2,"Looking into default storage");
1083 return aStorage->GetId(query);
1087 //_____________________________________________________________________________
1088 TList* AliCDBManager::GetAll(const AliCDBPath& path, Int_t runNumber,
1089 Int_t version, Int_t subVersion) {
1090 // get multiple AliCDBEntry objects from the database
1093 // RunNumber is not specified. Try with fRun
1095 AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun.");
1101 return GetAll(AliCDBId(path, runNumber, runNumber, version,
1105 //_____________________________________________________________________________
1106 TList* AliCDBManager::GetAll(const AliCDBPath& path,
1107 const AliCDBRunRange& runRange, Int_t version, Int_t subVersion) {
1108 // get multiple AliCDBEntry objects from the database
1110 return GetAll(AliCDBId(path, runRange, version, subVersion));
1113 //_____________________________________________________________________________
1114 TList* AliCDBManager::GetAll(const AliCDBId& query) {
1115 // get multiple AliCDBEntry objects from the database
1116 // Warning: this method works correctly only for queries of the type "Detector/*"
1117 // and not for more specific queries e.g. "Detector/Calib/*" !
1118 // Warning #2: Entries are cached, but GetAll will keep on retrieving objects from OCDB!
1119 // To get an object from cache use Get() function
1121 if(!fDefaultStorage) {
1122 AliError("No storage set!");
1126 if (!query.IsValid()) {
1127 AliError(Form("Invalid query: %s", query.ToString().Data()));
1131 if((fSpecificStorages.GetEntries()>0) && query.GetPath().BeginsWith('*')){
1132 // if specific storages are active a query with "*" is ambiguous
1133 AliError("Query too generic in this context!");
1137 if (query.IsAnyRange()) {
1138 AliError(Form("Unspecified run or runrange: %s",
1139 query.ToString().Data()));
1143 if(fLock && query.GetFirstRun() != fRun)
1144 AliFatal("Lock is ON: cannot use different run number than the internal one!");
1146 AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
1148 AliCDBStorage *aStorage;
1150 aStorage=GetStorage(aPar);
1151 AliDebug(2,Form("Looking into storage: %s", aPar->GetURI().Data()));
1154 aStorage=GetDefaultStorage();
1155 AliDebug(2,"Looking into default storage");
1159 if(aStorage) result = aStorage->GetAll(query);
1160 if(!result) return 0;
1162 // loop on result to check whether entries should be re-queried with specific storages
1163 if(fSpecificStorages.GetEntries()>0 && ! (fSpecificStorages.GetEntries() == 1 && aPar)) {
1164 AliInfo("Now look into all other specific storages...");
1167 AliCDBEntry* chkEntry=0;
1169 while((chkEntry = dynamic_cast<AliCDBEntry*> (iter.Next()))){
1170 AliCDBId& chkId = chkEntry->GetId();
1171 AliDebug(2, Form("Checking id %s ", chkId.GetPath().Data()));
1172 AliCDBParam *chkPar=SelectSpecificStorage(chkId.GetPath());
1173 if (!chkPar || aPar == chkPar) continue;
1174 AliCDBStorage *chkStorage = GetStorage(chkPar);
1175 AliDebug(2, Form("Found specific storage! %s", chkPar->GetURI().Data()));
1177 AliCDBEntry *newEntry=0;
1178 chkId.SetRunRange(query.GetFirstRun(), query.GetLastRun());
1179 chkId.SetVersion(query.GetVersion());
1180 chkId.SetSubVersion(query.GetSubVersion());
1182 if(chkStorage) newEntry = chkStorage->Get(chkId);
1183 if(!newEntry) continue;
1185 // object is found in specific storage: replace entry in the result list!
1186 chkEntry->SetOwner(1);
1187 delete result->Remove(chkEntry);
1188 result->AddFirst(newEntry);
1191 Int_t nEntries = result->GetEntries();
1192 AliInfo("After look into other specific storages, result list is:");
1193 for(int i=0; i<nEntries;i++){
1194 AliCDBEntry *entry = (AliCDBEntry*) result->At(i);
1195 AliInfo(Form("%s",entry->GetId().ToString().Data()));
1201 AliCDBEntry* entry=0;
1202 while((entry = dynamic_cast<AliCDBEntry*> (iter.Next()))){
1204 if(!fIds->Contains(&entry->GetId())){
1205 fIds->Add(entry->GetId().Clone());
1207 if(fCache && (query.GetFirstRun() == fRun)){
1208 CacheEntry(entry->GetId().GetPath(), entry);
1216 //_____________________________________________________________________________
1217 Bool_t AliCDBManager::Put(TObject* object, const AliCDBId& id, AliCDBMetaData* metaData, const char* mirrors, DataType type){
1218 // store an AliCDBEntry object into the database
1221 AliError("Null Entry! No storage will be done!");
1225 AliCDBEntry anEntry(object, id, metaData);
1226 return Put(&anEntry, mirrors, type);
1231 //_____________________________________________________________________________
1232 Bool_t AliCDBManager::Put(AliCDBEntry* entry, const char* mirrors, DataType type){
1233 // store an AliCDBEntry object into the database
1235 if(type == kPrivate && !fDefaultStorage) {
1236 AliError("No storage set!");
1241 AliError("No entry!");
1245 if (entry->GetObject()==0x0){
1246 AliError("No valid object in CDB entry!");
1250 if (!entry->GetId().IsValid()) {
1251 AliError(Form("Invalid entry ID: %s",
1252 entry->GetId().ToString().Data()));
1256 if (!entry->GetId().IsSpecified()) {
1257 AliError(Form("Unspecified entry ID: %s",
1258 entry->GetId().ToString().Data()));
1262 AliCDBId id = entry->GetId();
1263 AliCDBParam *aPar = SelectSpecificStorage(id.GetPath());
1265 AliCDBStorage *aStorage=0;
1268 aStorage=GetStorage(aPar);
1272 aStorage = GetStorage(fCondParam);
1275 aStorage = GetStorage(fRefParam);
1278 aStorage = GetDefaultStorage();
1283 AliDebug(2,Form("Storing object into storage: %s", aStorage->GetURI().Data()));
1285 TString strMirrors(mirrors);
1286 Bool_t result = kFALSE;
1287 if(!strMirrors.IsNull() && !strMirrors.IsWhitespace())
1288 result = aStorage->Put(entry, mirrors, type);
1290 result = aStorage->Put(entry, "", type);
1292 if(fRun >= 0) QueryCDB();
1299 //_____________________________________________________________________________
1300 void AliCDBManager::SetMirrorSEs(const char* mirrors)
1302 // set mirror Storage Elements for the default storage, if it is of type "alien"
1303 if(fDefaultStorage->GetType() != "alien"){
1304 AliInfo("The default storage is not of type \"alien\". Settings for Storage Elements are not taken into account!");
1307 fDefaultStorage->SetMirrorSEs(mirrors);
1310 //_____________________________________________________________________________
1311 const char* AliCDBManager::GetMirrorSEs() const {
1312 // get mirror Storage Elements for the default storage, if it is of type "alien"
1313 if(fDefaultStorage->GetType() != "alien"){
1314 AliInfo("The default storage is not of type \"alien\". Settings for Storage Elements are not taken into account!");
1317 return fDefaultStorage->GetMirrorSEs();
1320 //_____________________________________________________________________________
1321 void AliCDBManager::CacheEntry(const char* path, AliCDBEntry* entry)
1323 // cache AliCDBEntry. Cache is valid until run number is changed.
1325 AliCDBEntry *chkEntry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(path));
1328 AliDebug(2, Form("Object %s already in cache !!", path));
1331 AliDebug(2,Form("Caching entry %s", path));
1334 fEntryCache.Add(new TObjString(path), entry);
1335 AliDebug(2,Form("Cache entries: %d", fEntryCache.GetEntries()));
1339 //_____________________________________________________________________________
1340 void AliCDBManager::Print(Option_t* /*option*/) const
1342 // Print list of active storages and their URIs
1344 TString output=Form("Run number = %d; ",fRun);
1345 output += "Cache is ";
1346 if(!fCache) output += "NOT ";
1347 output += Form("ACTIVE; Number of active storages: %d\n",fActiveStorages.GetEntries());
1349 if(fDefaultStorage) {
1350 output += Form("\t*** Default Storage URI: \"%s\"\n",fDefaultStorage->GetURI().Data());
1351 // AliInfo(output.Data());
1353 if(fSpecificStorages.GetEntries()>0) {
1354 TIter iter(fSpecificStorages.GetTable());
1357 while((aPair = (TPair*) iter.Next())){
1358 output += Form("\t*** Specific storage %d: Path \"%s\" -> URI \"%s\"\n",
1359 i++, ((TObjString*) aPair->Key())->GetName(),
1360 ((AliCDBParam*) aPair->Value())->GetURI().Data());
1364 output += Form("*** Drain Storage URI: %s\n",fDrainStorage->GetURI().Data());
1366 AliInfo(output.Data());
1369 //_____________________________________________________________________________
1370 void AliCDBManager::SetRun(Int_t run)
1372 // Sets current run number.
1373 // When the run number changes the caching is cleared.
1378 if(fLock && fRun >= 0) {
1379 AliFatal("Lock is ON, cannot reset run number!");
1384 // here the LHCPeriod xml file is parsed; the string containing the correct period is returned; the default storage is set
1385 if (fStartRunLHCPeriod <= run && fEndRunLHCPeriod >= run){
1386 AliInfo("LHCPeriod alien folder for current run already in memory");
1388 SetDefaultStorageFromRun(run);
1389 if(fEntryCache.GetEntries()!=0) ClearCache();
1397 //_____________________________________________________________________________
1398 void AliCDBManager::ClearCache(){
1399 // clear AliCDBEntry cache
1401 AliDebug(2, Form("Cache entries to be deleted: %d",fEntryCache.GetEntries()));
1404 // To clean entries one by one
1405 TIter iter(fEntryCache.GetTable());
1407 while((pair= dynamic_cast<TPair*> (iter.Next()))){
1409 TObjString* key = dynamic_cast<TObjString*> (pair->Key());
1410 AliCDBEntry* entry = dynamic_cast<AliCDBEntry*> (pair->Value());
1411 AliDebug(2, Form("Deleting entry: %s", key->GetName()));
1412 if (entry) delete entry;
1413 delete fEntryCache.Remove(key);
1416 fEntryCache.DeleteAll();
1417 AliDebug(2, Form("After deleting - Cache entries: %d",fEntryCache.GetEntries()));
1420 //_____________________________________________________________________________
1421 void AliCDBManager::UnloadFromCache(const char* path){
1422 // unload cached object
1423 // that is remove the entry from the cache and the id from the list of ids
1425 if(!fActiveStorages.GetEntries()) {
1426 AliDebug(2, Form("No active storages. Object \"%s\" is not unloaded from cache", path));
1430 AliCDBPath queryPath(path);
1431 if(!queryPath.IsValid()) return;
1433 if(!queryPath.IsWildcard()) { // path is not wildcard, get it directly from the cache and unload it!
1434 if(fEntryCache.Contains(path)){
1435 AliDebug(2, Form("Unloading object \"%s\" from cache and from list of ids", path));
1436 TObjString pathStr(path);
1437 delete fEntryCache.Remove(&pathStr);
1438 // we do not remove from the list of Id's (it's not very coherent but we leave the
1439 // id for the benefit of the userinfo)
1443 while((id = dynamic_cast<AliCDBId*> (iter.Next()))){
1444 if(queryPath.Comprises(id->GetPath()))
1445 delete fIds->Remove(id);
1448 AliWarning(Form("Cache does not contain object \"%s\"!", path));
1450 AliDebug(2, Form("Cache entries: %d",fEntryCache.GetEntries()));
1454 // path is wildcard: loop on the cache and unload all comprised objects!
1455 TIter iter(fEntryCache.GetTable());
1459 while((pair = dynamic_cast<TPair*> (iter.Next()))){
1460 AliCDBPath entryPath = pair->Key()->GetName();
1461 if(queryPath.Comprises(entryPath)) {
1462 AliDebug(2, Form("Unloading object \"%s\" from cache and from list of ids", entryPath.GetPath().Data()));
1463 TObjString pathStr(entryPath.GetPath());
1464 delete fEntryCache.Remove(&pathStr);
1467 // we do not remove from the list of Id's (it's not very coherent but we leave the
1468 // id for the benefit of the userinfo)
1470 TIter iterids(fIds);
1472 while((anId = dynamic_cast<AliCDBId*> (iterids.Next()))){
1473 AliCDBPath aPath = anId->GetPath();
1474 TString aPathStr = aPath.GetPath();
1475 if(queryPath.Comprises(aPath)) {
1476 delete fIds->Remove(anId);
1481 AliDebug(2,Form("Cache entries and ids removed: %d Remaining: %d",removed,fEntryCache.GetEntries()));
1484 //_____________________________________________________________________________
1485 void AliCDBManager::DestroyActiveStorages() {
1486 // delete list of active storages
1488 fActiveStorages.DeleteAll();
1489 fSpecificStorages.DeleteAll();
1492 //_____________________________________________________________________________
1493 void AliCDBManager::DestroyActiveStorage(AliCDBStorage* /*storage*/) {
1494 // destroys active storage
1497 TIter iter(fActiveStorages.GetTable());
1499 while ((aPair = (TPair*) iter.Next())) {
1500 if(storage == (AliCDBStorage*) aPair->Value())
1501 delete fActiveStorages.Remove(aPair->Key());
1502 storage->Delete(); storage=0x0;
1508 //_____________________________________________________________________________
1509 void AliCDBManager::QueryCDB() {
1510 // query default and specific storages for files valid for fRun. Every storage loads the Ids into its list.
1513 AliError("Run number not yet set! Use AliCDBManager::SetRun.");
1516 if (!fDefaultStorage){
1517 AliError("Default storage is not set! Use AliCDBManager::SetDefaultStorage");
1520 if(fDefaultStorage->GetType() == "alien"){
1521 fDefaultStorage->QueryCDB(fRun);
1523 AliDebug(2,"Skipping query for valid files, it used only in grid...");
1526 TIter iter(&fSpecificStorages);
1527 TObjString *aCalibType=0;
1528 AliCDBParam* aPar=0;
1529 while((aCalibType = dynamic_cast<TObjString*> (iter.Next()))){
1530 aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
1532 AliDebug(2,Form("Querying specific storage %s",aCalibType->GetName()));
1533 AliCDBStorage *aStorage = GetStorage(aPar);
1534 if(aStorage->GetType() == "alien"){
1535 aStorage->QueryCDB(fRun,aCalibType->GetName());
1538 "Skipping query for valid files, it is used only in grid...");
1544 //______________________________________________________________________________________________
1545 const char* AliCDBManager::GetDataTypeName(DataType type)
1547 // returns the name (string) of the data type
1550 case kCondition: return "Conditions";
1551 case kReference: return "Reference";
1552 case kPrivate: return "Private";
1558 //______________________________________________________________________________________________
1559 Bool_t AliCDBManager::DiffObjects(const char *cdbFile1, const char *cdbFile2) const
1561 // Compare byte-by-byte the objects contained in the CDB entry in two different files,
1562 // whose name is passed as input
1564 // kTRUE - in case the content of the OCDB object (persistent part) is exactly the same
1565 // kFALSE - otherwise
1567 TString f1Str(cdbFile1);
1568 TString f2Str(cdbFile2);
1569 if (!gGrid && ( f1Str.BeginsWith("alien://") || f2Str.BeginsWith("alien://") ))
1570 TGrid::Connect("alien://");
1572 TFile * f1 = TFile::Open(cdbFile1);
1574 Printf("Cannot open file \"%s\"",cdbFile1);
1577 TFile * f2 = TFile::Open(cdbFile2);
1579 Printf("Cannot open file \"%s\"",cdbFile2);
1583 AliCDBEntry * entry1 = (AliCDBEntry*)f1->Get("AliCDBEntry");
1585 Printf("Cannot get CDB entry from file \"%s\"",cdbFile1);
1588 AliCDBEntry * entry2 = (AliCDBEntry*)f2->Get("AliCDBEntry");
1590 Printf("Cannot get CDB entry from file \"%s\"",cdbFile2);
1594 // stream the two objects in the buffer of two TMessages
1595 TObject* object1 = entry1->GetObject();
1596 TObject* object2 = entry2->GetObject();
1597 TMessage * file1 = new TMessage(TBuffer::kWrite);
1598 file1->WriteObject(object1);
1599 Int_t size1 = file1->Length();
1600 TMessage * file2 = new TMessage(TBuffer::kWrite);
1601 file2->WriteObject(object2);
1602 Int_t size2 = file2->Length();
1604 Printf("Problem 2: OCDB entry of different size (%d,%d)",size1,size2);
1608 // if the two buffers have the same size, check that they are the same byte-by-byte
1610 char* buf1 = file1->Buffer();
1611 char* buf2 = file2->Buffer();
1612 //for (Int_t i=0; i<size1; i++) if (file1->Buffer()[i]!=file2->Buffer()[i]) countDiff++;
1613 for(Int_t i=0; i<size1; i++)
1614 if (buf1[i]!=buf2[i]) countDiff++;
1617 Printf("The CDB objects differ by %d bytes.", countDiff);
1621 Printf("The CDB objects are the same in the two files.");
1625 //______________________________________________________________________________________________
1626 void AliCDBManager::InitShortLived()
1628 // Init the list of short-lived objects
1629 // currently disabled
1633 // fShortLived = new TList();
1634 // fShortLived->SetOwner(1);
1636 // fShortLived->Add(new TObjString("EMCAL/Calib/Data"));
1638 // fShortLived->Add(new TObjString("HMPID/Calib/Nmean"));
1639 // fShortLived->Add(new TObjString("HMPID/Calib/Qthre"));
1641 // fShortLived->Add(new TObjString("ITS/Calib/CalibSPD"));
1643 // fShortLived->Add(new TObjString("MUON/Calib/Gains"));
1644 // fShortLived->Add(new TObjString("MUON/Calib/HV"));
1645 // fShortLived->Add(new TObjString("MUON/Calib/Pedestals"));
1647 // fShortLived->Add(new TObjString("PHOS/Calib/CpvGainPedestals"));
1648 // fShortLived->Add(new TObjString("PHOS/Calib/EmcGainPedestals"));
1650 // fShortLived->Add(new TObjString("PMD/Calib/Data"));
1652 // fShortLived->Add(new TObjString("TRD/Calib/ChamberGainFactor"));
1653 // fShortLived->Add(new TObjString("TRD/Calib/LocalGainFactor"));
1654 // fShortLived->Add(new TObjString("TRD/Calib/ChamberT0"));
1655 // fShortLived->Add(new TObjString("TRD/Calib/LocalT0"));
1656 // fShortLived->Add(new TObjString("TRD/Calib/ChamberVdrift"));
1657 // fShortLived->Add(new TObjString("TRD/Calib/LocalVdrift"));
1659 // fShortLived->Add(new TObjString("ZDC/Calib/Data"));
1663 //______________________________________________________________________________________________
1664 Bool_t AliCDBManager::IsShortLived(const char* path)
1666 // returns the name (string) of the data type
1668 if(!fShortLived) return kFALSE;
1670 AliCDBPath aPath(path);
1671 if(!aPath.IsValid()){
1672 AliError(Form("Not a valid path: %s", path));
1676 return fShortLived->Contains(path);
1680 //______________________________________________________________________________________________
1681 ULong64_t AliCDBManager::SetLock(Bool_t lock, ULong64_t key){
1682 // To lock/unlock user must provide the key. A new key is provided after
1683 // each successful lock. User should always backup the returned key and
1684 // use it on next access.
1685 if (fLock == lock) return 0; // nothing to be done
1687 // User wants to lock - check his identity
1689 // Lock has a user - check his key
1691 AliFatal("Wrong key provided to lock CDB. Please remove CDB lock access from your code !");
1696 fKey = gSystem->Now();
1700 // User wants to unlock - check the provided key
1702 AliFatal("Lock is ON: wrong key provided");
1709 ///////////////////////////////////////////////////////////
1710 // AliCDBManager Parameter class //
1711 // interface to specific AliCDBParameter class //
1712 // (AliCDBGridParam, AliCDBLocalParam, AliCDBDumpParam) //
1713 ///////////////////////////////////////////////////////////
1715 AliCDBParam::AliCDBParam():
1723 //_____________________________________________________________________________
1724 AliCDBParam::~AliCDBParam() {