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