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