fUser(user),
fDBFolder(dbFolder),
fSE(se),
+fMirrorSEs(""),
fCacheFolder(cacheFolder),
fOperateDisconnected(operateDisconnected),
fCacheSize(cacheSize),
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;
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;
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
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:
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)
fCondParam(0),
fRefParam(0),
fRun(-1),
- fMirrorSEs(""),
fCache(kTRUE),
fLock(kFALSE),
fSnapshotMode(kFALSE),
}
//_____________________________________________________________________________
-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) {
}
AliCDBEntry anEntry(object, id, metaData);
- return Put(&anEntry, "", type);
+ return Put(&anEntry, mirrors, 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();
}
+//_____________________________________________________________________________
+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)
{
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;}
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);
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
}
//_____________________________________________________________________________
-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) {
AliCDBEntry anEntry(object, id, metaData);
- return Put(&anEntry, "", type);
+ return Put(&anEntry, mirrors, type);
}
//_____________________________________________________________________________
return 0;
}
- return PutEntry(entry,mirrors);
+
+ TString strMirrors(mirrors);
+ if(!strMirrors.IsNull() && !strMirrors.IsWhitespace())
+ return PutEntry(entry, mirrors);
+ else
+ return PutEntry(entry);
}
//_____________________________________________________________________________
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
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;
//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