Improved diagnostic messages. Different access strings for AliCDBGrid. New or renamed...
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Jan 2006 11:54:52 +0000 (11:54 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Jan 2006 11:54:52 +0000 (11:54 +0000)
12 files changed:
STEER/AliCDBDump.cxx
STEER/AliCDBDump.h
STEER/AliCDBGrid.cxx
STEER/AliCDBGrid.h
STEER/AliCDBId.cxx
STEER/AliCDBLocal.cxx
STEER/AliCDBLocal.h
STEER/AliCDBManager.cxx
STEER/AliCDBManager.h
STEER/AliCDBMetaData.h
STEER/AliCDBStorage.cxx
STEER/AliCDBStorage.h

index 552c6da..3bd1d76 100644 (file)
@@ -97,18 +97,18 @@ Bool_t AliCDBDump::IdToKeyName(const AliCDBRunRange& runRange, Int_t version,
 // build key name from AliCDBId data (run range, version, subVersion)
 
         if (!runRange.IsValid()) {
-                AliWarning(Form("Invalid run range <%d, %d>.",
+                AliDebug(2,Form("Invalid run range <%d, %d>.",
                         runRange.GetFirstRun(), runRange.GetLastRun()));
                 return kFALSE;
         }
 
         if (version < 0) {
-                AliWarning(Form("Invalid version <%d>.", version));
+                AliDebug(2,Form("Invalid version <%d>.", version));
                 return kFALSE;
         }
 
        if (subVersion < 0) {
-               AliWarning(Form("Invalid subversion <%s>.", subVersion));
+               AliDebug(2,Form("Invalid subversion <%s>.", subVersion));
                return kFALSE;
        }
     
@@ -181,7 +181,7 @@ Bool_t AliCDBDump::PrepareId(AliCDBId& id) {
        
                        if (!KeyNameToId(keyName, aRunRange, aVersion, 
                           aSubVersion)) {
-                               AliWarning(Form(
+                               AliDebug(2,Form(
                                        "Bad keyname <%s>!I'll skip it.", keyName));
                                continue;
                        }
@@ -206,7 +206,7 @@ Bool_t AliCDBDump::PrepareId(AliCDBId& id) {
        
                        if (!KeyNameToId(keyName, aRunRange, aVersion, 
                           aSubVersion)) {
-                               AliWarning(Form(
+                               AliDebug(2,Form(
                                        "Bad keyname <%s>!I'll skip it.", keyName));
                                continue;
                        }
@@ -233,7 +233,7 @@ Bool_t AliCDBDump::PrepareId(AliCDBId& id) {
 
        if(lastStorage.Contains(TString("new"), TString::kIgnoreCase) &&
           id.GetSubVersion() > 0 ){
-               AliWarning(Form("*** WARNING! a NEW object is being stored with version v%d_s%d",
+               AliWarning(Form("A NEW object is being stored with version v%d_s%d",
                                        id.GetVersion(),id.GetSubVersion()));
                AliWarning(Form("and it will hide previously stored object with v%d_s%d!",
                                        id.GetVersion(),id.GetSubVersion()-1));
@@ -545,12 +545,58 @@ Bool_t AliCDBDump::PutEntry(AliCDBEntry* entry) {
        }
 
         if(result) {
-               AliInfo(Form("AliCDBEntry stored into file %s",fFile->GetName()));
+               AliInfo(Form("CDB object stored into file %s",fFile->GetName()));
                AliInfo(Form("TDirectory/key name: %s/%s",id.GetPath().Data(),keyname.Data()));
         }
 
        return result;
 }
+//_____________________________________________________________________________
+TList* AliCDBDump::GetIdListFromFile(const char* fileName){
+
+       TString turl(fileName);
+       if (turl[0] != '/') {
+               turl.Prepend(TString(gSystem->WorkingDirectory()) + '/');
+       }
+       TFile *file = TFile::Open(turl);
+       if (!file) {
+               AliError(Form("Can't open selection file <%s>!", turl.Data()));
+               return NULL;
+       }
+       file->cd();
+
+       TList *list = new TList();
+       list->SetOwner();
+       int i=0;
+       TString keycycle;
+       
+       AliCDBId *id;
+       while(1){
+               i++;
+               keycycle = "AliCDBId;";
+               keycycle+=i;
+               
+               id = (AliCDBId*) file->Get(keycycle);
+               if(!id) break;
+               list->AddFirst(id);
+       }
+       file->Close(); delete file; file=0;     
+       return list;
+}
+
+//_____________________________________________________________________________
+Bool_t AliCDBDump::Contains(const char* path) const{
+// check for path in storage
+
+       TDirectory::TContext context(gDirectory, fFile);
+       if (!(fFile && fFile->IsOpen())) {
+                AliError("AliCDBDump storage is not initialized properly");
+                return kFALSE;
+        }
+       
+       return gDirectory->cd(path);
+
+}
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //                                                                                             //
@@ -594,8 +640,6 @@ AliCDBParam* AliCDBDumpFactory::CreateParameter(const char* dbString) {
                pathname.Prepend(TString(gSystem->WorkingDirectory()) + '/');
        }
 
-        AliInfo(pathname);
-
         return new AliCDBDumpParam(pathname, readOnly);
 }
 
index 1a483ce..9bd54a6 100644 (file)
@@ -24,12 +24,14 @@ public:
 
        virtual Bool_t IsReadOnly() const {return fReadOnly;};
        virtual Bool_t HasSubVersion() const {return kFALSE;};
+       virtual Bool_t Contains(const char* path) const;
 
 protected:
 
-       virtual AliCDBEntry* GetEntry(const AliCDBId& query);
-        virtual TList* GetEntries(const AliCDBId& query);
-        virtual Bool_t PutEntry(AliCDBEntry* entry);
+       virtual AliCDBEntry*    GetEntry(const AliCDBId& query);
+        virtual TList*                 GetEntries(const AliCDBId& query);
+        virtual Bool_t                 PutEntry(AliCDBEntry* entry);
+       virtual TList*          GetIdListFromFile(const char* fileName);
 
 private:
 
@@ -69,7 +71,6 @@ public:
 
         virtual Bool_t Validate(const char* dbString);
         virtual AliCDBParam* CreateParameter(const char* dbString);
-       virtual ~AliCDBDumpFactory() {}
 
 protected:
         virtual AliCDBStorage* Create(const AliCDBParam* param);
index 6a695d2..ddfd607 100644 (file)
 ClassImp(AliCDBGrid)
 
 //_____________________________________________________________________________
-AliCDBGrid::AliCDBGrid(const char *host, const Int_t port, 
-                       const char *user, const char *dbPath, const char *se) :
+AliCDBGrid::AliCDBGrid(const char *gridUrl, const char *user, const char *dbFolder, const char *se) :
 AliCDBStorage(),
-fHost(host),
-fPort(port),
+fGridUrl(gridUrl),
 fUser(user),
-fDBPath(dbPath),
+fDBFolder(dbFolder),
 fSE(se)
 {
 // constructor //
 
-       TString grid="alien://";
-       grid+=host; grid+=":"; grid+=port;
-
        // if the same Grid is alreay active, skip connection
-       if (!gGrid || TString(host) != gGrid->GetHost() || 
-           port != gGrid->GetPort() || TString(user) != gGrid->GetUser()) {
+       if (!gGrid || fGridUrl != gGrid->GridUrl()  
+            || fUser != gGrid->GetUser()) {
                // connection to the Grid
-               TGrid::Connect(grid.Data(),fUser.Data());
+               TGrid::Connect(fGridUrl.Data(),fUser.Data());
        }
 
        if(!gGrid) {
@@ -66,23 +61,23 @@ fSE(se)
        }
 
        TString initDir(gGrid->Pwd(0));
-       if (fDBPath[0] != '/') {
-               fDBPath.Prepend(initDir);
+       if (fDBFolder[0] != '/') {
+               fDBFolder.Prepend(initDir);
        }
 
        // check DBFolder: trying to cd to DBFolder; if it does not exist, create it
-       if(!gGrid->Cd(fDBPath.Data(),0)){
-               AliDebug(2,Form("Creating new folder <%s> ...",fDBPath.Data()));
-               if(!gGrid->Mkdir(fDBPath.Data(),"",0)){
-                       AliError(Form("Cannot create folder <%s> !",fDBPath.Data())); 
+       if(!gGrid->Cd(fDBFolder.Data(),0)){
+               AliDebug(2,Form("Creating new folder <%s> ...",fDBFolder.Data()));
+               if(!gGrid->Mkdir(fDBFolder.Data(),"",0)){
+                       AliError(Form("Cannot create folder <%s> !",fDBFolder.Data())); 
                }
        } else {
-               AliDebug(2,Form("Folder <%s> found",fDBPath.Data()));
+               AliDebug(2,Form("Folder <%s> found",fDBFolder.Data()));
        }
 
        // removes any '/' at the end of path, then append one '/'
-       while(fDBPath.EndsWith("/")) fDBPath.Remove(fDBPath.Last('/')); 
-       fDBPath+="/";
+       while(fDBFolder.EndsWith("/")) fDBFolder.Remove(fDBFolder.Last('/')); 
+       fDBFolder+="/";
 
        // return to the initial directory
        gGrid->Cd(initDir.Data(),0);
@@ -133,13 +128,13 @@ Bool_t AliCDBGrid::IdToFilename(const AliCDBRunRange& runRange, Int_t gridVersio
 // build file name from AliCDBId data (run range, version)
 
        if (!runRange.IsValid()) {
-               AliWarning(Form("Invalid run range <%d, %d>.", 
+               AliDebug(2,Form("Invalid run range <%d, %d>.", 
                        runRange.GetFirstRun(), runRange.GetLastRun()));
                return kFALSE;
        }
 
        if (gridVersion < 0) {
-               AliWarning(Form("Invalid version <%d>.", gridVersion));
+               AliDebug(2,Form("Invalid version <%d>.", gridVersion));
                 return kFALSE;
        }
  
@@ -161,7 +156,7 @@ Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
        TString initDir(gGrid->Pwd(0));
        TString pathName= id.GetPath();
 
-       TString dirName(fDBPath);
+       TString dirName(fDBFolder);
 
        Bool_t dirExist=kFALSE;
  
@@ -172,7 +167,7 @@ Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
                dirName+=buffer; dirName+="/";
                dirExist=gGrid->Cd(dirName,0);
                if (!dirExist) {
-                       AliInfo(Form("Creating new folder <%s> ...",dirName.Data()));
+                       AliDebug(2,Form("Creating new folder <%s> ...",dirName.Data()));
                        if(!gGrid->Mkdir(dirName,"",0)){
                                AliError(Form("Cannot create directory <%s> !",dirName.Data()));
                                gGrid->Cd(initDir.Data());
@@ -207,7 +202,7 @@ Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
 
        TString lastStorage = id.GetLastStorage();
        if(lastStorage.Contains(TString("new"), TString::kIgnoreCase) && id.GetVersion() > 1 ){
-               AliWarning(Form("*** WARNING! a NEW object is being stored with version %d",
+               AliWarning(Form("A NEW object is being stored with version %d",
                                        id.GetVersion()));
                AliWarning(Form("and it will hide previously stored object with version %d!",
                                        id.GetVersion()-1));
@@ -228,12 +223,12 @@ AliCDBId AliCDBGrid::GetId(const AliCDBId& query) {
 
        AliCDBId result(query.GetAliCDBPath(), -1, -1, -1, -1);
 
-       TString dirName(fDBPath);
-       dirName += query.GetPath(); // dirName = fDBPath/idPath
+       TString dirName(fDBFolder);
+       dirName += query.GetPath(); // dirName = fDBFolder/idPath
 
        if (!gGrid->Cd(dirName,0)) {
                AliError(Form("Directory <%s> not found", (query.GetPath()).Data()));
-               AliError(Form("in DB folder %s", fDBPath.Data()));
+               AliError(Form("in DB folder %s", fDBFolder.Data()));
                return result;
        }
  
@@ -305,7 +300,7 @@ AliCDBEntry* AliCDBGrid::GetEntry(const AliCDBId& queryId) {
                return NULL;
        }
 
-       filename.Prepend("/alien" + fDBPath + queryId.GetPath() + '/');
+       filename.Prepend("/alien" + fDBFolder + queryId.GetPath() + '/');
        filename += "?se="; filename += fSE.Data(); 
 
        AliInfo(Form("Opening file: %s",filename.Data()));
@@ -354,7 +349,7 @@ void AliCDBGrid::GetEntriesForLevel0(const char* level0,
        const AliCDBId& queryId, TList* result) {
 // multiple request (AliCDBStorage::GetAll)
 
-       TString level0Dir=fDBPath;
+       TString level0Dir=fDBFolder;
        level0Dir += level0;
 
        if (!gGrid->Cd(level0Dir,0)) {
@@ -377,7 +372,7 @@ void AliCDBGrid::GetEntriesForLevel1(const char* level0, const char* level1,
        const AliCDBId& queryId, TList* result) {
 // multiple request (AliCDBStorage::GetAll)
 
-       TString level1Dir=fDBPath;
+       TString level1Dir=fDBFolder;
        level1Dir += level0;
        level1Dir += '/';
        level1Dir += level1;
@@ -415,7 +410,7 @@ TList* AliCDBGrid::GetEntries(const AliCDBId& queryId) {
 
        TString initDir(gGrid->Pwd(0));
 
-       TGridResult *res = gGrid->Ls(fDBPath);
+       TGridResult *res = gGrid->Ls(fDBFolder);
        TString level0;
 
        for(int i=0; i < res->GetEntries(); i++){
@@ -445,7 +440,7 @@ Bool_t AliCDBGrid::PutEntry(AliCDBEntry* entry) {
                return kFALSE;
        } 
 
-       filename.Prepend("/alien" + fDBPath + id.GetPath() + '/');
+       filename.Prepend("/alien" + fDBFolder + id.GetPath() + '/');
        TString filenameCopy(filename);
        filename += "?se="; filename += fSE.Data(); 
  
@@ -471,13 +466,60 @@ Bool_t AliCDBGrid::PutEntry(AliCDBEntry* entry) {
        if (saveDir) saveDir->cd(); else gROOT->cd();
        file->Close(); delete file; file=0;
        if(result) {
-               AliInfo(Form("AliCDBEntry stored into file %s",filenameCopy.Data()));
+               AliInfo(Form("CDB object stored into file %s",filenameCopy.Data()));
                AliInfo(Form("using S.E. %s", fSE.Data()));
        }
  
        return result;
 }
 
+//_____________________________________________________________________________
+TList* AliCDBGrid::GetIdListFromFile(const char* fileName){
+
+       TString turl(fileName);
+       turl.Prepend("/alien" + fDBFolder);
+       turl += "?se="; turl += fSE.Data(); 
+       TFile *file = TFile::Open(turl);
+       if (!file) {
+               AliError(Form("Can't open selection file <%s>!", turl.Data()));
+               return NULL;
+       }
+
+       TList *list = new TList();
+       list->SetOwner();
+       int i=0;
+       TString keycycle;
+       
+       AliCDBId *id;
+       while(1){
+               i++;
+               keycycle = "AliCDBId;";
+               keycycle+=i;
+               
+               id = (AliCDBId*) file->Get(keycycle);
+               if(!id) break;
+               list->AddFirst(id);
+       }
+       file->Close(); delete file; file=0;
+       
+       return list;
+
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliCDBGrid::Contains(const char* path) const{
+// check for path in storage's DBFolder
+
+       TString initDir(gGrid->Pwd(0));
+       TString dirName(fDBFolder);
+       dirName += path; // dirName = fDBFolder/path
+       Bool_t result=kFALSE;
+       if (gGrid->Cd(dirName,0)) result=kTRUE;
+       gGrid->Cd(initDir.Data(),0);
+       return result;
+}
+
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //                                                                                             //
 // AliCDBGrid factory                                                                                 //
@@ -493,7 +535,8 @@ Bool_t AliCDBGridFactory::Validate(const char* gridString) {
        // pattern: alien://hostName:Port;user;dbPath;SE
        // example of a valid pattern:
        // "alien://aliendb4.cern.ch:9000;colla;DBTest;ALICE::CERN::Server"
-        TRegexp gridPattern("^alien://.+:[0-9]+;[a-zA-Z0-9_-.]+;.+;.+$");
+//        TRegexp gridPattern("^alien://.+:[0-9]+;[a-zA-Z0-9_-.]+;.+;.+$");
+        TRegexp gridPattern("^alien://.+$");
 
         return TString(gridString).Contains(gridPattern);
 }
@@ -505,24 +548,58 @@ AliCDBParam* AliCDBGridFactory::CreateParameter(const char* gridString) {
        if (!Validate(gridString)) {
                return NULL;
        }
-       TString buffer(gridString + sizeof("alien://") - 1);
-       TString host = buffer(0,buffer.First(':')); // host (ex. aliendb4.cern.ch)
-       buffer = buffer(host.Sizeof(),buffer.Sizeof());
-       TString strPort = buffer(0, buffer.First(';'));
-       Int_t port = atoi(strPort.Data());      // port number (ex. 9000)
-       buffer = buffer(strPort.Sizeof(),buffer.Sizeof());
-       TString user = buffer(0,buffer.First(';')); // user (ex. colla)
-       buffer = buffer(user.Sizeof(),buffer.Sizeof());
-       TString dbPath = buffer(0,buffer.First(';')); // DB path (ex. /alice/cern.ch/user/c/colla/DB)
-       TString se = buffer(dbPath.Sizeof(),buffer.Sizeof()); // storage element (ex. ALICE::CERN::Server)
+       //TString buffer(gridString + sizeof("alien://") - 1);
+       TString buffer(gridString);
+       TString gridUrl         = "alien://"; 
+       TString user            = "";
+       TString dbFolder        = "DBGrid";
+       TString se              = "ALICE::CERN::se01";
+
+       TObjArray *arr = buffer.Tokenize('?');
+       TIter iter(arr);
+       TObjString *str;
        
-       AliInfo(Form("host: %s",host.Data()));
-       AliInfo(Form("port: %d",port));
-       AliInfo(Form("user: %s",user.Data()));
-       AliInfo(Form("dbPath: %s",dbPath.Data()));
-       AliInfo(Form("s.e.: %s",se.Data()));
+       while((str = (TObjString*) iter.Next())){
+               TString entry(str->String());
+               Int_t indeq = entry.Index('=');
+               if(indeq == -1) {
+                       if(entry.BeginsWith("alien://")) { // maybe it's a gridUrl!
+                               gridUrl = entry;
+                               continue;
+                       } else {
+                               AliError(Form("Invalid entry! %s",entry.Data()));
+                               continue;
+                       }
+               }
+               
+               TString key = entry(0,indeq);
+               TString value = entry(indeq+1,entry.Length()-indeq);
+
+               if(key.Contains("grid",TString::kIgnoreCase)) {
+                       gridUrl += value;
+               } 
+               else if (key.Contains("user",TString::kIgnoreCase)){
+                       user = value;
+               }
+               else if (key.Contains("folder",TString::kIgnoreCase)){
+                       dbFolder = value;
+               }
+               else if (key.Contains("se",TString::kIgnoreCase)){
+                       se = value;
+               }
+               else{
+                       AliError(Form("Invalid entry! %s",entry.Data()));
+               }
+       }
+       delete arr; arr=0;
+               
+       AliInfo(Form("gridUrl:  %s",gridUrl.Data()));
+       AliInfo(Form("user:     %s",user.Data()));
+       AliInfo(Form("dbFolder: %s",dbFolder.Data()));
+       AliInfo(Form("s.e.:     %s",se.Data()));
 
-       return new AliCDBGridParam(host, port, user, dbPath, se);       
+       return new AliCDBGridParam(gridUrl, user, dbFolder, se);       
 }
 
 //_____________________________________________________________________________
@@ -532,8 +609,8 @@ AliCDBStorage* AliCDBGridFactory::Create(const AliCDBParam* param) {
        if (AliCDBGridParam::Class() == param->IsA()) {
                
                const AliCDBGridParam* gridParam = (const AliCDBGridParam*) param;
-               AliCDBGrid *grid = new AliCDBGrid(gridParam->GetHost(), gridParam->GetPort(), 
-                                     gridParam->GetUser(), gridParam->GetPath(),
+               AliCDBGrid *grid = new AliCDBGrid(gridParam->GridUrl(), 
+                                     gridParam->GetUser(), gridParam->GetDBFolder(),
                                      gridParam->GetSE()); 
 
                if(gGrid) return grid;
@@ -557,25 +634,24 @@ AliCDBGridParam::AliCDBGridParam() {
 }
 
 //_____________________________________________________________________________
-AliCDBGridParam::AliCDBGridParam(const char* host, 
-                               const Int_t port, 
+AliCDBGridParam::AliCDBGridParam(const char* gridUrl, 
                                const char* user, 
-                               const char* dbPath, 
+                               const char* dbFolder, 
                                const char* se):
- fHost(host),
- fPort(port),
+ fGridUrl(gridUrl),
  fUser(user),
- fDBPath(dbPath),
+ fDBFolder(dbFolder),
  fSE(se)
 {
 // constructor
        
        SetType("alien");
 
-       TString uri=("alien://");
-       uri+=host; uri+=":"; uri+=port; uri+=";";
-       uri+=user; uri+=";"; uri+=dbPath; uri+=";";
-       uri+=se;
+       TString uri;
+       uri+=fGridUrl; uri+="?";
+       uri+="User=";   uri+=fUser; uri+="?"; 
+       uri+="DBFolder="; uri+=fDBFolder; uri+="?";
+       uri+="SE=";     uri+=fSE;
        
        SetURI(uri);
 }
@@ -590,14 +666,14 @@ AliCDBGridParam::~AliCDBGridParam() {
 AliCDBParam* AliCDBGridParam::CloneParam() const {
 // clone parameter
 
-        return new AliCDBGridParam(fHost, fPort, fUser, fDBPath, fSE);
+        return new AliCDBGridParam(fGridUrl, fUser, fDBFolder, fSE);
 }
 
 //_____________________________________________________________________________
 ULong_t AliCDBGridParam::Hash() const {
 // return Hash function
 
-        return fHost.Hash()+fPort+fUser.Hash()+fDBPath.Hash()+fSE.Hash();
+        return fGridUrl.Hash()+fUser.Hash()+fDBFolder.Hash()+fSE.Hash();
 }
 
 //_____________________________________________________________________________
@@ -614,10 +690,9 @@ Bool_t AliCDBGridParam::IsEqual(const TObject* obj) const {
 
         AliCDBGridParam* other = (AliCDBGridParam*) obj;
 
-        if(fHost != other->fHost) return kFALSE;
-        if(fPort != other->fPort) return kFALSE;
+        if(fGridUrl != other->fGridUrl) return kFALSE;
         if(fUser != other->fUser) return kFALSE;
-        if(fDBPath != other->fDBPath) return kFALSE;
+        if(fDBFolder != other->fDBFolder) return kFALSE;
         if(fSE != other->fSE) return kFALSE;
        return kTRUE;
 }
index 7deb140..859f8a0 100644 (file)
@@ -7,7 +7,7 @@
 /////////////////////////////////////////////////////////////////////
 //                                                                 //
 //  class AliCDBGrid                                              //
-//  access class to a DataBase in an AliEn storage                //
+//  access class to a DataBase in an AliEn storage                //
 //                                                                 //
 /////////////////////////////////////////////////////////////////////
 
@@ -21,20 +21,18 @@ public:
                  
        virtual Bool_t IsReadOnly() const {return kFALSE;};
        virtual Bool_t HasSubVersion() const {return kFALSE;};
+       virtual Bool_t Contains(const char* path) const;
   
 protected:
 
        virtual AliCDBEntry*    GetEntry(const AliCDBId& queryId);
        virtual TList*          GetEntries(const AliCDBId& queryId);
        virtual Bool_t          PutEntry(AliCDBEntry* entry);
+       virtual TList*          GetIdListFromFile(const char* fileName);
 
 private:
  
-       AliCDBGrid(const char *host="aliendb4.cern.ch", 
-               const Int_t port = 9000, 
-               const char *user="colla", 
-               const char* dbPath = "/alice/cern.ch/user/c/colla/DB", 
-               const char *SE="ALICE::CERN::Server");
+       AliCDBGrid(const char *gridUrl, const char *user, const char* dbFolder, const char *se);
 
        virtual ~AliCDBGrid();
 
@@ -52,10 +50,9 @@ private:
        void GetEntriesForLevel1(const char* level0, const char* level1, 
                                 const AliCDBId& query, TList* result);
 
-       TString    fHost;       // Grid host
-       Int_t      fPort;       // port
+       TString    fGridUrl;    // Grid Url ("alien://aliendb4.cern.ch:9000")
        TString    fUser;       // User
-       TString    fDBPath;     // path of the DB folder
+       TString    fDBFolder;   // path of the DB folder
        TString    fSE;         // Storage Element 
 
 ClassDef(AliCDBGrid, 0)      // access class to a DataBase in an AliEn storage 
@@ -90,15 +87,14 @@ class AliCDBGridParam: public AliCDBParam {
        
 public:
        AliCDBGridParam();
-       AliCDBGridParam(const char* host, Int_t port, const char* user, 
-                       const char* dbPath, const char* se);
+       AliCDBGridParam(const char* gridUrl, const char* user, 
+                       const char* dbFolder, const char* se);
        
        virtual ~AliCDBGridParam();
 
-       const TString& GetHost() const {return fHost;};
-       const Int_t&   GetPort() const {return fPort;};
+       const TString& GridUrl() const {return fGridUrl;};
        const TString& GetUser() const {return fUser;};
-       const TString& GetPath() const {return fDBPath;};
+       const TString& GetDBFolder() const {return fDBFolder;};
        const TString& GetSE()   const {return fSE;};
 
        virtual AliCDBParam* CloneParam() const;
@@ -107,10 +103,9 @@ public:
         virtual Bool_t IsEqual(const TObject* obj) const;
 
 private:
-       TString fHost;       // Grid host
-       Int_t   fPort;       // port
+       TString fGridUrl;    // Grid url "Host:port"
        TString fUser;       // User
-       TString fDBPath;     // path of the DB folder
+       TString fDBFolder;   // path of the DB folder
        TString fSE;         // Storage Element 
 
        ClassDef(AliCDBGridParam, 0);
index 218fe54..f152353 100644 (file)
@@ -99,18 +99,16 @@ TString AliCDBId::ToString() const {
 // returns a string of Id data
 
        TString result;
-       result += "Path \"";
+       result += "path \"";
        result += GetPath();
-       result += "\"; RunRange [";
+       result += "\"; run range [";
        result += GetFirstRun();
        result += ",";
        result += GetLastRun();
-       result += "]; Version v";
+       result += "]; version v";
        result += GetVersion();
        result += "_s";
        result += GetSubVersion();
-       result += "; Previous storage ";
-       result += fLastStorage;
        
        return result;  
 }
index dca9b9a..233596d 100644 (file)
@@ -101,18 +101,18 @@ Bool_t AliCDBLocal::IdToFilename(const AliCDBRunRange& runRange, Int_t version,
 // build file name from AliCDBId data (run range, version, subVersion)
 
        if (!runRange.IsValid()) {
-               AliWarning(Form("Invalid run range <%d, %d>.", 
+               AliDebug(2,Form("Invalid run range <%d, %d>.", 
                        runRange.GetFirstRun(), runRange.GetLastRun()));
                return kFALSE;
        }
 
        if (version < 0) {
-               AliWarning(Form("Invalid version <%d>.", version));
+               AliDebug(2,Form("Invalid version <%d>.", version));
                 return kFALSE;
        }
 
        if (subVersion < 0) {
-               AliWarning(Form("Invalid subversion <%s>.", subVersion));
+               AliDebug(2,Form("Invalid subversion <%s>.", subVersion));
                return kFALSE;
        }
  
@@ -166,7 +166,7 @@ Bool_t AliCDBLocal::PrepareId(AliCDBId& id) {
        
                        if (!FilenameToId(filename, aRunRange, aVersion, 
                                aSubVersion)) {
-                               AliWarning(Form(
+                               AliDebug(2,Form(
                                        "Bad filename <%s>! I'll skip it.", 
                                        filename));
                                continue;
@@ -195,7 +195,7 @@ Bool_t AliCDBLocal::PrepareId(AliCDBId& id) {
 
                        if (!FilenameToId(filename, aRunRange, aVersion, 
                                aSubVersion)) {
-                               AliWarning(Form(
+                               AliDebug(2,Form(
                                        "Bad filename <%s>!I'll skip it.",
                                        filename));     
                                continue;
@@ -225,7 +225,7 @@ Bool_t AliCDBLocal::PrepareId(AliCDBId& id) {
 
        if(lastStorage.Contains(TString("new"), TString::kIgnoreCase) &&
           id.GetSubVersion() > 0 ){
-               AliWarning(Form("*** WARNING! a NEW object is being stored with version v%d_s%d",
+               AliWarning(Form("A NEW object is being stored with version v%d_s%d",
                                        id.GetVersion(),id.GetSubVersion()));
                AliWarning(Form("and it will hide previously stored object with v%d_s%d!",
                                        id.GetVersion(),id.GetSubVersion()-1));
@@ -582,7 +582,55 @@ Bool_t AliCDBLocal::PutEntry(AliCDBEntry* entry) {
        if (!result) AliError(Form("Can't write entry to file: %s", filename.Data()));
 
        file.Close();
-        if(result) AliInfo(Form("AliCDBEntry stored into file %s",filename.Data()));
+        if(result) AliInfo(Form("CDB object stored into file %s",filename.Data()));
+
+       return result;
+}
+
+//_____________________________________________________________________________
+TList* AliCDBLocal::GetIdListFromFile(const char* fileName){
+
+       TString fullFileName(fileName);
+       fullFileName.Prepend(fBaseDirectory+'/');
+       TFile *file = TFile::Open(fullFileName);
+       if (!file) {
+               AliError(Form("Can't open selection file <%s>!", fullFileName.Data()));
+               return NULL;
+       }
+       file->cd();
+
+       TList *list = new TList();
+       list->SetOwner();
+       int i=0;
+       TString keycycle;
+       
+       AliCDBId *id;
+       while(1){
+               i++;
+               keycycle = "AliCDBId;";
+               keycycle+=i;
+               
+               id = (AliCDBId*) file->Get(keycycle);
+               if(!id) break;
+               list->AddFirst(id);
+       }
+       file->Close(); delete file; file=0;     
+       return list;
+}
+
+//_____________________________________________________________________________
+Bool_t AliCDBLocal::Contains(const char* path) const{
+// check for path in storage's fBaseDirectory
+
+       TString dirName;
+       dirName += fBaseDirectory;
+       dirName += '/';
+       dirName += path; // dirName = fDBPath/path
+       Bool_t result=kFALSE;
+
+       void* dirPtr = gSystem->OpenDirectory(dirName); 
+       if (dirPtr) result=kTRUE;
+       gSystem->FreeDirectory(dirPtr);
 
        return result;
 }
@@ -620,8 +668,6 @@ AliCDBParam* AliCDBLocalFactory::CreateParameter(const char* dbString) {
                pathname.Prepend(TString(gSystem->WorkingDirectory()) + '/');
        }
 
-       AliInfo(pathname);
-
        return new AliCDBLocalParam(pathname);       
 }
 
index 00b11ec..d6f46df 100644 (file)
@@ -21,12 +21,14 @@ public:
 
        virtual Bool_t IsReadOnly() const {return kFALSE;};
        virtual Bool_t HasSubVersion() const {return kTRUE;};
+       virtual Bool_t Contains(const char* path) const;
 
 protected:
 
        virtual AliCDBEntry* GetEntry(const AliCDBId& queryId);
         virtual TList* GetEntries(const AliCDBId& queryId);
         virtual Bool_t PutEntry(AliCDBEntry* entry);
+       virtual TList*          GetIdListFromFile(const char* fileName);
 
 private:
 
index 69782ad..fb9fb84 100644 (file)
@@ -82,6 +82,8 @@ AliCDBManager::AliCDBManager():
 AliCDBManager::~AliCDBManager() {
 // destructor
        DestroyActiveStorages();
+       fDrainStorage = 0x0;
+       fDefaultStorage = 0x0;
 }
 
 //_____________________________________________________________________________
@@ -238,17 +240,9 @@ Bool_t AliCDBManager::Drain(AliCDBEntry *entry) {
 }
 
 //_____________________________________________________________________________
-void AliCDBManager::RemoveDrain() {
-// remove drain storage
-
-       fDrainStorage=0;
-}
-
-//_____________________________________________________________________________
 void AliCDBManager::SetDefaultStorage(const char* dbString) {
 // sets default storage from URI string
 
-       if(fDefaultStorage) fDefaultStorage = 0;
        fDefaultStorage = GetStorage(dbString); 
 }
 
@@ -256,7 +250,6 @@ void AliCDBManager::SetDefaultStorage(const char* dbString) {
 void AliCDBManager::SetDefaultStorage(const AliCDBParam* param) {
 // set default storage from AliCDBParam object
        
-       if(fDefaultStorage) fDefaultStorage = 0;
        fDrainStorage = GetStorage(param);
 }
 
@@ -264,16 +257,9 @@ void AliCDBManager::SetDefaultStorage(const AliCDBParam* param) {
 void AliCDBManager::SetDefaultStorage(AliCDBStorage* storage) {
 // set default storage from another active storage
        
-       if(fDefaultStorage) fDefaultStorage = 0;
        fDefaultStorage = storage;
 }
 
-//_____________________________________________________________________________
-void AliCDBManager::RemoveDefaultStorage() {
-// remove default storage
-
-       fDefaultStorage = 0;
-}
 
 //_____________________________________________________________________________
 void AliCDBManager::DestroyActiveStorages() {
@@ -284,7 +270,17 @@ void AliCDBManager::DestroyActiveStorages() {
 
 //_____________________________________________________________________________
 void AliCDBManager::DestroyActiveStorage(AliCDBStorage* /*storage*/) {
-// destroys active storage (not implemented)
+// destroys active storage
+
+/*
+       TIter iter(fActiveStorages.GetTable()); 
+       TPair* aPair;
+       while ((aPair = (TPair*) iter.Next())) {
+               if(storage == (AliCDBStorage*) aPair->Value())
+                       delete fActiveStorages.Remove(aPair->Key());
+                       storage->Delete(); storage=0x0;
+       }
+*/     
 
 }
 
index b0fb2ee..cbfdd66 100644 (file)
@@ -42,7 +42,7 @@ class AliCDBManager: public TObject {
        
        AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
 
-       void RemoveDefaultStorage();
+       void UnsetDefaultStorage() {fDefaultStorage = 0x0;}
 
        void SetDrain(const char* dbString);
        void SetDrain(const AliCDBParam* param);
@@ -52,7 +52,7 @@ class AliCDBManager: public TObject {
 
        Bool_t Drain(AliCDBEntry* entry);
 
-       void RemoveDrain();
+       void UnsetDrain(){fDrainStorage = 0x0;}
 
        void DestroyActiveStorages();
        void DestroyActiveStorage(AliCDBStorage* storage);
@@ -60,7 +60,7 @@ class AliCDBManager: public TObject {
        static void Destroy();
        ~AliCDBManager();
 
-       static AliCDBManager* Instance();
+       static AliCDBManager* Instance(); 
 
  private:
                
@@ -72,10 +72,10 @@ class AliCDBManager: public TObject {
 
        void Init();
        
-       TList fFactories;               // list of registered storage factories
-       TMap fActiveStorages;           // list of active storages
-       AliCDBStorage *fDefaultStorage; // pointer to default storage
-       AliCDBStorage *fDrainStorage;   // pointer to drain storage
+       TList fFactories;               //! list of registered storage factories
+       TMap fActiveStorages;           //! list of active storages
+       AliCDBStorage *fDefaultStorage; //! pointer to default storage
+       AliCDBStorage *fDrainStorage;   //! pointer to drain storage
 
        ClassDef(AliCDBManager, 0);
 };
@@ -93,8 +93,7 @@ class AliCDBStorageFactory: public TObject {
        
 public:
        virtual Bool_t Validate(const char* dbString) = 0;
-       virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
-       virtual ~AliCDBStorageFactory(){}
+       virtual AliCDBParam* CreateParameter(const char* dbString) = 0; 
 
 protected:
        virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
@@ -127,8 +126,8 @@ protected:
 
 private:
 
-       TString fType; // CDB type?
-       TString fURI;  // CDB URI?
+       TString fType; // CDB type
+       TString fURI;  // CDB URI
 
        ClassDef(AliCDBParam, 0);
 };
index 264bb02..36b9f99 100644 (file)
@@ -56,7 +56,7 @@ private:
 
        TString fObjectClassName;       // object's class name
        TString fResponsible;           // object's responsible person
-       UInt_t fBeamPeriod;             // beam period
+       UInt_t  fBeamPeriod;            // beam period
        TString fAliRootVersion;        // AliRoot version
        TString fComment;               // extra comments
        //TList fCalibRuns;             
index 8e881d1..37648c2 100644 (file)
@@ -13,6 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+#include <TKey.h>
 #include "AliCDBManager.h"
 #include "AliCDBStorage.h"
 
@@ -45,7 +46,7 @@ AliCDBId AliCDBStorage::GetSelection(const AliCDBId& id) {
        while ((aSelection = (AliCDBId*) iter.Next())) {
                // check if selection element contains id's path and run (range) 
                if (aSelection->Comprises(id)) {
-                       AliInfo(Form("Using selection criterion: %s ", aSelection->ToString().Data()));
+                       AliDebug(2,Form("Using selection criterion: %s ", aSelection->ToString().Data()));
                        // return required version and subversion
                        return AliCDBId(id.GetAliCDBPath(), 
                                id.GetAliCDBRunRange(),
@@ -55,11 +56,36 @@ AliCDBId AliCDBStorage::GetSelection(const AliCDBId& id) {
        }
        
        // no valid element is found in the list of selection criteria -> return
-       AliInfo("No matching selection criteria: highest version will be seeked!");
+       AliDebug(2,"Looking for objects with most recent version");
        return AliCDBId(id.GetAliCDBPath(), id.GetAliCDBRunRange());
 }
 
 //_____________________________________________________________________________
+void AliCDBStorage::ReadSelectionFromFile(const char *fileName){
+// read selection criteria list from file
+       
+       RemoveAllSelections();
+       
+       TList *list = GetIdListFromFile(fileName);
+       if(!list) return;
+       
+       list->SetOwner();       
+       Int_t nId = list->GetEntries();
+       AliCDBId *id;
+       TKey *key;
+       
+       for(int i=nId-1;i>=0;i--){
+               key = (TKey*) list->At(i);
+               id = (AliCDBId*) key->ReadObj();
+               if(id) AddSelection(*id);
+       }
+       delete list;
+       AliInfo(Form("Selection criteria list filled with %d entries",fSelections.GetEntries()));
+       PrintSelectionList();
+       
+}
+
+//_____________________________________________________________________________
 void AliCDBStorage::AddSelection(const AliCDBId& selection) {
 // add a selection criterion
 
@@ -176,9 +202,9 @@ AliCDBEntry* AliCDBStorage::Get(const AliCDBId& query) {
        AliCDBEntry* entry = GetEntry(query);
                
        if (entry) {
-               AliInfo(Form("Valid AliCDBEntry object found! %s", entry->GetId().ToString().Data()));
+               AliInfo(Form("CDB object retrieved: %s", entry->GetId().ToString().Data()));
        } else {
-               AliInfo(Form("Sorry, found no object valid for: name = <%s>, run = %d", 
+               AliInfo(Form("No valid CDB object found! request was: name = <%s>, run = %d", 
                        (query.GetPath()).Data(), query.GetFirstRun()));
        }
        
@@ -226,15 +252,15 @@ TList* AliCDBStorage::GetAll(const AliCDBId& query) {
 
        Int_t nEntries = result->GetEntries();
        if (nEntries) {
-                AliInfo(Form("%d AliCDBEntry objects found!",nEntries));
+                AliInfo(Form("%d AliCDBEntry objects retrieved.",nEntries));
                 for(int i=0; i<nEntries;i++){
                        AliCDBEntry *entry = (AliCDBEntry*) result->At(i);
                        AliInfo(Form("%s",entry->GetId().ToString().Data()));
                 
                 }
        } else {
-                AliInfo(Form("Sorry, found no object valid for: name = <%s>, run = %d", 
-                       (query.GetPath()).Data(), query.GetFirstRun()));
+                AliInfo(Form("No valid CDB object found! request was: name = <%s>, run = %d, version = %d", 
+                       (query.GetPath()).Data(), query.GetFirstRun(), query.GetVersion()));
        }
 
        // if drain storage is set, drain entries into drain storage
index 9e34602..1b8e9ba 100644 (file)
@@ -23,9 +23,9 @@ class AliCDBStorage: public TObject {
 
 public:
        AliCDBStorage();
-       virtual ~AliCDBStorage();       
-
 
+       void ReadSelectionFromFile(const char *fileName);
+       
        void AddSelection(const AliCDBId& selection);
 
        void AddSelection(const AliCDBPath& path, 
@@ -73,12 +73,16 @@ public:
        virtual Bool_t IsReadOnly() const = 0;
        virtual Bool_t HasSubVersion() const = 0;
 
+       virtual Bool_t Contains(const char* path) const = 0;
+
 protected:
                
+       virtual ~AliCDBStorage();       
        AliCDBId GetSelection(const AliCDBId& id);
        virtual AliCDBEntry* GetEntry(const AliCDBId& query) = 0;
        virtual TList* GetEntries(const AliCDBId& query) = 0;
        virtual Bool_t PutEntry(AliCDBEntry* entry) = 0; 
+       virtual TList *GetIdListFromFile(const char* fileName)=0;
 
 private: