]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
In RunSimulation the run number is set into AliCDBManager but the storages
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 Oct 2006 16:09:50 +0000 (16:09 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 Oct 2006 16:09:50 +0000 (16:09 +0000)
are not activated (this is done in Run()), and then AliCDBManager tries to
query the CDB for valid files. The problem was that there was no check that
the storage existed, and that was the cause of the crash. I added that
protection, now the query is skipped if the storage is not activated.

Alberto

STEER/AliCDBGrid.cxx
STEER/AliCDBGrid.h
STEER/AliCDBManager.cxx
STEER/AliCDBStorage.cxx
STEER/AliCDBStorage.h

index d39ed4dff516879dd50eda8027bd83e4605a3876..0d8569a09f2f08cfd6d9d99a343bc5502cd9fade 100644 (file)
@@ -24,7 +24,9 @@
 #include <TGrid.h>
 #include <TGridResult.h>
 #include <TFile.h>
+#include <TKey.h>
 #include <TROOT.h>
+#include <TSystem.h>
 #include <TObjArray.h>
 #include <TObjString.h>
 #include <TRegexp.h>
@@ -32,7 +34,6 @@
 #include "AliLog.h"
 #include "AliCDBEntry.h"
 #include "AliCDBGrid.h"
-#include "AliCDBMetaData.h"
 
 
 ClassImp(AliCDBGrid)
@@ -228,12 +229,12 @@ Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
 }
 
 //_____________________________________________________________________________
