]>
Commit | Line | Data |
---|---|---|
9e1ceb13 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
fdf65bb5 | 15 | //------------------------------------------------------------------------- |
16 | // Implementation of AliCDBManager and AliCDBParam classe | |
17 | // Author: Alberto Colla | |
18 | // e-mail: Alberto.Colla@cern.ch | |
19 | //------------------------------------------------------------------------- | |
9e1ceb13 | 20 | |
21 | #include "AliCDBManager.h" | |
22 | #include "AliCDBStorage.h" | |
23 | #include "AliLog.h" | |
24 | #include "AliCDBDump.h" | |
25 | #include "AliCDBLocal.h" | |
26 | #include "AliCDBGrid.h" | |
02c4845e | 27 | #include "AliCDBEntry.h" |
28 | #include "AliCDBMetaData.h" | |
9e1ceb13 | 29 | |
02c4845e | 30 | #include <TObjString.h> |
9e1ceb13 | 31 | #include <TSystem.h> |
32 | ||
33 | ClassImp(AliCDBParam) | |
34 | ||
35 | ClassImp(AliCDBManager) | |
36 | ||
b8ec52f6 | 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"); | |
9e1ceb13 | 40 | AliCDBManager* AliCDBManager::fgInstance = 0x0; |
41 | ||
42 | //_____________________________________________________________________________ | |
b8ec52f6 | 43 | AliCDBManager* AliCDBManager::Instance() |
44 | { | |
9e1ceb13 | 45 | // returns AliCDBManager instance (singleton) |
46 | ||
47 | if (!fgInstance) { | |
48 | fgInstance = new AliCDBManager(); | |
49 | fgInstance->Init(); | |
50 | } | |
51 | ||
52 | return fgInstance; | |
53 | } | |
54 | ||
55 | //_____________________________________________________________________________ | |
56 | void AliCDBManager::Init() { | |
57 | // factory registering | |
58 | ||
59 | RegisterFactory(new AliCDBDumpFactory()); | |
60 | RegisterFactory(new AliCDBLocalFactory()); | |
61 | // AliCDBGridFactory is registered only if AliEn libraries are enabled in Root | |
62 | if(!gSystem->Exec("root-config --has-alien |grep yes 2>&1 > /dev/null")){ // returns 0 if yes | |
63 | AliInfo("AliEn classes enabled in Root. AliCDBGrid factory registered."); | |
64 | RegisterFactory(new AliCDBGridFactory()); | |
b8ec52f6 | 65 | fCondParam = CreateParameter(fgkCondUri); |
66 | fRefParam = CreateParameter(fgkRefUri); | |
9e1ceb13 | 67 | } |
4667c116 | 68 | |
69 | InitShortLived(); | |
9e1ceb13 | 70 | } |
71 | //_____________________________________________________________________________ | |
72 | void AliCDBManager::Destroy() { | |
73 | // delete ALCDBManager instance and active storages | |
74 | ||
75 | if (fgInstance) { | |
4b5e0dce | 76 | //fgInstance->Delete(); |
9e1ceb13 | 77 | delete fgInstance; |
78 | fgInstance = 0x0; | |
79 | } | |
80 | } | |
81 | ||
82 | //_____________________________________________________________________________ | |
83 | AliCDBManager::AliCDBManager(): | |
fe12e09c | 84 | TObject(), |
85 | fFactories(), | |
86 | fActiveStorages(), | |
87 | fSpecificStorages(), | |
b21e3194 | 88 | fEntryCache(), |
89 | fIds(0), | |
90 | fStorageMap(0), | |
91 | fShortLived(0), | |
fe12e09c | 92 | fDefaultStorage(NULL), |
93 | fDrainStorage(NULL), | |
b21e3194 | 94 | fCondParam(0), |
95 | fRefParam(0), | |
4667c116 | 96 | fRun(-1), |
1f341624 | 97 | fCache(kTRUE), |
98 | fLock(kFALSE) | |
9e1ceb13 | 99 | { |
100 | // default constuctor | |
4b5e0dce | 101 | fFactories.SetOwner(1); |
62032124 | 102 | fActiveStorages.SetOwner(1); |
103 | fSpecificStorages.SetOwner(1); | |
104 | fEntryCache.SetOwner(1); | |
b21e3194 | 105 | |
106 | fStorageMap = new TMap(); | |
107 | fStorageMap->SetOwner(1); | |
108 | fIds = new TList(); | |
109 | fIds->SetOwner(1); | |
9e1ceb13 | 110 | } |
111 | ||
112 | //_____________________________________________________________________________ | |
113 | AliCDBManager::~AliCDBManager() { | |
114 | // destructor | |
4b5e0dce | 115 | ClearCache(); |
9e1ceb13 | 116 | DestroyActiveStorages(); |
62032124 | 117 | fFactories.Delete(); |
b05400be | 118 | fDrainStorage = 0x0; |
119 | fDefaultStorage = 0x0; | |
b21e3194 | 120 | delete fStorageMap; fStorageMap = 0; |
121 | delete fIds; fIds = 0; | |
b8ec52f6 | 122 | delete fCondParam; |
123 | delete fRefParam; | |
4667c116 | 124 | delete fShortLived; fShortLived = 0x0; |
9e1ceb13 | 125 | } |
126 | ||
9e1ceb13 | 127 | //_____________________________________________________________________________ |
128 | void AliCDBManager::PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage){ | |
129 | // put a storage object into the list of active storages | |
130 | ||
131 | fActiveStorages.Add(param, storage); | |
132 | AliDebug(1, Form("Active storages: %d", fActiveStorages.GetEntries())); | |
133 | } | |
134 | ||
135 | //_____________________________________________________________________________ | |
136 | void AliCDBManager::RegisterFactory(AliCDBStorageFactory* factory) { | |
137 | // add a storage factory to the list of registerd factories | |
138 | ||
139 | if (!fFactories.Contains(factory)) { | |
140 | fFactories.Add(factory); | |
141 | } | |
142 | } | |
143 | ||
144 | //_____________________________________________________________________________ | |
fdf65bb5 | 145 | Bool_t AliCDBManager::HasStorage(const char* dbString) const { |
b21e3194 | 146 | // check if dbString is a URI valid for one of the registered factories |
9e1ceb13 | 147 | |
148 | TIter iter(&fFactories); | |
149 | ||
62032124 | 150 | AliCDBStorageFactory* factory=0; |
9e1ceb13 | 151 | while ((factory = (AliCDBStorageFactory*) iter.Next())) { |
152 | ||
153 | if (factory->Validate(dbString)) { | |
154 | return kTRUE; | |
4005d0b5 | 155 | } |
9e1ceb13 | 156 | } |
157 | ||
158 | return kFALSE; | |
159 | } | |
160 | ||
161 | //_____________________________________________________________________________ | |
fdf65bb5 | 162 | AliCDBParam* AliCDBManager::CreateParameter(const char* dbString) const { |
9e1ceb13 | 163 | // create AliCDBParam object from URI string |
164 | ||
165 | TIter iter(&fFactories); | |
166 | ||
62032124 | 167 | AliCDBStorageFactory* factory=0; |
9e1ceb13 | 168 | while ((factory = (AliCDBStorageFactory*) iter.Next())) { |
9e1ceb13 | 169 | AliCDBParam* param = factory->CreateParameter(dbString); |
62032124 | 170 | if(param) return param; |
9e1ceb13 | 171 | } |
172 | ||
173 | return NULL; | |
174 | } | |
175 | ||
176 | //_____________________________________________________________________________ | |
177 | AliCDBStorage* AliCDBManager::GetStorage(const char* dbString) { | |
178 | // get storage object from URI string | |
1f341624 | 179 | |
9e1ceb13 | 180 | AliCDBParam* param = CreateParameter(dbString); |
181 | if (!param) { | |
c3a7b59a | 182 | AliError(Form("Failed to activate requested storage! Check URI: %s", dbString)); |
9e1ceb13 | 183 | return NULL; |
82096dfc | 184 | } |
9e1ceb13 | 185 | |
186 | AliCDBStorage* aStorage = GetStorage(param); | |
187 | ||
188 | delete param; | |
9e1ceb13 | 189 | return aStorage; |
190 | } | |
191 | ||
192 | //_____________________________________________________________________________ | |
193 | AliCDBStorage* AliCDBManager::GetStorage(const AliCDBParam* param) { | |
194 | // get storage object from AliCDBParam object | |
1f341624 | 195 | |
82096dfc | 196 | // if the list of active storages already contains |
9e1ceb13 | 197 | // the requested storage, return it |
198 | AliCDBStorage* aStorage = GetActiveStorage(param); | |
199 | if (aStorage) { | |
200 | return aStorage; | |
201 | } | |
202 | ||
1f341624 | 203 | // if lock is ON, cannot activate more storages! |
204 | if(fLock) { | |
205 | if (fDefaultStorage) { | |
206 | AliFatal("Lock is ON, and default storage is already set: " | |
207 | "cannot reset it or activate more storages!"); | |
208 | } | |
209 | } | |
210 | ||
9e1ceb13 | 211 | TIter iter(&fFactories); |
212 | ||
62032124 | 213 | AliCDBStorageFactory* factory=0; |
917a098b | 214 | |
9e1ceb13 | 215 | // loop on the list of registered factories |
216 | while ((factory = (AliCDBStorageFactory*) iter.Next())) { | |
217 | ||
218 | // each factory tries to create its storage from the parameter | |
219 | aStorage = factory->Create(param); | |
220 | if (aStorage) { | |
221 | PutActiveStorage(param->CloneParam(), aStorage); | |
917a098b | 222 | aStorage->SetURI(param->GetURI()); |
6dc56e97 | 223 | if(fRun >= 0) { |
96b7636d | 224 | if(aStorage->GetType() == "alien"){ |
225 | aStorage->QueryCDB(fRun); | |
226 | } else { | |
227 | AliDebug(2, | |
228 | "Skipping query for valid files, it is used only in grid..."); | |
229 | } | |
c3a7b59a | 230 | } |
9e1ceb13 | 231 | return aStorage; |
232 | } | |
233 | } | |
234 | ||
c3a7b59a | 235 | AliError(Form("Failed to activate requested storage! Check URI: %s", param->GetURI().Data())); |
236 | ||
9e1ceb13 | 237 | return NULL; |
238 | } | |
239 | ||
62032124 | 240 | //_____________________________________________________________________________ |
241 | AliCDBStorage* AliCDBManager::GetActiveStorage(const AliCDBParam* param) { | |
242 | // get a storage object from the list of active storages | |
243 | ||
244 | return dynamic_cast<AliCDBStorage*> (fActiveStorages.GetValue(param)); | |
245 | } | |
246 | ||
9e1ceb13 | 247 | //_____________________________________________________________________________ |
248 | TList* AliCDBManager::GetActiveStorages() { | |
249 | // return list of active storages | |
62032124 | 250 | // user has responsibility to delete returned object |
9e1ceb13 | 251 | |
252 | TList* result = new TList(); | |
253 | ||
917a098b | 254 | TIter iter(fActiveStorages.GetTable()); |
62032124 | 255 | TPair* aPair=0; |
9e1ceb13 | 256 | while ((aPair = (TPair*) iter.Next())) { |
257 | result->Add(aPair->Value()); | |
258 | } | |
259 | ||
260 | return result; | |
261 | } | |
262 | ||
263 | //_____________________________________________________________________________ | |
264 | void AliCDBManager::SetDrain(const char* dbString) { | |
265 | // set drain storage from URI string | |
266 | ||
267 | fDrainStorage = GetStorage(dbString); | |
268 | } | |
269 | ||
270 | //_____________________________________________________________________________ | |
271 | void AliCDBManager::SetDrain(const AliCDBParam* param) { | |
272 | // set drain storage from AliCDBParam | |
b8ec52f6 | 273 | |
9e1ceb13 | 274 | fDrainStorage = GetStorage(param); |
275 | } | |
276 | ||
277 | //_____________________________________________________________________________ | |
278 | void AliCDBManager::SetDrain(AliCDBStorage* storage) { | |
279 | // set drain storage from another active storage | |
280 | ||
281 | fDrainStorage = storage; | |
282 | } | |
283 | ||
284 | //_____________________________________________________________________________ | |
285 | Bool_t AliCDBManager::Drain(AliCDBEntry *entry) { | |
286 | // drain retrieved object to drain storage | |
287 | ||
b8ec52f6 | 288 | AliDebug(2, "Draining into drain storage..."); |
9e1ceb13 | 289 | return fDrainStorage->Put(entry); |
290 | } | |
291 | ||
9e1ceb13 | 292 | //_____________________________________________________________________________ |
293 | void AliCDBManager::SetDefaultStorage(const char* dbString) { | |
294 | // sets default storage from URI string | |
1f341624 | 295 | |
82096dfc | 296 | AliInfo(Form("Setting Default storage to: %s",dbString)); |
4954c5cd | 297 | AliCDBStorage* bckStorage = fDefaultStorage; |
298 | ||
82096dfc | 299 | fDefaultStorage = GetStorage(dbString); |
95c0e132 | 300 | |
301 | if(!fDefaultStorage) return; | |
4954c5cd | 302 | |
303 | if(bckStorage && (fDefaultStorage != bckStorage)){ | |
304 | AliWarning("Existing default storage replaced: clearing cache!"); | |
305 | ClearCache(); | |
306 | } | |
b21e3194 | 307 | |
308 | if (fStorageMap->Contains("default")) { | |
309 | delete fStorageMap->Remove(fStorageMap->GetValue("default")); | |
310 | } | |
311 | fStorageMap->Add(new TObjString("default"), new TObjString(fDefaultStorage->GetURI())); | |
9e1ceb13 | 312 | } |
313 | ||
314 | //_____________________________________________________________________________ | |
315 | void AliCDBManager::SetDefaultStorage(const AliCDBParam* param) { | |
316 | // set default storage from AliCDBParam object | |
1f341624 | 317 | |
4954c5cd | 318 | AliCDBStorage* bckStorage = fDefaultStorage; |
319 | ||
b8ec52f6 | 320 | fDefaultStorage = GetStorage(param); |
4954c5cd | 321 | |
95c0e132 | 322 | if(!fDefaultStorage) return; |
323 | ||
4954c5cd | 324 | if(bckStorage && (fDefaultStorage != bckStorage)){ |
325 | AliWarning("Existing default storage replaced: clearing cache!"); | |
326 | ClearCache(); | |
327 | } | |
b21e3194 | 328 | |
329 | if (fStorageMap->Contains("default")) { | |
330 | delete fStorageMap->Remove(fStorageMap->GetValue("default")); | |
331 | } | |
332 | fStorageMap->Add(new TObjString("default"), new TObjString(fDefaultStorage->GetURI())); | |
9e1ceb13 | 333 | } |
334 | ||
335 | //_____________________________________________________________________________ | |
336 | void AliCDBManager::SetDefaultStorage(AliCDBStorage* storage) { | |
337 | // set default storage from another active storage | |
1f341624 | 338 | |
339 | // if lock is ON, cannot activate more storages! | |
340 | if(fLock) { | |
341 | if (fDefaultStorage) { | |
342 | AliFatal("Lock is ON, and default storage is already set: " | |
343 | "cannot reset it or activate more storages!"); | |
344 | } | |
345 | } | |
346 | ||
347 | if (!storage) { | |
348 | UnsetDefaultStorage(); | |
349 | return; | |
350 | } | |
351 | ||
4954c5cd | 352 | AliCDBStorage* bckStorage = fDefaultStorage; |
353 | ||
9e1ceb13 | 354 | fDefaultStorage = storage; |
4954c5cd | 355 | |
356 | if(bckStorage && (fDefaultStorage != bckStorage)){ | |
357 | AliWarning("Existing default storage replaced: clearing cache!"); | |
358 | ClearCache(); | |
359 | } | |
b21e3194 | 360 | |
361 | if (fStorageMap->Contains("default")) { | |
362 | delete fStorageMap->Remove(fStorageMap->GetValue("default")); | |
363 | } | |
364 | fStorageMap->Add(new TObjString("default"), new TObjString(fDefaultStorage->GetURI())); | |
9e1ceb13 | 365 | } |
4667c116 | 366 | |
367 | //_____________________________________________________________________________ | |
1f341624 | 368 | void AliCDBManager::UnsetDefaultStorage() { |
369 | // Unset default storage | |
370 | ||
371 | // if lock is ON, action is forbidden! | |
372 | if(fLock) { | |
373 | if (fDefaultStorage) { | |
374 | AliFatal("Lock is ON: cannot unset default storage!"); | |
375 | } | |
376 | } | |
377 | ||
378 | if (fDefaultStorage) { | |
379 | AliWarning("Clearing cache!"); | |
380 | ClearCache(); | |
381 | } | |
382 | ||
383 | fDefaultStorage = 0x0; | |
4667c116 | 384 | } |
9e1ceb13 | 385 | |
02c4845e | 386 | //_____________________________________________________________________________ |
024cf675 | 387 | void AliCDBManager::SetSpecificStorage(const char* calibType, const char* dbString) { |
388 | // sets storage specific for detector or calibration type (works with AliCDBManager::Get(...)) | |
02c4845e | 389 | |
390 | AliCDBParam *aPar = CreateParameter(dbString); | |
391 | if(!aPar) return; | |
024cf675 | 392 | SetSpecificStorage(calibType, aPar); |
02c4845e | 393 | delete aPar; |
394 | } | |
395 | ||
396 | //_____________________________________________________________________________ | |
024cf675 | 397 | void AliCDBManager::SetSpecificStorage(const char* calibType, AliCDBParam* param) { |
398 | // sets storage specific for detector or calibration type (works with AliCDBManager::Get(...)) | |
399 | // Default storage should be defined prior to any specific storages, e.g.: | |
400 | // AliCDBManager::instance()->SetDefaultStorage("alien://"); | |
c3a7b59a | 401 | // AliCDBManager::instance()->SetSpecificStorage("TPC/*","local://DB_TPC"); |
402 | // AliCDBManager::instance()->SetSpecificStorage("*/Align/*","local://DB_TPCAlign"); | |
403 | // calibType must be a valid CDB path! (3 level folder structure) | |
02c4845e | 404 | |
405 | if(!fDefaultStorage) { | |
c3a7b59a | 406 | AliError("Please activate a default storage first!"); |
02c4845e | 407 | return; |
408 | } | |
4005d0b5 | 409 | |
62032124 | 410 | AliCDBPath aPath(calibType); |
411 | if(!aPath.IsValid()){ | |
412 | AliError(Form("Not a valid path: %s", calibType)); | |
413 | return; | |
414 | } | |
415 | ||
416 | TObjString *objCalibType = new TObjString(aPath.GetPath()); | |
024cf675 | 417 | if(fSpecificStorages.Contains(objCalibType)){ |
62032124 | 418 | AliWarning(Form("Storage \"%s\" already activated! It will be replaced by the new one", |
024cf675 | 419 | calibType)); |
4005d0b5 | 420 | AliCDBParam *checkPar = dynamic_cast<AliCDBParam*> (fSpecificStorages.GetValue(calibType)); |
421 | if(checkPar) delete checkPar; | |
8e245d15 | 422 | delete fSpecificStorages.Remove(objCalibType); |
02c4845e | 423 | } |
95c0e132 | 424 | AliCDBStorage *aStorage = GetStorage(param); |
425 | if(!aStorage) return; | |
96b7636d | 426 | |
427 | fSpecificStorages.Add(objCalibType, param->CloneParam()); | |
b21e3194 | 428 | |
429 | if(fStorageMap->Contains(objCalibType)){ | |
430 | delete fStorageMap->Remove(objCalibType); | |
431 | } | |
432 | fStorageMap->Add(objCalibType->Clone(), new TObjString(param->GetURI())); | |
433 | ||
02c4845e | 434 | } |
435 | ||
436 | //_____________________________________________________________________________ | |
024cf675 | 437 | AliCDBStorage* AliCDBManager::GetSpecificStorage(const char* calibType) { |
438 | // get storage specific for detector or calibration type | |
4b5e0dce | 439 | |
9c7fb557 | 440 | AliCDBPath calibPath(calibType); |
441 | if(!calibPath.IsValid()) return NULL; | |
96b7636d | 442 | |
9c7fb557 | 443 | AliCDBParam *checkPar = (AliCDBParam*) fSpecificStorages.GetValue(calibPath.GetPath()); |
02c4845e | 444 | if(!checkPar){ |
b8ec52f6 | 445 | AliError(Form("%s storage not found!", calibType)); |
02c4845e | 446 | return NULL; |
447 | } else { | |
448 | return GetStorage(checkPar); | |
449 | } | |
96b7636d | 450 | |
02c4845e | 451 | } |
452 | ||
024cf675 | 453 | //_____________________________________________________________________________ |
454 | AliCDBParam* AliCDBManager::SelectSpecificStorage(const TString& path) { | |
82096dfc | 455 | // select storage valid for path from the list of specific storages |
024cf675 | 456 | |
62032124 | 457 | AliCDBPath aPath(path); |
4005d0b5 | 458 | if(!aPath.IsValid()) return NULL; |
62032124 | 459 | |
024cf675 | 460 | TIter iter(&fSpecificStorages); |
62032124 | 461 | TObjString *aCalibType=0; |
96b7636d | 462 | AliCDBPath tmpPath("null/null/null"); |
024cf675 | 463 | AliCDBParam* aPar=0; |
464 | while((aCalibType = (TObjString*) iter.Next())){ | |
62032124 | 465 | AliCDBPath calibTypePath(aCalibType->GetName()); |
466 | if(calibTypePath.Comprises(aPath)) { | |
96b7636d | 467 | if(calibTypePath.Comprises(tmpPath)) continue; |
024cf675 | 468 | aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType); |
96b7636d | 469 | tmpPath.SetPath(calibTypePath.GetPath()); |
024cf675 | 470 | } |
471 | } | |
472 | return aPar; | |
473 | } | |
474 | ||
02c4845e | 475 | //_____________________________________________________________________________ |
4667c116 | 476 | AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path, Int_t runNumber, |
02c4845e | 477 | Int_t version, Int_t subVersion) { |
478 | // get an AliCDBEntry object from the database | |
479 | ||
024cf675 | 480 | if(runNumber < 0){ |
481 | // RunNumber is not specified. Try with fRun | |
482 | if (fRun < 0){ | |
483 | AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun."); | |
484 | return NULL; | |
485 | } | |
486 | runNumber = fRun; | |
487 | } | |
488 | ||
02c4845e | 489 | return Get(AliCDBId(path, runNumber, runNumber, version, subVersion)); |
490 | } | |
491 | ||
492 | //_____________________________________________________________________________ | |
4667c116 | 493 | AliCDBEntry* AliCDBManager::Get(const AliCDBPath& path, |
02c4845e | 494 | const AliCDBRunRange& runRange, Int_t version, |
495 | Int_t subVersion) { | |
496 | // get an AliCDBEntry object from the database! | |
497 | ||
498 | return Get(AliCDBId(path, runRange, version, subVersion)); | |
499 | } | |
500 | ||
501 | //_____________________________________________________________________________ | |
4667c116 | 502 | AliCDBEntry* AliCDBManager::Get(const AliCDBId& query) { |
02c4845e | 503 | // get an AliCDBEntry object from the database |
504 | ||
505 | if(!fDefaultStorage) { | |
506 | AliError("No storage set!"); | |
507 | return NULL; | |
508 | } | |
509 | ||
510 | // check if query's path and runRange are valid | |
511 | // query is invalid also if version is not specified and subversion is! | |
512 | if (!query.IsValid()) { | |
513 | AliError(Form("Invalid query: %s", query.ToString().Data())); | |
514 | return NULL; | |
515 | } | |
024cf675 | 516 | |
517 | // query is not specified if path contains wildcard or run range= [-1,-1] | |
518 | if (!query.IsSpecified()) { | |
4667c116 | 519 | AliError(Form("Unspecified query: %s", |
02c4845e | 520 | query.ToString().Data())); |
521 | return NULL; | |
522 | } | |
523 | ||
1f341624 | 524 | if(fLock && query.GetFirstRun() != fRun) |
525 | AliFatal("Lock is ON: cannot use different run number than the internal one!"); | |
526 | ||
527 | if(fCache && query.GetFirstRun() != fRun) | |
024cf675 | 528 | AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!"); |
529 | ||
024cf675 | 530 | AliCDBEntry *entry=0; |
8e245d15 | 531 | |
024cf675 | 532 | // first look into map of cached objects |
62032124 | 533 | if(fCache && query.GetFirstRun() == fRun) |
024cf675 | 534 | entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath()); |
535 | ||
536 | if(entry) { | |
b8ec52f6 | 537 | AliDebug(2, Form("Object %s retrieved from cache !!",query.GetPath().Data())); |
024cf675 | 538 | return entry; |
539 | } | |
96b7636d | 540 | |
541 | // Entry is not in cache -> retrieve it from CDB and cache it!! | |
024cf675 | 542 | AliCDBStorage *aStorage=0; |
543 | AliCDBParam *aPar=SelectSpecificStorage(query.GetPath()); | |
1f341624 | 544 | // Bool_t usedDefStorage=kTRUE; |
62032124 | 545 | |
02c4845e | 546 | if(aPar) { |
547 | aStorage=GetStorage(aPar); | |
548 | TString str = aPar->GetURI(); | |
549 | AliDebug(2,Form("Looking into storage: %s",str.Data())); | |
1f341624 | 550 | // usedDefStorage=kFALSE; |
4667c116 | 551 | |
02c4845e | 552 | } else { |
553 | aStorage=GetDefaultStorage(); | |
96b7636d | 554 | AliDebug(2,"Looking into default storage"); |
02c4845e | 555 | } |
4667c116 | 556 | |
024cf675 | 557 | entry = aStorage->Get(query); |
024cf675 | 558 | |
4667c116 | 559 | if(entry && fCache && (query.GetFirstRun() == fRun)){ |
024cf675 | 560 | CacheEntry(query.GetPath(), entry); |
561 | } | |
8e245d15 | 562 | |
b21e3194 | 563 | if(entry && !fIds->Contains(&entry->GetId())){ |
564 | fIds->Add(entry->GetId().Clone()); | |
565 | } | |
566 | ||
567 | ||
024cf675 | 568 | return entry; |
4667c116 | 569 | |
570 | } | |
571 | ||
0f40a831 | 572 | //_____________________________________________________________________________ |
573 | const char* AliCDBManager::GetURI(const char* path) { | |
574 | // return the URI of the storage where to look for path | |
575 | ||
576 | if(!IsDefaultStorageSet()) return 0; | |
577 | ||
578 | AliCDBParam *aPar=SelectSpecificStorage(path); | |
579 | ||
580 | if(aPar) { | |
581 | return aPar->GetURI().Data(); | |
582 | ||
583 | } else { | |
584 | return GetDefaultStorage()->GetURI().Data(); | |
585 | } | |
586 | ||
587 | return 0; | |
588 | } | |
589 | ||
4667c116 | 590 | //_____________________________________________________________________________ |
591 | AliCDBId* AliCDBManager::GetId(const AliCDBPath& path, Int_t runNumber, | |
592 | Int_t version, Int_t subVersion) { | |
593 | // get the AliCDBId of the valid object from the database (does not retrieve the object) | |
594 | // User must delete returned object! | |
595 | ||
596 | if(runNumber < 0){ | |
597 | // RunNumber is not specified. Try with fRun | |
598 | if (fRun < 0){ | |
599 | AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun."); | |
600 | return NULL; | |
601 | } | |
602 | runNumber = fRun; | |
603 | } | |
604 | ||
605 | return GetId(AliCDBId(path, runNumber, runNumber, version, subVersion)); | |
606 | } | |
607 | ||
608 | //_____________________________________________________________________________ | |
609 | AliCDBId* AliCDBManager::GetId(const AliCDBPath& path, | |
610 | const AliCDBRunRange& runRange, Int_t version, | |
611 | Int_t subVersion) { | |
612 | // get the AliCDBId of the valid object from the database (does not retrieve the object) | |
613 | // User must delete returned object! | |
614 | ||
615 | return GetId(AliCDBId(path, runRange, version, subVersion)); | |
616 | } | |
617 | ||
618 | //_____________________________________________________________________________ | |
619 | AliCDBId* AliCDBManager::GetId(const AliCDBId& query) { | |
620 | // get the AliCDBId of the valid object from the database (does not retrieve the object) | |
621 | // User must delete returned object! | |
622 | ||
623 | if(!fDefaultStorage) { | |
624 | AliError("No storage set!"); | |
625 | return NULL; | |
626 | } | |
627 | ||
628 | // check if query's path and runRange are valid | |
629 | // query is invalid also if version is not specified and subversion is! | |
630 | if (!query.IsValid()) { | |
631 | AliError(Form("Invalid query: %s", query.ToString().Data())); | |
632 | return NULL; | |
633 | } | |
634 | ||
635 | // query is not specified if path contains wildcard or run range= [-1,-1] | |
636 | if (!query.IsSpecified()) { | |
637 | AliError(Form("Unspecified query: %s", | |
638 | query.ToString().Data())); | |
639 | return NULL; | |
640 | } | |
641 | ||
642 | if(fCache && query.GetFirstRun() != fRun) | |
643 | AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!"); | |
644 | ||
645 | AliCDBEntry* entry = 0; | |
646 | ||
647 | // first look into map of cached objects | |
648 | if(fCache && query.GetFirstRun() == fRun) | |
649 | entry = (AliCDBEntry*) fEntryCache.GetValue(query.GetPath()); | |
650 | ||
651 | if(entry) { | |
652 | AliDebug(2, Form("Object %s retrieved from cache !!",query.GetPath().Data())); | |
653 | return dynamic_cast<AliCDBId*> (entry->GetId().Clone()); | |
654 | } | |
655 | ||
656 | // Entry is not in cache -> retrieve it from CDB and cache it!! | |
657 | AliCDBStorage *aStorage=0; | |
658 | AliCDBParam *aPar=SelectSpecificStorage(query.GetPath()); | |
659 | ||
660 | if(aPar) { | |
661 | aStorage=GetStorage(aPar); | |
662 | TString str = aPar->GetURI(); | |
663 | AliDebug(2,Form("Looking into storage: %s",str.Data())); | |
024cf675 | 664 | |
4667c116 | 665 | } else { |
666 | aStorage=GetDefaultStorage(); | |
667 | AliDebug(2,"Looking into default storage"); | |
668 | } | |
669 | ||
670 | return aStorage->GetId(query); | |
671 | ||
02c4845e | 672 | } |
673 | ||
674 | //_____________________________________________________________________________ | |
62032124 | 675 | TList* AliCDBManager::GetAll(const AliCDBPath& path, Int_t runNumber, |
02c4845e | 676 | Int_t version, Int_t subVersion) { |
677 | // get multiple AliCDBEntry objects from the database | |
678 | ||
afd8dbf4 | 679 | if(runNumber < 0){ |
680 | // RunNumber is not specified. Try with fRun | |
681 | if (fRun < 0){ | |
682 | AliError("Run number neither specified in query nor set in AliCDBManager! Use AliCDBManager::SetRun."); | |
683 | return NULL; | |
684 | } | |
685 | runNumber = fRun; | |
686 | } | |
687 | ||
02c4845e | 688 | return GetAll(AliCDBId(path, runNumber, runNumber, version, |
689 | subVersion)); | |
690 | } | |
691 | ||
692 | //_____________________________________________________________________________ | |
8e245d15 | 693 | TList* AliCDBManager::GetAll(const AliCDBPath& path, |
02c4845e | 694 | const AliCDBRunRange& runRange, Int_t version, Int_t subVersion) { |
695 | // get multiple AliCDBEntry objects from the database | |
696 | ||
697 | return GetAll(AliCDBId(path, runRange, version, subVersion)); | |
698 | } | |
699 | ||
700 | //_____________________________________________________________________________ | |
701 | TList* AliCDBManager::GetAll(const AliCDBId& query) { | |
702 | // get multiple AliCDBEntry objects from the database | |
024cf675 | 703 | // Warning: this method works correctly only for queries of the type "Detector/*" |
704 | // and not for more specific queries e.g. "Detector/Calib/*" ! | |
8e245d15 | 705 | // Warning #2: Entries are cached, but GetAll will keep on retrieving objects from OCDB! |
706 | // To get an object from cache use Get() function | |
02c4845e | 707 | |
708 | if(!fDefaultStorage) { | |
709 | AliError("No storage set!"); | |
710 | return NULL; | |
711 | } | |
712 | ||
713 | if (!query.IsValid()) { | |
714 | AliError(Form("Invalid query: %s", query.ToString().Data())); | |
715 | return NULL; | |
716 | } | |
717 | ||
afd8dbf4 | 718 | if((fSpecificStorages.GetEntries()>0) && query.GetPath().BeginsWith('*')){ |
719 | // if specific storages are active a query with "*" is ambiguous | |
720 | AliError("Query too generic in this context!"); | |
8e245d15 | 721 | return NULL; |
02c4845e | 722 | } |
723 | ||
724 | if (query.IsAnyRange()) { | |
725 | AliError(Form("Unspecified run or runrange: %s", | |
8e245d15 | 726 | query.ToString().Data())); |
02c4845e | 727 | return NULL; |
8e245d15 | 728 | } |
729 | ||
1f341624 | 730 | if(fLock && query.GetFirstRun() != fRun) |
731 | AliFatal("Lock is ON: cannot use different run number than the internal one!"); | |
732 | ||
6dc56e97 | 733 | AliCDBParam *aPar=SelectSpecificStorage(query.GetPath()); |
024cf675 | 734 | |
8e245d15 | 735 | AliCDBStorage *aStorage; |
02c4845e | 736 | if(aPar) { |
737 | aStorage=GetStorage(aPar); | |
96b7636d | 738 | AliDebug(2,Form("Looking into storage: %s", aPar->GetURI().Data())); |
8e245d15 | 739 | |
02c4845e | 740 | } else { |
741 | aStorage=GetDefaultStorage(); | |
8e245d15 | 742 | AliDebug(2,"Looking into default storage"); |
02c4845e | 743 | } |
744 | ||
96b7636d | 745 | TList *result = 0; |
746 | if(aStorage) result = aStorage->GetAll(query); | |
8e245d15 | 747 | if(!result) return 0; |
748 | ||
96b7636d | 749 | // loop on result to check whether entries should be re-queried with specific storages |
750 | if(fSpecificStorages.GetEntries()>0 && ! (fSpecificStorages.GetEntries() == 1 && aPar)) { | |
751 | AliInfo("Now look into all other specific storages..."); | |
752 | ||
753 | TIter iter(result); | |
754 | AliCDBEntry* chkEntry=0; | |
755 | ||
756 | while((chkEntry = dynamic_cast<AliCDBEntry*> (iter.Next()))){ | |
757 | AliCDBId& chkId = chkEntry->GetId(); | |
758 | AliDebug(2, Form("Checking id %s ", chkId.GetPath().Data())); | |
759 | AliCDBParam *chkPar=SelectSpecificStorage(chkId.GetPath()); | |
760 | if (!chkPar || aPar == chkPar) continue; | |
761 | AliCDBStorage *chkStorage = GetStorage(chkPar); | |
762 | AliDebug(2, Form("Found specific storage! %s", chkPar->GetURI().Data())); | |
763 | ||
764 | AliCDBEntry *newEntry=0; | |
765 | chkId.SetRunRange(query.GetFirstRun(), query.GetLastRun()); | |
766 | chkId.SetVersion(query.GetVersion()); | |
767 | chkId.SetSubVersion(query.GetSubVersion()); | |
768 | ||
769 | if(chkStorage) newEntry = chkStorage->Get(chkId); | |
770 | if(!newEntry) continue; | |
771 | ||
772 | // object is found in specific storage: replace entry in the result list! | |
773 | chkEntry->SetOwner(1); | |
774 | delete result->Remove(chkEntry); | |
775 | result->AddFirst(newEntry); | |
776 | } | |
777 | ||
778 | Int_t nEntries = result->GetEntries(); | |
779 | AliInfo("After look into other specific storages, result list is:"); | |
780 | for(int i=0; i<nEntries;i++){ | |
781 | AliCDBEntry *entry = (AliCDBEntry*) result->At(i); | |
782 | AliInfo(Form("%s",entry->GetId().ToString().Data())); | |
783 | } | |
784 | } | |
785 | ||
8e245d15 | 786 | // caching entries |
b21e3194 | 787 | TIter iter(result); |
788 | AliCDBEntry* entry=0; | |
789 | while((entry = dynamic_cast<AliCDBEntry*> (iter.Next()))){ | |
02c4845e | 790 | |
b21e3194 | 791 | if(!fIds->Contains(&entry->GetId())){ |
792 | fIds->Add(entry->GetId().Clone()); | |
793 | } | |
794 | if(fCache && (query.GetFirstRun() == fRun)){ | |
96b7636d | 795 | CacheEntry(entry->GetId().GetPath(), entry); |
8e245d15 | 796 | } |
797 | } | |
798 | ||
b21e3194 | 799 | |
8e245d15 | 800 | return result; |
02c4845e | 801 | } |
802 | ||
803 | //_____________________________________________________________________________ | |
b8ec52f6 | 804 | Bool_t AliCDBManager::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData, DataType type){ |
02c4845e | 805 | // store an AliCDBEntry object into the database |
806 | ||
807 | AliCDBEntry anEntry(object, id, metaData); | |
b8ec52f6 | 808 | return Put(&anEntry, type); |
02c4845e | 809 | |
810 | } | |
811 | ||
812 | ||
813 | //_____________________________________________________________________________ | |
b8ec52f6 | 814 | Bool_t AliCDBManager::Put(AliCDBEntry* entry, DataType type){ |
02c4845e | 815 | // store an AliCDBEntry object into the database |
816 | ||
b8ec52f6 | 817 | if(type == kPrivate && !fDefaultStorage) { |
02c4845e | 818 | AliError("No storage set!"); |
819 | return kFALSE; | |
820 | } | |
821 | ||
822 | if (!entry){ | |
823 | AliError("No entry!"); | |
824 | return kFALSE; | |
825 | } | |
826 | ||
827 | if (!entry->GetId().IsValid()) { | |
828 | AliError(Form("Invalid entry ID: %s", | |
829 | entry->GetId().ToString().Data())); | |
830 | return kFALSE; | |
831 | } | |
832 | ||
833 | if (!entry->GetId().IsSpecified()) { | |
834 | AliError(Form("Unspecified entry ID: %s", | |
835 | entry->GetId().ToString().Data())); | |
836 | return kFALSE; | |
837 | } | |
838 | ||
839 | AliCDBId id = entry->GetId(); | |
024cf675 | 840 | AliCDBParam *aPar = SelectSpecificStorage(id.GetPath()); |
841 | ||
4005d0b5 | 842 | AliCDBStorage *aStorage=0; |
02c4845e | 843 | |
844 | if(aPar) { | |
845 | aStorage=GetStorage(aPar); | |
02c4845e | 846 | } else { |
b8ec52f6 | 847 | switch(type){ |
848 | case kCondition: | |
849 | aStorage = GetStorage(fCondParam); | |
850 | break; | |
851 | case kReference: | |
852 | aStorage = GetStorage(fRefParam); | |
853 | break; | |
854 | case kPrivate: | |
855 | aStorage = GetDefaultStorage(); | |
856 | break; | |
857 | } | |
02c4845e | 858 | } |
859 | ||
b8ec52f6 | 860 | AliDebug(2,Form("Storing object into storage: %s", aStorage->GetURI().Data())); |
861 | ||
4005d0b5 | 862 | Bool_t result = aStorage->Put(entry, type); |
863 | ||
864 | if(fRun >= 0) QueryCDB(); | |
865 | ||
866 | return result; | |
02c4845e | 867 | |
868 | ||
869 | } | |
9e1ceb13 | 870 | |
4b5e0dce | 871 | //_____________________________________________________________________________ |
872 | void AliCDBManager::CacheEntry(const char* path, AliCDBEntry* entry) | |
873 | { | |
874 | // cache AliCDBEntry. Cache is valid until run number is changed. | |
875 | ||
96b7636d | 876 | AliCDBEntry *chkEntry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(path)); |
877 | ||
878 | if(chkEntry) { | |
879 | AliDebug(2, Form("Object %s already in cache !!", path)); | |
880 | return; | |
881 | } else { | |
882 | AliDebug(2,Form("Caching entry %s", path)); | |
883 | } | |
884 | ||
4b5e0dce | 885 | fEntryCache.Add(new TObjString(path), entry); |
96b7636d | 886 | AliDebug(2,Form("Cache entries: %d", fEntryCache.GetEntries())); |
4b5e0dce | 887 | |
888 | } | |
889 | ||
917a098b | 890 | //_____________________________________________________________________________ |
891 | void AliCDBManager::Print(Option_t* /*option*/) const | |
892 | { | |
893 | // Print list of active storages and their URIs | |
917a098b | 894 | |
b8ec52f6 | 895 | TString output=Form("Run number = %d; ",fRun); |
896 | output += "Cache is "; | |
917a098b | 897 | if(!fCache) output += "NOT "; |
b8ec52f6 | 898 | output += Form("ACTIVE; Number of active storages: %d\n",fActiveStorages.GetEntries()); |
917a098b | 899 | |
900 | if(fDefaultStorage) { | |
b8ec52f6 | 901 | output += Form("\t*** Default Storage URI: \"%s\"\n",fDefaultStorage->GetURI().Data()); |
902 | // AliInfo(output.Data()); | |
917a098b | 903 | } |
904 | if(fSpecificStorages.GetEntries()>0) { | |
917a098b | 905 | TIter iter(fSpecificStorages.GetTable()); |
62032124 | 906 | TPair *aPair=0; |
b8ec52f6 | 907 | Int_t i=1; |
917a098b | 908 | while((aPair = (TPair*) iter.Next())){ |
b8ec52f6 | 909 | output += Form("\t*** Specific storage %d: Path \"%s\" -> URI \"%s\"\n", |
910 | i++, ((TObjString*) aPair->Key())->GetName(), | |
917a098b | 911 | ((AliCDBParam*) aPair->Value())->GetURI().Data()); |
917a098b | 912 | } |
917a098b | 913 | } |
914 | if(fDrainStorage) { | |
b8ec52f6 | 915 | output += Form("*** Drain Storage URI: %s\n",fDrainStorage->GetURI().Data()); |
917a098b | 916 | } |
b8ec52f6 | 917 | AliInfo(output.Data()); |
917a098b | 918 | } |
919 | ||
4b5e0dce | 920 | //_____________________________________________________________________________ |
c3a7b59a | 921 | void AliCDBManager::SetRun(Int_t run) |
4b5e0dce | 922 | { |
917a098b | 923 | // Sets current run number. |
4b5e0dce | 924 | // When the run number changes the caching is cleared. |
1f341624 | 925 | |
4b5e0dce | 926 | if (fRun == run) |
927 | return; | |
928 | ||
1f341624 | 929 | if(fLock && fRun >= 0) { |
930 | AliFatal("Lock is ON, cannot reset run number!"); | |
931 | } | |
932 | ||
4b5e0dce | 933 | fRun = run; |
934 | ClearCache(); | |
62032124 | 935 | QueryCDB(); |
4b5e0dce | 936 | } |
937 | ||
938 | //_____________________________________________________________________________ | |
939 | void AliCDBManager::ClearCache(){ | |
940 | // clear AliCDBEntry cache | |
941 | ||
1f341624 | 942 | AliDebug(2, Form("Cache entries to be deleted: %d",fEntryCache.GetEntries())); |
943 | ||
944 | /* | |
945 | // To clean entries one by one | |
946 | TIter iter(fEntryCache.GetTable()); | |
947 | TPair* pair=0; | |
948 | while((pair= dynamic_cast<TPair*> (iter.Next()))){ | |
949 | ||
950 | TObjString* key = dynamic_cast<TObjString*> (pair->Key()); | |
951 | AliCDBEntry* entry = dynamic_cast<AliCDBEntry*> (pair->Value()); | |
952 | AliDebug(2, Form("Deleting entry: %s", key->GetName())); | |
953 | if (entry) delete entry; | |
954 | delete fEntryCache.Remove(key); | |
955 | } | |
956 | */ | |
4b5e0dce | 957 | fEntryCache.DeleteAll(); |
1f341624 | 958 | AliDebug(2, Form("After deleting - Cache entries: %d",fEntryCache.GetEntries())); |
4b5e0dce | 959 | } |
960 | ||
4005d0b5 | 961 | //_____________________________________________________________________________ |
962 | void AliCDBManager::UnloadFromCache(const char* path){ | |
963 | // unload cached object | |
964 | ||
965 | AliCDBPath queryPath(path); | |
966 | if(!queryPath.IsValid()) return; | |
967 | ||
968 | if(!queryPath.IsWildcard()) { // path is not wildcard, get it directly from the cache and unload it! | |
969 | if(fEntryCache.Contains(path)){ | |
970 | AliInfo(Form("Unloading object \"%s\" from cache", path)); | |
971 | TObjString pathStr(path); | |
972 | AliCDBEntry *entry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(&pathStr)); | |
973 | if(entry) delete entry; | |
974 | delete fEntryCache.Remove(&pathStr); | |
975 | } else { | |
976 | AliError(Form("Cache does not contain object \"%s\"!", path)) | |
977 | } | |
978 | AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries())); | |
979 | return; | |
980 | } | |
981 | ||
982 | // path is wildcard: loop on the cache and unload all comprised objects! | |
983 | TIter iter(fEntryCache.GetTable()); | |
984 | TPair* pair = 0; | |
985 | ||
986 | while((pair = dynamic_cast<TPair*> (iter.Next()))){ | |
987 | AliCDBPath entryPath = pair->Key()->GetName(); | |
988 | if(queryPath.Comprises(entryPath)) { | |
989 | AliInfo(Form("Unloading object \"%s\" from cache", entryPath.GetPath().Data())); | |
990 | TObjString pathStr(entryPath.GetPath().Data()); | |
991 | AliCDBEntry *entry = dynamic_cast<AliCDBEntry*> (fEntryCache.GetValue(&pathStr)); | |
992 | if(entry) delete entry; | |
993 | delete fEntryCache.Remove(&pathStr); | |
994 | } | |
995 | } | |
996 | AliDebug(2,Form("Cache entries: %d",fEntryCache.GetEntries())); | |
997 | } | |
998 | ||
9e1ceb13 | 999 | //_____________________________________________________________________________ |
1000 | void AliCDBManager::DestroyActiveStorages() { | |
1001 | // delete list of active storages | |
1002 | ||
1003 | fActiveStorages.DeleteAll(); | |
02c4845e | 1004 | fSpecificStorages.DeleteAll(); |
9e1ceb13 | 1005 | } |
1006 | ||
1007 | //_____________________________________________________________________________ | |
1008 | void AliCDBManager::DestroyActiveStorage(AliCDBStorage* /*storage*/) { | |
b05400be | 1009 | // destroys active storage |
1010 | ||
1011 | /* | |
917a098b | 1012 | TIter iter(fActiveStorages.GetTable()); |
b05400be | 1013 | TPair* aPair; |
1014 | while ((aPair = (TPair*) iter.Next())) { | |
1015 | if(storage == (AliCDBStorage*) aPair->Value()) | |
1016 | delete fActiveStorages.Remove(aPair->Key()); | |
1017 | storage->Delete(); storage=0x0; | |
1018 | } | |
6dc56e97 | 1019 | */ |
9e1ceb13 | 1020 | |
1021 | } | |
1022 | ||
62032124 | 1023 | //_____________________________________________________________________________ |
1024 | void AliCDBManager::QueryCDB() { | |
1025 | // query default and specific storages for files valid for fRun. Every storage loads the Ids into its list. | |
1026 | ||
1027 | if (fRun < 0){ | |
1028 | AliError("Run number not yet set! Use AliCDBManager::SetRun."); | |
1029 | return; | |
1030 | } | |
6dc56e97 | 1031 | if (!fDefaultStorage){ |
1032 | AliError("Default storage is not set! Use AliCDBManager::SetDefaultStorage"); | |
1033 | return; | |
1034 | } | |
1035 | if(fDefaultStorage->GetType() == "alien"){ | |
1036 | fDefaultStorage->QueryCDB(fRun); | |
1037 | } else { | |
1038 | AliDebug(2,"Skipping query for valid files, it used only in grid..."); | |
1039 | } | |
62032124 | 1040 | |
1041 | TIter iter(&fSpecificStorages); | |
1042 | TObjString *aCalibType=0; | |
1043 | AliCDBParam* aPar=0; | |
1044 | while((aCalibType = dynamic_cast<TObjString*> (iter.Next()))){ | |
1045 | aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType); | |
1046 | if(aPar) { | |
c3a7b59a | 1047 | AliDebug(2,Form("Querying specific storage %s",aCalibType->GetName())); |
6dc56e97 | 1048 | AliCDBStorage *aStorage = GetStorage(aPar); |
1049 | if(aStorage->GetType() == "alien"){ | |
1050 | aStorage->QueryCDB(fRun,aCalibType->GetName()); | |
1051 | } else { | |
1052 | AliDebug(2, | |
1053 | "Skipping query for valid files, it is used only in grid..."); | |
1054 | } | |
62032124 | 1055 | } |
1056 | } | |
62032124 | 1057 | } |
1058 | ||
b8ec52f6 | 1059 | //______________________________________________________________________________________________ |
1060 | const char* AliCDBManager::GetDataTypeName(DataType type) | |
1061 | { | |
1062 | // returns the name (string) of the data type | |
1063 | ||
1064 | switch (type){ | |
1065 | case kCondition: return "Conditions"; | |
1066 | case kReference: return "Reference"; | |
1067 | case kPrivate: return "Private"; | |
1068 | } | |
1069 | return 0; | |
1070 | ||
1071 | } | |
62032124 | 1072 | |
4667c116 | 1073 | //______________________________________________________________________________________________ |
1074 | void AliCDBManager::InitShortLived() | |
1075 | { | |
1076 | // Init the list of short-lived objects | |
1077 | // currently disabled | |
1078 | ||
1079 | fShortLived=0x0; | |
1080 | ||
1081 | // fShortLived = new TList(); | |
1082 | // fShortLived->SetOwner(1); | |
1083 | // | |
1084 | // fShortLived->Add(new TObjString("EMCAL/Calib/Data")); | |
1085 | // | |
1086 | // fShortLived->Add(new TObjString("HMPID/Calib/Nmean")); | |
1087 | // fShortLived->Add(new TObjString("HMPID/Calib/Qthre")); | |
1088 | // | |
1089 | // fShortLived->Add(new TObjString("ITS/Calib/CalibSPD")); | |
1090 | // | |
1091 | // fShortLived->Add(new TObjString("MUON/Calib/Gains")); | |
1092 | // fShortLived->Add(new TObjString("MUON/Calib/HV")); | |
1093 | // fShortLived->Add(new TObjString("MUON/Calib/Pedestals")); | |
1094 | // | |
1095 | // fShortLived->Add(new TObjString("PHOS/Calib/CpvGainPedestals")); | |
1096 | // fShortLived->Add(new TObjString("PHOS/Calib/EmcGainPedestals")); | |
1097 | // | |
1098 | // fShortLived->Add(new TObjString("PMD/Calib/Data")); | |
1099 | // | |
1100 | // fShortLived->Add(new TObjString("TRD/Calib/ChamberGainFactor")); | |
1101 | // fShortLived->Add(new TObjString("TRD/Calib/LocalGainFactor")); | |
1102 | // fShortLived->Add(new TObjString("TRD/Calib/ChamberT0")); | |
1103 | // fShortLived->Add(new TObjString("TRD/Calib/LocalT0")); | |
1104 | // fShortLived->Add(new TObjString("TRD/Calib/ChamberVdrift")); | |
1105 | // fShortLived->Add(new TObjString("TRD/Calib/LocalVdrift")); | |
1106 | // | |
1107 | // fShortLived->Add(new TObjString("ZDC/Calib/Data")); | |
1108 | ||
1109 | } | |
1110 | ||
1111 | //______________________________________________________________________________________________ | |
1112 | Bool_t AliCDBManager::IsShortLived(const char* path) | |
1113 | { | |
1114 | // returns the name (string) of the data type | |
1115 | ||
1116 | if(!fShortLived) return kFALSE; | |
1117 | ||
1118 | AliCDBPath aPath(path); | |
1119 | if(!aPath.IsValid()){ | |
1120 | AliError(Form("Not a valid path: %s", path)); | |
1121 | return kFALSE; | |
1122 | } | |
1123 | ||
1124 | return fShortLived->Contains(path); | |
1125 | ||
1126 | } | |
1127 | ||
1f341624 | 1128 | //______________________________________________________________________________________________ |
1129 | void AliCDBManager::SetLock(Bool_t lock){ | |
1130 | ||
1131 | if(fLock == kTRUE && lock == kFALSE) { | |
1132 | AliFatal("Lock is ON: cannot reset it!"); | |
1133 | } | |
1134 | ||
1135 | fLock=lock; | |
1136 | } | |
1137 | ||
9e1ceb13 | 1138 | /////////////////////////////////////////////////////////// |
1139 | // AliCDBManager Parameter class // | |
1140 | // interface to specific AliCDBParameter class // | |
1141 | // (AliCDBGridParam, AliCDBLocalParam, AliCDBDumpParam) // | |
1142 | /////////////////////////////////////////////////////////// | |
1143 | ||
62032124 | 1144 | AliCDBParam::AliCDBParam(): |
fe12e09c | 1145 | fType(), |
1146 | fURI() | |
62032124 | 1147 | { |
9e1ceb13 | 1148 | // constructor |
1149 | ||
1150 | } | |
1151 | ||
1152 | //_____________________________________________________________________________ | |
1153 | AliCDBParam::~AliCDBParam() { | |
1154 | // destructor | |
1155 | ||
1156 | } | |
1157 |