]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/AliShuttleConfig.cxx
Fixes to calls for MeanMaterialBudget (now in AliTracker) (From Jouri Belikov)
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttleConfig.cxx
CommitLineData
73abe331 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$Log$
86aa42c3 18Revision 1.20 2007/04/04 10:33:36 jgrosseo
191) Storing of files to the Grid is now done _after_ your preprocessors succeeded. This is transparent, which means that you can still use the same functions (Store, StoreReferenceData) to store files to the Grid. However, the Shuttle first stores them locally and transfers them after the preprocessor finished. The return code of these two functions has changed from UInt_t to Bool_t which gives you the success of the storing.
20In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
21
222) The meaning of the return code of the preprocessor has changed. 0 is now success and any other value means failure. This value is stored in the log and you can use it to keep details about the error condition.
23
243) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
25
264) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
27
285) New function AliPreprocessor::ProcessDCS(). If you do not need to have DCS data in all cases, you can skip the processing by implemting this function and returning kFALSE under certain conditions. E.g. if there is a certain run type.
29If you always need DCS data (like before), you do not need to implement it.
30
316) The run type has been added to the monitoring page
32
9827400b 33Revision 1.19 2007/02/28 10:41:56 acolla
34Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
35AliPreprocessor::GetRunType() function.
36Added some ldap definition files.
37
441b0e9c 38Revision 1.18 2007/01/23 19:20:03 acolla
39Removed old ldif files, added TOF, MCH ldif files. Added some options in
40AliShuttleConfig::Print. Added in Ali Shuttle: SetShuttleTempDir and
41SetShuttleLogDir
42
36c99a6a 43Revision 1.17 2007/01/18 11:17:47 jgrosseo
44changing spaces to tabs ;-)
45
f59d2f8f 46Revision 1.16 2007/01/18 11:10:35 jgrosseo
47adding the possibility of defining DCS alias and data points with patterns
48first pattern introduced: [N..M] to add all names between the two digits, this works also recursively.
49
40150741 50Revision 1.15 2007/01/15 18:27:11 acolla
51implementation of sending mail to subdetector expert in case the preprocessor fails.
52shuttle.schema updated with expert's email entry
53
fc5a4708 54Revision 1.13 2006/12/07 08:51:26 jgrosseo
55update (alberto):
56table, db names in ldap configuration
57added GRP preprocessor
58DCS data can also be retrieved by data point
59
2c15234c 60Revision 1.12 2006/11/16 16:16:48 jgrosseo
61introducing strict run ordering flag
62removed giving preprocessor name to preprocessor, they have to know their name themselves ;-)
63
be48e3ea 64Revision 1.11 2006/11/06 14:23:04 jgrosseo
65major update (Alberto)
66o) reading of run parameters from the logbook
67o) online offline naming conversion
68o) standalone DCSclient package
69
eba76848 70Revision 1.10 2006/10/20 15:22:59 jgrosseo
71o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child
72o) Merging Collect, CollectAll, CollectNew function
73o) Removing implementation of empty copy constructors (declaration still there!)
74
cb343cfd 75Revision 1.9 2006/10/02 16:38:39 jgrosseo
76update (alberto):
77fixed memory leaks
78storing of objects that failed to be stored to the grid before
79interfacing of shuttle status table in daq system
80
2bb7b766 81Revision 1.8 2006/08/15 10:50:00 jgrosseo
82effc++ corrections (alberto)
83
4f0ab988 84Revision 1.7 2006/07/20 09:54:40 jgrosseo
85introducing status management: The processing per subdetector is divided into several steps,
86after each step the status is stored on disk. If the system crashes in any of the steps the Shuttle
87can keep track of the number of failures and skips further processing after a certain threshold is
88exceeded. These thresholds can be configured in LDAP.
89
5164a766 90Revision 1.6 2006/07/19 10:09:55 jgrosseo
91new configuration, accesst to DAQ FES (Alberto)
92
57f50b3c 93Revision 1.5 2006/07/10 13:01:41 jgrosseo
94enhanced storing of last sucessfully processed run (alberto)
95
a7160fe9 96Revision 1.4 2006/06/12 09:11:16 jgrosseo
97coding conventions (Alberto)
98
58bc3020 99Revision 1.3 2006/06/06 14:26:40 jgrosseo
100o) removed files that were moved to STEER
101o) shuttle updated to follow the new interface (Alberto)
102
b948db8d 103Revision 1.7 2006/05/12 09:07:16 colla
10412/05/06
105New configuration complete
106
107Revision 1.2 2006/03/07 07:52:34 hristov
108New version (B.Yordanov)
109
d477ad88 110Revision 1.4 2005/11/19 14:20:31 byordano
111logbook config added to AliShuttleConfig
112
113Revision 1.3 2005/11/17 19:24:25 byordano
114TList changed to TObjArray in AliShuttleConfig
115
116Revision 1.2 2005/11/17 14:43:23 byordano
117import to local CVS
118
119Revision 1.1.1.1 2005/10/28 07:33:58 hristov
120Initial import as subdirectory in AliRoot
121
73abe331 122Revision 1.1.1.1 2005/09/12 22:11:40 byordano
123SHUTTLE package
124
125Revision 1.3 2005/08/30 09:13:02 byordano
126some docs added
127
128*/
129
130
131//
132// This class keeps the AliShuttle configuration.
133// It reads the configuration for LDAP server.
134// For every child entry in basedn which has schema type 'shuttleConfig'
135// it creates a detector configuration. This configuration includes:
136// DCS server host and port and the set of aliases for which data from
137// will be retrieved (used by AliShuttle).
138//
139
140
141#include "AliShuttleConfig.h"
57f50b3c 142#include "AliShuttleInterface.h"
73abe331 143
144#include "AliLog.h"
145
b948db8d 146#include <TSystem.h>
73abe331 147#include <TObjString.h>
148#include <TLDAPResult.h>
149#include <TLDAPEntry.h>
150#include <TLDAPAttribute.h>
151
57f50b3c 152
58bc3020 153AliShuttleConfig::AliShuttleConfigHolder::AliShuttleConfigHolder(const TLDAPEntry* entry):
57f50b3c 154fDetector(""),
155fDCSHost(""),
156fDCSPort(0),
fc5a4708 157fDCSAliases(0),
158fDCSDataPoints(0),
36c99a6a 159fDCSAliasesComp(0),
160fDCSDataPointsComp(0),
57c1a579 161fResponsibles(0),
57f50b3c 162fIsValid(kFALSE),
be48e3ea 163fSkipDCSQuery(kFALSE),
164fStrictRunOrder(kFALSE)
73abe331 165{
58bc3020 166// constructor of the shuttle configuration holder
167
73abe331 168 TLDAPAttribute* anAttribute;
2bb7b766 169 fDCSAliases = new TObjArray();
170 fDCSAliases->SetOwner(1);
2c15234c 171 fDCSDataPoints = new TObjArray();
172 fDCSDataPoints->SetOwner(1);
36c99a6a 173 fDCSAliasesComp = new TObjArray();
174 fDCSAliasesComp->SetOwner(1);
175 fDCSDataPointsComp = new TObjArray();
176 fDCSDataPointsComp->SetOwner(1);
57c1a579 177 fResponsibles = new TObjArray();
178 fResponsibles->SetOwner(1);
57f50b3c 179
180 anAttribute = entry->GetAttribute("det"); // MUST
2c15234c 181 if (!anAttribute)
182 {
183 AliError(Form("Invalid configuration! No \"det\" attribute!"));
184 return;
185 }
73abe331 186 fDetector = anAttribute->GetValue();
73abe331 187
be48e3ea 188 anAttribute = entry->GetAttribute("StrictRunOrder"); // MAY
189 if (!anAttribute)
190 {
191 AliWarning(Form("%s did not set StrictRunOrder flag - the default is FALSE",
192 fDetector.Data()));
193 } else {
194 TString strictRunStr = anAttribute->GetValue();
195 if (!(strictRunStr == "0" || strictRunStr == "1"))
196 {
197 AliError("Invalid configuration! StrictRunOrder flag must be 0 or 1!");
198 return;
199 }
200 fStrictRunOrder = (Bool_t) strictRunStr.Atoi();
201 }
202
86aa42c3 203 anAttribute = entry->GetAttribute("responsible"); // MAY
57c1a579 204 if (!anAttribute)
205 {
86aa42c3 206 AliDebug(2, "Warning! No \"responsible\" attribute!");
57c1a579 207 }
86aa42c3 208 else
57c1a579 209 {
86aa42c3 210 const char* aResponsible;
211 while ((aResponsible = anAttribute->GetValue()))
212 {
213 fResponsibles->AddLast(new TObjString(aResponsible));
214 }
57c1a579 215 }
86aa42c3 216
57f50b3c 217 anAttribute = entry->GetAttribute("DCSHost"); // MAY
2c15234c 218 if (!anAttribute)
219 {
57c1a579 220 AliDebug(2,
57f50b3c 221 Form("%s has not DCS host entry - Shuttle will skip DCS data query!",
222 fDetector.Data()));
223 fIsValid = kTRUE;
224 fSkipDCSQuery = kTRUE;
73abe331 225 return;
226 }
57f50b3c 227
b948db8d 228 fDCSHost = anAttribute->GetValue();
73abe331 229
57f50b3c 230 anAttribute = entry->GetAttribute("DCSPort"); // MAY
2c15234c 231 if (!anAttribute)
232 {
57f50b3c 233 AliError(Form("Invalid configuration! %s has DCS Host but no port number!",
234 fDetector.Data()));
73abe331 235 return;
236 }
237 TString portStr = anAttribute->GetValue();
b948db8d 238 fDCSPort = portStr.Atoi();
73abe331 239
2c15234c 240 anAttribute = entry->GetAttribute("DCSalias"); // MAY
241 if (anAttribute)
242 {
243 const char* anAlias;
244 while ((anAlias = anAttribute->GetValue()))
245 {
36c99a6a 246 fDCSAliasesComp->AddLast(new TObjString(anAlias));
40150741 247 ExpandAndAdd(fDCSAliases, anAlias);
2c15234c 248 }
73abe331 249 }
57f50b3c 250
2c15234c 251 anAttribute = entry->GetAttribute("DCSdatapoint"); // MAY
252 if (anAttribute)
253 {
254 const char* aDataPoint;
255 while ((aDataPoint = anAttribute->GetValue()))
256 {
36c99a6a 257 fDCSDataPointsComp->AddLast(new TObjString(aDataPoint));
258 ExpandAndAdd(fDCSDataPoints, aDataPoint);
2c15234c 259 }
b948db8d 260 }
261
73abe331 262 fIsValid = kTRUE;
263}
264
40150741 265//______________________________________________________________________________________________
266void AliShuttleConfig::AliShuttleConfigHolder::ExpandAndAdd(TObjArray* target, const char* entry)
267{
f59d2f8f 268 //
269 // adds <entry> to <target> applying expanding of the name
270 // [N..M] creates M-N+1 names with the corresponding digits
271 //
40150741 272
f59d2f8f 273 TString entryStr(entry);
40150741 274
f59d2f8f 275 Int_t begin = entryStr.Index("[");
276 Int_t end = entryStr.Index("]");
277 if (begin != -1 && end != -1 && end > begin)
278 {
279 TString before(entryStr(0, begin));
280 TString after(entryStr(end+1, entryStr.Length()));
40150741 281
f59d2f8f 282 AliDebug(2, Form("Found [] pattern. Splitted input string %s %s", before.Data(), after.Data()));
40150741 283
f59d2f8f 284 Int_t dotdot = entryStr.Index("..");
40150741 285
f59d2f8f 286 TString nStr(entryStr(begin+1, dotdot-begin-1));
287 TString mStr(entryStr(dotdot+2, end-dotdot-2));
40150741 288
f59d2f8f 289 AliDebug(2, Form("Found [N..M] pattern. %s %s", nStr.Data(), mStr.Data()));
40150741 290
f59d2f8f 291 if (nStr.IsDigit() && mStr.IsDigit())
292 {
293 Int_t n = nStr.Atoi();
294 Int_t m = mStr.Atoi();
40150741 295
f59d2f8f 296 Int_t nDigits = nStr.Length();
297 TString formatStr;
298 formatStr.Form("%%s%%0%dd%%s", nDigits);
40150741 299
f59d2f8f 300 AliDebug(2, Form("Format string is %s", formatStr.Data()));
40150741 301
f59d2f8f 302 for (Int_t current = n; current<=m; ++current)
303 {
304 TString newEntry;
305 newEntry.Form(formatStr.Data(), before.Data(), current, after.Data());
40150741 306
f59d2f8f 307 AliDebug(2, Form("Calling recursive with %s", newEntry.Data()));
40150741 308
f59d2f8f 309 // and go recursive
310 ExpandAndAdd(target, newEntry);
311 }
40150741 312
f59d2f8f 313 // return here because we processed the entries already recursively.
314 return;
315 }
316 }
40150741 317
f59d2f8f 318 AliDebug(2, Form("Adding name %s", entry));
319 target->AddLast(new TObjString(entry));
40150741 320}
321
a7160fe9 322//______________________________________________________________________________________________
323AliShuttleConfig::AliShuttleConfigHolder::~AliShuttleConfigHolder()
58bc3020 324{
325// destructor of the shuttle configuration holder
326
2bb7b766 327 delete fDCSAliases;
2c15234c 328 delete fDCSDataPoints;
57c1a579 329 delete fResponsibles;
73abe331 330}
331
332ClassImp(AliShuttleConfig)
333
a7160fe9 334//______________________________________________________________________________________________
335AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
73abe331 336 const char* binddn, const char* password, const char* basedn):
57c1a579 337 fIsValid(kFALSE), fConfigHost(host),
fc5a4708 338 fDAQlbHost(""), fDAQlbPort(), fDAQlbUser(""), fDAQlbPass(""),
441b0e9c 339 fDAQlbDB(""), fDAQlbTable(""), fShuttlelbTable(""), fRunTypelbTable(""),
9827400b 340 fMaxRetries(0), fPPTimeOut(0), fPPMaxMem(0), fDetectorMap(), fDetectorList(),
2bb7b766 341 fShuttleInstanceHost(""), fProcessedDetectors(), fProcessAll(kFALSE)
73abe331 342{
343 //
344 // host: ldap server host
345 // port: ldap server port
346 // binddn: binddn used for ldap binding (simple bind is used!).
347 // password: password for binddn
b948db8d 348 // basedn: this is basedn whose childeren entries which have
73abe331 349 // (objectClass=shuttleConfig) will be used as detector configurations.
350 //
351
2bb7b766 352 fDetectorMap.SetOwner();
353 fDetectorList.SetOwner(0); //fDetectorList and fDetectorMap share the same object!
354 fProcessedDetectors.SetOwner();
355
b948db8d 356 TLDAPServer aServer(host, port, binddn, password, 3);
57f50b3c 357
73abe331 358 if (!aServer.IsConnected()) {
2bb7b766 359 AliError(Form("Can't connect to ldap server %s:%d",
73abe331 360 host, port));
361 return;
362 }
363
b948db8d 364 // reads configuration for the shuttle running on this machine
2bb7b766 365
b948db8d 366 fShuttleInstanceHost = gSystem->HostName();
2bb7b766 367 TString queryFilter = Form("(ShuttleHost=%s)", fShuttleInstanceHost.Data());
368
369 TLDAPResult* aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, queryFilter.Data());
b948db8d 370
73abe331 371 if (!aResult) {
372 AliError(Form("Can't find configuration with base DN: %s",
373 basedn));
374 return;
375 }
b948db8d 376
377 if (aResult->GetCount() == 0) {
57f50b3c 378 AliError(Form("No Shuttle instance for host = %s!",
379 fShuttleInstanceHost.Data()));
b948db8d 380 AliError(Form("All detectors will be processed."));
381 fProcessAll=kTRUE;
382 }
383
384 if (aResult->GetCount() > 1) {
57f50b3c 385 AliError(Form("More than one Shuttle instance for host %s!",
386 fShuttleInstanceHost.Data()));
2bb7b766 387 delete aResult;
b948db8d 388 return;
389 }
57f50b3c 390
2bb7b766 391 TLDAPEntry* anEntry = 0;
392 TLDAPAttribute* anAttribute = 0;
b948db8d 393
394 if(!fProcessAll){
395 anEntry = aResult->GetNext();
396 anAttribute = anEntry->GetAttribute("detectors");
397 const char *detName;
398 while((detName = anAttribute->GetValue())){
399 TObjString *objDet= new TObjString(detName);
400 fProcessedDetectors.Add(objDet);
401 }
402 }
403
2bb7b766 404 delete anEntry; delete aResult;
405
57f50b3c 406 // Detector configuration (DCS Archive DB settings)
407
2bb7b766 408 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, "(objectClass=AliShuttleDetector)");
b948db8d 409 if (!aResult) {
2bb7b766 410 AliError(Form("Can't find configuration with base DN: %s", basedn));
b948db8d 411 return;
412 }
413
57f50b3c 414
73abe331 415 while ((anEntry = aResult->GetNext())) {
58bc3020 416 AliShuttleConfigHolder* aHolder = new AliShuttleConfigHolder(anEntry);
73abe331 417 delete anEntry;
418
419 if (!aHolder->IsValid()) {
57f50b3c 420 AliError("Detector configuration error!");
73abe331 421 delete aHolder;
2bb7b766 422 delete aResult;
57f50b3c 423 return;
73abe331 424 }
425
426 TObjString* detStr = new TObjString(aHolder->GetDetector());
427 fDetectorMap.Add(detStr, aHolder);
d477ad88 428 fDetectorList.AddLast(detStr);
57f50b3c 429 }
430
73abe331 431 delete aResult;
432
57f50b3c 433 // Global configuration (DAQ logbook)
d477ad88 434
435 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL,
b948db8d 436 "(objectClass=AliShuttleGlobalConfig)");
d477ad88 437 if (!aResult) {
438 AliError(Form("Can't find configuration with base DN: %s",
439 basedn));
440 return;
441 }
442
443 if (aResult->GetCount() == 0) {
b948db8d 444 AliError("Can't find DAQ logbook configuration!");
2bb7b766 445 delete aResult;
d477ad88 446 return;
447 }
448
449 if (aResult->GetCount() > 1) {
b948db8d 450 AliError("More than one DAQ logbook configuration found!");
2bb7b766 451 delete aResult;
d477ad88 452 return;
453 }
454
455 anEntry = aResult->GetNext();
57f50b3c 456
b948db8d 457 anAttribute = anEntry->GetAttribute("DAQLogbookHost");
d477ad88 458 if (!anAttribute) {
b948db8d 459 AliError("Can't find DAQLogbookHost attribute!");
2bb7b766 460 delete anEntry; delete aResult;
d477ad88 461 return;
462 }
57f50b3c 463 fDAQlbHost = anAttribute->GetValue();
d477ad88 464
fc5a4708 465 anAttribute = anEntry->GetAttribute("DAQLogbookPort"); // MAY
466 if (anAttribute)
467 {
468 fDAQlbPort = ((TString) anAttribute->GetValue()).Atoi();
469 } else {
470 fDAQlbPort = 3306; // mysql
471 }
472
b948db8d 473 anAttribute = anEntry->GetAttribute("DAQLogbookUser");
d477ad88 474 if (!anAttribute) {
b948db8d 475 AliError("Can't find DAQLogbookUser attribute!");
2bb7b766 476 delete aResult; delete anEntry;
d477ad88 477 return;
478 }
57f50b3c 479 fDAQlbUser = anAttribute->GetValue();
480
b948db8d 481 anAttribute = anEntry->GetAttribute("DAQLogbookPassword");
d477ad88 482 if (!anAttribute) {
b948db8d 483 AliError("Can't find DAQLogbookPassword attribute!");
2bb7b766 484 delete aResult; delete anEntry;
d477ad88 485 return;
486 }
57f50b3c 487 fDAQlbPass = anAttribute->GetValue();
d477ad88 488
2c15234c 489 anAttribute = anEntry->GetAttribute("DAQLogbookDB");
490 if (!anAttribute) {
491 AliError("Can't find DAQLogbookDB attribute!");
492 delete aResult; delete anEntry;
493 return;
494 }
495 fDAQlbDB = anAttribute->GetValue();
496
497 anAttribute = anEntry->GetAttribute("DAQLogbookTable");
498 if (!anAttribute) {
499 AliError("Can't find DAQLogbookTable attribute!");
500 delete aResult; delete anEntry;
501 return;
502 }
503 fDAQlbTable = anAttribute->GetValue();
504
441b0e9c 505 anAttribute = anEntry->GetAttribute("ShuttleLogbookTable");
506 if (!anAttribute) {
507 AliError("Can't find ShuttleLogbookTable attribute!");
508 delete aResult; delete anEntry;
509 return;
510 }
511 fShuttlelbTable = anAttribute->GetValue();
512
513 anAttribute = anEntry->GetAttribute("RunTypeLogbookTable");
514 if (!anAttribute) {
515 AliError("Can't find RunTypeLogbookTable attribute!");
516 delete aResult; delete anEntry;
517 return;
518 }
519 fRunTypelbTable = anAttribute->GetValue();
2c15234c 520
cb343cfd 521 anAttribute = anEntry->GetAttribute("MaxRetries");
5164a766 522 if (!anAttribute) {
cb343cfd 523 AliError("Can't find MaxRetries attribute!");
2bb7b766 524 delete aResult; delete anEntry;
5164a766 525 return;
526 }
527 TString tmpStr = anAttribute->GetValue();
cb343cfd 528 fMaxRetries = tmpStr.Atoi();
5164a766 529
cb343cfd 530 anAttribute = anEntry->GetAttribute("PPTimeOut");
5164a766 531 if (!anAttribute) {
cb343cfd 532 AliError("Can't find PPTimeOut attribute!");
2bb7b766 533 delete aResult; delete anEntry;
5164a766 534 return;
535 }
536 tmpStr = anAttribute->GetValue();
cb343cfd 537 fPPTimeOut = tmpStr.Atoi();
5164a766 538
9827400b 539 anAttribute = anEntry->GetAttribute("PPMaxMem");
540 if (!anAttribute) {
541 AliError("Can't find PPMaxMem attribute!");
542 delete aResult; delete anEntry;
543 return;
544 }
545 tmpStr = anAttribute->GetValue();
546 fPPMaxMem = tmpStr.Atoi();
547
2bb7b766 548 delete aResult; delete anEntry;
57f50b3c 549
2c15234c 550 // FXS configuration (FXS logbook and hosts)
57f50b3c 551
57f50b3c 552 for(int iSys=0;iSys<3;iSys++){
eba76848 553 queryFilter = Form("(system=%s)", AliShuttleInterface::GetSystemName(iSys));
57f50b3c 554 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, queryFilter.Data());
555 if (!aResult) {
556 AliError(Form("Can't find configuration for system: %s",
eba76848 557 AliShuttleInterface::GetSystemName(iSys)));
57f50b3c 558 return;
559 }
560
561 if (aResult->GetCount() != 1 ) {
2c15234c 562 AliError("Error in FXS configuration!");
2bb7b766 563 delete aResult;
57f50b3c 564 return;
565 }
566
567 anEntry = aResult->GetNext();
568
2c15234c 569 anAttribute = anEntry->GetAttribute("DBHost");
57f50b3c 570 if (!anAttribute) {
fc5a4708 571 AliError(Form ("Can't find DBHost attribute for %s!!",
eba76848 572 AliShuttleInterface::GetSystemName(iSys)));
2bb7b766 573 delete aResult; delete anEntry;
57f50b3c 574 return;
575 }
2c15234c 576 fFXSdbHost[iSys] = anAttribute->GetValue();
57f50b3c 577
fc5a4708 578 anAttribute = anEntry->GetAttribute("DBPort"); // MAY
579 if (anAttribute)
580 {
581 fFXSdbPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
582 } else {
583 fFXSdbPort[iSys] = 3306; // mysql
584 }
585
2c15234c 586 anAttribute = anEntry->GetAttribute("DBUser");
57f50b3c 587 if (!anAttribute) {
2c15234c 588 AliError(Form ("Can't find DBUser attribute for %s!!",
eba76848 589 AliShuttleInterface::GetSystemName(iSys)));
2bb7b766 590 delete aResult; delete anEntry;
57f50b3c 591 return;
592 }
2c15234c 593 fFXSdbUser[iSys] = anAttribute->GetValue();
57f50b3c 594
2c15234c 595 anAttribute = anEntry->GetAttribute("DBPassword");
57f50b3c 596 if (!anAttribute) {
2c15234c 597 AliError(Form ("Can't find DBPassword attribute for %s!!",
eba76848 598 AliShuttleInterface::GetSystemName(iSys)));
2bb7b766 599 delete aResult; delete anEntry;
57f50b3c 600 return;
601 }
2c15234c 602 fFXSdbPass[iSys] = anAttribute->GetValue();
603
604 anAttribute = anEntry->GetAttribute("DBName");
605 if (!anAttribute) {
606 AliError(Form ("Can't find DBName attribute for %s!!",
607 AliShuttleInterface::GetSystemName(iSys)));
608 delete aResult; delete anEntry;
609 return;
610 }
611
612 fFXSdbName[iSys] = anAttribute->GetValue();
613 anAttribute = anEntry->GetAttribute("DBTable");
614 if (!anAttribute) {
615 AliError(Form ("Can't find DBTable attribute for %s!!",
616 AliShuttleInterface::GetSystemName(iSys)));
617 delete aResult; delete anEntry;
618 return;
619 }
620 fFXSdbTable[iSys] = anAttribute->GetValue();
57f50b3c 621
622 anAttribute = anEntry->GetAttribute("FSHost");
623 if (!anAttribute) {
624 AliError(Form ("Can't find FSHost attribute for %s!!",
eba76848 625 AliShuttleInterface::GetSystemName(iSys)));
2bb7b766 626 delete aResult; delete anEntry;
57f50b3c 627 return;
628 }
2c15234c 629 fFXSHost[iSys] = anAttribute->GetValue();
57f50b3c 630
fc5a4708 631 anAttribute = anEntry->GetAttribute("FSPort"); // MAY
632 if (anAttribute)
633 {
634 fFXSPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
635 } else {
636 fFXSPort[iSys] = 22; // scp port number
637 }
638
57f50b3c 639 anAttribute = anEntry->GetAttribute("FSUser");
640 if (!anAttribute) {
641 AliError(Form ("Can't find FSUser attribute for %s!!",
eba76848 642 AliShuttleInterface::GetSystemName(iSys)));
2bb7b766 643 delete aResult; delete anEntry;
57f50b3c 644 return;
645 }
2c15234c 646 fFXSUser[iSys] = anAttribute->GetValue();
57f50b3c 647
648 anAttribute = anEntry->GetAttribute("FSPassword");
2c15234c 649 if (anAttribute) fFXSPass[iSys] = anAttribute->GetValue();
57f50b3c 650
2bb7b766 651 delete aResult; delete anEntry;
57f50b3c 652 }
653
73abe331 654 fIsValid = kTRUE;
655}
656
a7160fe9 657//______________________________________________________________________________________________
658AliShuttleConfig::~AliShuttleConfig()
58bc3020 659{
660// destructor
661
73abe331 662 fDetectorMap.DeleteAll();
2bb7b766 663 fDetectorList.Clear();
664 fProcessedDetectors.Delete();
73abe331 665}
666
a7160fe9 667//______________________________________________________________________________________________
668const TObjArray* AliShuttleConfig::GetDetectors() const
58bc3020 669{
73abe331 670 //
671 // returns collection of TObjString which contains the name
672 // of every detector which is in the configuration.
673 //
674
675 return &fDetectorList;
676}
677
a7160fe9 678//______________________________________________________________________________________________
679Bool_t AliShuttleConfig::HasDetector(const char* detector) const
58bc3020 680{
73abe331 681 //
682 // checks for paricular detector in the configuration.
683 //
684 return fDetectorMap.GetValue(detector) != NULL;
685}
686
a7160fe9 687//______________________________________________________________________________________________
688const char* AliShuttleConfig::GetDCSHost(const char* detector) const
58bc3020 689{
73abe331 690 //
691 // returns DCS server host used by particular detector
692 //
693
58bc3020 694 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
73abe331 695 if (!aHolder) {
696 AliError(Form("There isn't configuration for detector: %s",
697 detector));
698 return NULL;
699 }
700
b948db8d 701 return aHolder->GetDCSHost();
73abe331 702}
703
a7160fe9 704//______________________________________________________________________________________________
705Int_t AliShuttleConfig::GetDCSPort(const char* detector) const
58bc3020 706{
73abe331 707 //
708 // returns DCS server port used by particular detector
709 //
710
711
58bc3020 712 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
73abe331 713 if (!aHolder) {
714 AliError(Form("There isn't configuration for detector: %s",
715 detector));
716 return 0;
717 }
718
b948db8d 719 return aHolder->GetDCSPort();
73abe331 720}
721
a7160fe9 722//______________________________________________________________________________________________
723const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector) const
58bc3020 724{
73abe331 725 //
726 // returns collection of TObjString which represents the set of aliases
727 // which used for data retrieval for particular detector
728 //
729
58bc3020 730 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
73abe331 731 if (!aHolder) {
732 AliError(Form("There isn't configuration for detector: %s",
733 detector));
734 return NULL;
735 }
736
b948db8d 737 return aHolder->GetDCSAliases();
738}
739
2c15234c 740//______________________________________________________________________________________________
741const TObjArray* AliShuttleConfig::GetDCSDataPoints(const char* detector) const
742{
743 //
744 // returns collection of TObjString which represents the set of aliases
745 // which used for data retrieval for particular detector
746 //
747
748 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
749 if (!aHolder) {
750 AliError(Form("There isn't configuration for detector: %s",
751 detector));
752 return NULL;
753 }
754
755 return aHolder->GetDCSDataPoints();
756}
757
57c1a579 758//______________________________________________________________________________________________
759const TObjArray* AliShuttleConfig::GetResponsibles(const char* detector) const
760{
761 //
762 // returns collection of TObjString which represents the list of mail addresses
763 // of the detector's responsible(s)
764 //
765
766 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
767 if (!aHolder) {
768 AliError(Form("There isn't configuration for detector: %s",
769 detector));
770 return NULL;
771 }
772
773 return aHolder->GetResponsibles();
774}
775
a7160fe9 776//______________________________________________________________________________________________
777Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
58bc3020 778{
b948db8d 779 // return TRUE if detector is handled by host or if fProcessAll is TRUE
780
781 if(fProcessAll) return kTRUE;
782 TIter iter(&fProcessedDetectors);
783 TObjString* detName;
784 while((detName = (TObjString*) iter.Next())){
785 if(detName->String() == detector) return kTRUE;
786 }
787 return kFALSE;
73abe331 788}
789
be48e3ea 790//______________________________________________________________________________________________
791Bool_t AliShuttleConfig::StrictRunOrder(const char* detector) const
792{
793 // return TRUE if detector wants strict run ordering of stored data
794
795 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
796 if (!aHolder)
797 {
798 AliError(Form("There isn't configuration for detector: %s",
799 detector));
800 return kTRUE;
801 }
802
803 return aHolder->StrictRunOrder();
804}
805
a7160fe9 806//______________________________________________________________________________________________
36c99a6a 807void AliShuttleConfig::Print(Option_t* option) const
58bc3020 808{
809// print configuration
36c99a6a 810// options : "": print configuration for all detectors, aliases and DPs in compacted format
811// "uncompact": print configuration for all detectors, aliases and DPs in uncompacted format
812// "DET": print configuration for DET, aliases and DPs in compacted format
813// "DET, uncompact": print configuration for DET, aliases and DPs in uncompacted format
814
73abe331 815 TString result;
816 result += '\n';
d477ad88 817
57c1a579 818 result += "####################################################\n";
819 result += Form(" Shuttle configuration from %s \n", fConfigHost.Data());
820 result += "####################################################\n";
821 result += Form("\nShuttle running on %s \n", fShuttleInstanceHost.Data());
57f50b3c 822
823 if(fProcessAll) {
57c1a579 824 result += Form("All detectors will be processed! \n");
57f50b3c 825 } else {
826 result += "Detectors processed by this host: ";
827 TIter it(&fProcessedDetectors);
828 TObjString* aDet;
829 while ((aDet = (TObjString*) it.Next())) {
830 result += Form("%s ", aDet->String().Data());
831 }
57c1a579 832 result += "\n";
b948db8d 833 }
b948db8d 834
9827400b 835 result += Form("PP time out = %d - Max PP memsize = %d KB - Max total retries = %d\n\n", fPPTimeOut, fPPMaxMem, fMaxRetries);
57c1a579 836 result += "------------------------------------------------------\n";
2bb7b766 837
57c1a579 838 result += Form("Logbook Configuration \n\n \tHost: %s:%d; \tUser: %s; ",
fc5a4708 839 fDAQlbHost.Data(), fDAQlbPort, fDAQlbUser.Data());
b948db8d 840
2c15234c 841// result += "Password: ";
842// result.Append('*', fDAQlbPass.Length());
441b0e9c 843 result += Form("\tDB: %s; \tTables: %s, %s, %s",
844 fDAQlbDB.Data(), fDAQlbTable.Data(), fShuttlelbTable.Data(), fRunTypelbTable.Data());
2c15234c 845
57f50b3c 846 result += "\n\n";
847
57c1a579 848 result += "------------------------------------------------------\n";
849 result += "FXS configuration\n\n";
850
57f50b3c 851 for(int iSys=0;iSys<3;iSys++){
57c1a579 852 result += Form("*** %s ***\n", AliShuttleInterface::GetSystemName(iSys));
fc5a4708 853 result += Form("\tDB host: %s:%d; \tUser: %s; \tName: %s; \tTable: %s\n",
854 fFXSdbHost[iSys].Data(), fFXSdbPort[iSys], fFXSdbUser[iSys].Data(),
2c15234c 855 fFXSdbName[iSys].Data(), fFXSdbTable[iSys].Data());
856 // result += Form("DB Password:",fFXSdbPass[iSys].Data());
fc5a4708 857 result += Form("\tFXS host: %s:%d; \tUser: %s\n\n", fFXSHost[iSys].Data(), fFXSPort[iSys],
858 fFXSUser[iSys].Data());
2c15234c 859 // result += Form("FXS Password:",fFXSPass[iSys].Data());
57f50b3c 860 }
b948db8d 861
36c99a6a 862 TString optStr(option);
863
57c1a579 864 result += "------------------------------------------------------\n";
865 result += "Detector-specific configuration\n\n";
73abe331 866 TIter iter(fDetectorMap.GetTable());
867 TPair* aPair;
868 while ((aPair = (TPair*) iter.Next())) {
58bc3020 869 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) aPair->Value();
36c99a6a 870 if (option != 0 && !optStr.Contains(aHolder->GetDetector()) && optStr.CompareTo("uncompact",TString::kIgnoreCase) != 0 )
871 continue;
57c1a579 872 result += Form("*** %s *** \n", aHolder->GetDetector());
873
874 const TObjArray* responsibles = aHolder->GetResponsibles();
875 if (responsibles->GetEntries() != 0)
876 {
877 result += "\tDetector responsible(s): ";
878 TIter it(responsibles);
879 TObjString* aResponsible;
880 while ((aResponsible = (TObjString*) it.Next()))
881 {
882 result += Form("%s ", aResponsible->String().Data());
883 }
884 result += "\n";
885 }
886
887 result += Form("\tStrict run ordering: %s \n", aHolder->StrictRunOrder() ? "YES" : "NO");
be48e3ea 888 if(aHolder->SkipDCSQuery())
889 {
2c15234c 890 result += "\n";
be48e3ea 891 continue;
892 }
57f50b3c 893 result += Form("\tAmanda server: %s:%d \n", aHolder->GetDCSHost(), aHolder->GetDCSPort());
894
36c99a6a 895 const TObjArray* aliases = 0;
896 if (optStr.Contains("uncompact",TString::kIgnoreCase))
897 {
898 aliases = aHolder->GetDCSAliases();
899 } else {
900 aliases = aHolder->GetCompactDCSAliases();
901 }
902
2c15234c 903 if (aliases->GetEntries() != 0)
904 {
905 result += "\tDCS Aliases: ";
906 TIter it(aliases);
907 TObjString* anAlias;
908 while ((anAlias = (TObjString*) it.Next()))
909 {
910 result += Form("%s ", anAlias->String().Data());
911 }
912 result += "\n";
57f50b3c 913 }
914
36c99a6a 915 const TObjArray* dataPoints = 0;
916 if (optStr.Contains("uncompact",TString::kIgnoreCase))
917 {
918 dataPoints = aHolder->GetDCSDataPoints();
919 } else {
920 dataPoints = aHolder->GetCompactDCSDataPoints();
921 }
2c15234c 922 if (dataPoints->GetEntries() != 0)
923 {
924 result += "\tDCS Data Points: ";
925 TIter it(dataPoints);
926 TObjString* aDataPoint;
927 while ((aDataPoint = (TObjString*) it.Next())) {
928 result += Form("%s ", aDataPoint->String().Data());
929 }
930 result += "\n";
931 }
932 result += "\n";
73abe331 933 }
934
57f50b3c 935 if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n";
936
73abe331 937 AliInfo(result);
938}