LCOV - code coverage report
Current view: top level - STEER/CDB - AliCDBManager.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 17 31 54.8 %
Date: 2016-06-14 17:26:59 Functions: 18 48 37.5 %

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

Generated by: LCOV version 1.11