1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /////////////////////////////////////////////////////////////////////////////////////////////////
19 // access class to a DataBase in an AliEn storage //
21 /////////////////////////////////////////////////////////////////////////////////////////////////
25 #include <TGridResult.h>
30 #include <TObjArray.h>
31 #include <TObjString.h>
36 #include "AliCDBEntry.h"
37 #include "AliCDBGrid.h"
38 #include "AliCDBManager.h"
43 //_____________________________________________________________________________
44 AliCDBGrid::AliCDBGrid(const char *gridUrl, const char *user, const char *dbFolder,
45 const char *se, const char* cacheFolder, Bool_t operateDisconnected,
46 Long64_t cacheSize, Long_t cleanupInterval) :
53 fCacheFolder(cacheFolder),
54 fOperateDisconnected(operateDisconnected),
55 fCacheSize(cacheSize),
56 fCleanupInterval(cleanupInterval)
60 // if the same Grid is alreay active, skip connection
61 if (!gGrid || fGridUrl != gGrid->GridUrl()
62 || (( fUser != "" ) && ( fUser != gGrid->GetUser() )) ) {
63 // connection to the Grid
64 AliInfo("Connection to the Grid...");
66 AliInfo(Form("gGrid = %p; fGridUrl = %s; gGrid->GridUrl() = %s",gGrid,fGridUrl.Data(), gGrid->GridUrl()));
67 AliInfo(Form("fUser = %s; gGrid->GetUser() = %s",fUser.Data(), gGrid->GetUser()));
69 TGrid::Connect(fGridUrl.Data(),fUser.Data());
73 AliError("Connection failed!");
77 TString initDir(gGrid->Pwd(0));
78 if (fDBFolder[0] != '/') {
79 fDBFolder.Prepend(initDir);
82 // check DBFolder: trying to cd to DBFolder; if it does not exist, create it
83 if(!gGrid->Cd(fDBFolder.Data(),0)){
84 AliDebug(2,Form("Creating new folder <%s> ...",fDBFolder.Data()));
85 TGridResult* res = gGrid->Command(Form("mkdir -p %s",fDBFolder.Data()));
86 TString result = res->GetKey(0,"__result__");
88 AliFatal(Form("Cannot create folder <%s> !",fDBFolder.Data()));
92 AliDebug(2,Form("Folder <%s> found",fDBFolder.Data()));
95 // removes any '/' at the end of path, then append one '/'
96 while(fDBFolder.EndsWith("/")) fDBFolder.Remove(fDBFolder.Last('/'));
100 fBaseFolder = fDBFolder;
104 // Check if local cache folder is already defined
105 TString origCache(TFile::GetCacheFileDir());
106 if(fCacheFolder.Length() > 0) {
107 if(origCache.Length() == 0) {
108 AliInfo(Form("Setting local cache to: %s", fCacheFolder.Data()));
109 } else if(fCacheFolder != origCache) {
110 AliWarning(Form("Local cache folder was already defined, changing it to: %s",
111 fCacheFolder.Data()));
114 // default settings are: operateDisconnected=kTRUE, forceCacheread = kFALSE
115 if(!TFile::SetCacheFileDir(fCacheFolder.Data(), fOperateDisconnected)) {
116 AliError(Form("Could not set cache folder %s !", fCacheFolder.Data()));
119 // reset fCacheFolder because the function may have
120 // slightly changed the folder name (e.g. '/' added)
121 fCacheFolder = TFile::GetCacheFileDir();
124 // default settings are: cacheSize=1GB, cleanupInterval = 0
125 if(!TFile::ShrinkCacheFileDir(fCacheSize, fCleanupInterval)) {
126 AliError(Form("Could not set following values "
127 "to ShrinkCacheFileDir: cacheSize = %lld, cleanupInterval = %ld !",
128 fCacheSize, fCleanupInterval));
132 // return to the initial directory
133 gGrid->Cd(initDir.Data(),0);
135 fNretry = 3; // default
136 fInitRetrySeconds = 5; // default
139 //_____________________________________________________________________________
140 AliCDBGrid::~AliCDBGrid() {
142 delete gGrid; gGrid=0;
146 //_____________________________________________________________________________
147 Bool_t AliCDBGrid::FilenameToId(TString& filename, AliCDBId& id) {
148 // build AliCDBId from full path filename (fDBFolder/path/Run#x_#y_v#z_s0.root)
150 if(filename.Contains(fDBFolder)){
151 filename = filename(fDBFolder.Length(),filename.Length()-fDBFolder.Length());
154 TString idPath = filename(0,filename.Last('/'));
156 if(!id.IsValid()) return kFALSE;
158 filename=filename(idPath.Length()+1,filename.Length()-idPath.Length());
161 // valid filename: Run#firstRun_#lastRun_v#version_s0.root
162 TRegexp keyPattern("^Run[0-9]+_[0-9]+_v[0-9]+_s0.root$");
163 keyPattern.Index(filename, &mSize);
166 // TODO backward compatibility ... maybe remove later!
168 TRegexp oldKeyPattern("^Run[0-9]+_[0-9]+_v[0-9]+.root$");
169 oldKeyPattern.Index(filename, &oldmSize);
171 AliDebug(2,Form("Bad filename <%s>.", filename.Data()));
174 AliDebug(2,Form("Old filename format <%s>.", filename.Data()));
175 id.SetSubVersion(-11); // TODO trick to ensure backward compatibility
179 id.SetSubVersion(-1); // TODO trick to ensure backward compatibility
182 filename.Resize(filename.Length() - sizeof(".root") + 1);
184 TObjArray* strArray = (TObjArray*) filename.Tokenize("_");
186 TString firstRunString(((TObjString*) strArray->At(0))->GetString());
187 id.SetFirstRun(atoi(firstRunString.Data() + 3));
188 id.SetLastRun(atoi(((TObjString*) strArray->At(1))->GetString()));
190 TString verString(((TObjString*) strArray->At(2))->GetString());
191 id.SetVersion(atoi(verString.Data() + 1));
198 //_____________________________________________________________________________
199 Bool_t AliCDBGrid::IdToFilename(const AliCDBId& id, TString& filename) const {
200 // build file name from AliCDBId (path, run range, version) and fDBFolder
202 if (!id.GetAliCDBRunRange().IsValid()) {
203 AliDebug(2,Form("Invalid run range <%d, %d>.",
204 id.GetFirstRun(), id.GetLastRun()));
208 if (id.GetVersion() < 0) {
209 AliDebug(2,Form("Invalid version <%d>.", id.GetVersion()));
213 filename = Form("Run%d_%d_v%d",
218 if (id.GetSubVersion() != -11) filename += "_s0"; // TODO to ensure backward compatibility
221 filename.Prepend(fDBFolder + id.GetPath() + '/');
226 //_____________________________________________________________________________
227 void AliCDBGrid::SetRetry(Int_t nretry, Int_t initsec) {
229 // Function to set the exponential retry for putting entries in the OCDB
231 AliWarning("WARNING!!! You are changing the exponential retry times and delay: this function should be used by experts!");
233 fInitRetrySeconds = initsec;
234 AliDebug(2,Form("fNretry = %d, fInitRetrySeconds = %d", fNretry, fInitRetrySeconds));
238 //_____________________________________________________________________________
239 Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
240 // prepare id (version) of the object that will be stored (called by PutEntry)
242 TString initDir(gGrid->Pwd(0));
244 TString dirName(fDBFolder);
246 Bool_t dirExist=kFALSE;
250 // go to the path; if directory does not exist, create it
251 for(int i=0;i<3;i++){
252 //TString cmd("find -d ");
253 //cmd += Form("%s ",dirName);
255 //gGrid->Command(cmd.Data());
256 dirName+=Form("%s/",id.GetPathLevel(i).Data());
257 dirExist=gGrid->Cd(dirName,0);
259 AliDebug(2,Form("Creating new folder <%s> ...",dirName.Data()));
260 if(!gGrid->Mkdir(dirName,"",0)){
261 AliError(Form("Cannot create directory <%s> !",dirName.Data()));
262 gGrid->Cd(initDir.Data());
266 // if folders are new add tags to them
268 // TODO Currently disabled
269 // add short lived tag!
270 // AliInfo("Tagging level 1 folder with \"ShortLived\" tag");
271 // if(!AddTag(dirName,"ShortLived_try")){
272 // AliError(Form("Could not tag folder %s !", dirName.Data()));
273 // if(!gGrid->Rmdir(dirName.Data())){
274 // AliError(Form("Unexpected: could not remove %s directory!", dirName.Data()));
280 AliDebug(2,"Tagging level 2 folder with \"CDB\" and \"CDB_MD\" tag");
281 if(!AddTag(dirName,"CDB")){
282 AliError(Form("Could not tag folder %s !", dirName.Data()));
283 if(!gGrid->Rmdir(dirName.Data())){
284 AliError(Form("Unexpected: could not remove %s directory!", dirName.Data()));
288 if(!AddTag(dirName,"CDB_MD")){
289 AliError(Form("Could not tag folder %s !", dirName.Data()));
290 if(!gGrid->Rmdir(dirName.Data())){
291 AliError(Form("Unexpected: could not remove %s directory!", dirName.Data()));
296 // TODO Currently disabled
297 // add short lived tag!
298 // TString path=id.GetPath();
299 // if(AliCDBManager::Instance()->IsShortLived(path.Data())) {
300 // AliInfo(Form("Tagging %s as short lived", dirName.Data()));
301 // if(!TagShortLived(dirName, kTRUE)){
302 // AliError(Form("Could not tag folder %s !", dirName.Data()));
303 // if(!gGrid->Rmdir(dirName.Data())){
304 // AliError(Form("Unexpected: could not remove %s directory!", dirName.Data()));
309 // AliInfo(Form("Tagging %s as long lived", dirName.Data()));
310 // if(!TagShortLived(dirName, kFALSE)){
311 // AliError(Form("Could not tag folder %s !", dirName.Data()));
312 // if(!gGrid->Rmdir(dirName.Data())){
313 // AliError(Form("Unexpected: could not remove %s directory!", dirName.Data()));
321 gGrid->Cd(initDir,0);
324 AliCDBId anId; // the id got from filename
325 AliCDBRunRange lastRunRange(-1,-1); // highest runRange found
326 Int_t lastVersion=0; // highest version found
328 TGridResult *res = gGrid->Ls(dirName);
330 //loop on the files in the directory, look for highest version
331 for(int i=0; i < res->GetEntries(); i++){
332 filename=res->GetFileNamePath(i);
333 if (!FilenameToId(filename, anId)) continue;
334 if (anId.GetAliCDBRunRange().Overlaps(id.GetAliCDBRunRange()) && anId.GetVersion() > lastVersion) {
335 lastVersion = anId.GetVersion();
336 lastRunRange = anId.GetAliCDBRunRange();
342 // GRP entries with explicitly set version escape default incremental versioning
343 if(id.GetPath().Contains("GRP") && id.HasVersion() && lastVersion!=0)
345 AliDebug(5,Form("Entry %s won't be put in the destination OCDB", id.ToString().Data()));
349 id.SetVersion(lastVersion + 1);
352 TString lastStorage = id.GetLastStorage();
353 if(lastStorage.Contains(TString("new"), TString::kIgnoreCase) && id.GetVersion() > 1 ){
354 AliDebug(2, Form("A NEW object is being stored with version %d",
356 AliDebug(2, Form("and it will hide previously stored object with version %d!",
360 if(!lastRunRange.IsAnyRange() && !(lastRunRange.IsEqual(&id.GetAliCDBRunRange())))
361 AliWarning(Form("Run range modified w.r.t. previous version (Run%d_%d_v%d)",
362 lastRunRange.GetFirstRun(), lastRunRange.GetLastRun(), id.GetVersion()));
367 //_____________________________________________________________________________
368 AliCDBId* AliCDBGrid::GetId(const TObjArray& validFileIds, const AliCDBId& query) {
369 // look for the Id that matches query's requests (highest or exact version)
371 if(validFileIds.GetEntriesFast() < 1)
374 TIter iter(&validFileIds);
379 while((anIdPtr = dynamic_cast<AliCDBId*> (iter.Next()))){
380 if(anIdPtr->GetPath() != query.GetPath()) continue;
382 //if(!CheckVersion(query, anIdPtr, result)) return NULL;
384 if (!query.HasVersion()){ // look for highest version
385 if(result && result->GetVersion() > anIdPtr->GetVersion()) continue;
386 if(result && result->GetVersion() == anIdPtr->GetVersion()) {
387 AliError(Form("More than one object valid for run %d, version %d!",
388 query.GetFirstRun(), anIdPtr->GetVersion()));
391 result = new AliCDBId(*anIdPtr);
392 } else { // look for specified version
393 if(query.GetVersion() != anIdPtr->GetVersion()) continue;
394 if(result && result->GetVersion() == anIdPtr->GetVersion()){
395 AliError(Form("More than one object valid for run %d, version %d!",
396 query.GetFirstRun(), anIdPtr->GetVersion()));
399 result = new AliCDBId(*anIdPtr);
407 //_____________________________________________________________________________
408 AliCDBId* AliCDBGrid::GetEntryId(const AliCDBId& queryId) {
409 // get AliCDBId from the database
410 // User must delete returned object
414 AliCDBId selectedId(queryId);
415 if (!selectedId.HasVersion()) {
416 // if version is not specified, first check the selection criteria list
417 GetSelection(&selectedId);
420 TObjArray validFileIds;
421 validFileIds.SetOwner(1);
423 // look for file matching query requests (path, runRange, version)
424 if(selectedId.GetFirstRun() == fRun && fPathFilter.Comprises(selectedId.GetAliCDBPath()) &&
425 fVersion == selectedId.GetVersion() && !fMetaDataFilter){
426 // look into list of valid files previously loaded with AliCDBStorage::FillValidFileIds()
427 AliDebug(2, Form("List of files valid for run %d was loaded. Looking there for fileids valid for path %s!",
428 selectedId.GetFirstRun(), selectedId.GetPath().Data()));
429 dataId = GetId(fValidFileIds, selectedId);
432 // List of files valid for reqested run was not loaded. Looking directly into CDB
433 AliDebug(2, Form("List of files valid for run %d and version %d was not loaded. Looking directly into CDB for fileids valid for path %s!",
434 selectedId.GetFirstRun(), selectedId.GetVersion(), selectedId.GetPath().Data()));
437 MakeQueryFilter(selectedId.GetFirstRun(), selectedId.GetLastRun(), 0, filter);
439 TString pattern = ".root";
440 TString optionQuery = "-y -m";
441 if(selectedId.GetVersion() >= 0) {
442 pattern.Prepend(Form("_v%d_s0",selectedId.GetVersion()));
446 TString folderCopy(Form("%s%s/Run",fDBFolder.Data(),selectedId.GetPath().Data()));
448 if (optionQuery.Contains("-y")){
449 AliInfo("Only latest version will be returned");
452 AliDebug(2,Form("** fDBFolder = %s, pattern = %s, filter = %s",folderCopy.Data(), pattern.Data(), filter.Data()));
453 TGridResult *res = gGrid->Query(folderCopy, pattern, filter, optionQuery.Data());
455 for(int i=0; i<res->GetEntries(); i++){
456 AliCDBId *validFileId = new AliCDBId();
457 TString filename = res->GetKey(i, "lfn");
458 if(filename == "") continue;
459 if(FilenameToId(filename, *validFileId))
460 validFileIds.AddLast(validFileId);
464 return 0; // this should be only in case of file catalogue glitch
467 dataId = GetId(validFileIds, selectedId);
473 //_____________________________________________________________________________
474 AliCDBEntry* AliCDBGrid::GetEntry(const AliCDBId& queryId) {
475 // get AliCDBEntry from the database
477 AliCDBId* dataId = GetEntryId(queryId);
480 AliFatal(TString::Format("No valid CDB object found! request was: %s", queryId.ToString().Data()));
485 if (!IdToFilename(*dataId, filename)) {
486 AliDebug(2,Form("Bad data ID encountered! Subnormal error!"));
488 AliFatal(TString::Format("No valid CDB object found! request was: %s", queryId.ToString().Data()));
491 AliCDBEntry* anEntry = GetEntryFromFile(filename, dataId);
495 AliFatal(TString::Format("No valid CDB object found! request was: %s", queryId.ToString().Data()));
500 //_____________________________________________________________________________
501 AliCDBEntry* AliCDBGrid::GetEntryFromFile(TString& filename, AliCDBId* dataId){
502 // Get AliCBEntry object from file "filename"
504 AliDebug(2,Form("Opening file: %s",filename.Data()));
506 filename.Prepend("/alien");
508 // if option="CACHEREAD" TFile will use the local caching facility!
509 TString option="READ";
510 if(fCacheFolder != ""){
512 // Check if local cache folder was changed in the meanwhile
513 TString origCache(TFile::GetCacheFileDir());
514 if(fCacheFolder != origCache) {
515 AliWarning(Form("Local cache folder has been overwritten!! fCacheFolder = %s origCache = %s",
516 fCacheFolder.Data(), origCache.Data()));
517 TFile::SetCacheFileDir(fCacheFolder.Data(), fOperateDisconnected);
518 TFile::ShrinkCacheFileDir(fCacheSize, fCleanupInterval);
521 option.Prepend("CACHE");
524 AliDebug(2, Form("Option: %s", option.Data()));
526 TFile *file = TFile::Open(filename, option);
528 AliDebug(2,Form("Can't open file <%s>!", filename.Data()));
532 // get the only AliCDBEntry object from the file
533 // the object in the file is an AliCDBEntry entry named "AliCDBEntry"
535 AliCDBEntry* anEntry = dynamic_cast<AliCDBEntry*> (file->Get("AliCDBEntry"));
538 AliDebug(2,Form("Bad storage data: file does not contain an AliCDBEntry object!"));
543 // The object's Id is not reset during storage
544 // If object's Id runRange or version do not match with filename,
545 // it means that someone renamed file by hand. In this case a warning msg is issued.
548 AliCDBId entryId = anEntry->GetId();
549 Int_t tmpSubVersion = dataId->GetSubVersion();
550 dataId->SetSubVersion(entryId.GetSubVersion()); // otherwise filename and id may mismatch
551 if(!entryId.IsEqual(dataId)){
552 AliWarning(Form("Mismatch between file name and object's Id!"));
553 AliWarning(Form("File name: %s", dataId->ToString().Data()));
554 AliWarning(Form("Object's Id: %s", entryId.ToString().Data()));
556 dataId->SetSubVersion(tmpSubVersion);
559 anEntry->SetLastStorage("grid");
561 // Check whether entry contains a TTree. In case load the tree in memory!
562 LoadTreeFromFile(anEntry);
564 // close file, return retieved entry
565 file->Close(); delete file; file=0;
570 //_____________________________________________________________________________
571 TList* AliCDBGrid::GetEntries(const AliCDBId& queryId) {
572 // multiple request (AliCDBStorage::GetAll)
574 TList* result = new TList();
577 TObjArray validFileIds;
578 validFileIds.SetOwner(1);
580 Bool_t alreadyLoaded = kFALSE;
582 // look for file matching query requests (path, runRange)
583 if(queryId.GetFirstRun() == fRun &&
584 fPathFilter.Comprises(queryId.GetAliCDBPath()) && fVersion < 0 && !fMetaDataFilter){
585 // look into list of valid files previously loaded with AliCDBStorage::FillValidFileIds()
586 AliDebug(2,Form("List of files valid for run %d and for path %s was loaded. Looking there!",
587 queryId.GetFirstRun(), queryId.GetPath().Data()));
589 alreadyLoaded = kTRUE;
592 // List of files valid for reqested run was not loaded. Looking directly into CDB
593 AliDebug(2,Form("List of files valid for run %d and for path %s was not loaded. Looking directly into CDB!",
594 queryId.GetFirstRun(), queryId.GetPath().Data()));
597 MakeQueryFilter(queryId.GetFirstRun(), queryId.GetLastRun(), 0, filter);
599 TString path = queryId.GetPath();
601 TString pattern = "Run*.root";
602 TString optionQuery = "-y";
604 TString addFolder = "";
605 if (!path.Contains("*")){
606 if (!path.BeginsWith("/")) addFolder += "/";
610 if (path.BeginsWith("/")) path.Remove(0,1);
611 if (path.EndsWith("/")) path.Remove(path.Length()-1,1);
612 TObjArray* tokenArr = path.Tokenize("/");
613 if (tokenArr->GetEntries() != 3) {
614 AliError("Not a 3 level path! Keeping old query...");
615 pattern.Prepend(path+"/");
618 TString str0 = ((TObjString*)tokenArr->At(0))->String();
619 TString str1 = ((TObjString*)tokenArr->At(1))->String();
620 TString str2 = ((TObjString*)tokenArr->At(2))->String();
621 if (str0 != "*" && str1 != "*" && str2 == "*"){
622 // e.g. "ITS/Calib/*"
623 addFolder = "/"+str0+"/"+str1;
625 else if (str0 != "*" && str1 == "*" && str2 == "*"){
627 addFolder = "/"+str0;
629 else if (str0 == "*" && str1 == "*" && str2 == "*"){
631 // do nothing: addFolder is already an empty string;
634 // e.g. "ITS/*/RecoParam"
635 pattern.Prepend(path+"/");
638 delete tokenArr; tokenArr=0;
641 TString folderCopy(Form("%s%s",fDBFolder.Data(),addFolder.Data()));
643 AliDebug(2,Form("fDBFolder = %s, pattern = %s, filter = %s",folderCopy.Data(), pattern.Data(), filter.Data()));
645 TGridResult *res = gGrid->Query(folderCopy, pattern, filter, optionQuery.Data());
648 AliError("Grid query failed");
652 for(int i=0; i<res->GetEntries(); i++){
653 AliCDBId *validFileId = new AliCDBId();
654 TString filename = res->GetKey(i, "lfn");
655 if(filename == "") continue;
656 if(FilenameToId(filename, *validFileId))
657 validFileIds.AddLast(validFileId);
664 iter = new TIter(&fValidFileIds);
666 iter = new TIter(&validFileIds);
669 TObjArray selectedIds;
670 selectedIds.SetOwner(1);
672 // loop on list of valid Ids to select the right version to get.
673 // According to query and to the selection criteria list, version can be the highest or exact
677 AliCDBPath queryPath = queryId.GetAliCDBPath();
678 while((anIdPtr = dynamic_cast<AliCDBId*> (iter->Next()))){
679 AliCDBPath thisCDBPath = anIdPtr->GetAliCDBPath();
680 if(!(queryPath.Comprises(thisCDBPath)) || pathCopy.GetPath() == thisCDBPath.GetPath()) continue;
681 pathCopy = thisCDBPath;
683 // check the selection criteria list for this query
684 AliCDBId thisId(*anIdPtr);
685 thisId.SetVersion(queryId.GetVersion());
686 if(!thisId.HasVersion()) GetSelection(&thisId);
689 dataId = GetId(fValidFileIds, thisId);
691 dataId = GetId(validFileIds, thisId);
693 if(dataId) selectedIds.Add(dataId);
698 // selectedIds contains the Ids of the files matching all requests of query!
699 // All the objects are now ready to be retrieved
700 iter = new TIter(&selectedIds);
701 while((anIdPtr = dynamic_cast<AliCDBId*> (iter->Next()))){
703 if (!IdToFilename(*anIdPtr, filename)) {
704 AliDebug(2,Form("Bad data ID encountered! Subnormal error!"));
708 AliCDBEntry* anEntry = GetEntryFromFile(filename, anIdPtr);
710 if(anEntry) result->Add(anEntry);
718 //_____________________________________________________________________________
719 Bool_t AliCDBGrid::PutEntry(AliCDBEntry* entry, const char* mirrors) {
720 // put an AliCDBEntry object into the database
722 AliCDBId& id = entry->GetId();
724 // set version for the entry to be stored
725 if (!PrepareId(id)) return kFALSE;
727 // build filename from entry's id
729 if (!IdToFilename(id, filename)) {
730 AliError("Bad ID encountered, cannot make a file name out of it!");
734 TString folderToTag = Form("%s%s",
736 id.GetPath().Data());
738 TDirectory* saveDir = gDirectory;
740 TString fullFilename = Form("/alien%s", filename.Data());
741 TString seMirrors(mirrors);
742 if(seMirrors.IsNull() || seMirrors.IsWhitespace()) seMirrors=GetMirrorSEs();
743 // specify SE to filename
744 // if a list of SEs was passed to this method or set via SetMirrorSEs, set the first as SE for opening the file.
745 // The other SEs will be used in cascade in case of failure in opening the file.
746 // The remaining SEs will be used to create replicas.
747 TObjArray *arraySEs = seMirrors.Tokenize(',');
748 Int_t nSEs = arraySEs->GetEntries();
749 Int_t remainingSEs = 1;
751 if (fSE != "default") fullFilename += Form("?se=%s",fSE.Data());
758 TFile *reopenedFile = 0;
759 AliDebug(2, Form("fNretry = %d, fInitRetrySeconds = %d",fNretry,fInitRetrySeconds));
760 TString targetSE("");
762 Bool_t result = kFALSE;
763 Bool_t reOpenResult = kFALSE;
764 Int_t reOpenAttempts=0;
765 while( !reOpenResult && reOpenAttempts<2 ) { //loop to check the file after closing it, to catch the unlikely but possible case when the file
766 // is cleaned up by alien just before closing as a consequence of a network disconnection while writing
768 while( !file && remainingSEs>0 ) {
770 TObjString *target = (TObjString*) arraySEs->At(nSEs-remainingSEs);
771 targetSE=target->String();
772 if ( !(targetSE.BeginsWith("ALICE::") && targetSE.CountChar(':')==4) ) {
773 AliError( Form("\"%s\" is an invalid storage element identifier.",targetSE.Data()) );
776 if ( fullFilename.Contains('?')) fullFilename.Remove(fullFilename.Last('?') );
777 fullFilename += Form("?se=%s",targetSE.Data());
779 Int_t remainingAttempts=fNretry;
780 Int_t nsleep = fInitRetrySeconds; // number of seconds between attempts. We let it increase exponentially
781 AliDebug(2, Form("Uploading file into SE #%d: %s",nSEs-remainingSEs+1,targetSE.Data()));
782 while(remainingAttempts > 0) {
783 AliDebug(2, Form("Uploading file into OCDB at %s - Attempt #%d",targetSE.Data(),fNretry-remainingAttempts+1));
785 file = TFile::Open(fullFilename,"CREATE");
786 if(!file || !file->IsWritable()){
787 if(file) { // file is not writable
788 file->Close(); delete file; file=0;
790 TString message(TString::Format("Attempt %d failed.",fNretry-remainingAttempts));
791 if(remainingAttempts>0) {
792 message += " Sleeping for "; message += nsleep; message += " seconds";
794 if(remainingSEs>0) message += " Trying to upload at next SE";
796 AliDebug(2, message.Data());
797 if(remainingAttempts>0) sleep(nsleep);
801 nsleep*=fInitRetrySeconds;
806 AliError(Form("All %d attempts have failed on all %d SEs. Returning...",fNretry,nSEs));
812 //SetTreeToFile(entry, file);
813 entry->SetVersion(id.GetVersion());
815 // write object (key name: "AliCDBEntry")
816 result = (file->WriteTObject(entry, "AliCDBEntry") != 0);
819 AliError(Form("Can't write entry to file <%s>!", filename.Data()));
821 AliDebug(2, Form("Reopening file %s for checking its correctness",fullFilename.Data()));
822 reopenedFile = TFile::Open(fullFilename.Data(),"READ");
824 reOpenResult = kFALSE;
825 AliInfo(Form("The file %s was closed successfully but cannot be reopened. Trying now to regenerate it (regeneration attempt number %d)",
826 fullFilename.Data(),++reOpenAttempts));
828 AliDebug(2, Form("Removing file %s", filename.Data()));
829 if(!gGrid->Rm(filename.Data()))
830 AliError("Can't delete file!");
833 reOpenResult = kTRUE;
834 if ( ! AliCDBManager::Instance()->IsOCDBUploadMode() ) {
835 reopenedFile->Close();
836 delete reopenedFile; reopenedFile=0;
842 if (saveDir) saveDir->cd(); else gROOT->cd();
845 if(result && reOpenResult) {
847 if(!TagFileId(filename, &id)){
848 AliInfo(Form("CDB tagging failed. Deleting file %s!",filename.Data()));
849 if(!gGrid->Rm(filename.Data()))
850 AliError("Can't delete file!");
854 TagFileMetaData(filename, entry->GetMetaData());
856 AliError("The file could not be opened or the object could not be written.");
857 if(!gGrid->Rm(filename.Data()))
858 AliError("Can't delete file!");
862 AliInfo(Form("CDB object stored into file %s", filename.Data()));
864 AliInfo(Form("Storage Element: %s", fSE.Data()));
866 AliInfo(Form("Storage Element: %s", targetSE.Data()));
868 //In case of other SEs specified by the user, mirror the file to the remaining SEs
869 for(Int_t i=0; i<nSEs; i++){
870 if(i==nSEs-remainingSEs-1) continue; // skip mirroring to the SE where the file was saved
871 TString mirrorCmd("mirror ");
872 mirrorCmd += filename;
874 TObjString *target = (TObjString*) arraySEs->At(i);
875 TString mirrorSE(target->String());
876 mirrorCmd += mirrorSE;
877 AliDebug(5,Form("mirror command: \"%s\"",mirrorCmd.Data()));
878 AliInfo(Form("Mirroring to storage element: %s", mirrorSE.Data()));
879 gGrid->Command(mirrorCmd.Data());
881 arraySEs->Delete(); arraySEs=0;
883 if ( AliCDBManager::Instance()->IsOCDBUploadMode() ) { // if uploading to OCDBs, add to cvmfs too
884 if ( !filename.BeginsWith("/alice/data") && !filename.BeginsWith("/alice/simulation/2008/v4-15-Release") ) {
885 AliError ( Form ( "Cannot upload to CVMFS OCDBs a non official CDB object: \"%s\"!", filename.Data() ) );
887 if ( !PutInCvmfs( filename, reopenedFile) )
888 AliError( Form( "Could not upload AliEn file \"%s\" to CVMFS OCDB!", filename.Data() ) );
890 reopenedFile->Close();
891 delete reopenedFile; reopenedFile=0;
897 //_____________________________________________________________________________
898 Bool_t AliCDBGrid::PutInCvmfs(TString &filename, TFile *cdbFile) const {
899 // Add the CDB object to cvmfs OCDB
901 TString cvmfsFilename(filename);
902 if (cvmfsFilename.EndsWith("/")) cvmfsFilename.Remove(cvmfsFilename.Length()-1,1);
903 TString basename = ( cvmfsFilename(cvmfsFilename.Last('/')+1, cvmfsFilename.Length()) ); // Run0_99999999_v2_s0.root
904 TString cvmfsDirname = cvmfsFilename.Remove ( cvmfsFilename.Last('/')+1, cvmfsFilename.Length() ); // /alice/data/2011/OCDB/GRP/GRP/Data
906 TRegexp re_RawFolder("^/alice/data/20[0-9]+/OCDB");
907 TRegexp re_MCFolder("^/alice/simulation/2008/v4-15-Release");
908 TString rawFolder = cvmfsDirname(re_RawFolder);
909 TString mcFolder = cvmfsDirname(re_MCFolder);
910 if ( !rawFolder.IsNull() ) {
911 cvmfsDirname.Replace(0, 6, "/cvmfs/alice-ocdb.cern.ch/calibration");
912 } else if ( !mcFolder.IsNull() ){
913 cvmfsDirname.Replace(0,36,"/cvmfs/alice-ocdb.cern.ch/calibration/MC");
915 AliError(Form("OCDB folder set for an invalid OCDB storage:\n %s", cvmfsDirname.Data()));
918 // now cvmfsDirname is "/cvmfs/alice-ocdb.cern.ch/calibration/data/2011/OCDB/GRP/GRP/Data"
919 AliDebug(3, Form("Publishing \"%s\" in \"%s\"", basename.Data(), cvmfsDirname.Data()));
921 // Tar the file with the right prefix path
922 cdbFile->Cp( basename.Data() );
923 TString tarFileName("cdbObjectToAdd.tar.gz");
924 // tarCommand should be e.g.: tar --transform 's,^,/cvmfs/alice-ocdb.cern.ch/calibration/data/2010/OCDB/,S' -cvzf objecttoadd.tar.gz basename
925 Int_t result = gSystem->Exec ( Form( "tar --transform 's,^,%s,S' -cvzf %s %s", cvmfsDirname.Data(), tarFileName.Data(), basename.Data() ) );
927 AliError ( Form ( "Could not create the tarball for the object \"%s\"", filename.Data() ) );
931 // Copy the file to cvmfs
932 result = gSystem->Exec( Form( "ocdb-cvmfs %s", tarFileName.Data() ) );
934 AliError ( Form ( "Could not execute \"ocdb-cvmfs %s\"", filename.Data() ) );
938 // Remove the local file and the tar-file
939 gSystem->Exec( Form( "rm %s", basename.Data() ) );
940 gSystem->Exec( Form( "rm %s", tarFileName.Data() ) );
945 //_____________________________________________________________________________
946 Bool_t AliCDBGrid::AddTag(TString& folderToTag, const char* tagname){
947 // add "tagname" tag (CDB or CDB_MD) to folder where object will be stored
949 Bool_t result = kTRUE;
950 AliDebug(2, Form("adding %s tag to folder %s", tagname, folderToTag.Data()));
951 TString addTag = Form("addTag %s %s", folderToTag.Data(), tagname);
952 TGridResult *gridres = gGrid->Command(addTag.Data());
953 const char* resCode = gridres->GetKey(0,"__result__"); // '1' if success
954 if(resCode[0] != '1') {
955 AliError(Form("Couldn't add %s tags to folder %s !",
956 tagname, folderToTag.Data()));
963 //_____________________________________________________________________________
964 Bool_t AliCDBGrid::TagFileId(TString& filename, const AliCDBId* id){
965 // tag stored object in CDB table using object Id's parameters
968 TString dirname(filename);
969 Int_t dirNumber = gGrid->Mkdir(dirname.Remove(dirname.Last('/')),"-d");
971 TString addTagValue1 = Form("addTagValue %s CDB ", filename.Data());
972 TString addTagValue2 = Form("first_run=%d last_run=%d version=%d ",
976 TString addTagValue3 = Form("path_level_0=\"%s\" path_level_1=\"%s\" path_level_2=\"%s\" ",
977 id->GetPathLevel(0).Data(),
978 id->GetPathLevel(1).Data(),
979 id->GetPathLevel(2).Data());
980 //TString addTagValue4 = Form("version_path=\"%s\" dir_number=%d",Form("%d_%s",id->GetVersion(),filename.Data()),dirNumber);
981 TString addTagValue4 = Form("version_path=\"%09d%s\" dir_number=%d",id->GetVersion(),filename.Data(),dirNumber);
982 TString addTagValue = Form("%s%s%s%s",
986 addTagValue4.Data());
988 Bool_t result = kFALSE;
989 AliDebug(2, Form("Tagging file. Tag command: %s", addTagValue.Data()));
990 TGridResult* res = gGrid->Command(addTagValue.Data());
991 const char* resCode = res->GetKey(0,"__result__"); // '1' if success
992 if(resCode[0] != '1') {
993 AliError(Form("Couldn't add CDB tag value to file %s !",
997 AliDebug(2, "Object successfully tagged.");
1005 //_____________________________________________________________________________
1006 Bool_t AliCDBGrid::TagShortLived(TString& filename, Bool_t value){
1007 // tag folder with ShortLived tag
1009 TString addTagValue = Form("addTagValue %s ShortLived_try value=%d", filename.Data(), value);
1011 Bool_t result = kFALSE;
1012 AliDebug(2, Form("Tagging file. Tag command: %s", addTagValue.Data()));
1013 TGridResult* res = gGrid->Command(addTagValue.Data());
1014 const char* resCode = res->GetKey(0,"__result__"); // '1' if success
1015 if(resCode[0] != '1') {
1016 AliError(Form("Couldn't add ShortLived tag value to file %s !", filename.Data()));
1019 AliDebug(2,"Object successfully tagged.");
1027 //_____________________________________________________________________________
1028 Bool_t AliCDBGrid::TagFileMetaData(TString& filename, const AliCDBMetaData* md){
1029 // tag stored object in CDB table using object Id's parameters
1031 TString addTagValue1 = Form("addTagValue %s CDB_MD ", filename.Data());
1032 TString addTagValue2 = Form("object_classname=\"%s\" responsible=\"%s\" beam_period=%d ",
1033 md->GetObjectClassName(),
1034 md->GetResponsible(),
1035 md->GetBeamPeriod());
1036 TString addTagValue3 = Form("aliroot_version=\"%s\" comment=\"%s\"",
1037 md->GetAliRootVersion(),
1039 TString addTagValue = Form("%s%s%s",
1040 addTagValue1.Data(),
1041 addTagValue2.Data(),
1042 addTagValue3.Data());
1044 Bool_t result = kFALSE;
1045 AliDebug(2, Form("Tagging file. Tag command: %s", addTagValue.Data()));
1046 TGridResult* res = gGrid->Command(addTagValue.Data());
1047 const char* resCode = res->GetKey(0,"__result__"); // '1' if success
1048 if(resCode[0] != '1') {
1049 AliWarning(Form("Couldn't add CDB_MD tag value to file %s !",
1053 AliDebug(2,"Object successfully tagged.");
1059 //_____________________________________________________________________________
1060 TList* AliCDBGrid::GetIdListFromFile(const char* fileName){
1062 TString turl(fileName);
1063 turl.Prepend("/alien" + fDBFolder);
1064 turl += "?se="; turl += fSE.Data();
1065 TFile *file = TFile::Open(turl);
1067 AliError(Form("Can't open selection file <%s>!", turl.Data()));
1071 TList *list = new TList();
1079 keycycle = "AliCDBId;";
1082 id = (AliCDBId*) file->Get(keycycle);
1086 file->Close(); delete file; file=0;
1093 //_____________________________________________________________________________
1094 Bool_t AliCDBGrid::Contains(const char* path) const{
1095 // check for path in storage's DBFolder
1097 TString initDir(gGrid->Pwd(0));
1098 TString dirName(fDBFolder);
1099 dirName += path; // dirName = fDBFolder/path
1100 Bool_t result=kFALSE;
1101 if (gGrid->Cd(dirName,0)) result=kTRUE;
1102 gGrid->Cd(initDir.Data(),0);
1106 //_____________________________________________________________________________
1107 void AliCDBGrid::QueryValidFiles()
1109 // Query the CDB for files valid for AliCDBStorage::fRun
1110 // Fills list fValidFileIds with AliCDBId objects extracted from CDB files
1111 // selected from AliEn metadata.
1112 // If fVersion was not set, fValidFileIds is filled with highest versions.
1115 MakeQueryFilter(fRun, fRun, fMetaDataFilter, filter);
1117 TString path = fPathFilter.GetPath();
1119 TString pattern = "Run*";
1120 TString optionQuery = "-y";
1122 pattern += Form("_v%d_s0", fVersion);
1126 AliDebug(2,Form("pattern: %s", pattern.Data()));
1128 TString addFolder = "";
1129 if (!path.Contains("*")){
1130 if (!path.BeginsWith("/")) addFolder += "/";
1134 if (path.BeginsWith("/")) path.Remove(0,1);
1135 if (path.EndsWith("/")) path.Remove(path.Length()-1,1);
1136 TObjArray* tokenArr = path.Tokenize("/");
1137 if (tokenArr->GetEntries() != 3) {
1138 AliError("Not a 3 level path! Keeping old query...");
1139 pattern.Prepend(path+"/");
1142 TString str0 = ((TObjString*)tokenArr->At(0))->String();
1143 TString str1 = ((TObjString*)tokenArr->At(1))->String();
1144 TString str2 = ((TObjString*)tokenArr->At(2))->String();
1145 if (str0 != "*" && str1 != "*" && str2 == "*"){
1146 // e.g. "ITS/Calib/*"
1147 addFolder = "/"+str0+"/"+str1;
1149 else if (str0 != "*" && str1 == "*" && str2 == "*"){
1151 addFolder = "/"+str0;
1153 else if (str0 == "*" && str1 == "*" && str2 == "*"){
1155 // do nothing: addFolder is already an empty string;
1158 // e.g. "ITS/*/RecoParam"
1159 pattern.Prepend(path+"/");
1162 delete tokenArr; tokenArr=0;
1165 TString folderCopy(Form("%s%s",fDBFolder.Data(),addFolder.Data()));
1167 AliDebug(2,Form("fDBFolder = %s, pattern = %s, filter = %s",folderCopy.Data(), pattern.Data(), filter.Data()));
1169 if (optionQuery == "-y"){
1170 AliInfo("Only latest version will be returned");
1173 TGridResult *res = gGrid->Query(folderCopy, pattern, filter, optionQuery.Data());
1176 AliError("Grid query failed");
1182 while ((map = (TMap*)next())) {
1184 if ((entry = (TObjString *) ((TMap *)map)->GetValue("lfn"))) {
1185 TString& filename = entry->String();
1186 if(filename.IsNull()) continue;
1187 AliDebug(2,Form("Found valid file: %s", filename.Data()));
1188 AliCDBId *validFileId = new AliCDBId();
1189 Bool_t result = FilenameToId(filename, *validFileId);
1191 fValidFileIds.AddLast(validFileId);
1202 //_____________________________________________________________________________
1203 void AliCDBGrid::MakeQueryFilter(Int_t firstRun, Int_t lastRun,
1204 const AliCDBMetaData* md, TString& result) const
1206 // create filter for file query
1208 result = Form("CDB:first_run<=%d and CDB:last_run>=%d", firstRun, lastRun);
1210 // if(version >= 0) {
1211 // result += Form(" and CDB:version=%d", version);
1213 // if(pathFilter.GetLevel0() != "*") {
1214 // result += Form(" and CDB:path_level_0=\"%s\"", pathFilter.GetLevel0().Data());
1216 // if(pathFilter.GetLevel1() != "*") {
1217 // result += Form(" and CDB:path_level_1=\"%s\"", pathFilter.GetLevel1().Data());
1219 // if(pathFilter.GetLevel2() != "*") {
1220 // result += Form(" and CDB:path_level_2=\"%s\"", pathFilter.GetLevel2().Data());
1224 if(md->GetObjectClassName()[0] != '\0') {
1225 result += Form(" and CDB_MD:object_classname=\"%s\"", md->GetObjectClassName());
1227 if(md->GetResponsible()[0] != '\0') {
1228 result += Form(" and CDB_MD:responsible=\"%s\"", md->GetResponsible());
1230 if(md->GetBeamPeriod() != 0) {
1231 result += Form(" and CDB_MD:beam_period=%d", md->GetBeamPeriod());
1233 if(md->GetAliRootVersion()[0] != '\0') {
1234 result += Form(" and CDB_MD:aliroot_version=\"%s\"", md->GetAliRootVersion());
1236 if(md->GetComment()[0] != '\0') {
1237 result += Form(" and CDB_MD:comment=\"%s\"", md->GetComment());
1240 AliDebug(2, Form("filter: %s",result.Data()));
1245 /////////////////////////////////////////////////////////////////////////////////////////////////
1247 // AliCDBGrid factory //
1249 /////////////////////////////////////////////////////////////////////////////////////////////////
1251 ClassImp(AliCDBGridFactory)
1253 //_____________________________________________________________________________
1254 Bool_t AliCDBGridFactory::Validate(const char* gridString) {
1255 // check if the string is valid Grid URI
1257 TRegexp gridPattern("^alien://.+$");
1259 return TString(gridString).Contains(gridPattern);
1262 //_____________________________________________________________________________
1263 AliCDBParam* AliCDBGridFactory::CreateParameter(const char* gridString) {
1264 // create AliCDBGridParam class from the URI string
1266 if (!Validate(gridString)) {
1270 TString buffer(gridString);
1272 TString gridUrl = "alien://";
1274 TString dbFolder = "";
1275 TString se = "default";
1276 TString cacheFolder = "";
1277 Bool_t operateDisconnected = kTRUE;
1278 Long64_t cacheSize = (UInt_t) 1024*1024*1024; // 1GB
1279 Long_t cleanupInterval = 0;
1281 TObjArray *arr = buffer.Tokenize('?');
1283 TObjString *str = 0;
1285 while((str = (TObjString*) iter.Next())){
1286 TString entry(str->String());
1287 Int_t indeq = entry.Index('=');
1289 if(entry.BeginsWith("alien://")) { // maybe it's a gridUrl!
1293 AliError(Form("Invalid entry! %s",entry.Data()));
1298 TString key = entry(0,indeq);
1299 TString value = entry(indeq+1,entry.Length()-indeq);
1301 if(key.Contains("grid",TString::kIgnoreCase)) {
1304 else if (key.Contains("user",TString::kIgnoreCase)){
1307 else if (key.Contains("se",TString::kIgnoreCase)){
1310 else if (key.Contains("cacheF",TString::kIgnoreCase)){
1311 cacheFolder = value;
1312 if (!cacheFolder.IsNull() && !cacheFolder.EndsWith("/"))
1315 else if (key.Contains("folder",TString::kIgnoreCase)){
1318 else if (key.Contains("operateDisc",TString::kIgnoreCase)){
1319 if(value == "kTRUE") {
1320 operateDisconnected = kTRUE;
1321 } else if (value == "kFALSE") {
1322 operateDisconnected = kFALSE;
1323 } else if (value == "0" || value == "1") {
1324 operateDisconnected = (Bool_t) value.Atoi();
1326 AliError(Form("Invalid entry! %s",entry.Data()));
1330 else if (key.Contains("cacheS",TString::kIgnoreCase)){
1331 if(value.IsDigit()) {
1332 cacheSize = value.Atoi();
1334 AliError(Form("Invalid entry! %s",entry.Data()));
1338 else if (key.Contains("cleanupInt",TString::kIgnoreCase)){
1339 if(value.IsDigit()) {
1340 cleanupInterval = value.Atoi();
1342 AliError(Form("Invalid entry! %s",entry.Data()));
1347 AliError(Form("Invalid entry! %s",entry.Data()));
1353 AliDebug(2, Form("gridUrl: %s", gridUrl.Data()));
1354 AliDebug(2, Form("user: %s", user.Data()));
1355 AliDebug(2, Form("dbFolder: %s", dbFolder.Data()));
1356 AliDebug(2, Form("s.e.: %s", se.Data()));
1357 AliDebug(2, Form("local cache folder: %s", cacheFolder.Data()));
1358 AliDebug(2, Form("local cache operate disconnected: %d", operateDisconnected));
1359 AliDebug(2, Form("local cache size: %lld", cacheSize));
1360 AliDebug(2, Form("local cache cleanup interval: %ld", cleanupInterval));
1363 AliError("Base folder must be specified!");
1367 return new AliCDBGridParam(gridUrl.Data(), user.Data(),
1368 dbFolder.Data(), se.Data(), cacheFolder.Data(),
1369 operateDisconnected, cacheSize, cleanupInterval);
1372 //_____________________________________________________________________________
1373 AliCDBStorage* AliCDBGridFactory::Create(const AliCDBParam* param) {
1374 // create AliCDBGrid storage instance from parameters
1376 AliCDBGrid *grid = 0;
1377 if (AliCDBGridParam::Class() == param->IsA()) {
1379 const AliCDBGridParam* gridParam = (const AliCDBGridParam*) param;
1380 grid = new AliCDBGrid(gridParam->GridUrl().Data(),
1381 gridParam->GetUser().Data(),
1382 gridParam->GetDBFolder().Data(),
1383 gridParam->GetSE().Data(),
1384 gridParam->GetCacheFolder().Data(),
1385 gridParam->GetOperateDisconnected(),
1386 gridParam->GetCacheSize(),
1387 gridParam->GetCleanupInterval());
1391 if(!gGrid && grid) {
1392 delete grid; grid=0;
1398 /////////////////////////////////////////////////////////////////////////////////////////////////
1400 // AliCDBGrid Parameter class // //
1402 /////////////////////////////////////////////////////////////////////////////////////////////////
1404 ClassImp(AliCDBGridParam)
1406 //_____________________________________________________________________________
1407 AliCDBGridParam::AliCDBGridParam():
1414 fOperateDisconnected(),
1419 // default constructor
1423 //_____________________________________________________________________________
1424 AliCDBGridParam::AliCDBGridParam(const char* gridUrl, const char* user, const char* dbFolder,
1425 const char* se, const char* cacheFolder, Bool_t operateDisconnected,
1426 Long64_t cacheSize, Long_t cleanupInterval):
1430 fDBFolder(dbFolder),
1432 fCacheFolder(cacheFolder),
1433 fOperateDisconnected(operateDisconnected),
1434 fCacheSize(cacheSize),
1435 fCleanupInterval(cleanupInterval)
1441 TString uri = Form("%s?User=%s?DBFolder=%s?SE=%s?CacheFolder=%s"
1442 "?OperateDisconnected=%d?CacheSize=%lld?CleanupInterval=%ld",
1443 fGridUrl.Data(), fUser.Data(),
1444 fDBFolder.Data(), fSE.Data(), fCacheFolder.Data(),
1445 fOperateDisconnected, fCacheSize, fCleanupInterval);
1450 //_____________________________________________________________________________
1451 AliCDBGridParam::~AliCDBGridParam() {
1456 //_____________________________________________________________________________
1457 AliCDBParam* AliCDBGridParam::CloneParam() const {
1460 return new AliCDBGridParam(fGridUrl.Data(), fUser.Data(),
1461 fDBFolder.Data(), fSE.Data(), fCacheFolder.Data(),
1462 fOperateDisconnected, fCacheSize, fCleanupInterval);
1465 //_____________________________________________________________________________
1466 ULong_t AliCDBGridParam::Hash() const {
1467 // return Hash function
1469 return fGridUrl.Hash()+fUser.Hash()+fDBFolder.Hash()+fSE.Hash()+fCacheFolder.Hash();
1472 //_____________________________________________________________________________
1473 Bool_t AliCDBGridParam::IsEqual(const TObject* obj) const {
1474 // check if this object is equal to AliCDBParam obj
1480 if (AliCDBGridParam::Class() != obj->IsA()) {
1484 AliCDBGridParam* other = (AliCDBGridParam*) obj;
1486 if(fGridUrl != other->fGridUrl) return kFALSE;
1487 if(fUser != other->fUser) return kFALSE;
1488 if(fDBFolder != other->fDBFolder) return kFALSE;
1489 if(fSE != other->fSE) return kFALSE;
1490 if(fCacheFolder != other->fCacheFolder) return kFALSE;
1491 if(fOperateDisconnected != other->fOperateDisconnected) return kFALSE;
1492 if(fCacheSize != other->fCacheSize) return kFALSE;
1493 if(fCleanupInterval != other->fCleanupInterval) return kFALSE;