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