-AliCDBId* AliCDBGrid::GetId(const TList& validFileIds, const AliCDBId& query) {
+AliCDBId* AliCDBGrid::GetId(const TObjArray& validFileIds, const AliCDBId& query) {
 // look for the Id that matches query's requests (highest or exact version)
 
-       if(validFileIds.GetEntries() < 1) {
+       if(validFileIds.GetEntriesFast() < 1) {
                return NULL;
-       } else if (validFileIds.GetEntries() == 1) {
+       } else if (validFileIds.GetEntriesFast() == 1) {
                return dynamic_cast<AliCDBId*> (validFileIds.At(0));
        }
 
@@ -283,7 +284,7 @@ AliCDBEntry* AliCDBGrid::GetEntry(const AliCDBId& queryId) {
                GetSelection(&selectedId);
        }
 
-       TList validFileIds;
+       TObjArray validFileIds;
        validFileIds.SetOwner(1);
 
        // look for file matching query requests (path, runRange, version)
@@ -300,10 +301,14 @@ AliCDBEntry* AliCDBGrid::GetEntry(const AliCDBId& queryId) {
                                        selectedId.GetFirstRun(), selectedId.GetPath().Data()));
 
                TString filter;
-               MakeQueryFilter(selectedId.GetFirstRun(), selectedId.GetLastRun(),
-                               selectedId.GetAliCDBPath(), selectedId.GetVersion(), 0, filter);
+               MakeQueryFilter(selectedId.GetFirstRun(), selectedId.GetLastRun(), 0, filter);
 
-               TGridResult *res = gGrid->Query(fDBFolder, "Run*.root", filter, "");
+               TString pattern = Form("%s/Run*", selectedId.GetPath().Data());
+               if(selectedId.GetVersion() >= 0) pattern += Form("_v%d",selectedId.GetVersion());
+               pattern += ".root";
+               AliDebug(2,Form("pattern: %s", pattern.Data()));
+
+               TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
                AliCDBId validFileId;
                for(int i=0; i<res->GetEntries(); i++){
                        TString filename = res->GetKey(i, "lfn");
@@ -381,7 +386,7 @@ TList* AliCDBGrid::GetEntries(const AliCDBId& queryId) {
        TList* result = new TList();
        result->SetOwner();
 
-       TList validFileIds;
+       TObjArray validFileIds;
        validFileIds.SetOwner(1);
 
        Bool_t alreadyLoaded = kFALSE;
@@ -401,10 +406,13 @@ TList* AliCDBGrid::GetEntries(const AliCDBId& queryId) {
                                        queryId.GetFirstRun(), queryId.GetPath().Data()));
 
                TString filter;
-               MakeQueryFilter(queryId.GetFirstRun(), queryId.GetLastRun(),
-                               queryId.GetAliCDBPath(), queryId.GetVersion(), 0, filter);
+               MakeQueryFilter(queryId.GetFirstRun(), queryId.GetLastRun(), 0, filter);
+
+               TString pattern = Form("%s/Run*.root", queryId.GetPath().Data());
+               AliDebug(2,Form("pattern: %s", pattern.Data()));
+
+               TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
 
-               TGridResult *res = gGrid->Query(fDBFolder, "Run*.root", filter, "");
                AliCDBId validFileId;
                for(int i=0; i<res->GetEntries(); i++){
                        TString filename = res->GetKey(i, "lfn");
@@ -422,7 +430,7 @@ TList* AliCDBGrid::GetEntries(const AliCDBId& queryId) {
                iter = new TIter(&validFileIds);
        }
 
-       TList selectedIds;
+       TObjArray selectedIds;
        selectedIds.SetOwner(1);
 
        // loop on list of valid Ids to select the right version to get.
@@ -559,19 +567,19 @@ Bool_t AliCDBGrid::AddTag(TString& folderToTag, const char* tagname){
 Bool_t AliCDBGrid::TagFileId(TString& filename, const AliCDBId* id){
 // tag stored object in CDB table using object Id's parameters
 
-       TString addTagValue1 = Form("addTagValue %s CDB ", filename.Data());
-       TString addTagValue2 = Form("first_run=%d last_run=%d version=%d ",
+       TString addTagValue_1 = Form("addTagValue %s CDB ", filename.Data());
+       TString addTagValue_2 = Form("first_run=%d last_run=%d version=%d ",
                                        id->GetFirstRun(),
                                        id->GetLastRun(),
                                        id->GetVersion());
-       TString addTagValue3 = Form("path_level_0=\"%s\" path_level_1=\"%s\" path_level_2=\"%s\"",
+       TString addTagValue_3 = Form("path_level_0=\"%s\" path_level_1=\"%s\" path_level_2=\"%s\"",
                                        id->GetLevel0().Data(),
                                        id->GetLevel1().Data(),
                                        id->GetLevel2().Data());
        TString addTagValue = Form("%s%s%s",
-                                       addTagValue1.Data(),
-                                       addTagValue2.Data(),
-                                       addTagValue3.Data());
+                                       addTagValue_1.Data(),
+                                       addTagValue_2.Data(),
+                                       addTagValue_3.Data());
 
        Bool_t result = kFALSE;
        AliDebug(2, Form("Tagging file. Tag command: %s", addTagValue.Data()));
@@ -594,18 +602,18 @@ Bool_t AliCDBGrid::TagFileId(TString& filename, const AliCDBId* id){
 Bool_t AliCDBGrid::TagFileMetaData(TString& filename, const AliCDBMetaData* md){
 // tag stored object in CDB table using object Id's parameters
 
-       TString addTagValue1 = Form("addTagValue %s CDB_MD ", filename.Data());
-       TString addTagValue2 = Form("object_classname=\"%s\" responsible=\"%s\" beam_period=%d ",
+       TString addTagValue_1 = Form("addTagValue %s CDB_MD ", filename.Data());
+       TString addTagValue_2 = Form("object_classname=\"%s\" responsible=\"%s\" beam_period=%d ",
                                        md->GetObjectClassName(),
                                        md->GetResponsible(),
                                        md->GetBeamPeriod());
-       TString addTagValue3 = Form("aliroot_version=\"%s\" comment=\"%s\"",
+       TString addTagValue_3 = Form("aliroot_version=\"%s\" comment=\"%s\"",
                                        md->GetAliRootVersion(),
                                        md->GetComment());
        TString addTagValue = Form("%s%s%s",
-                                       addTagValue1.Data(),
-                                       addTagValue2.Data(),
-                                       addTagValue3.Data());
+                                       addTagValue_1.Data(),
+                                       addTagValue_2.Data(),
+                                       addTagValue_3.Data());
 
        Bool_t result = kFALSE;
        AliDebug(2, Form("Tagging file. Tag command: %s", addTagValue.Data()));
@@ -624,7 +632,7 @@ Bool_t AliCDBGrid::TagFileMetaData(TString& filename, const AliCDBMetaData* md){
 
 //_____________________________________________________________________________
 TList* AliCDBGrid::GetIdListFromFile(const char* fileName){
-  // Gets the CDB Id list from the file fileName
+
        TString turl(fileName);
        turl.Prepend("/alien" + fDBFolder);
        turl += "?se="; turl += fSE.Data();
@@ -676,9 +684,15 @@ void AliCDBGrid::QueryValidFiles()
 // fills list fValidFileIds with AliCDBId objects created from file name
 
        TString filter;
-       MakeQueryFilter(fRun, fRun, fPathFilter, fVersion, fMetaDataFilter, filter);
+       MakeQueryFilter(fRun, fRun, fMetaDataFilter, filter);
+
+       TString pattern = Form("%s/Run*", fPathFilter.GetPath().Data());
+       if(fVersion >= 0) pattern += Form("_v%d", fVersion);
+       pattern += ".root";
+       AliDebug(2,Form("pattern: %s", pattern.Data()));
+
+       TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
 
-       TGridResult *res = gGrid->Query(fDBFolder, "Run*.root", filter, "");
        AliCDBId validFileId;
        for(int i=0; i<res->GetEntries(); i++){
                TString filename = res->GetKey(i, "lfn");
@@ -695,25 +709,24 @@ void AliCDBGrid::QueryValidFiles()
 
 //_____________________________________________________________________________
 void AliCDBGrid::MakeQueryFilter(Int_t firstRun, Int_t lastRun,
-                                       const AliCDBPath& pathFilter, Int_t version,
                                        const AliCDBMetaData* md, TString& result) const
 {
 // create filter for file query
 
        result = Form("CDB:first_run<=%d and CDB:last_run>=%d", firstRun, lastRun);
 
-       if(version >= 0) {
-               result += Form(" and CDB:version=%d", version);
-       }
-       if(pathFilter.GetLevel0() != "*") {
-               result += Form(" and CDB:path_level_0=\"%s\"", pathFilter.GetLevel0().Data());
-       }
-       if(pathFilter.GetLevel1() != "*") {
-               result += Form(" and CDB:path_level_1=\"%s\"", pathFilter.GetLevel1().Data());
-       }
-       if(pathFilter.GetLevel2() != "*") {
-               result += Form(" and CDB:path_level_2=\"%s\"", pathFilter.GetLevel2().Data());
-       }
+//     if(version >= 0) {
+//             result += Form(" and CDB:version=%d", version);
+//     }
+//     if(pathFilter.GetLevel0() != "*") {
+//             result += Form(" and CDB:path_level_0=\"%s\"", pathFilter.GetLevel0().Data());
+//     }
+//     if(pathFilter.GetLevel1() != "*") {
+//             result += Form(" and CDB:path_level_1=\"%s\"", pathFilter.GetLevel1().Data());
+//     }
+//     if(pathFilter.GetLevel2() != "*") {
+//             result += Form(" and CDB:path_level_2=\"%s\"", pathFilter.GetLevel2().Data());
+//     }
 
        if(md){
                if(md->GetObjectClassName()[0] != '\0') {
@@ -740,7 +753,7 @@ void AliCDBGrid::MakeQueryFilter(Int_t firstRun, Int_t lastRun,
 Int_t AliCDBGrid::GetLatestVersion(const char* path, Int_t run){
 // get last version found in the database valid for run and path
 
-       TList validFileIds;
+       TObjArray validFileIds;
        validFileIds.SetOwner(1);
 
        AliCDBPath aCDBPath(path);
@@ -752,8 +765,7 @@ Int_t AliCDBGrid::GetLatestVersion(const char* path, Int_t run){
        AliCDBId* dataId = 0;
 
        // look for file matching query requests (path, runRange, version)
-       if(run == fRun &&
-                       fPathFilter.Comprises(aCDBPath) && fVersion < 0){
+       if(run == fRun && fPathFilter.Comprises(aCDBPath) && fVersion < 0){
                // look into list of valid files previously loaded with AliCDBStorage::FillValidFileIds()
                AliDebug(2, Form("List of files valid for run %d and for path %s was loaded. Looking there!",
                                        run, path));
@@ -767,9 +779,12 @@ Int_t AliCDBGrid::GetLatestVersion(const char* path, Int_t run){
                                run, path));
 
        TString filter;
-       MakeQueryFilter(run, run, aCDBPath, -1, 0, filter);
+       MakeQueryFilter(run, run, 0, filter);
+
+       TString pattern = Form("%s/Run*.root", path);
+       AliDebug(2,Form("pattern: %s", pattern.Data()));
 
-       TGridResult *res = gGrid->Query(fDBFolder, "Run*.root", filter, "");
+       TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
        AliCDBId validFileId;
        for(int i=0; i<res->GetEntries(); i++){
                TString filename = res->GetKey(i, "lfn");
index 944d7a0d7c54fe22091fe2942fcd666d03c87735..a061ab991425e19d857475c0d24eb9ee2404b6a4 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "AliCDBStorage.h"
 #include "AliCDBManager.h"
-class AliCDBMetaData;
+#include "AliCDBMetaData.h"
 
 class AliCDBGrid: public AliCDBStorage {
        friend class AliCDBGridFactory;
@@ -46,17 +46,14 @@ private:
        Bool_t FilenameToId(TString& filename, AliCDBId& id);
 
        Bool_t PrepareId(AliCDBId& id);
-       AliCDBId* GetId(const TList& validFileIds, const AliCDBId& query);
+       AliCDBId* GetId(const TObjArray& validFileIds, const AliCDBId& query);
        AliCDBEntry* GetEntryFromFile(TString& filename, const AliCDBId* dataId);
 
        Bool_t AddTag(TString& foldername, const char* tagname);
        Bool_t TagFileId(TString& filename, const AliCDBId* id);
        Bool_t TagFileMetaData(TString& filename, const AliCDBMetaData* md);
 
-//     Bool_t CheckVersion(const AliCDBId& query, AliCDBId* idToCheck, AliCDBId* result);
-
-       void MakeQueryFilter(Int_t firstRun, Int_t lastRun, const AliCDBPath& pathFilter, Int_t version,
-                               const AliCDBMetaData* md, TString& result) const;
+       void MakeQueryFilter(Int_t firstRun, Int_t lastRun, const AliCDBMetaData* md, TString& result) const;
 
        virtual void QueryValidFiles();
 
@@ -80,7 +77,6 @@ public:
 
        virtual Bool_t Validate(const char* gridString);
         virtual AliCDBParam* CreateParameter(const char* gridString);
-       virtual ~AliCDBGridFactory(){}
 
 protected:
         virtual AliCDBStorage* Create(const AliCDBParam* param);
index 2a7cfb58326b3e806906ae4c426871981f511143..d2929b6bce7d9a872e04cedd2cba54a0c4d1ddef 100644 (file)
@@ -188,7 +188,7 @@ AliCDBStorage* AliCDBManager::GetStorage(const AliCDBParam* param) {
                if (aStorage) {
                        PutActiveStorage(param->CloneParam(), aStorage);
                        aStorage->SetURI(param->GetURI());
-                       if(fRun > 0) {
+                       if(fRun >= 0) {
                                aStorage->QueryCDB(fRun);
                        }
                        return aStorage;
@@ -400,7 +400,7 @@ AliCDBEntry* AliCDBManager::Get(const AliCDBId& query) {
                 return NULL;
        }
 
-       if(fCache && query.GetFirstRun() != fRun) 
+       if(fCache && query.GetFirstRun() != fRun)
                AliWarning("Run number explicitly set in query: CDB cache temporarily disabled!");
 
        
@@ -496,7 +496,8 @@ TList* AliCDBManager::GetAll(const AliCDBId& query) {
        }       
         
        TObjString objStrLev0(query.GetLevel0());
-       AliCDBParam *aPar = (AliCDBParam*) fSpecificStorages.GetValue(&objStrLev0);
+       //AliCDBParam *aPar = (AliCDBParam*) fSpecificStorages.GetValue(&objStrLev0);
+       AliCDBParam *aPar=SelectSpecificStorage(query.GetPath());
 
        AliCDBStorage *aStorage;        
        if(aPar) {
@@ -663,7 +664,7 @@ void AliCDBManager::DestroyActiveStorage(AliCDBStorage* /*storage*/) {
                        delete fActiveStorages.Remove(aPair->Key());
                        storage->Delete(); storage=0x0;
        }
-*/     
+*/
 
 }
 
@@ -675,9 +676,15 @@ void AliCDBManager::QueryCDB() {
                AliError("Run number not yet set! Use AliCDBManager::SetRun.");
        return;
        }
-
-       AliInfo(Form("Querying default and specific storages for files valid for run %d", fRun));
-       fDefaultStorage->QueryCDB(fRun);
+       if (!fDefaultStorage){
+               AliError("Default storage is not set! Use AliCDBManager::SetDefaultStorage");
+       return;
+       }
+       if(fDefaultStorage->GetType() == "alien"){
+               fDefaultStorage->QueryCDB(fRun);
+       } else {
+               AliDebug(2,"Skipping query for valid files, it used only in grid...");
+       }
 
        TIter iter(&fSpecificStorages);
        TObjString *aCalibType=0;
@@ -686,11 +693,15 @@ void AliCDBManager::QueryCDB() {
                aPar = (AliCDBParam*) fSpecificStorages.GetValue(aCalibType);
                if(aPar) {
                        AliDebug(2,Form("Querying specific storage %s",aCalibType->GetName()));
-                       GetStorage(aPar)->QueryCDB(fRun,aCalibType->GetName());
-
+                       AliCDBStorage *aStorage = GetStorage(aPar);
+                       if(aStorage->GetType() == "alien"){
+                               aStorage->QueryCDB(fRun,aCalibType->GetName());
+                       } else {
+                               AliDebug(2,
+                                       "Skipping query for valid files, it is used only in grid...");
+                       }
                }
        }
-
 }
 
 
index 7b2316ffe03c3c3e977bc79874e65919085feec1..3e3a8880920936dd4ead50e58addc06f54d1fa26 100644 (file)
@@ -378,6 +378,9 @@ void AliCDBStorage::QueryCDB(Int_t run, const char* pathFilter,
 
        fVersion = version;
 
+       AliInfo(Form("Querying files valid for run %d and path \"%s\" into CDB storage  \"%s://%s\"",
+                               fRun, pathFilter, fType.Data(), fBaseFolder.Data()));
+
        // Clear fValidFileIds list (it cannot be filled twice!
        AliDebug(2, "Clearing list of CDB Id's previously loaded");
        fValidFileIds.Clear();
@@ -388,9 +391,7 @@ void AliCDBStorage::QueryCDB(Int_t run, const char* pathFilter,
        QueryValidFiles();
        AliCDBId queryId(pathFilter,run,run,version);
 
-       AliInfo(Form("%d files valid for request <%s> found in CDB storage \"%s://%s\"",
-                               fValidFileIds.GetEntries(), queryId.ToString().Data(),
-                               fType.Data(), fBaseFolder.Data()));
+       AliInfo(Form("%d valid files found!", fValidFileIds.GetEntriesFast()));
 
 }
 
@@ -413,7 +414,7 @@ void AliCDBStorage::PrintQueryCDB(){
        while ((anId = dynamic_cast<AliCDBId*>(iter.Next()))) {
                message += Form("\t%s\n", anId->ToString().Data());
        }
-       message += Form("\n\tTotal: %d objects found\n", fValidFileIds.GetEntries());
+       message += Form("\n\tTotal: %d objects found\n", fValidFileIds.GetEntriesFast());
        AliInfo(Form("%s", message.Data()));
 }
 
index cba746be5e9fe98fd5580ce2f2c9f9ab0e1f19f4..1fee0bc881a7e4a6b1723859407da19ff5124b12 100644 (file)
@@ -16,6 +16,7 @@
 #include "AliCDBMetaData.h"
 
 #include <TList.h>
+#include <TObjArray.h>
 
 class AliCDBEntry;
 class AliCDBPath;
@@ -84,7 +85,7 @@ public:
        void QueryCDB(Int_t run, const char* pathFilter="*",
                        Int_t version=-1, AliCDBMetaData *mdFilter=0);
        void PrintQueryCDB();
-       TList* GetQueryCDBList() {return &fValidFileIds;}
+       TObjArray* GetQueryCDBList() {return &fValidFileIds;}
 
        virtual Int_t GetLatestVersion(const char* path, Int_t run)=0;
        virtual Int_t GetLatestSubVersion(const char* path, Int_t run, Int_t version=-1)=0;
@@ -99,7 +100,7 @@ protected:
        virtual TList *GetIdListFromFile(const char* fileName)=0;
        virtual void   QueryValidFiles() = 0;
 
-       TList fValidFileIds;    // list of Id's of the files valid for a given run (cached as fRun)
+       TObjArray fValidFileIds;        // list of Id's of the files valid for a given run (cached as fRun)
        Int_t fRun;             // run number, used to manage list of valid files
        AliCDBPath fPathFilter; // path filter, used to manage list of valid files
        Int_t fVersion;         // version, used to manage list of valid files