]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliCDBGrid.cxx
More corrections in return code (trying to make the return code of the GRP private...
[u/mrichter/AliRoot.git] / STEER / AliCDBGrid.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /////////////////////////////////////////////////////////////////////////////////////////////////
17 //                                                                                             //
18 // AliCDBGrid                                                                                  //
19 // access class to a DataBase in an AliEn storage                                              //
20 //                                                                                             //
21 /////////////////////////////////////////////////////////////////////////////////////////////////
22
23
24 #include <TGrid.h>
25 #include <TGridResult.h>
26 #include <TFile.h>
27 #include <TKey.h>
28 #include <TROOT.h>
29 #include <TList.h>
30 #include <TObjArray.h>
31 #include <TObjString.h>
32 #include <TRegexp.h>
33
34 #include "AliLog.h"
35 #include "AliCDBEntry.h"
36 #include "AliCDBGrid.h"
37 #include "AliCDBManager.h"
38
39
40 ClassImp(AliCDBGrid)
41
42 //_____________________________________________________________________________
43 AliCDBGrid::AliCDBGrid(const char *gridUrl, const char *user, const char *dbFolder,
44                        const char *se, const char* cacheFolder, Bool_t operateDisconnected,
45                        Long64_t cacheSize, Long_t cleanupInterval) :
46 AliCDBStorage(),
47 fGridUrl(gridUrl),
48 fUser(user),
49 fDBFolder(dbFolder),
50 fSE(se),
51 fCacheFolder(cacheFolder),
52 fOperateDisconnected(operateDisconnected),
53 fCacheSize(cacheSize),
54 fCleanupInterval(cleanupInterval)
55 {
56 // constructor //
57
58         // if the same Grid is alreay active, skip connection
59         if (!gGrid || fGridUrl != gGrid->GridUrl()
60              || (( fUser != "" ) && ( fUser != gGrid->GetUser() )) ) {
61                 // connection to the Grid
62                 AliInfo("Connection to the Grid...");
63                 if(gGrid){
64                         AliInfo(Form("gGrid = %x; fGridUrl = %s; gGrid->GridUrl() = %s",gGrid,fGridUrl.Data(), gGrid->GridUrl()));
65                         AliInfo(Form("fUser = %s; gGrid->GetUser() = %s",fUser.Data(), gGrid->GetUser()));
66                 }
67                 TGrid::Connect(fGridUrl.Data(),fUser.Data());
68         }
69
70         if(!gGrid) {
71                 AliError("Connection failed!");
72                 return;
73         }
74
75         TString initDir(gGrid->Pwd(0));
76         if (fDBFolder[0] != '/') {
77                 fDBFolder.Prepend(initDir);
78         }
79
80         // check DBFolder: trying to cd to DBFolder; if it does not exist, create it
81         if(!gGrid->Cd(fDBFolder.Data(),0)){
82                 AliDebug(2,Form("Creating new folder <%s> ...",fDBFolder.Data()));
83                 TGridResult* res = gGrid->Command(Form("mkdir -p %s",fDBFolder.Data()));
84                 TString result = res->GetKey(0,"__result__");
85                 if(result == "0"){
86                         AliFatal(Form("Cannot create folder <%s> !",fDBFolder.Data()));
87                         return;
88                 }
89         } else {
90                 AliDebug(2,Form("Folder <%s> found",fDBFolder.Data()));
91         }
92
93         // removes any '/' at the end of path, then append one '/'
94         while(fDBFolder.EndsWith("/")) fDBFolder.Remove(fDBFolder.Last('/')); 
95         fDBFolder+="/";
96
97         fType="alien";
98         fBaseFolder = fDBFolder;
99
100         // Setting the cache
101
102         // Check if local cache folder is already defined
103         TString origCache(TFile::GetCacheFileDir());
104         if(fCacheFolder.Length() > 0) {
105                 if(origCache.Length() == 0) {
106                         AliInfo(Form("Setting local cache to: %s", fCacheFolder.Data()));
107                 } else if(fCacheFolder != origCache) {
108                         AliWarning(Form("Local cache folder was already defined, changing it to: %s",
109                                         fCacheFolder.Data()));
110                 }
111
112                 // default settings are: operateDisconnected=kTRUE, forceCacheread = kFALSE
113                 if(!TFile::SetCacheFileDir(fCacheFolder.Data(), fOperateDisconnected)) {
114                         AliError(Form("Could not set cache folder %s !", fCacheFolder.Data()));
115                         fCacheFolder = "";
116                 } else {
117                         // reset fCacheFolder because the function may have
118                         // slightly changed the folder name (e.g. '/' added)
119                         fCacheFolder = TFile::GetCacheFileDir();
120                 }
121
122                 // default settings are: cacheSize=1GB, cleanupInterval = 0
123                 if(!TFile::ShrinkCacheFileDir(fCacheSize, fCleanupInterval)) {
124                         AliError(Form("Could not set following values "
125                                 "to ShrinkCacheFileDir: cacheSize = %d, cleanupInterval = %d !",
126                                 fCacheSize, fCleanupInterval));
127                 }
128         }
129
130         // return to the initial directory
131         gGrid->Cd(initDir.Data(),0);
132 }
133
134 //_____________________________________________________________________________
135 AliCDBGrid::~AliCDBGrid()
136 {
137 // destructor
138         delete gGrid; gGrid=0;
139
140 }
141
142 //_____________________________________________________________________________
143 Bool_t AliCDBGrid::FilenameToId(TString& filename, AliCDBId& id) {
144 // build AliCDBId from full path filename (fDBFolder/path/Run#x_#y_v#z_s0.root)
145
146         if(filename.Contains(fDBFolder)){
147                 filename = filename(fDBFolder.Length(),filename.Length()-fDBFolder.Length());
148         }
149
150         TString idPath = filename(0,filename.Last('/'));
151         id.SetPath(idPath);
152         if(!id.IsValid()) return kFALSE;
153
154         filename=filename(idPath.Length()+1,filename.Length()-idPath.Length());
155
156         Ssiz_t mSize;
157         // valid filename: Run#firstRun_#lastRun_v#version_s0.root
158         TRegexp keyPattern("^Run[0-9]+_[0-9]+_v[0-9]+_s0.root$");
159         keyPattern.Index(filename, &mSize);
160         if (!mSize) {
161
162                 // TODO backward compatibility ... maybe remove later!
163                 Ssiz_t oldmSize;
164                 TRegexp oldKeyPattern("^Run[0-9]+_[0-9]+_v[0-9]+.root$");
165                 oldKeyPattern.Index(filename, &oldmSize);
166                 if(!oldmSize) {
167                         AliDebug(2,Form("Bad filename <%s>.", filename.Data()));
168                         return kFALSE;
169                 } else {
170                         AliDebug(2,Form("Old filename format <%s>.", filename.Data()));
171                         id.SetSubVersion(-11); // TODO trick to ensure backward compatibility
172                 }
173
174         } else {
175                 id.SetSubVersion(-1); // TODO trick to ensure backward compatibility
176         }
177
178         filename.Resize(filename.Length() - sizeof(".root") + 1);
179
180         TObjArray* strArray = (TObjArray*) filename.Tokenize("_");
181
182         TString firstRunString(((TObjString*) strArray->At(0))->GetString());
183         id.SetFirstRun(atoi(firstRunString.Data() + 3));
184         id.SetLastRun(atoi(((TObjString*) strArray->At(1))->GetString()));
185
186         TString verString(((TObjString*) strArray->At(2))->GetString());
187         id.SetVersion(atoi(verString.Data() + 1));
188
189         delete strArray;
190
191         return kTRUE;
192 }
193
194 //_____________________________________________________________________________
195 Bool_t AliCDBGrid::IdToFilename(const AliCDBId& id, TString& filename) const {
196 // build file name from AliCDBId (path, run range, version) and fDBFolder
197
198         if (!id.GetAliCDBRunRange().IsValid()) {
199                 AliDebug(2,Form("Invalid run range <%d, %d>.",
200                         id.GetFirstRun(), id.GetLastRun()));
201                 return kFALSE;
202         }
203
204         if (id.GetVersion() < 0) {
205                 AliDebug(2,Form("Invalid version <%d>.", id.GetVersion()));
206                 return kFALSE;
207         }
208
209         filename = Form("Run%d_%d_v%d",
210                                 id.GetFirstRun(),
211                                 id.GetLastRun(),
212                                 id.GetVersion());
213
214         if (id.GetSubVersion() != -11) filename += "_s0"; // TODO to ensure backward compatibility
215         filename += ".root";
216
217         filename.Prepend(fDBFolder + id.GetPath() + '/');
218
219         return kTRUE;
220 }
221
222 //_____________________________________________________________________________
223 Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
224 // prepare id (version) of the object that will be stored (called by PutEntry)
225
226         TString initDir(gGrid->Pwd(0));
227
228         TString dirName(fDBFolder);
229
230         Bool_t dirExist=kFALSE;
231
232
233
234         // go to the path; if directory does not exist, create it
235         for(int i=0;i<3;i++){
236                 dirName+=Form("%s/",id.GetPathLevel(i).Data());
237                 dirExist=gGrid->Cd(dirName,0);
238                 if (!dirExist) {
239                         AliDebug(2,Form("Creating new folder <%s> ...",dirName.Data()));
240                         if(!gGrid->Mkdir(dirName,"",0)){
241                                 AliError(Form("Cannot create directory <%s> !",dirName.Data()));
242                                 gGrid->Cd(initDir.Data());
243                         return kFALSE;
244                         }
245
246                         // if folders are new add tags to them
247                         if(i == 1) {
248                                 // TODO Currently disabled
249                                 // add short lived tag!
250                                 // AliInfo("Tagging level 1 folder with \"ShortLived\" tag");
251                                 // if(!AddTag(dirName,"ShortLived_try")){
252                                 //      AliError(Form("Could not tag folder %s !", dirName.Data()));
253                                 //      if(!gGrid->Rmdir(dirName.Data())){
254                                 //              AliError(Form("Unexpected: could not remove %s directory!", dirName.Data()));
255                                 //      }
256                                 //      return 0;
257                                 //}
258
259                         } else if(i == 2) {
260                                 AliDebug(2,"Tagging level 2 folder with \"CDB\" and \"CDB_MD\" tag");
261                                 if(!AddTag(dirName,"CDB")){
262                                         AliError(Form("Could not tag folder %s !", dirName.Data()));
263                                         if(!gGrid->Rmdir(dirName.Data())){
264                                                 AliError(Form("Unexpected: could not remove %s directory!", dirName.Data()));
265                                         }
266                                         return 0;
267                                 }
268                                 if(!AddTag(dirName,"CDB_MD")){
269                                         AliError(Form("Could not tag folder %s !", dirName.Data()));
270                                         if(!gGrid->Rmdir(dirName.Data())){
271                                                 AliError(Form("Unexpected: could not remove %s directory!", dirName.Data()));
272                                         }
273                                         return 0;
274                                 }
275
276                                 // TODO Currently disabled
277                                 // add short lived tag!
278                                 // TString path=id.GetPath();
279                                 // if(AliCDBManager::Instance()->IsShortLived(path.Data())) {
280                                 //      AliInfo(Form("Tagging %s as short lived", dirName.Data()));
281                                 //      if(!TagShortLived(dirName, kTRUE)){
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()));
285                                 //              }
286                                 //              return 0;
287                                 //      }
288                                 // } else {
289                                 //      AliInfo(Form("Tagging %s as long lived", dirName.Data()));
290                                 //      if(!TagShortLived(dirName, kFALSE)){
291                                 //              AliError(Form("Could not tag folder %s !", dirName.Data()));
292                                 //              if(!gGrid->Rmdir(dirName.Data())){
293                                 //                      AliError(Form("Unexpected: could not remove %s directory!", dirName.Data()));
294                                 //              }
295                                 //              return 0;
296                                 //      }
297                                 // }
298                         }
299                 }
300         }
301         gGrid->Cd(initDir,0);
302
303         TString filename;
304         AliCDBId anId; // the id got from filename
305         AliCDBRunRange lastRunRange(-1,-1); // highest runRange found
306         Int_t lastVersion=0; // highest version found
307
308         TGridResult *res = gGrid->Ls(dirName);
309
310         //loop on the files in the directory, look for highest version
311         for(int i=0; i < res->GetEntries(); i++){
312                 filename=res->GetFileNamePath(i);
313                 if (!FilenameToId(filename, anId)) continue;
314                 if (anId.GetAliCDBRunRange().Overlaps(id.GetAliCDBRunRange()) && anId.GetVersion() > lastVersion) {
315                         lastVersion = anId.GetVersion();
316                         lastRunRange = anId.GetAliCDBRunRange();
317                 }
318
319         }
320         delete res;
321
322         id.SetVersion(lastVersion + 1);
323         id.SetSubVersion(0);
324
325         TString lastStorage = id.GetLastStorage();
326         if(lastStorage.Contains(TString("new"), TString::kIgnoreCase) && id.GetVersion() > 1 ){
327                 AliDebug(2, Form("A NEW object is being stored with version %d",
328                                         id.GetVersion()));
329                 AliDebug(2, Form("and it will hide previously stored object with version %d!",
330                                         id.GetVersion()-1));
331         }
332
333         if(!lastRunRange.IsAnyRange() && !(lastRunRange.IsEqual(&id.GetAliCDBRunRange())))
334                 AliWarning(Form("Run range modified w.r.t. previous version (Run%d_%d_v%d)",
335                         lastRunRange.GetFirstRun(), lastRunRange.GetLastRun(), id.GetVersion()));
336
337         return kTRUE;
338 }
339
340 //_____________________________________________________________________________
341 AliCDBId* AliCDBGrid::GetId(const TObjArray& validFileIds, const AliCDBId& query) {
342 // look for the Id that matches query's requests (highest or exact version)
343
344         if(validFileIds.GetEntriesFast() < 1) {
345                 return NULL;
346         } else if (validFileIds.GetEntriesFast() == 1) {
347                 return dynamic_cast<AliCDBId*> (validFileIds.At(0)->Clone());
348         }
349
350         TIter iter(&validFileIds);
351
352         AliCDBId *anIdPtr=0;
353         AliCDBId* result=0;
354
355         while((anIdPtr = dynamic_cast<AliCDBId*> (iter.Next()))){
356                 if(anIdPtr->GetPath() != query.GetPath()) continue;
357
358                 //if(!CheckVersion(query, anIdPtr, result)) return NULL;
359
360                 if (!query.HasVersion()){ // look for highest version
361                         if(result && result->GetVersion() > anIdPtr->GetVersion()) continue;
362                         if(result && result->GetVersion() == anIdPtr->GetVersion()) {
363                                 AliError(Form("More than one object valid for run %d, version %d!",
364                                         query.GetFirstRun(), anIdPtr->GetVersion()));
365                                 return NULL;
366                         }
367                         result = anIdPtr;
368                 } else { // look for specified version
369                         if(query.GetVersion() != anIdPtr->GetVersion()) continue;
370                         if(result && result->GetVersion() == anIdPtr->GetVersion()){
371                                 AliError(Form("More than one object valid for run %d, version %d!",
372                                         query.GetFirstRun(), anIdPtr->GetVersion()));
373                                 return NULL;
374                         }
375                         result = anIdPtr;
376                 }
377
378         }
379         
380         if (!result) return NULL;
381
382         return dynamic_cast<AliCDBId*> (result->Clone());
383 }
384
385 //_____________________________________________________________________________
386 AliCDBId* AliCDBGrid::GetEntryId(const AliCDBId& queryId) {
387 // get AliCDBId from the database
388 // User must delete returned object
389
390         AliCDBId* dataId=0;
391
392         AliCDBId selectedId(queryId);
393         if (!selectedId.HasVersion()) {
394                 // if version is not specified, first check the selection criteria list
395                 GetSelection(&selectedId);
396         }
397
398         TObjArray validFileIds;
399         validFileIds.SetOwner(1);
400
401         // look for file matching query requests (path, runRange, version)
402         if(selectedId.GetFirstRun() == fRun &&
403                         fPathFilter.Comprises(selectedId.GetAliCDBPath()) && fVersion < 0 && !fMetaDataFilter){
404                 // look into list of valid files previously loaded with AliCDBStorage::FillValidFileIds()
405                 AliDebug(2, Form("List of files valid for run %d and for path %s was loaded. Looking there!",
406                                         selectedId.GetFirstRun(), selectedId.GetPath().Data()));
407                 dataId = GetId(fValidFileIds, selectedId);
408
409         } else {
410                 // List of files valid for reqested run was not loaded. Looking directly into CDB
411                 AliDebug(2, Form("List of files valid for run %d and for path %s was not loaded. Looking directly into CDB!",
412                                         selectedId.GetFirstRun(), selectedId.GetPath().Data()));
413
414                 TString filter;
415                 MakeQueryFilter(selectedId.GetFirstRun(), selectedId.GetLastRun(), 0, filter);
416
417                 TString pattern = Form("%s/Run*", selectedId.GetPath().Data());
418                 if(selectedId.GetVersion() >= 0) pattern += Form("_v%d*",selectedId.GetVersion());
419                 pattern += ".root";
420                 AliDebug(2,Form("pattern: %s", pattern.Data()));
421
422                 TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
423                 AliCDBId validFileId;
424                 for(int i=0; i<res->GetEntries(); i++){
425                         TString filename = res->GetKey(i, "lfn");
426                         if(filename == "") continue;
427                         if(FilenameToId(filename, validFileId))
428                                         validFileIds.AddLast(validFileId.Clone());
429                 }
430                 delete res;
431                 dataId = GetId(validFileIds, selectedId);
432         }
433
434         return dataId;
435 }
436
437 //_____________________________________________________________________________
438 AliCDBEntry* AliCDBGrid::GetEntry(const AliCDBId& queryId) {
439 // get AliCDBEntry from the database
440
441         AliCDBId* dataId = GetEntryId(queryId);
442
443         if (!dataId) return NULL;
444
445         TString filename;
446         if (!IdToFilename(*dataId, filename)) {
447                 AliDebug(2,Form("Bad data ID encountered! Subnormal error!"));
448                 delete dataId;
449                 return NULL;
450         }
451
452         AliCDBEntry* anEntry = GetEntryFromFile(filename, dataId);
453
454         delete dataId;
455         return anEntry;
456 }
457
458 //_____________________________________________________________________________
459 AliCDBEntry* AliCDBGrid::GetEntryFromFile(TString& filename, AliCDBId* dataId){
460 // Get AliCBEntry object from file "filename"
461
462         AliDebug(2,Form("Opening file: %s",filename.Data()));
463
464         filename.Prepend("/alien");
465
466         // if option="CACHEREAD" TFile will use the local caching facility!
467         TString option="READ";
468         if(fCacheFolder != ""){
469
470                 // Check if local cache folder was changed in the meanwhile
471                 TString origCache(TFile::GetCacheFileDir());
472                 if(fCacheFolder != origCache) {
473                         AliWarning(Form("Local cache folder has been overwritten!! fCacheFolder = %s origCache = %s",
474                                         fCacheFolder.Data(), origCache.Data()));
475                         TFile::SetCacheFileDir(fCacheFolder.Data(), fOperateDisconnected);
476                         TFile::ShrinkCacheFileDir(fCacheSize, fCleanupInterval);
477                 }
478
479                 option.Prepend("CACHE");
480         }
481
482         AliDebug(2, Form("Option: %s", option.Data()));
483
484         TFile *file = TFile::Open(filename, option);
485         if (!file) {
486                 AliDebug(2,Form("Can't open file <%s>!", filename.Data()));
487                 return NULL;
488         }
489
490         // get the only AliCDBEntry object from the file
491         // the object in the file is an AliCDBEntry entry named "AliCDBEntry"
492
493         AliCDBEntry* anEntry = dynamic_cast<AliCDBEntry*> (file->Get("AliCDBEntry"));
494
495         if (!anEntry) {
496                 AliDebug(2,Form("Bad storage data: file does not contain an AliCDBEntry object!"));
497                 file->Close();
498                 return NULL;
499         }
500
501         // The object's Id is not reset during storage
502         // If object's Id runRange or version do not match with filename,
503         // it means that someone renamed file by hand. In this case a warning msg is issued.
504
505         if(anEntry){
506                 AliCDBId entryId = anEntry->GetId();
507                 Int_t tmpSubVersion = dataId->GetSubVersion();
508                 dataId->SetSubVersion(entryId.GetSubVersion()); // otherwise filename and id may mismatch
509                 if(!entryId.IsEqual(dataId)){
510                         AliWarning(Form("Mismatch between file name and object's Id!"));
511                         AliWarning(Form("File name: %s", dataId->ToString().Data()));
512                         AliWarning(Form("Object's Id: %s", entryId.ToString().Data()));
513                 }
514                 dataId->SetSubVersion(tmpSubVersion);
515         }
516
517         anEntry->SetLastStorage("grid");
518
519         // Check whether entry contains a TTree. In case load the tree in memory!
520         LoadTreeFromFile(anEntry);
521
522         // close file, return retieved entry
523         file->Close(); delete file; file=0;
524
525         return anEntry;
526 }
527
528 //_____________________________________________________________________________
529 TList* AliCDBGrid::GetEntries(const AliCDBId& queryId) {
530 // multiple request (AliCDBStorage::GetAll)
531
532         TList* result = new TList();
533         result->SetOwner();
534
535         TObjArray validFileIds;
536         validFileIds.SetOwner(1);
537
538         Bool_t alreadyLoaded = kFALSE;
539
540         // look for file matching query requests (path, runRange)
541         if(queryId.GetFirstRun() == fRun &&
542                         fPathFilter.Comprises(queryId.GetAliCDBPath()) && fVersion < 0 && !fMetaDataFilter){
543                 // look into list of valid files previously loaded with AliCDBStorage::FillValidFileIds()
544                 AliDebug(2,Form("List of files valid for run %d and for path %s was loaded. Looking there!",
545                                         queryId.GetFirstRun(), queryId.GetPath().Data()));
546
547                 alreadyLoaded = kTRUE;
548
549         } else {
550                 // List of files valid for reqested run was not loaded. Looking directly into CDB
551                 AliDebug(2,Form("List of files valid for run %d and for path %s was not loaded. Looking directly into CDB!",
552                                         queryId.GetFirstRun(), queryId.GetPath().Data()));
553
554                 TString filter;
555                 MakeQueryFilter(queryId.GetFirstRun(), queryId.GetLastRun(), 0, filter);
556
557                 TString pattern = Form("%s/Run*.root", queryId.GetPath().Data());
558                 AliDebug(2,Form("pattern: %s", pattern.Data()));
559
560                 TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
561
562                 AliCDBId validFileId;
563                 for(int i=0; i<res->GetEntries(); i++){
564                         TString filename = res->GetKey(i, "lfn");
565                         if(filename == "") continue;
566                         if(FilenameToId(filename, validFileId))
567                                         validFileIds.AddLast(validFileId.Clone());
568                 }
569                 delete res;
570         }
571
572         TIter *iter=0;
573         if(alreadyLoaded){
574                 iter = new TIter(&fValidFileIds);
575         } else {
576                 iter = new TIter(&validFileIds);
577         }
578
579         TObjArray selectedIds;
580         selectedIds.SetOwner(1);
581
582         // loop on list of valid Ids to select the right version to get.
583         // According to query and to the selection criteria list, version can be the highest or exact
584         AliCDBPath pathCopy;
585         AliCDBId* anIdPtr=0;
586         AliCDBId* dataId=0;
587         AliCDBPath queryPath = queryId.GetAliCDBPath();
588         while((anIdPtr = dynamic_cast<AliCDBId*> (iter->Next()))){
589                 AliCDBPath thisCDBPath = anIdPtr->GetAliCDBPath();
590                 if(!(queryPath.Comprises(thisCDBPath)) || pathCopy.GetPath() == thisCDBPath.GetPath()) continue;
591                 pathCopy = thisCDBPath;
592
593                 // check the selection criteria list for this query
594                 AliCDBId thisId(*anIdPtr);
595                 thisId.SetVersion(queryId.GetVersion());
596                 if(!thisId.HasVersion()) GetSelection(&thisId);
597
598                 if(alreadyLoaded){
599                         dataId = GetId(fValidFileIds, thisId);
600                 } else {
601                         dataId = GetId(validFileIds, thisId);
602                 }
603                 if(dataId) selectedIds.Add(dataId);
604         }
605
606         delete iter; iter=0;
607
608         // selectedIds contains the Ids of the files matching all requests of query!
609         // All the objects are now ready to be retrieved
610         iter = new TIter(&selectedIds);
611         while((anIdPtr = dynamic_cast<AliCDBId*> (iter->Next()))){
612                 TString filename;
613                 if (!IdToFilename(*anIdPtr, filename)) {
614                         AliDebug(2,Form("Bad data ID encountered! Subnormal error!"));
615                         continue;
616                 }
617
618                 AliCDBEntry* anEntry = GetEntryFromFile(filename, anIdPtr);
619
620                 if(anEntry) result->Add(anEntry);
621
622         }
623         delete iter; iter=0;
624
625         return result;
626 }
627
628 //_____________________________________________________________________________
629 Bool_t AliCDBGrid::PutEntry(AliCDBEntry* entry) {
630 // put an AliCDBEntry object into the database
631
632         AliCDBId& id = entry->GetId();
633
634         // set version for the entry to be stored
635         if (!PrepareId(id)) return kFALSE;
636
637         // build filename from entry's id
638         TString filename;
639         if (!IdToFilename(id, filename)) {
640                 AliError("Bad ID encountered! Subnormal error!");
641                 return kFALSE;
642         }
643
644         TString folderToTag = Form("%s%s",
645                                         fDBFolder.Data(),
646                                         id.GetPath().Data());
647
648         TDirectory* saveDir = gDirectory;
649
650         TString fullFilename = Form("/alien%s", filename.Data());
651         // specify SE to filename
652         if (fSE != "default") fullFilename += Form("?se=%s",fSE.Data());
653
654         // open file
655         TFile *file = TFile::Open(fullFilename,"CREATE");
656         if(!file || !file->IsWritable()){
657                 AliError(Form("Can't open file <%s>!", filename.Data()));
658                 if(file && !file->IsWritable()) file->Close(); delete file; file=0;
659                 return kFALSE;
660         }
661
662         file->cd();
663
664         //SetTreeToFile(entry, file);
665
666         entry->SetVersion(id.GetVersion());
667
668         // write object (key name: "AliCDBEntry")
669         Bool_t result = (file->WriteTObject(entry, "AliCDBEntry") != 0);
670         if (!result) AliError(Form("Can't write entry to file <%s>!", filename.Data()));
671
672
673         if (saveDir) saveDir->cd(); else gROOT->cd();
674         file->Close(); delete file; file=0;
675
676         if(result) {
677         
678                 if(!TagFileId(filename, &id)){
679                         AliInfo(Form("CDB tagging failed. Deleting file %s!",filename.Data()));
680                         if(!gGrid->Rm(filename.Data()))
681                                 AliError("Can't delete file!");
682                         return kFALSE;
683                 }
684
685                 TagFileMetaData(filename, entry->GetMetaData());
686         }
687
688         AliInfo(Form("CDB object stored into file %s", filename.Data()));
689         AliInfo(Form("Storage Element: %s", fSE.Data()));
690         return result;
691 }
692 //_____________________________________________________________________________
693 Bool_t AliCDBGrid::AddTag(TString& folderToTag, const char* tagname){
694 // add "tagname" tag (CDB or CDB_MD) to folder where object will be stored
695
696         Bool_t result = kTRUE;
697         AliDebug(2, Form("adding %s tag to folder %s", tagname, folderToTag.Data()));
698         TString addTag = Form("addTag %s %s", folderToTag.Data(), tagname);
699         TGridResult *gridres = gGrid->Command(addTag.Data());
700         const char* resCode = gridres->GetKey(0,"__result__"); // '1' if success
701         if(resCode[0] != '1') {
702                 AliError(Form("Couldn't add %s tags to folder %s !",
703                                                 tagname, folderToTag.Data()));
704                 result = kFALSE;
705         }
706         delete gridres;
707         return result;
708 }
709
710 //_____________________________________________________________________________
711 Bool_t AliCDBGrid::TagFileId(TString& filename, const AliCDBId* id){
712 // tag stored object in CDB table using object Id's parameters
713
714         TString addTagValue1 = Form("addTagValue %s CDB ", filename.Data());
715         TString addTagValue2 = Form("first_run=%d last_run=%d version=%d ",
716                                         id->GetFirstRun(),
717                                         id->GetLastRun(),
718                                         id->GetVersion());
719         TString addTagValue3 = Form("path_level_0=\"%s\" path_level_1=\"%s\" path_level_2=\"%s\"",
720                                         id->GetPathLevel(0).Data(),
721                                         id->GetPathLevel(1).Data(),
722                                         id->GetPathLevel(2).Data());
723         TString addTagValue = Form("%s%s%s",
724                                         addTagValue1.Data(),
725                                         addTagValue2.Data(),
726                                         addTagValue3.Data());
727
728         Bool_t result = kFALSE;
729         AliDebug(2, Form("Tagging file. Tag command: %s", addTagValue.Data()));
730         TGridResult* res = gGrid->Command(addTagValue.Data());
731         const char* resCode = res->GetKey(0,"__result__"); // '1' if success
732         if(resCode[0] != '1') {
733                 AliError(Form("Couldn't add CDB tag value to file %s !",
734                                                 filename.Data()));
735                 result = kFALSE;
736         } else {
737                 AliDebug(2, "Object successfully tagged.");
738                 result = kTRUE;
739         }
740         delete res;
741         return result;
742
743 }
744
745 //_____________________________________________________________________________
746 Bool_t AliCDBGrid::TagShortLived(TString& filename, Bool_t value){
747 // tag folder with ShortLived tag
748
749         TString addTagValue = Form("addTagValue %s ShortLived_try value=%d", filename.Data(), value);
750
751         Bool_t result = kFALSE;
752         AliDebug(2, Form("Tagging file. Tag command: %s", addTagValue.Data()));
753         TGridResult* res = gGrid->Command(addTagValue.Data());
754         const char* resCode = res->GetKey(0,"__result__"); // '1' if success
755         if(resCode[0] != '1') {
756                 AliError(Form("Couldn't add ShortLived tag value to file %s !", filename.Data()));
757                 result = kFALSE;
758         } else {
759                 AliDebug(2,"Object successfully tagged.");
760                 result = kTRUE;
761         }
762         delete res;
763         return result;
764
765 }
766
767 //_____________________________________________________________________________
768 Bool_t AliCDBGrid::TagFileMetaData(TString& filename, const AliCDBMetaData* md){
769 // tag stored object in CDB table using object Id's parameters
770
771         TString addTagValue1 = Form("addTagValue %s CDB_MD ", filename.Data());
772         TString addTagValue2 = Form("object_classname=\"%s\" responsible=\"%s\" beam_period=%d ",
773                                         md->GetObjectClassName(),
774                                         md->GetResponsible(),
775                                         md->GetBeamPeriod());
776         TString addTagValue3 = Form("aliroot_version=\"%s\" comment=\"%s\"",
777                                         md->GetAliRootVersion(),
778                                         md->GetComment());
779         TString addTagValue = Form("%s%s%s",
780                                         addTagValue1.Data(),
781                                         addTagValue2.Data(),
782                                         addTagValue3.Data());
783
784         Bool_t result = kFALSE;
785         AliDebug(2, Form("Tagging file. Tag command: %s", addTagValue.Data()));
786         TGridResult* res = gGrid->Command(addTagValue.Data());
787         const char* resCode = res->GetKey(0,"__result__"); // '1' if success
788         if(resCode[0] != '1') {
789                 AliWarning(Form("Couldn't add CDB_MD tag value to file %s !",
790                                                 filename.Data()));
791                 result = kFALSE;
792         } else {
793                 AliDebug(2,"Object successfully tagged.");
794                 result = kTRUE;
795         }
796         return result;
797 }
798
799 //_____________________________________________________________________________
800 TList* AliCDBGrid::GetIdListFromFile(const char* fileName){
801
802         TString turl(fileName);
803         turl.Prepend("/alien" + fDBFolder);
804         turl += "?se="; turl += fSE.Data();
805         TFile *file = TFile::Open(turl);
806         if (!file) {
807                 AliError(Form("Can't open selection file <%s>!", turl.Data()));
808                 return NULL;
809         }
810
811         TList *list = new TList();
812         list->SetOwner();
813         int i=0;
814         TString keycycle;
815
816         AliCDBId *id;
817         while(1){
818                 i++;
819                 keycycle = "AliCDBId;";
820                 keycycle+=i;
821                 
822                 id = (AliCDBId*) file->Get(keycycle);
823                 if(!id) break;
824                 list->AddFirst(id);
825         }
826         file->Close(); delete file; file=0;
827         
828         return list;
829
830
831 }
832
833 //_____________________________________________________________________________
834 Bool_t AliCDBGrid::Contains(const char* path) const{
835 // check for path in storage's DBFolder
836
837         TString initDir(gGrid->Pwd(0));
838         TString dirName(fDBFolder);
839         dirName += path; // dirName = fDBFolder/path
840         Bool_t result=kFALSE;
841         if (gGrid->Cd(dirName,0)) result=kTRUE;
842         gGrid->Cd(initDir.Data(),0);
843         return result;
844 }
845
846 //_____________________________________________________________________________
847 void AliCDBGrid::QueryValidFiles()
848 {
849 // Query the CDB for files valid for AliCDBStorage::fRun
850 // fills list fValidFileIds with AliCDBId objects created from file name
851
852         TString filter;
853         MakeQueryFilter(fRun, fRun, fMetaDataFilter, filter);
854
855         TString pattern = Form("%s/Run*", fPathFilter.GetPath().Data());
856         if(fVersion >= 0) pattern += Form("_v%d*", fVersion);
857         pattern += ".root";
858         AliDebug(2,Form("pattern: %s", pattern.Data()));
859
860         TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
861
862         if (!res) {
863                 AliError("Grid query failed");
864                 return;
865         }
866
867         AliCDBId validFileId;
868         for(int i=0; i<res->GetEntries(); i++){
869                 TString filename = res->GetKey(i, "lfn");
870                 if(filename == "") continue;
871                 AliDebug(2,Form("Found valid file: %s", filename.Data()));
872                 Bool_t result = FilenameToId(filename, validFileId);
873                 if(result) {
874                         fValidFileIds.AddLast(validFileId.Clone());
875                 }
876         }
877         delete res;
878
879 }
880
881 //_____________________________________________________________________________
882 void AliCDBGrid::MakeQueryFilter(Int_t firstRun, Int_t lastRun,
883                                         const AliCDBMetaData* md, TString& result) const
884 {
885 // create filter for file query
886
887         result = Form("CDB:first_run<=%d and CDB:last_run>=%d", firstRun, lastRun);
888
889 //      if(version >= 0) {
890 //              result += Form(" and CDB:version=%d", version);
891 //      }
892 //      if(pathFilter.GetLevel0() != "*") {
893 //              result += Form(" and CDB:path_level_0=\"%s\"", pathFilter.GetLevel0().Data());
894 //      }
895 //      if(pathFilter.GetLevel1() != "*") {
896 //              result += Form(" and CDB:path_level_1=\"%s\"", pathFilter.GetLevel1().Data());
897 //      }
898 //      if(pathFilter.GetLevel2() != "*") {
899 //              result += Form(" and CDB:path_level_2=\"%s\"", pathFilter.GetLevel2().Data());
900 //      }
901
902         if(md){
903                 if(md->GetObjectClassName()[0] != '\0') {
904                         result += Form(" and CDB_MD:object_classname=\"%s\"", md->GetObjectClassName());
905                 }
906                 if(md->GetResponsible()[0] != '\0') {
907                         result += Form(" and CDB_MD:responsible=\"%s\"", md->GetResponsible());
908                 }
909                 if(md->GetBeamPeriod() != 0) {
910                         result += Form(" and CDB_MD:beam_period=%d", md->GetBeamPeriod());
911                 }
912                 if(md->GetAliRootVersion()[0] != '\0') {
913                         result += Form(" and CDB_MD:aliroot_version=\"%s\"", md->GetAliRootVersion());
914                 }
915                 if(md->GetComment()[0] != '\0') {
916                         result += Form(" and CDB_MD:comment=\"%s\"", md->GetComment());
917                 }
918         }
919         AliDebug(2, Form("filter: %s",result.Data()));
920
921 }
922
923 //_____________________________________________________________________________
924 Int_t AliCDBGrid::GetLatestVersion(const char* path, Int_t run){
925 // get last version found in the database valid for run and path
926
927         AliCDBPath aCDBPath(path);
928         if(!aCDBPath.IsValid() || aCDBPath.IsWildcard()) {
929                 AliError(Form("Invalid path in request: %s", path));
930                 return -1;
931         }
932         AliCDBId query(path, run, run, -1, -1);
933         AliCDBId* dataId = 0;
934
935         // look for file matching query requests (path, runRange, version)
936         if(run == fRun && fPathFilter.Comprises(aCDBPath) && fVersion < 0){
937                 // look into list of valid files previously loaded with AliCDBStorage::FillValidFileIds()
938                 AliDebug(2, Form("List of files valid for run %d and for path %s was loaded. Looking there!",
939                                         run, path));
940                 dataId = GetId(fValidFileIds, query);
941                 if (!dataId) return -1;
942                 Int_t version = dataId->GetVersion();
943                 delete dataId;
944                 return version;
945
946         }
947         // List of files valid for reqested run was not loaded. Looking directly into CDB
948         AliDebug(2, Form("List of files valid for run %d and for path %s was not loaded. Looking directly into CDB!",
949                                 run, path));
950
951         TObjArray validFileIds;
952         validFileIds.SetOwner(1);
953
954         TString filter;
955         MakeQueryFilter(run, run, 0, filter);
956
957         TString pattern = Form("%s/Run*.root", path);
958         AliDebug(2,Form("pattern: %s", pattern.Data()));
959
960         TGridResult *res = gGrid->Query(fDBFolder, pattern, filter, "");
961         AliCDBId validFileId;
962         for(int i=0; i<res->GetEntries(); i++){
963                 TString filename = res->GetKey(i, "lfn");
964                 if(filename == "") continue;
965                 if(FilenameToId(filename, validFileId))
966                                 validFileIds.AddLast(validFileId.Clone());
967         }
968         delete res;
969
970         dataId = GetId(validFileIds, query);
971         if (!dataId) return -1;
972
973         Int_t version = dataId->GetVersion();
974         delete dataId;
975         return version;
976
977 }
978
979 //_____________________________________________________________________________
980 Int_t AliCDBGrid::GetLatestSubVersion(const char* /*path*/, Int_t /*run*/, Int_t /*version*/){
981 // get last subversion found in the database valid for run and path
982         AliError("Objects in GRID storage have no sub version!");
983         return -1;
984 }
985
986
987 /////////////////////////////////////////////////////////////////////////////////////////////////
988 //                                                                                             //
989 // AliCDBGrid factory                                                                          //
990 //                                                                                             //
991 /////////////////////////////////////////////////////////////////////////////////////////////////
992
993 ClassImp(AliCDBGridFactory)
994
995 //_____________________________________________________________________________
996 Bool_t AliCDBGridFactory::Validate(const char* gridString) {
997 // check if the string is valid Grid URI
998
999         TRegexp gridPattern("^alien://.+$");
1000
1001         return TString(gridString).Contains(gridPattern);
1002 }
1003
1004 //_____________________________________________________________________________
1005 AliCDBParam* AliCDBGridFactory::CreateParameter(const char* gridString) {
1006 // create AliCDBGridParam class from the URI string
1007
1008         if (!Validate(gridString)) {
1009                 return NULL;
1010         }
1011
1012         TString buffer(gridString);
1013
1014         TString gridUrl         = "alien://";
1015         TString user            = "";
1016         TString dbFolder        = "";
1017         TString se              = "default";
1018         TString cacheFolder     = "";
1019         Bool_t  operateDisconnected = kTRUE;
1020         Long64_t cacheSize          = (UInt_t) 1024*1024*1024; // 1GB
1021         Long_t cleanupInterval      = 0;
1022
1023         TObjArray *arr = buffer.Tokenize('?');
1024         TIter iter(arr);
1025         TObjString *str = 0;
1026
1027         while((str = (TObjString*) iter.Next())){
1028                 TString entry(str->String());
1029                 Int_t indeq = entry.Index('=');
1030                 if(indeq == -1) {
1031                         if(entry.BeginsWith("alien://")) { // maybe it's a gridUrl!
1032                                 gridUrl = entry;
1033                                 continue;
1034                         } else {
1035                                 AliError(Form("Invalid entry! %s",entry.Data()));
1036                                 continue;
1037                         }
1038                 }
1039                 
1040                 TString key = entry(0,indeq);
1041                 TString value = entry(indeq+1,entry.Length()-indeq);
1042
1043                 if(key.Contains("grid",TString::kIgnoreCase)) {
1044                         gridUrl += value;
1045                 }
1046                 else if (key.Contains("user",TString::kIgnoreCase)){
1047                         user = value;
1048                 }
1049                 else if (key.Contains("se",TString::kIgnoreCase)){
1050                         se = value;
1051                 }
1052                 else if (key.Contains("cacheF",TString::kIgnoreCase)){
1053                         cacheFolder = value;
1054                         if (!cacheFolder.EndsWith("/"))
1055                                 cacheFolder += "/";
1056                 }
1057                 else if (key.Contains("folder",TString::kIgnoreCase)){
1058                         dbFolder = value;
1059                 }
1060                 else if (key.Contains("operateDisc",TString::kIgnoreCase)){
1061                         if(value == "kTRUE") {
1062                                 operateDisconnected = kTRUE;
1063                         } else if (value == "kFALSE") {
1064                                 operateDisconnected = kFALSE;
1065                         } else if (value == "0" || value == "1") {
1066                                 operateDisconnected = (Bool_t) value.Atoi();
1067                         } else {
1068                                 AliError(Form("Invalid entry! %s",entry.Data()));
1069                                 return NULL;
1070                         }
1071                 }
1072                 else if (key.Contains("cacheS",TString::kIgnoreCase)){
1073                         if(value.IsDigit()) {
1074                                 cacheSize = value.Atoi();
1075                         } else {
1076                                 AliError(Form("Invalid entry! %s",entry.Data()));
1077                                 return NULL;
1078                         }
1079                 }
1080                 else if (key.Contains("cleanupInt",TString::kIgnoreCase)){
1081                         if(value.IsDigit()) {
1082                                 cleanupInterval = value.Atoi();
1083                         } else {
1084                                 AliError(Form("Invalid entry! %s",entry.Data()));
1085                                 return NULL;
1086                         }
1087                 }
1088                 else{
1089                         AliError(Form("Invalid entry! %s",entry.Data()));
1090                         return NULL;
1091                 }
1092         }
1093         delete arr; arr=0;
1094
1095         AliDebug(2, Form("gridUrl:      %s", gridUrl.Data()));
1096         AliDebug(2, Form("user: %s", user.Data()));
1097         AliDebug(2, Form("dbFolder:     %s", dbFolder.Data()));
1098         AliDebug(2, Form("s.e.: %s", se.Data()));
1099         AliDebug(2, Form("local cache folder: %s", cacheFolder.Data()));
1100         AliDebug(2, Form("local cache operate disconnected: %d", operateDisconnected));
1101         AliDebug(2, Form("local cache size: %d", cacheSize));
1102         AliDebug(2, Form("local cache cleanup interval: %d", cleanupInterval));
1103
1104         if(dbFolder == ""){
1105                 AliError("Base folder must be specified!");
1106                 return NULL;
1107         }
1108
1109         return new AliCDBGridParam(gridUrl.Data(), user.Data(),
1110                           dbFolder.Data(), se.Data(), cacheFolder.Data(),
1111                           operateDisconnected, cacheSize, cleanupInterval);
1112 }
1113
1114 //_____________________________________________________________________________
1115 AliCDBStorage* AliCDBGridFactory::Create(const AliCDBParam* param) {
1116 // create AliCDBGrid storage instance from parameters
1117         
1118         AliCDBGrid *grid = 0;
1119         if (AliCDBGridParam::Class() == param->IsA()) {
1120
1121                 const AliCDBGridParam* gridParam = (const AliCDBGridParam*) param;
1122                 grid = new AliCDBGrid(gridParam->GridUrl().Data(),
1123                                       gridParam->GetUser().Data(),
1124                                       gridParam->GetDBFolder().Data(),
1125                                       gridParam->GetSE().Data(),
1126                                       gridParam->GetCacheFolder().Data(),
1127                                       gridParam->GetOperateDisconnected(),
1128                                       gridParam->GetCacheSize(),
1129                                       gridParam->GetCleanupInterval());
1130
1131         }
1132
1133         if(!gGrid && grid) {
1134                 delete grid; grid=0;
1135         }
1136
1137         return grid;
1138 }
1139
1140 /////////////////////////////////////////////////////////////////////////////////////////////////
1141 //                                                                                             //
1142 // AliCDBGrid Parameter class                                                                  //                                         //
1143 //                                                                                             //
1144 /////////////////////////////////////////////////////////////////////////////////////////////////
1145
1146 ClassImp(AliCDBGridParam)
1147
1148 //_____________________________________________________________________________
1149 AliCDBGridParam::AliCDBGridParam():
1150  AliCDBParam(),
1151  fGridUrl(),
1152  fUser(),
1153  fDBFolder(),
1154  fSE(),
1155  fCacheFolder(),
1156  fOperateDisconnected(),
1157  fCacheSize(),
1158  fCleanupInterval()
1159
1160  {
1161 // default constructor
1162
1163 }
1164
1165 //_____________________________________________________________________________
1166 AliCDBGridParam::AliCDBGridParam(const char* gridUrl, const char* user, const char* dbFolder,
1167                                 const char* se, const char* cacheFolder, Bool_t operateDisconnected,
1168                                 Long64_t cacheSize, Long_t cleanupInterval):
1169  AliCDBParam(),
1170  fGridUrl(gridUrl),
1171  fUser(user),
1172  fDBFolder(dbFolder),
1173  fSE(se),
1174  fCacheFolder(cacheFolder),
1175  fOperateDisconnected(operateDisconnected),
1176  fCacheSize(cacheSize),
1177  fCleanupInterval(cleanupInterval)
1178 {
1179 // constructor
1180
1181         SetType("alien");
1182
1183         TString uri = Form("%s?User=%s?DBFolder=%s?SE=%s?CacheFolder=%s"
1184                         "?OperateDisconnected=%d?CacheSize=%d?CleanupInterval=%d",
1185                         fGridUrl.Data(), fUser.Data(),
1186                         fDBFolder.Data(), fSE.Data(), fCacheFolder.Data(),
1187                         fOperateDisconnected, fCacheSize, fCleanupInterval);
1188
1189         SetURI(uri.Data());
1190 }
1191
1192 //_____________________________________________________________________________
1193 AliCDBGridParam::~AliCDBGridParam() {
1194 // destructor
1195
1196 }
1197
1198 //_____________________________________________________________________________
1199 AliCDBParam* AliCDBGridParam::CloneParam() const {
1200 // clone parameter
1201
1202         return new AliCDBGridParam(fGridUrl.Data(), fUser.Data(),
1203                                         fDBFolder.Data(), fSE.Data(), fCacheFolder.Data(),
1204                                         fOperateDisconnected, fCacheSize, fCleanupInterval);
1205 }
1206
1207 //_____________________________________________________________________________
1208 ULong_t AliCDBGridParam::Hash() const {
1209 // return Hash function
1210
1211         return fGridUrl.Hash()+fUser.Hash()+fDBFolder.Hash()+fSE.Hash()+fCacheFolder.Hash();
1212 }
1213
1214 //_____________________________________________________________________________
1215 Bool_t AliCDBGridParam::IsEqual(const TObject* obj) const {
1216 // check if this object is equal to AliCDBParam obj
1217
1218         if (this == obj) {
1219                 return kTRUE;
1220         }
1221
1222         if (AliCDBGridParam::Class() != obj->IsA()) {
1223                 return kFALSE;
1224         }
1225
1226         AliCDBGridParam* other = (AliCDBGridParam*) obj;
1227
1228         if(fGridUrl != other->fGridUrl) return kFALSE;
1229         if(fUser != other->fUser) return kFALSE;
1230         if(fDBFolder != other->fDBFolder) return kFALSE;
1231         if(fSE != other->fSE) return kFALSE;
1232         if(fCacheFolder != other->fCacheFolder) return kFALSE;
1233         if(fOperateDisconnected != other->fOperateDisconnected) return kFALSE;
1234         if(fCacheSize != other->fCacheSize) return kFALSE;
1235         if(fCleanupInterval != other->fCleanupInterval) return kFALSE;
1236         return kTRUE;
1237 }
1238