]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
moving the mirrorSEs datamember to AliCDBGrid
authorrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 4 Sep 2012 10:03:19 +0000 (10:03 +0000)
committerrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 4 Sep 2012 10:03:19 +0000 (10:03 +0000)
STEER/CDB/AliCDBGrid.cxx
STEER/CDB/AliCDBGrid.h
STEER/CDB/AliCDBManager.cxx
STEER/CDB/AliCDBManager.h
STEER/CDB/AliCDBStorage.cxx
STEER/CDB/AliCDBStorage.h

index 85d63b64e367e749ef5389389c0c091ec7fdf5f8..55341b90c01cde3eceb444e77fdfcbb1219aab6d 100644 (file)
@@ -49,6 +49,7 @@ fGridUrl(gridUrl),
 fUser(user),
 fDBFolder(dbFolder),
 fSE(se),
+fMirrorSEs(""),
 fCacheFolder(cacheFolder),
 fOperateDisconnected(operateDisconnected),
 fCacheSize(cacheSize),
@@ -732,9 +733,11 @@ Bool_t AliCDBGrid::PutEntry(AliCDBEntry* entry, const char* mirrors) {
 
        TString fullFilename = Form("/alien%s", filename.Data());
        TString seMirrors(mirrors);
+       if(seMirrors.IsNull() || seMirrors.IsWhitespace()) seMirrors=GetMirrorSEs();
        // specify SE to filename
-       // if a list of SEs was passed, set the first as SE for opening the file. The others will be used in cascade in case of
-       // failure in opening the file. The remaining will be used to create replicas.
+       // if a list of SEs was passed to this method or set via SetMirrorSEs, set the first as SE for opening the file.
+       // The other SEs will be used in cascade in case of failure in opening the file.
+       // The remaining SEs will be used to create replicas.
        TObjArray *arraySEs = seMirrors.Tokenize(',');
        Int_t nSEs = arraySEs->GetEntries();
        Int_t remainingSEs = 1;
@@ -756,7 +759,7 @@ Bool_t AliCDBGrid::PutEntry(AliCDBEntry* entry, const char* mirrors) {
                    AliError(Form("\"%s\" is an invalid storage element identifier.",targetSE.Data()));
                    continue;
                }
-               fullFilename.Remove(fullFilename.Last('?'));
+               if(fullFilename.Contains('?')) fullFilename.Remove(fullFilename.Last('?'));
                fullFilename += Form("?se=%s",targetSE.Data());
            }
            Int_t remainingAttempts=fNretry;
@@ -832,6 +835,7 @@ Bool_t AliCDBGrid::PutEntry(AliCDBEntry* entry, const char* mirrors) {
 
        return result;
 }
