]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliCDBGrid.cxx
New version of CDB framework. Proper initialization of CDB inside AliSimulation and...
[u/mrichter/AliRoot.git] / STEER / AliCDBGrid.cxx
CommitLineData
9e1ceb13 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 <TSystem.h>
30#include <TObjArray.h>
31#include <TObjString.h>
32#include <TRegexp.h>
33
34#include "AliLog.h"
fdf65bb5 35#include "AliCDBEntry.h"
9e1ceb13 36#include "AliCDBGrid.h"
37
38
39ClassImp(AliCDBGrid)
40
41//_____________________________________________________________________________
b05400be 42AliCDBGrid::AliCDBGrid(const char *gridUrl, const char *user, const char *dbFolder, const char *se) :
9e1ceb13 43AliCDBStorage(),
b05400be 44fGridUrl(gridUrl),
9e1ceb13 45fUser(user),
b05400be 46fDBFolder(dbFolder),
9e1ceb13 47fSE(se)
48{
49// constructor //
50
9e1ceb13 51 // if the same Grid is alreay active, skip connection
b05400be 52 if (!gGrid || fGridUrl != gGrid->GridUrl()
024cf675 53 || (( fUser != "" ) && ( fUser != gGrid->GetUser() )) ) {
9e1ceb13 54 // connection to the Grid
024cf675 55 AliInfo("Connection to the Grid!!!!");
56 if(gGrid){
57 AliInfo(Form("gGrid = %x; fGridUrl = %s; gGrid->GridUrl() = %s",gGrid,fGridUrl.Data(), gGrid->GridUrl()));
58 AliInfo(Form("fUser = %s; gGrid->GetUser() = %s",fUser.Data(), gGrid->GetUser()));
59 }
b05400be 60 TGrid::Connect(fGridUrl.Data(),fUser.Data());
9e1ceb13 61 }
62
63 if(!gGrid) {
64 AliError("Connection failed!");
65 return;
66 }
67
68 TString initDir(gGrid->Pwd(0));
b05400be 69 if (fDBFolder[0] != '/') {
70 fDBFolder.Prepend(initDir);
9e1ceb13 71 }
72
73 // check DBFolder: trying to cd to DBFolder; if it does not exist, create it
b05400be 74 if(!gGrid->Cd(fDBFolder.Data(),0)){
75 AliDebug(2,Form("Creating new folder <%s> ...",fDBFolder.Data()));
76 if(!gGrid->Mkdir(fDBFolder.Data(),"",0)){
77 AliError(Form("Cannot create folder <%s> !",fDBFolder.Data()));
9e1ceb13 78 }
79 } else {
b05400be 80 AliDebug(2,Form("Folder <%s> found",fDBFolder.Data()));
9e1ceb13 81 }
82
83 // removes any '/' at the end of path, then append one '/'
b05400be 84 while(fDBFolder.EndsWith("/")) fDBFolder.Remove(fDBFolder.Last('/'));
85 fDBFolder+="/";
9e1ceb13 86
87 // return to the initial directory
88 gGrid->Cd(initDir.Data(),0);
89}
90
91//_____________________________________________________________________________
92AliCDBGrid::~AliCDBGrid()
93{
94// destructor
95
96}
97
98//_____________________________________________________________________________
99Bool_t AliCDBGrid::FilenameToId(const char* filename, AliCDBRunRange& runRange,
100 Int_t& gridVersion) {
101// build AliCDBId from filename numbers
102
103 Ssiz_t mSize;
104
105 // valid filename: Run#firstRun_#lastRun_v#version.root
106 TRegexp keyPattern("^Run[0-9]+_[0-9]+_v[0-9]+.root$");
107 keyPattern.Index(filename, &mSize);
108 if (!mSize) {
109 AliDebug(2,Form("Bad filename <%s>.", filename));
110 return kFALSE;
111 }
112
113 TString idString(filename);
114 idString.Resize(idString.Length() - sizeof(".root") + 1);
115
116 TObjArray* strArray = (TObjArray*) idString.Tokenize("_");
117
118 TString firstRunString(((TObjString*) strArray->At(0))->GetString());
119 runRange.SetFirstRun(atoi(firstRunString.Data() + 3));
120 runRange.SetLastRun(atoi(((TObjString*) strArray->At(1))->GetString()));
121
122 TString verString(((TObjString*) strArray->At(2))->GetString());
123 gridVersion = atoi(verString.Data() + 1);
124
125 delete strArray;
126
127 return kTRUE;
128}
129
130//_____________________________________________________________________________
131Bool_t AliCDBGrid::IdToFilename(const AliCDBRunRange& runRange, Int_t gridVersion,
132 TString& filename) {
133// build file name from AliCDBId data (run range, version)
134
135 if (!runRange.IsValid()) {
b05400be 136 AliDebug(2,Form("Invalid run range <%d, %d>.",
9e1ceb13 137 runRange.GetFirstRun(), runRange.GetLastRun()));
138 return kFALSE;
139 }
140
141 if (gridVersion < 0) {
b05400be 142 AliDebug(2,Form("Invalid version <%d>.", gridVersion));
9e1ceb13 143 return kFALSE;
144 }
145
146 filename += "Run";
147 filename += runRange.GetFirstRun();
148 filename += "_";
149 filename += runRange.GetLastRun();
150 filename += "_v";
151 filename += gridVersion;
152 filename += ".root";
153
154 return kTRUE;
155}
156
157//_____________________________________________________________________________
158Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
159// prepare id (version) of the object that will be stored (called by PutEntry)
160
161 TString initDir(gGrid->Pwd(0));
162 TString pathName= id.GetPath();
163
b05400be 164 TString dirName(fDBFolder);
9e1ceb13 165
166 Bool_t dirExist=kFALSE;
167
168 // go to the path; if directory does not exist, create it
169 TObjArray *arrName=pathName.Tokenize("/");
170 for(int i=0;i<arrName->GetEntries();i++){
171 TString buffer((arrName->At(i))->GetName());
172 dirName+=buffer; dirName+="/";
173 dirExist=gGrid->Cd(dirName,0);
174 if (!dirExist) {
b05400be 175 AliDebug(2,Form("Creating new folder <%s> ...",dirName.Data()));
9e1ceb13 176 if(!gGrid->Mkdir(dirName,"",0)){
177 AliError(Form("Cannot create directory <%s> !",dirName.Data()));
178 gGrid->Cd(initDir.Data());
179 return kFALSE;
180 }
181 }
182 }
183 delete arrName;
184 gGrid->Cd(initDir,0);
185
186 const char* filename;
187 AliCDBRunRange aRunRange; // the runRange got from filename
188 AliCDBRunRange lastRunRange(-1,-1); // highest runRange found
189 Int_t aVersion; // the version got from filename
190 Int_t lastVersion=0; // highest version found
191
192 TGridResult *res = gGrid->Ls(dirName);
193
194 //loop on the files in the directory, look for highest version
195 for(int i=0; i < res->GetEntries(); i++){
196 filename=res->GetFileName(i);
197 if (!FilenameToId(filename, aRunRange, aVersion)) continue;
198 if (aRunRange.Overlaps(id.GetAliCDBRunRange()) && aVersion > lastVersion) {
199 lastVersion = aVersion;
200 lastRunRange = aRunRange;
201 }
202
203 }
204 delete res;
205
206 id.SetVersion(lastVersion + 1);
207
208 TString lastStorage = id.GetLastStorage();
209 if(lastStorage.Contains(TString("new"), TString::kIgnoreCase) && id.GetVersion() > 1 ){
b05400be 210 AliWarning(Form("A NEW object is being stored with version %d",
9e1ceb13 211 id.GetVersion()));
7541e2ae 212 AliWarning(Form("and it will hide previously stored object with version %d!",
9e1ceb13 213 id.GetVersion()-1));
214 }
215
216 if(!lastRunRange.IsAnyRange() && !(lastRunRange.IsEqual(&id.GetAliCDBRunRange())))
217 AliWarning(Form("Run range modified w.r.t. previous version (Run%d_%d_v%d)",
218 lastRunRange.GetFirstRun(), lastRunRange.GetLastRun(), id.GetVersion()));
219
220 return kTRUE;
221}
222
223//_____________________________________________________________________________
4b5e0dce 224Bool_t AliCDBGrid::GetId(const AliCDBId& query, AliCDBId& result) {
9e1ceb13 225// look for filename matching query (called by GetEntry)
226
227 TString initDir(gGrid->Pwd(0));
228
b05400be 229 TString dirName(fDBFolder);
230 dirName += query.GetPath(); // dirName = fDBFolder/idPath
9e1ceb13 231
232 if (!gGrid->Cd(dirName,0)) {
024cf675 233 AliDebug(2,Form("Directory <%s> not found", (query.GetPath()).Data()));
234 AliDebug(2,Form("in DB folder %s", fDBFolder.Data()));
4b5e0dce 235 return kFALSE;
9e1ceb13 236 }
237
238 TGridResult *res = gGrid->Ls(dirName);
239
240 const char* filename;
241 AliCDBRunRange aRunRange; // the runRange got from filename
242 Int_t aVersion; // the version got from filename
243
244 for(int i=0; i < res->GetEntries(); i++){
245 filename=res->GetFileName(i);
246 if (!FilenameToId(filename, aRunRange, aVersion)) continue;
247 // aRunRange and aVersion filled from filename
248
249 if (!aRunRange.Comprises(query.GetAliCDBRunRange())) continue;
250 // aRunRange contains requested run!
251
252 if (!query.HasVersion()){ // look for highest version
253 if(result.GetVersion() > aVersion) continue;
254 if(result.GetVersion() == aVersion) {
024cf675 255 AliDebug(2,Form("More than one object valid for run %d, version %d!",
9e1ceb13 256 query.GetFirstRun(), aVersion));
4b5e0dce 257 return kFALSE;
9e1ceb13 258 }
259 result.SetVersion(aVersion);
260 result.SetFirstRun(aRunRange.GetFirstRun());
261 result.SetLastRun(aRunRange.GetLastRun());
262
263 } else { // look for specified version
264 if(query.GetVersion() != aVersion) continue;
265 if(result.GetVersion() == aVersion){
024cf675 266 AliDebug(2,Form("More than one object valid for run %d, version %d!",
9e1ceb13 267 query.GetFirstRun(), aVersion));
4b5e0dce 268 return kFALSE;
9e1ceb13 269 }
270 result.SetVersion(aVersion);
271 result.SetFirstRun(aRunRange.GetFirstRun());
272 result.SetLastRun(aRunRange.GetLastRun());
273 }
274 } // end loop on filenames
275 delete res;
276
277 gGrid->Cd(initDir.Data(),0);
278
4b5e0dce 279 return kTRUE;
9e1ceb13 280}
281
282//_____________________________________________________________________________
283AliCDBEntry* AliCDBGrid::GetEntry(const AliCDBId& queryId) {
284// get AliCDBEntry from the database
285
4b5e0dce 286 AliCDBId dataId(queryId.GetAliCDBPath(), -1, -1, -1, -1);
287 Bool_t result;
9e1ceb13 288
289 // look for a filename matching query requests (path, runRange, version, subVersion)
290 if (!queryId.HasVersion()) {
291 // if version is not specified, first check the selection criteria list
4b5e0dce 292 AliCDBId selectedId(queryId);
293 GetSelection(&selectedId);
294 result = GetId(selectedId,dataId);
9e1ceb13 295 } else {
4b5e0dce 296 result = GetId(queryId,dataId);
9e1ceb13 297 }
298
4b5e0dce 299 if (!result || !dataId.IsSpecified()) return NULL;
9e1ceb13 300
301 TString filename;
302 if (!IdToFilename(dataId.GetAliCDBRunRange(), dataId.GetVersion(),filename)) {
024cf675 303 AliDebug(2,Form("Bad data ID encountered! Subnormal error!"));
9e1ceb13 304 return NULL;
305 }
306
b05400be 307 filename.Prepend("/alien" + fDBFolder + queryId.GetPath() + '/');
9e1ceb13 308 filename += "?se="; filename += fSE.Data();
309
024cf675 310 AliDebug(2,Form("Opening file: %s",filename.Data()));
9e1ceb13 311 TFile *file = TFile::Open(filename);
312 if (!file) {
024cf675 313 AliDebug(2,Form("Can't open file <%s>!", filename.Data()));
9e1ceb13 314 return NULL;
315 }
316
317 // get the only AliCDBEntry object from the file
318 // the object in the file is an AliCDBEntry entry named "AliCDBEntry"
319
320 TObject* anObject = file->Get("AliCDBEntry");
321
322 if (!anObject) {
024cf675 323 AliDebug(2,Form("Bad storage data: NULL entry object!"));
9e1ceb13 324 return NULL;
325 }
326
327 if (AliCDBEntry::Class() != anObject->IsA()) {
024cf675 328 AliDebug(2,Form("Bad storage data: Invalid entry object!"));
9e1ceb13 329 return NULL;
330 }
331
332 AliCDBId entryId = ((AliCDBEntry* ) anObject)->GetId();
333
334 // The object's Id is not reset during storage
335 // If object's Id runRange or version do not match with filename,
336 // it means that someone renamed file by hand. In this case a warning msg is issued.
337
338 ((AliCDBEntry*) anObject)->SetLastStorage("grid");
339
340 if(!((entryId.GetAliCDBRunRange()).IsEqual(&dataId.GetAliCDBRunRange())) ||
341 entryId.GetVersion() != dataId.GetVersion()){
342 AliWarning(Form("Either RunRange or gridVersion in the object's metadata do noth match with fileName numbers:"));
343 AliWarning(Form("someone renamed file by hand!"));
344 }
345
346 // close file, return retieved entry
347 file->Close(); delete file; file=0;
348 return (AliCDBEntry*) anObject;
349}
350
351//_____________________________________________________________________________
352void AliCDBGrid::GetEntriesForLevel0(const char* level0,
353 const AliCDBId& queryId, TList* result) {
354// multiple request (AliCDBStorage::GetAll)
355
b05400be 356 TString level0Dir=fDBFolder;
9e1ceb13 357 level0Dir += level0;
358
359 if (!gGrid->Cd(level0Dir,0)) {
024cf675 360 AliDebug(2,Form("Level0 directory <%s> not found", level0Dir.Data()));
9e1ceb13 361 return;
362 }
363
364 TGridResult *res = gGrid->Ls(level0Dir);
365 TString level1;
366 for(int i=0; i < res->GetEntries(); i++){
367 level1=res->GetFileName(i);
368 if (queryId.GetAliCDBPath().Level1Comprises(level1))
369 GetEntriesForLevel1(level0, level1, queryId, result);
370 }
371 delete res;
372}
373
374//_____________________________________________________________________________
375void AliCDBGrid::GetEntriesForLevel1(const char* level0, const char* level1,
376 const AliCDBId& queryId, TList* result) {
377// multiple request (AliCDBStorage::GetAll)
378
b05400be 379 TString level1Dir=fDBFolder;
9e1ceb13 380 level1Dir += level0;
381 level1Dir += '/';
382 level1Dir += level1;
383
384 if (!gGrid->Cd(level1Dir,0)) {
024cf675 385 AliDebug(2,Form("Level1 directory <%s> not found", level1Dir.Data()));
9e1ceb13 386 return;
387 }
388
389 TGridResult *res = gGrid->Ls(level1Dir);
390 TString level2;
391 for(int i=0; i < res->GetEntries(); i++){
392 level2=res->GetFileName(i);
393 if (queryId.GetAliCDBPath().Level2Comprises(level2)){
394 AliCDBPath entryPath(level0, level1, level2);
395 AliCDBId entryId(entryPath,
396 queryId.GetAliCDBRunRange(),
397 queryId.GetVersion(),
398 queryId.GetSubVersion());
399
400 AliCDBEntry* anEntry = GetEntry(entryId);
401 if (anEntry) result->Add(anEntry);
402
403 }
404 }
405 delete res;
406}
407
408//_____________________________________________________________________________
409TList* AliCDBGrid::GetEntries(const AliCDBId& queryId) {
410// multiple request (AliCDBStorage::GetAll)
411
412 TList* result = new TList();
413 result->SetOwner();
414
415 TString initDir(gGrid->Pwd(0));
416
b05400be 417 TGridResult *res = gGrid->Ls(fDBFolder);
9e1ceb13 418 TString level0;
419
420 for(int i=0; i < res->GetEntries(); i++){
421 level0=res->GetFileName(i);
422 if (queryId.GetAliCDBPath().Level0Comprises(level0))
423 GetEntriesForLevel0(level0, queryId, result);
424 }
425 delete res;
426
427 gGrid->Cd(initDir.Data(),0);
428 return result;
429}
430
431//_____________________________________________________________________________
432Bool_t AliCDBGrid::PutEntry(AliCDBEntry* entry) {
433// put an AliCDBEntry object into the database
434
435 AliCDBId& id = entry->GetId();
436
437 // set version for the entry to be stored
438 if (!PrepareId(id)) return kFALSE;
439
440 // build filename from entry's id
441 TString filename;
442 if (!IdToFilename(id.GetAliCDBRunRange(), id.GetVersion(), filename)) {
443 AliError("Bad ID encountered! Subnormal error!");
444 return kFALSE;
445 }
446
b05400be 447 filename.Prepend("/alien" + fDBFolder + id.GetPath() + '/');
9e1ceb13 448 TString filenameCopy(filename);
449 filename += "?se="; filename += fSE.Data();
450
451 TDirectory* saveDir = gDirectory;
452
453 // open file
454 TFile *file = TFile::Open(filename,"CREATE");
455 if(!file || !file->IsWritable()){
456 AliError(Form("Can't open file <%s>!", filename.Data()));
457 if(file && !file->IsWritable()) file->Close(); delete file; file=0;
458 return kFALSE;
459 }
460
461 file->cd();
462
463 entry->SetVersion(id.GetVersion());
464
465 // write object (key name: "AliCDBEntry")
466 Bool_t result = (entry->Write("AliCDBEntry") != 0);
467 if (!result) AliError(Form("Can't write entry to file <%s>!",filename.Data()));
468
469
470 if (saveDir) saveDir->cd(); else gROOT->cd();
471 file->Close(); delete file; file=0;
472 if(result) {
b05400be 473 AliInfo(Form("CDB object stored into file %s",filenameCopy.Data()));
9e1ceb13 474 AliInfo(Form("using S.E. %s", fSE.Data()));
475 }
476
477 return result;
478}
479
b05400be 480//_____________________________________________________________________________
481TList* AliCDBGrid::GetIdListFromFile(const char* fileName){
482
483 TString turl(fileName);
484 turl.Prepend("/alien" + fDBFolder);
485 turl += "?se="; turl += fSE.Data();
486 TFile *file = TFile::Open(turl);
487 if (!file) {
488 AliError(Form("Can't open selection file <%s>!", turl.Data()));
489 return NULL;
490 }
491
492 TList *list = new TList();
493 list->SetOwner();
494 int i=0;
495 TString keycycle;
496
497 AliCDBId *id;
498 while(1){
499 i++;
500 keycycle = "AliCDBId;";
501 keycycle+=i;
502
503 id = (AliCDBId*) file->Get(keycycle);
504 if(!id) break;
505 list->AddFirst(id);
506 }
507 file->Close(); delete file; file=0;
508
509 return list;
510
511
512}
513
514//_____________________________________________________________________________
515Bool_t AliCDBGrid::Contains(const char* path) const{
516// check for path in storage's DBFolder
517
518 TString initDir(gGrid->Pwd(0));
519 TString dirName(fDBFolder);
520 dirName += path; // dirName = fDBFolder/path
521 Bool_t result=kFALSE;
522 if (gGrid->Cd(dirName,0)) result=kTRUE;
523 gGrid->Cd(initDir.Data(),0);
524 return result;
525}
526
9e1ceb13 527/////////////////////////////////////////////////////////////////////////////////////////////////
528// //
529// AliCDBGrid factory //
530// //
531/////////////////////////////////////////////////////////////////////////////////////////////////
532
533ClassImp(AliCDBGridFactory)
534
535//_____________________________________________________________________________
536Bool_t AliCDBGridFactory::Validate(const char* gridString) {
537// check if the string is valid Grid URI
538
539 // pattern: alien://hostName:Port;user;dbPath;SE
540 // example of a valid pattern:
541 // "alien://aliendb4.cern.ch:9000;colla;DBTest;ALICE::CERN::Server"
b05400be 542// TRegexp gridPattern("^alien://.+:[0-9]+;[a-zA-Z0-9_-.]+;.+;.+$");
543 TRegexp gridPattern("^alien://.+$");
9e1ceb13 544
545 return TString(gridString).Contains(gridPattern);
546}
547
548//_____________________________________________________________________________
549AliCDBParam* AliCDBGridFactory::CreateParameter(const char* gridString) {
550// create AliCDBGridParam class from the URI string
551
552 if (!Validate(gridString)) {
553 return NULL;
554 }
b05400be 555 //TString buffer(gridString + sizeof("alien://") - 1);
556 TString buffer(gridString);
557
558 TString gridUrl = "alien://";
559 TString user = "";
560 TString dbFolder = "DBGrid";
561 TString se = "ALICE::CERN::se01";
562
563 TObjArray *arr = buffer.Tokenize('?');
564 TIter iter(arr);
565 TObjString *str;
9e1ceb13 566
b05400be 567 while((str = (TObjString*) iter.Next())){
568 TString entry(str->String());
569 Int_t indeq = entry.Index('=');
570 if(indeq == -1) {
571 if(entry.BeginsWith("alien://")) { // maybe it's a gridUrl!
572 gridUrl = entry;
573 continue;
574 } else {
575 AliError(Form("Invalid entry! %s",entry.Data()));
576 continue;
577 }
578 }
579
580 TString key = entry(0,indeq);
581 TString value = entry(indeq+1,entry.Length()-indeq);
582
583 if(key.Contains("grid",TString::kIgnoreCase)) {
584 gridUrl += value;
585 }
586 else if (key.Contains("user",TString::kIgnoreCase)){
587 user = value;
588 }
589 else if (key.Contains("folder",TString::kIgnoreCase)){
590 dbFolder = value;
591 }
592 else if (key.Contains("se",TString::kIgnoreCase)){
593 se = value;
594 }
595 else{
596 AliError(Form("Invalid entry! %s",entry.Data()));
597 }
598 }
599 delete arr; arr=0;
600
601 AliInfo(Form("gridUrl: %s",gridUrl.Data()));
602 AliInfo(Form("user: %s",user.Data()));
603 AliInfo(Form("dbFolder: %s",dbFolder.Data()));
604 AliInfo(Form("s.e.: %s",se.Data()));
9e1ceb13 605
b05400be 606 return new AliCDBGridParam(gridUrl, user, dbFolder, se);
9e1ceb13 607}
608
609//_____________________________________________________________________________
610AliCDBStorage* AliCDBGridFactory::Create(const AliCDBParam* param) {
611// create AliCDBGrid storage instance from parameters
612
613 if (AliCDBGridParam::Class() == param->IsA()) {
614
615 const AliCDBGridParam* gridParam = (const AliCDBGridParam*) param;
b05400be 616 AliCDBGrid *grid = new AliCDBGrid(gridParam->GridUrl(),
617 gridParam->GetUser(), gridParam->GetDBFolder(),
9e1ceb13 618 gridParam->GetSE());
619
620 if(gGrid) return grid;
621 }
622
623 return NULL;
624}
625
626/////////////////////////////////////////////////////////////////////////////////////////////////
627// //
628// AliCDBGrid Parameter class // //
629// //
630/////////////////////////////////////////////////////////////////////////////////////////////////
631
632ClassImp(AliCDBGridParam)
633
634//_____________________________________________________________________________
635AliCDBGridParam::AliCDBGridParam() {
636// default constructor
637
638}
639
640//_____________________________________________________________________________
b05400be 641AliCDBGridParam::AliCDBGridParam(const char* gridUrl,
9e1ceb13 642 const char* user,
b05400be 643 const char* dbFolder,
9e1ceb13 644 const char* se):
b05400be 645 fGridUrl(gridUrl),
9e1ceb13 646 fUser(user),
b05400be 647 fDBFolder(dbFolder),
9e1ceb13 648 fSE(se)
649{
650// constructor
651
652 SetType("alien");
653
b05400be 654 TString uri;
655 uri+=fGridUrl; uri+="?";
656 uri+="User="; uri+=fUser; uri+="?";
657 uri+="DBFolder="; uri+=fDBFolder; uri+="?";
658 uri+="SE="; uri+=fSE;
9e1ceb13 659
660 SetURI(uri);
661}
662
663//_____________________________________________________________________________
664AliCDBGridParam::~AliCDBGridParam() {
665// destructor
666
667}
668
669//_____________________________________________________________________________
670AliCDBParam* AliCDBGridParam::CloneParam() const {
671// clone parameter
672
b05400be 673 return new AliCDBGridParam(fGridUrl, fUser, fDBFolder, fSE);
9e1ceb13 674}
675
676//_____________________________________________________________________________
677ULong_t AliCDBGridParam::Hash() const {
678// return Hash function
679
b05400be 680 return fGridUrl.Hash()+fUser.Hash()+fDBFolder.Hash()+fSE.Hash();
9e1ceb13 681}
682
683//_____________________________________________________________________________
684Bool_t AliCDBGridParam::IsEqual(const TObject* obj) const {
685// check if this object is equal to AliCDBParam obj
686
687 if (this == obj) {
688 return kTRUE;
689 }
690
691 if (AliCDBGridParam::Class() != obj->IsA()) {
692 return kFALSE;
693 }
694
695 AliCDBGridParam* other = (AliCDBGridParam*) obj;
696
b05400be 697 if(fGridUrl != other->fGridUrl) return kFALSE;
9e1ceb13 698 if(fUser != other->fUser) return kFALSE;
b05400be 699 if(fDBFolder != other->fDBFolder) return kFALSE;
9e1ceb13 700 if(fSE != other->fSE) return kFALSE;
701 return kTRUE;
702}
703