]>
Commit | Line | Data |
---|---|---|
9e1ceb13 | 1 | #ifndef ALI_CDB_MANAGER_H |
2 | #define ALI_CDB_MANAGER_H | |
3 | ||
4 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice */ | |
6 | ||
7 | ///////////////////////////////////////////////////////////////////// | |
8 | // // | |
9 | // class AliCDBManager // | |
10 | // // | |
11 | ///////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #include <TObject.h> | |
14 | #include <TList.h> | |
15 | #include <TMap.h> | |
27cac7e3 | 16 | #include <TSystem.h> |
c022b397 | 17 | #include <TFile.h> |
9e1ceb13 | 18 | |
fdf65bb5 | 19 | class AliCDBEntry; |
02c4845e | 20 | class AliCDBId; |
21 | class AliCDBPath; | |
22 | class AliCDBRunRange; | |
23 | class AliCDBMetaData; | |
9e1ceb13 | 24 | class AliCDBStorage; |
25 | class AliCDBStorageFactory; | |
26 | class AliCDBParam; | |
27 | ||
28 | class AliCDBManager: public TObject { | |
29 | ||
5078a13f | 30 | public: |
31 | enum DataType {kCondition=0, kReference, kPrivate}; | |
9e1ceb13 | 32 | |
5078a13f | 33 | void RegisterFactory(AliCDBStorageFactory* factory); |
9e1ceb13 | 34 | |
5078a13f | 35 | Bool_t HasStorage(const char* dbString) const; |
9e1ceb13 | 36 | |
5078a13f | 37 | AliCDBParam* CreateParameter(const char* dbString) const; |
38 | AliCDBParam* GetCondParam() const {return fCondParam;} | |
39 | AliCDBParam* GetRefParam() const {return fRefParam;} | |
40 | static const char* GetDataTypeName(DataType type); | |
9e1ceb13 | 41 | |
5078a13f | 42 | AliCDBStorage* GetStorage(const char* dbString); |
b8ec52f6 | 43 | |
5078a13f | 44 | TList* GetActiveStorages(); |
9e1ceb13 | 45 | |
5078a13f | 46 | const TMap* GetStorageMap() const {return fStorageMap;} |
47 | const TList* GetRetrievedIds() const {return fIds;} | |
b21e3194 | 48 | |
5078a13f | 49 | void SetDefaultStorage(const char* dbString); |
50 | void SetDefaultStorage(const AliCDBParam* param); | |
51 | void SetDefaultStorage(AliCDBStorage *storage); | |
52 | void SetDefaultStorage(const char* runType, const char* simType); | |
53 | void SetDefaultStorageFromRun(Int_t run); | |
4667c116 | 54 | |
5078a13f | 55 | Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;} |
56 | AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;} | |
57 | void UnsetDefaultStorage(); | |
4667c116 | 58 | |
5078a13f | 59 | void SetSpecificStorage(const char* calibType, const char* dbString); |
02c4845e | 60 | |
5078a13f | 61 | AliCDBStorage* GetSpecificStorage(const char* calibType); |
9e1ceb13 | 62 | |
5078a13f | 63 | void SetDrain(const char* dbString); |
64 | void SetDrain(const AliCDBParam* param); | |
65 | void SetDrain(AliCDBStorage *storage); | |
9e1ceb13 | 66 | |
5078a13f | 67 | Bool_t IsDrainSet() const {return fDrainStorage != 0;} |
9e1ceb13 | 68 | |
5078a13f | 69 | Bool_t Drain(AliCDBEntry* entry); |
9e1ceb13 | 70 | |
5078a13f | 71 | void UnsetDrain(){fDrainStorage = 0x0;} |
9e1ceb13 | 72 | |
5078a13f | 73 | AliCDBEntry* Get(const AliCDBId& query, Bool_t forceCaching=kFALSE); |
74 | AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1, | |
75 | Int_t version = -1, Int_t subVersion = -1); | |
76 | AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
77 | Int_t version = -1, Int_t subVersion = -1); | |
78 | AliCDBEntry* GetEntryFromSnapshot(const char* path); | |
02c4845e | 79 | |
5078a13f | 80 | const char* GetURI(const char* path); |
4667c116 | 81 | |
5078a13f | 82 | TList* GetAll(const AliCDBId& query); |
83 | TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1, | |
84 | Int_t version = -1, Int_t subVersion = -1); | |
85 | TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
86 | Int_t version = -1, Int_t subVersion = -1); | |
02c4845e | 87 | |
5078a13f | 88 | Bool_t Put(TObject* object, const AliCDBId& id, AliCDBMetaData* metaData, |
89 | const char* mirrors="", DataType type=kPrivate); | |
90 | Bool_t Put(AliCDBEntry* entry, const char* mirrors="", DataType type=kPrivate); | |
b8ec52f6 | 91 | |
5078a13f | 92 | void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;} |
93 | Bool_t GetCacheFlag() const {return fCache;} | |
4b5e0dce | 94 | |
5078a13f | 95 | ULong64_t SetLock(Bool_t lockFlag=kTRUE, ULong64_t key=0); |
96 | Bool_t GetLock() const {return fLock;} | |
7de84b33 | 97 | |
5078a13f | 98 | void SetRaw(Bool_t rawFlag){fRaw=rawFlag;} |
99 | Bool_t GetRaw() const {return fRaw;} | |
4b5e0dce | 100 | |
5078a13f | 101 | void SetRun(Int_t run); |
102 | Int_t GetRun() const {return fRun;} | |
3d152e8d | 103 | |
5078a13f | 104 | void SetMirrorSEs(const char* mirrors); |
105 | const char* GetMirrorSEs() const; | |
917a098b | 106 | |
5078a13f | 107 | void DestroyActiveStorages(); |
108 | void DestroyActiveStorage(AliCDBStorage* storage); | |
62032124 | 109 | |
5078a13f | 110 | void QueryCDB(); |
917a098b | 111 | |
5078a13f | 112 | void Print(Option_t* option="") const; |
9e1ceb13 | 113 | |
5078a13f | 114 | static void Destroy(); |
115 | ~AliCDBManager(); | |
8e245d15 | 116 | |
5078a13f | 117 | void ClearCache(); |
118 | void UnloadFromCache(const char* path); | |
119 | const TMap* GetEntryCache() const {return &fEntryCache;} | |
4667c116 | 120 | |
5078a13f | 121 | Bool_t IsShortLived(const char* path); |
9e1ceb13 | 122 | |
5078a13f | 123 | static AliCDBManager* Instance(TMap *entryCache = NULL, Int_t run = -1); |
b7df0cc5 | 124 | |
5078a13f | 125 | void Init(); |
126 | void InitFromCache(TMap *entryCache, Int_t run); | |
127 | Bool_t InitFromSnapshot(const char* snapshotFileName, Bool_t overwrite=kTRUE); | |
128 | Bool_t SetSnapshotMode(const char* snapshotFileName="OCDB.root"); | |
129 | void UnsetSnapshotMode() {fSnapshotMode=kFALSE;} | |
130 | void DumpToSnapshotFile(const char* snapshotFileName, Bool_t singleKeys); | |
a37a1dfc | 131 | |
5078a13f | 132 | Int_t GetStartRunLHCPeriod(); |
133 | Int_t GetEndRunLHCPeriod(); | |
134 | TString GetLHCPeriod(); | |
b8ec52f6 | 135 | |
5078a13f | 136 | Bool_t DiffObjects(const char *cdbFile1, const char *cdbFile2) const; |
b8ec52f6 | 137 | |
5078a13f | 138 | protected: |
fe12e09c | 139 | |
5078a13f | 140 | static TString fgkCondUri; // URI of the Conditions data base folder |
141 | static TString fgkRefUri; // URI of the Reference data base folder | |
142 | static TString fgkMCIdealStorage; // URI of the MC-Ideal Conditions data base folder form MC data | |
143 | static TString fgkMCFullStorage; // URI of the MC-Full Conditions data base folder form MC data | |
144 | static TString fgkMCResidualStorage; // URI of the MC-Residual Conditions data base folder form MC data | |
145 | static TString fgkOCDBFolderXMLfile; // alien path of the XML file for OCDB folder <--> Run range correspondance | |
917a098b | 146 | |
5078a13f | 147 | AliCDBManager() ; |
148 | AliCDBManager(const AliCDBManager & source); | |
149 | AliCDBManager & operator=(const AliCDBManager & source); | |
8e245d15 | 150 | |
5078a13f | 151 | static AliCDBManager* fgInstance; // AliCDBManager instance |
9e1ceb13 | 152 | |
5078a13f | 153 | AliCDBStorage* GetStorage(const AliCDBParam* param); |
154 | AliCDBStorage* GetActiveStorage(const AliCDBParam* param); | |
155 | void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage); | |
156 | void SetSpecificStorage(const char* calibType, const AliCDBParam* param); | |
157 | void AlienToCvmfsUri(TString& uriString) const; | |
158 | void ValidateCvmfsCase() const; | |
4667c116 | 159 | |
5078a13f | 160 | void CacheEntry(const char* path, AliCDBEntry* entry); |
4667c116 | 161 | |
5078a13f | 162 | AliCDBParam* SelectSpecificStorage(const TString& path); |
b21e3194 | 163 | |
5078a13f | 164 | AliCDBId* GetId(const AliCDBId& query); |
165 | AliCDBId* GetId(const AliCDBPath& path, Int_t runNumber=-1, | |
166 | Int_t version = -1, Int_t subVersion = -1); | |
167 | AliCDBId* GetId(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
168 | Int_t version = -1, Int_t subVersion = -1); | |
4b5e0dce | 169 | |
9e1ceb13 | 170 | |
5078a13f | 171 | // void Init(); |
172 | void InitShortLived(); | |
173 | // void InitFromCache(TMap *entryCache, Int_t run); | |
4b5e0dce | 174 | |
4b5e0dce | 175 | |
5078a13f | 176 | TList fFactories; //! list of registered storage factories |
177 | TMap fActiveStorages; //! list of active storages | |
178 | TMap fSpecificStorages; //! list of detector-specific storages | |
179 | TMap fEntryCache; //! cache of the retrieved objects | |
c022b397 | 180 | |
5078a13f | 181 | TList* fIds; //! List of the retrieved object Id's (to be streamed to file) |
182 | TMap* fStorageMap; //! list of storages (to be streamed to file) | |
183 | TList* fShortLived; //! List of short lived objects | |
7de84b33 | 184 | |
5078a13f | 185 | AliCDBStorage *fDefaultStorage; //! pointer to default storage |
186 | AliCDBStorage *fDrainStorage; //! pointer to drain storage | |
a6f59240 | 187 | |
5078a13f | 188 | AliCDBParam* fCondParam; // Conditions data storage parameters |
189 | AliCDBParam* fRefParam; // Reference data storage parameters | |
4667c116 | 190 | |
5078a13f | 191 | Int_t fRun; //! The run number |
192 | Bool_t fCache; //! The cache flag | |
193 | Bool_t fLock; //! Lock flag, if ON default storage and run number cannot be reset | |
194 | ||
195 | Bool_t fSnapshotMode; //! flag saying if we are in snapshot mode | |
196 | TFile *fSnapshotFile; | |
197 | ||
198 | Bool_t fRaw; // flag to say whether we are in the raw case | |
199 | TString fCvmfsOcdb; // set from $OCDB_PATH, points to a cvmfs AliRoot package | |
200 | Int_t fStartRunLHCPeriod; // 1st run of the LHC period set | |
201 | Int_t fEndRunLHCPeriod; // last run of the LHC period set | |
202 | TString fLHCPeriod; // LHC period alien folder | |
203 | ||
204 | private: | |
205 | ULong64_t fKey; //! Key for locking/unlocking | |
206 | ||
207 | ||
208 | ClassDef(AliCDBManager, 0); | |
9e1ceb13 | 209 | }; |
210 | ||
211 | ||
212 | ///////////////////////////////////////////////////////////////////// | |
213 | // // | |
214 | // class AliCDBStorageFactory // | |
215 | // // | |
216 | ///////////////////////////////////////////////////////////////////// | |
217 | ||
218 | class AliCDBParam; | |
219 | class AliCDBStorageFactory: public TObject { | |
5078a13f | 220 | friend class AliCDBManager; |
221 | ||
222 | public: | |
223 | virtual ~AliCDBStorageFactory(){} | |
224 | virtual Bool_t Validate(const char* dbString) = 0; | |
225 | virtual AliCDBParam* CreateParameter(const char* dbString) = 0; | |
9e1ceb13 | 226 | |
5078a13f | 227 | protected: |
228 | virtual AliCDBStorage* Create(const AliCDBParam* param) = 0; | |
9e1ceb13 | 229 | |
5078a13f | 230 | ClassDef(AliCDBStorageFactory, 0); |
9e1ceb13 | 231 | }; |
232 | ||
233 | ///////////////////////////////////////////////////////////////////// | |
234 | // // | |
235 | // class AliCDBParam // | |
236 | // // | |
237 | ///////////////////////////////////////////////////////////////////// | |
238 | ||
239 | class AliCDBParam: public TObject { | |
240 | ||
5078a13f | 241 | public: |
9e1ceb13 | 242 | |
5078a13f | 243 | AliCDBParam(); |
244 | virtual ~AliCDBParam(); | |
9e1ceb13 | 245 | |
5078a13f | 246 | const TString& GetType() const {return fType;}; |
247 | const TString& GetURI() const {return fURI;}; | |
9e1ceb13 | 248 | |
5078a13f | 249 | virtual AliCDBParam* CloneParam() const = 0; |
9e1ceb13 | 250 | |
5078a13f | 251 | protected: |
9e1ceb13 | 252 | |
5078a13f | 253 | void SetType(const char* type) {fType = type;}; |
254 | void SetURI(const char* uri) {fURI = uri;}; | |
9e1ceb13 | 255 | |
5078a13f | 256 | private: |
9e1ceb13 | 257 | |
5078a13f | 258 | TString fType; //! CDB type |
259 | TString fURI; //! CDB URI | |
9e1ceb13 | 260 | |
5078a13f | 261 | ClassDef(AliCDBParam, 0); |
9e1ceb13 | 262 | }; |
263 | ||
264 | #endif |