+
 //_____________________________________________________________________________
 Bool_t AliCDBGrid::AddTag(TString& folderToTag, const char* tagname){
 // add "tagname" tag (CDB or CDB_MD) to folder where object will be stored
index 155d1771547a4c32ae078e64dc3d68c075a0a8b7..e1f684eb4364f01db70c1a2b9eb364421c9e984b 100644 (file)
@@ -27,6 +27,9 @@ public:
        virtual Int_t  GetLatestSubVersion(const char* path, Int_t run, Int_t version);
        virtual Bool_t IdToFilename(const AliCDBId& id, TString& filename) const;
        virtual void SetRetry(Int_t nretry, Int_t initsec);
+       virtual void SetMirrorSEs(const char* mirrors) {fMirrorSEs=mirrors;}
+       virtual const char* GetMirrorSEs() const {return fMirrorSEs;}
+
 
 protected:
 
@@ -67,6 +70,7 @@ private:
        TString    fUser;        // User
        TString    fDBFolder;    // path of the DB folder
        TString    fSE;          // Storage Element
+       TString    fMirrorSEs;   // Mirror Storage Elements
        TString    fCacheFolder; // local cache folder
        Bool_t     fOperateDisconnected; // Operate disconnected flag
        Long64_t   fCacheSize;           // local cache size (in bytes)
index 4acc838442d430952f1f23f52e27d25b12500606..ee224d5664fc4d3510fc549fda3d7575cfc477ce 100644 (file)
@@ -297,7 +297,6 @@ AliCDBManager::AliCDBManager():
   fCondParam(0),
   fRefParam(0),
   fRun(-1),
-  fMirrorSEs(""),
   fCache(kTRUE),
   fLock(kFALSE),
   fSnapshotMode(kFALSE),
@@ -1209,7 +1208,7 @@ TList* AliCDBManager::GetAll(const AliCDBId& query) {
 }
 
 //_____________________________________________________________________________
-Bool_t AliCDBManager::Put(TObject* object, const AliCDBId& id, AliCDBMetaData* metaData, const DataType type){
+Bool_t AliCDBManager::Put(TObject* object, const AliCDBId& id, AliCDBMetaData* metaData, const char* mirrors, const DataType type){
 // store an AliCDBEntry object into the database
 
        if (object==0x0) {
@@ -1218,7 +1217,7 @@ Bool_t AliCDBManager::Put(TObject* object, const AliCDBId& id, AliCDBMetaData* m
        } 
 
        AliCDBEntry anEntry(object, id, metaData);
-       return Put(&anEntry, "", type);
+       return Put(&anEntry, mirrors, type);
 
 }
 
@@ -1282,7 +1281,7 @@ Bool_t AliCDBManager::Put(AliCDBEntry* entry, const char* mirrors, DataType type
        if(!strMirrors.IsNull() && !strMirrors.IsWhitespace())
            result = aStorage->Put(entry, mirrors, type);
        else
-           result = aStorage->Put(entry, fMirrorSEs, type);
+           result = aStorage->Put(entry, "", type);
 
        if(fRun >= 0) QueryCDB();
 
@@ -1291,6 +1290,27 @@ Bool_t AliCDBManager::Put(AliCDBEntry* entry, const char* mirrors, DataType type
 
 }
 
+//_____________________________________________________________________________
+void AliCDBManager::SetMirrorSEs(const char* mirrors)
+{
+// set mirror Storage Elements for the default storage, if it is of type "alien"
+    if(fDefaultStorage->GetType() != "alien"){
+       AliInfo("The default storage is not of type \"alien\". Settings for Storage Elements are not taken into account!");
+       return;
+    }
+    fDefaultStorage->SetMirrorSEs(mirrors);
+}
+
+//_____________________________________________________________________________
+const char* AliCDBManager::GetMirrorSEs() const {
+// get mirror Storage Elements for the default storage, if it is of type "alien"
+    if(fDefaultStorage->GetType() != "alien"){
+       AliInfo("The default storage is not of type \"alien\". Settings for Storage Elements are not taken into account!");
+       return "";
+    }
+    return fDefaultStorage->GetMirrorSEs();
+}
+
 //_____________________________________________________________________________
 void AliCDBManager::CacheEntry(const char* path, AliCDBEntry* entry)
 {
index c262dbbca78c92a40733899b3f2c4f1a3e687a7f..6903b6f122046592000a44f53fbcdee41065a317 100644 (file)
@@ -87,8 +87,8 @@ class AliCDBManager: public TObject {
        TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
                                 Int_t version = -1, Int_t subVersion = -1); 
 
-       Bool_t Put(TObject* object, const AliCDBId& id,
-                       AliCDBMetaData* metaData, const DataType type=kPrivate);
+       Bool_t Put(TObject* object, const AliCDBId& id, AliCDBMetaData* metaData,
+                       const char* mirrors="", const DataType type=kPrivate);
        Bool_t Put(AliCDBEntry* entry, const char* mirrors="", DataType type=kPrivate);
 
        void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
@@ -103,8 +103,8 @@ class AliCDBManager: public TObject {
        void SetRun(Int_t run);
        Int_t GetRun() const {return fRun;}
 
-       void SetMirrorSEs(const char* mirrors){fMirrorSEs=mirrors;}
-       const char* GetMirrorSEs() const {return fMirrorSEs;}
+       void SetMirrorSEs(const char* mirrors);
+       const char* GetMirrorSEs() const;
 
        void DestroyActiveStorages();
        void DestroyActiveStorage(AliCDBStorage* storage);
@@ -185,7 +185,6 @@ protected:
        AliCDBParam* fRefParam;         // Reference data storage parameters
 
        Int_t fRun;                     //! The run number
-       const char* fMirrorSEs;         //! List of SEs used in case we are putting objects on an AliEn storage 
        Bool_t fCache;                  //! The cache flag
        Bool_t fLock;   //! Lock flag, if ON default storage and run number cannot be reset
 
index 301f61f6f26c67ba12f6acd83986a6230d990f6f..1ff59070537e4605aeac1fb344e49d92a8c3581f 100644 (file)
@@ -375,7 +375,7 @@ AliCDBId* AliCDBStorage::GetId(const AliCDBPath& path,
 }
 
 //_____________________________________________________________________________
-Bool_t AliCDBStorage::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData, AliCDBManager::DataType type) {
+Bool_t AliCDBStorage::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData, const char* mirrors, AliCDBManager::DataType type) {
 // store an AliCDBEntry object into the database
        
        if (object==0x0) {
@@ -385,7 +385,7 @@ Bool_t AliCDBStorage::Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaDat
 
        AliCDBEntry anEntry(object, id, metaData);
 
-       return Put(&anEntry, "", type);
+       return Put(&anEntry, mirrors, type);
 }
 
 //_____________________________________________________________________________
@@ -423,7 +423,12 @@ Bool_t AliCDBStorage::Put(AliCDBEntry* entry, const char* mirrors, AliCDBManager
                        return 0;
        }
 
-       return PutEntry(entry,mirrors);
+       
+       TString strMirrors(mirrors);
+       if(!strMirrors.IsNull() && !strMirrors.IsWhitespace())
+           return PutEntry(entry, mirrors);
+       else
+           return PutEntry(entry);
 }
 
 //_____________________________________________________________________________
@@ -498,6 +503,34 @@ AliCDBManager::DataType AliCDBStorage::GetDataType() const {
        return AliCDBManager::kPrivate;
 }
 
+//_____________________________________________________________________________
+void AliCDBStorage::SetMirrorSEs(const char* mirrors) {
+// if the current storage is not of "alien" type, just issue a warning
+// AliCDBGrid implements its own SetMirrorSEs method
+
+        TString storageType = GetType();
+       if(storageType != "alien"){
+           AliWarning(Form("The current storage is of type \"%s\" and cannot handle SEs. Setting skipped!",storageType.Data()));
+           return;
+       }
+       AliError("We should never get here!! AliCDBGrid must have masked this virtual method!");
+       return;
+}
+
+//_____________________________________________________________________________
+const char* AliCDBStorage::GetMirrorSEs() const {
+// if the current storage is not of "alien" type, just issue a warning
+// AliCDBGrid implements its own GetMirrorSEs method
+
+        TString storageType = GetType();
+       if(storageType != "alien"){
+           AliWarning(Form("The current storage is of type \"%s\" and cannot handle SEs. Returning empty string!",storageType.Data()));
+           return "";
+       }
+       AliError("We should never get here!! AliCDBGrid must have masked this virtual method!");
+       return "";
+}
+
 //_____________________________________________________________________________
 void AliCDBStorage::LoadTreeFromFile(AliCDBEntry *entry) const {
 // Checks whether entry contains a TTree and in case loads it into memory
index 72bab165746aa5e3ae20495965d150a33e00da33..620a82559b46691fe9dee5ce3e9f7e75668bc0cc 100644 (file)
@@ -84,10 +84,13 @@ public:
        AliCDBId* GetId(const AliCDBPath& path, const AliCDBRunRange& runRange,
                                 Int_t version = -1, Int_t subVersion = -1);
 
-       Bool_t Put(TObject* object, AliCDBId& id,  AliCDBMetaData* metaData,
+       Bool_t Put(TObject* object, AliCDBId& id,  AliCDBMetaData* metaData, const char* mirrors="",
                                AliCDBManager::DataType type=AliCDBManager::kPrivate);
        Bool_t Put(AliCDBEntry* entry, const char* mirrors="", AliCDBManager::DataType type=AliCDBManager::kPrivate);
 
+       virtual void SetMirrorSEs(const char* mirrors);
+       virtual const char* GetMirrorSEs() const;
+
        virtual Bool_t IsReadOnly() const = 0;
        virtual Bool_t HasSubVersion() const = 0;
        virtual Bool_t Contains(const char* path) const = 0;
@@ -116,9 +119,9 @@ protected:
        //void  SetTreeToFile(AliCDBEntry* entry, TFile* file) const;
 
        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
+       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
        AliCDBMetaData* fMetaDataFilter; // metadata, used to manage list of valid files
 
        TList fSelections;      // list of selection criteria