High_gain/low_gain calculation added; histogram names changed to satisfy AliPHOSDA1...
[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$
fb40ead4 18Revision 1.27 2007/12/17 03:23:32 jgrosseo
19several bugfixes
20added "empty preprocessor" as placeholder for Acorde in FDR
21
4508ab8b 22Revision 1.26 2007/12/07 19:14:36 acolla
23in AliShuttleTrigger:
24
25Added automatic collection of new runs on a regular time basis (settable from the configuration)
26
27in AliShuttleConfig: new members
28
29- triggerWait: time to wait for DIM trigger (s) before starting automatic collection of new runs
30- mode: run mode (test, prod) -> used to build log folder (logs or logs_PROD)
31
32in AliShuttle:
33
34- logs now stored in logs/#RUN/DET_#RUN.log
35
7d4cf768 36Revision 1.25 2007/11/26 16:58:37 acolla
37Monalisa configuration added: host and table name
38
b832ec02 39Revision 1.24 2007/10/24 10:44:08 acolla
40
41debug AliInfo removed
42
cb03e6c1 43Revision 1.23 2007/09/28 15:27:40 acolla
44
45AliDCSClient "multiSplit" option added in the DCS configuration
46in AliDCSMessage: variable MAX_BODY_SIZE set to 500000
47
542b6cc8 48Revision 1.22 2007/09/27 16:53:13 acolla
49Detectors can have more than one AMANDA server. SHUTTLE queries the servers sequentially,
50merges the dcs aliases/DPs in one TMap and sends it to the preprocessor.
51
1d172743 52Revision 1.21 2007/04/27 07:06:48 jgrosseo
53GetFileSources returns empty list in case of no files, but successful query
54No mails sent in testmode
55
86aa42c3 56Revision 1.20 2007/04/04 10:33:36 jgrosseo
571) 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.
58In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
59
602) 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.
61
623) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
63
644) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
65
665) 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.
67If you always need DCS data (like before), you do not need to implement it.
68
696) The run type has been added to the monitoring page
70
9827400b 71Revision 1.19 2007/02/28 10:41:56 acolla
72Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
73AliPreprocessor::GetRunType() function.
74Added some ldap definition files.
75
441b0e9c 76Revision 1.18 2007/01/23 19:20:03 acolla
77Removed old ldif files, added TOF, MCH ldif files. Added some options in
78AliShuttleConfig::Print. Added in Ali Shuttle: SetShuttleTempDir and
79SetShuttleLogDir
80
36c99a6a 81Revision 1.17 2007/01/18 11:17:47 jgrosseo
82changing spaces to tabs ;-)
83
f59d2f8f 84Revision 1.16 2007/01/18 11:10:35 jgrosseo
85adding the possibility of defining DCS alias and data points with patterns
86first pattern introduced: [N..M] to add all names between the two digits, this works also recursively.
87
40150741 88Revision 1.15 2007/01/15 18:27:11 acolla
89implementation of sending mail to subdetector expert in case the preprocessor fails.
90shuttle.schema updated with expert's email entry
91
fc5a4708 92Revision 1.13 2006/12/07 08:51:26 jgrosseo
93update (alberto):
94table, db names in ldap configuration
95added GRP preprocessor
96DCS data can also be retrieved by data point
97
2c15234c 98Revision 1.12 2006/11/16 16:16:48 jgrosseo
99introducing strict run ordering flag
100removed giving preprocessor name to preprocessor, they have to know their name themselves ;-)
101
be48e3ea 102Revision 1.11 2006/11/06 14:23:04 jgrosseo
103major update (Alberto)
104o) reading of run parameters from the logbook
105o) online offline naming conversion
106o) standalone DCSclient package
107
eba76848 108Revision 1.10 2006/10/20 15:22:59 jgrosseo
109o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child
110o) Merging Collect, CollectAll, CollectNew function
111o) Removing implementation of empty copy constructors (declaration still there!)
112
cb343cfd 113Revision 1.9 2006/10/02 16:38:39 jgrosseo
114update (alberto):
115fixed memory leaks
116storing of objects that failed to be stored to the grid before
117interfacing of shuttle status table in daq system
118
2bb7b766 119Revision 1.8 2006/08/15 10:50:00 jgrosseo
120effc++ corrections (alberto)
121
4f0ab988 122Revision 1.7 2006/07/20 09:54:40 jgrosseo
123introducing status management: The processing per subdetector is divided into several steps,
124after each step the status is stored on disk. If the system crashes in any of the steps the Shuttle
125can keep track of the number of failures and skips further processing after a certain threshold is
126exceeded. These thresholds can be configured in LDAP.
127
5164a766 128Revision 1.6 2006/07/19 10:09:55 jgrosseo
129new configuration, accesst to DAQ FES (Alberto)
130
57f50b3c 131Revision 1.5 2006/07/10 13:01:41 jgrosseo
132enhanced storing of last sucessfully processed run (alberto)
133
a7160fe9 134Revision 1.4 2006/06/12 09:11:16 jgrosseo
135coding conventions (Alberto)
136
58bc3020 137Revision 1.3 2006/06/06 14:26:40 jgrosseo
138o) removed files that were moved to STEER
139o) shuttle updated to follow the new interface (Alberto)
140
b948db8d 141Revision 1.7 2006/05/12 09:07:16 colla
14212/05/06
143New configuration complete
144
145Revision 1.2 2006/03/07 07:52:34 hristov
146New version (B.Yordanov)
147
d477ad88 148Revision 1.4 2005/11/19 14:20:31 byordano
149logbook config added to AliShuttleConfig
150
151Revision 1.3 2005/11/17 19:24:25 byordano
152TList changed to TObjArray in AliShuttleConfig
153
154Revision 1.2 2005/11/17 14:43:23 byordano
155import to local CVS
156
157Revision 1.1.1.1 2005/10/28 07:33:58 hristov
158Initial import as subdirectory in AliRoot
159
73abe331 160Revision 1.1.1.1 2005/09/12 22:11:40 byordano
161SHUTTLE package
162
163Revision 1.3 2005/08/30 09:13:02 byordano
164some docs added
165
166*/
167
168
169//
170// This class keeps the AliShuttle configuration.
171// It reads the configuration for LDAP server.
172// For every child entry in basedn which has schema type 'shuttleConfig'
173// it creates a detector configuration. This configuration includes:
174// DCS server host and port and the set of aliases for which data from
175// will be retrieved (used by AliShuttle).
176//
177
178
179#include "AliShuttleConfig.h"
57f50b3c 180#include "AliShuttleInterface.h"
73abe331 181
182#include "AliLog.h"
183
b948db8d 184#include <TSystem.h>
73abe331 185#include <TObjString.h>
186#include <TLDAPResult.h>
187#include <TLDAPEntry.h>
188#include <TLDAPAttribute.h>
189
57f50b3c 190
1d172743 191AliShuttleConfig::AliShuttleDCSConfigHolder::AliShuttleDCSConfigHolder(const TLDAPEntry* entry):
57f50b3c 192fDCSHost(""),
193fDCSPort(0),
542b6cc8 194fMultiSplit(100),
fc5a4708 195fDCSAliases(0),
196fDCSDataPoints(0),
36c99a6a 197fDCSAliasesComp(0),
198fDCSDataPointsComp(0),
1d172743 199fIsValid(kFALSE)
73abe331 200{
1d172743 201// constructor of the shuttle DCS configuration holder
58bc3020 202
73abe331 203 TLDAPAttribute* anAttribute;
2bb7b766 204 fDCSAliases = new TObjArray();
205 fDCSAliases->SetOwner(1);
2c15234c 206 fDCSDataPoints = new TObjArray();
207 fDCSDataPoints->SetOwner(1);
36c99a6a 208 fDCSAliasesComp = new TObjArray();
209 fDCSAliasesComp->SetOwner(1);
210 fDCSDataPointsComp = new TObjArray();
211 fDCSDataPointsComp->SetOwner(1);
73abe331 212
86aa42c3 213
1d172743 214 anAttribute = entry->GetAttribute("dcsHost");
2c15234c 215 if (!anAttribute)
216 {
1d172743 217 AliError("Unexpected: no DCS host!");
73abe331 218 return;
219 }
57f50b3c 220
b948db8d 221 fDCSHost = anAttribute->GetValue();
73abe331 222
1d172743 223 anAttribute = entry->GetAttribute("dcsPort");
2c15234c 224 if (!anAttribute)
225 {
1d172743 226 AliError("Unexpected: no DCS port!");
73abe331 227 return;
228 }
229 TString portStr = anAttribute->GetValue();
b948db8d 230 fDCSPort = portStr.Atoi();
73abe331 231
542b6cc8 232 anAttribute = entry->GetAttribute("multiSplit"); // MAY
233 if (anAttribute)
234 {
235 TString multiSplitStr = anAttribute->GetValue();
236 fMultiSplit = multiSplitStr.Atoi();
237 if(fMultiSplit == 0) {
238 AliError("MultiSplit must be a positive integer!");
239 return;
240 }
241
242 }
243
1d172743 244 anAttribute = entry->GetAttribute("dcsAlias"); // MAY
2c15234c 245 if (anAttribute)
246 {
247 const char* anAlias;
248 while ((anAlias = anAttribute->GetValue()))
249 {
36c99a6a 250 fDCSAliasesComp->AddLast(new TObjString(anAlias));
40150741 251 ExpandAndAdd(fDCSAliases, anAlias);
2c15234c 252 }
73abe331 253 }
57f50b3c 254
1d172743 255 anAttribute = entry->GetAttribute("dcsDP"); // MAY
2c15234c 256 if (anAttribute)
257 {
258 const char* aDataPoint;
259 while ((aDataPoint = anAttribute->GetValue()))
260 {
36c99a6a 261 fDCSDataPointsComp->AddLast(new TObjString(aDataPoint));
262 ExpandAndAdd(fDCSDataPoints, aDataPoint);
2c15234c 263 }
b948db8d 264 }
fb40ead4 265
73abe331 266 fIsValid = kTRUE;
267}
268
40150741 269//______________________________________________________________________________________________
1d172743 270void AliShuttleConfig::AliShuttleDCSConfigHolder::ExpandAndAdd(TObjArray* target, const char* entry)
40150741 271{
f59d2f8f 272 //
273 // adds <entry> to <target> applying expanding of the name
274 // [N..M] creates M-N+1 names with the corresponding digits
275 //
40150741 276
f59d2f8f 277 TString entryStr(entry);
40150741 278
f59d2f8f 279 Int_t begin = entryStr.Index("[");
280 Int_t end = entryStr.Index("]");
281 if (begin != -1 && end != -1 && end > begin)
282 {
283 TString before(entryStr(0, begin));
284 TString after(entryStr(end+1, entryStr.Length()));
40150741 285
f59d2f8f 286 AliDebug(2, Form("Found [] pattern. Splitted input string %s %s", before.Data(), after.Data()));
40150741 287
f59d2f8f 288 Int_t dotdot = entryStr.Index("..");
40150741 289
f59d2f8f 290 TString nStr(entryStr(begin+1, dotdot-begin-1));
291 TString mStr(entryStr(dotdot+2, end-dotdot-2));
40150741 292
f59d2f8f 293 AliDebug(2, Form("Found [N..M] pattern. %s %s", nStr.Data(), mStr.Data()));
40150741 294
f59d2f8f 295 if (nStr.IsDigit() && mStr.IsDigit())
296 {
297 Int_t n = nStr.Atoi();
298 Int_t m = mStr.Atoi();
40150741 299
f59d2f8f 300 Int_t nDigits = nStr.Length();
301 TString formatStr;
302 formatStr.Form("%%s%%0%dd%%s", nDigits);
40150741 303
f59d2f8f 304 AliDebug(2, Form("Format string is %s", formatStr.Data()));
40150741 305
f59d2f8f 306 for (Int_t current = n; current<=m; ++current)
307 {
308 TString newEntry;
309 newEntry.Form(formatStr.Data(), before.Data(), current, after.Data());
40150741 310
f59d2f8f 311 AliDebug(2, Form("Calling recursive with %s", newEntry.Data()));
40150741 312
f59d2f8f 313 // and go recursive
314 ExpandAndAdd(target, newEntry);
315 }
40150741 316
f59d2f8f 317 // return here because we processed the entries already recursively.
318 return;
319 }
320 }
40150741 321
f59d2f8f 322 AliDebug(2, Form("Adding name %s", entry));
323 target->AddLast(new TObjString(entry));
40150741 324}
325
a7160fe9 326//______________________________________________________________________________________________
1d172743 327AliShuttleConfig::AliShuttleDCSConfigHolder::~AliShuttleDCSConfigHolder()
58bc3020 328{
329// destructor of the shuttle configuration holder
330
2bb7b766 331 delete fDCSAliases;
2c15234c 332 delete fDCSDataPoints;
1d172743 333 delete fDCSAliasesComp;
334 delete fDCSDataPointsComp;
335}
336
337//______________________________________________________________________________________________
338AliShuttleConfig::AliShuttleDetConfigHolder::AliShuttleDetConfigHolder(const TLDAPEntry* entry):
339fDetector(""),
340fDCSConfig(),
341fResponsibles(0),
342fIsValid(kFALSE),
343fSkipDCSQuery(kFALSE),
344fStrictRunOrder(kFALSE)
345{
346// constructor of the shuttle configuration holder
347
348 TLDAPAttribute* anAttribute;
349
350 fResponsibles = new TObjArray();
351 fResponsibles->SetOwner(1);
352 fDCSConfig = new TObjArray();
353 fDCSConfig->SetOwner(1);
354
355 anAttribute = entry->GetAttribute("det"); // MUST
356 if (!anAttribute)
357 {
358 AliError(Form("No \"det\" attribute!"));
359 return;
360 }
361 fDetector = anAttribute->GetValue();
362
363 anAttribute = entry->GetAttribute("strictRunOrder"); // MAY
364 if (!anAttribute)
365 {
366 AliWarning(Form("%s did not set strictRunOrder flag - the default is FALSE",
367 fDetector.Data()));
368 } else {
369 TString strictRunStr = anAttribute->GetValue();
370 if (!(strictRunStr == "0" || strictRunStr == "1"))
371 {
372 AliError("strictRunOrder flag must be 0 or 1!");
373 return;
374 }
375 fStrictRunOrder = (Bool_t) strictRunStr.Atoi();
376 }
377
378 anAttribute = entry->GetAttribute("responsible"); // MAY
379 if (!anAttribute)
380 {
381 AliDebug(2, "Warning! No \"responsible\" attribute!");
382 }
383 else
384 {
385 const char* aResponsible;
386 while ((aResponsible = anAttribute->GetValue()))
387 {
388 fResponsibles->AddLast(new TObjString(aResponsible));
389 }
390 }
391
392 fIsValid = kTRUE;
393}
394
395//______________________________________________________________________________________________
396AliShuttleConfig::AliShuttleDetConfigHolder::~AliShuttleDetConfigHolder()
397{
398// destructor of the shuttle configuration holder
399
57c1a579 400 delete fResponsibles;
1d172743 401 delete fDCSConfig;
402}
403
404//______________________________________________________________________________________________
405const char* AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSHost(Int_t iServ) const
406{
407 //
408 // returns DCS server host
409 //
410
411 if (iServ < 0 || iServ >= GetNServers()) return 0;
412
413 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
414 (fDCSConfig->At(iServ));
415
416 return aHolder->GetDCSHost();
417}
418
419//______________________________________________________________________________________________
420Int_t AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSPort(Int_t iServ) const
421{
422 //
423 // returns DCS server port
424 //
425
426 if (iServ < 0 || iServ >= GetNServers()) return 0;
427
428 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
429 (fDCSConfig->At(iServ));
430
431 return aHolder->GetDCSPort();
432}
433
542b6cc8 434//______________________________________________________________________________________________
435Int_t AliShuttleConfig::AliShuttleDetConfigHolder::GetMultiSplit(Int_t iServ) const
436{
437 //
438 // returns DCS "multi split" value
439 //
440
441 if (iServ < 0 || iServ >= GetNServers()) return 0;
442
443 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
444 (fDCSConfig->At(iServ));
445
446 return aHolder->GetMultiSplit();
447}
448
1d172743 449//______________________________________________________________________________________________
450const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSAliases(Int_t iServ) const
451{
452 //
453 // returns collection of TObjString which represents the set of aliases
454 // which used for data retrieval for particular detector
455 //
456
457 if (iServ < 0 || iServ >= GetNServers()) return 0;
458
459 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
460 (fDCSConfig->At(iServ));
461
462 return aHolder->GetDCSAliases();
463}
464
465//______________________________________________________________________________________________
466const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSDataPoints(Int_t iServ) const
467{
468 //
469 // returns collection of TObjString which represents the set of aliases
470 // which used for data retrieval for particular detector
471 //
472
473 if (iServ < 0 || iServ >= GetNServers()) return 0;
474
475 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
476 (fDCSConfig->At(iServ));
477
478 return aHolder->GetDCSDataPoints();
479}
480
481//______________________________________________________________________________________________
482const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetCompactDCSAliases(Int_t iServ) const
483{
484 //
485 // returns collection of TObjString which represents the set of aliases
486 // which used for data retrieval for particular detector (Compact style)
487 //
488
489 if (iServ < 0 || iServ >= GetNServers()) return 0;
490
491 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
492 (fDCSConfig->At(iServ));
493
494 return aHolder->GetCompactDCSAliases();
495}
496
497//______________________________________________________________________________________________
498const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetCompactDCSDataPoints(Int_t iServ) const
499{
500 //
501 // returns collection of TObjString which represents the set of aliases
502 // which used for data retrieval for particular detector (Compact style)
503 //
504
505 if (iServ < 0 || iServ >= GetNServers()) return 0;
506
507 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
508 (fDCSConfig->At(iServ));
509
510 return aHolder->GetCompactDCSDataPoints();
511}
512
513//______________________________________________________________________________________________
514void AliShuttleConfig::AliShuttleDetConfigHolder::AddDCSConfig(AliShuttleDCSConfigHolder* holder)
515{
516 //
517 // adds a DCS configuration set in the array of DCS configurations
518 //
519
520 if(!holder) return;
521 fDCSConfig->AddLast(holder);
73abe331 522}
523
524ClassImp(AliShuttleConfig)
525
a7160fe9 526//______________________________________________________________________________________________
527AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
73abe331 528 const char* binddn, const char* password, const char* basedn):
1d172743 529 fConfigHost(host),
530 fDAQlbHost(""),
531 fDAQlbPort(),
532 fDAQlbUser(""),
533 fDAQlbPass(""),
534 fDAQlbDB(""),
535 fDAQlbTable(""),
536 fShuttlelbTable(""),
537 fRunTypelbTable(""),
538 fMaxRetries(0),
539 fPPTimeOut(0),
540 fPPMaxMem(0),
b832ec02 541 fMonitorHost(""),
542 fMonitorTable(""),
7d4cf768 543 fTriggerWait(3600),
544 fRunMode(kTest),
1d172743 545 fDetectorMap(),
546 fDetectorList(),
fb40ead4 547 fAdmin(),
1d172743 548 fShuttleInstanceHost(""),
549 fProcessedDetectors(),
fb40ead4 550 fKeepDCSMap(kFALSE),
551 fKeepTempFolder(kFALSE),
552 fSendMail(kFALSE),
1d172743 553 fProcessAll(kFALSE),
554 fIsValid(kFALSE)
fb40ead4 555
73abe331 556{
557 //
558 // host: ldap server host
559 // port: ldap server port
560 // binddn: binddn used for ldap binding (simple bind is used!).
561 // password: password for binddn
b948db8d 562 // basedn: this is basedn whose childeren entries which have
73abe331 563 //
564
1d172743 565 fDetectorMap.SetOwner(1);
2bb7b766 566 fDetectorList.SetOwner(0); //fDetectorList and fDetectorMap share the same object!
567 fProcessedDetectors.SetOwner();
fb40ead4 568
569 for (int i=0; i<5; i++)
570 {
571 fAdmin[i] = new TObjArray();
572 fAdmin[i]->SetOwner();
573 }
2bb7b766 574
b948db8d 575 TLDAPServer aServer(host, port, binddn, password, 3);
57f50b3c 576
73abe331 577 if (!aServer.IsConnected()) {
2bb7b766 578 AliError(Form("Can't connect to ldap server %s:%d",
73abe331 579 host, port));
580 return;
581 }
582
b948db8d 583 // reads configuration for the shuttle running on this machine
1d172743 584
585 TLDAPResult* aResult = 0;
586 TLDAPEntry* anEntry = 0;
587
588 TList dcsList;
589 dcsList.SetOwner(1);
590 TList detList;
591 detList.SetOwner(1);
592 TList globalList;
593 globalList.SetOwner(1);
594 TList sysList;
595 sysList.SetOwner(1);
596 TList hostList;
597 hostList.SetOwner(1);
598
599 aResult = aServer.Search(basedn, LDAP_SCOPE_SUBTREE, 0, 0);
600
601 if (!aResult)
602 {
603 AliError(Form("Can't find configuration with base DN: %s !", basedn));
73abe331 604 return;
605 }
1d172743 606
607 while ((anEntry = aResult->GetNext()))
608 {
609 TString dn = anEntry->GetDn();
610
611 if (dn.BeginsWith("dcsHost="))
612 {
613 dcsList.Add(anEntry);
614 }
615 else if (dn.BeginsWith("det="))
616 {
617 detList.Add(anEntry);
618 }
619 else if (dn.BeginsWith("name=globalConfig"))
620 {
621 globalList.Add(anEntry);
622 }
623 else if (dn.BeginsWith("system="))
624 {
625 sysList.Add(anEntry);
626 }
627 else if (dn.BeginsWith("shuttleHost="))
628 {
629 hostList.Add(anEntry);
630 }
631 else
632 {
633 delete anEntry;
634 }
635
b948db8d 636 }
1d172743 637 delete aResult;
638
639 Int_t result=0;
640
641 result += SetGlobalConfig(&globalList);
642 result += SetSysConfig(&sysList);
643 result += SetDetConfig(&detList,&dcsList);
644 result += SetHostConfig(&hostList);
645
646 if(result)
647 {
648 AliError("Configuration is INVALID!");
b948db8d 649 }
1d172743 650 else
651 {
652 fIsValid = kTRUE;
b948db8d 653 }
1d172743 654}
b948db8d 655
1d172743 656//______________________________________________________________________________________________
657AliShuttleConfig::~AliShuttleConfig()
658{
659// destructor
57f50b3c 660
1d172743 661 fDetectorMap.DeleteAll();
662 fDetectorList.Clear();
663 fProcessedDetectors.Delete();
fb40ead4 664
665 delete[] fAdmin;
666
1d172743 667}
b948db8d 668
1d172743 669//______________________________________________________________________________________________
670const TObjArray* AliShuttleConfig::GetDetectors() const
671{
672 //
673 // returns collection of TObjString which contains the name
674 // of every detector which is in the configuration.
675 //
57f50b3c 676
1d172743 677 return &fDetectorList;
678}
73abe331 679
1d172743 680//______________________________________________________________________________________________
681Bool_t AliShuttleConfig::HasDetector(const char* detector) const
682{
683 //
684 // checks for paricular detector in the configuration.
685 //
686 return fDetectorMap.GetValue(detector) != NULL;
687}
73abe331 688
1d172743 689//______________________________________________________________________________________________
690Int_t AliShuttleConfig::GetNServers(const char* detector) const
691{
692 //
693 // returns number of DCS servers for detector
694 //
695
696 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
697 if (!aHolder) {
698 AliError(Form("There isn't configuration for detector: %s",
699 detector));
700 return 0;
57f50b3c 701 }
702
1d172743 703 return aHolder->GetNServers();
704}
d477ad88 705
d477ad88 706
1d172743 707//______________________________________________________________________________________________
708const char* AliShuttleConfig::GetDCSHost(const char* detector, Int_t iServ) const
709{
710 //
711 // returns i-th DCS server host used by particular detector
712 //
713
714 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
715 if (!aHolder) {
716 AliError(Form("There isn't configuration for detector: %s",
717 detector));
718 return NULL;
d477ad88 719 }
720
1d172743 721 return aHolder->GetDCSHost(iServ);
722}
723
724//______________________________________________________________________________________________
725Int_t AliShuttleConfig::GetDCSPort(const char* detector, Int_t iServ) const
726{
727 //
728 // returns i-th DCS server port used by particular detector
729 //
730
731
732 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
733 if (!aHolder) {
734 AliError(Form("There isn't configuration for detector: %s",
735 detector));
736 return 0;
737 }
738
739 return aHolder->GetDCSPort(iServ);
740}
741
542b6cc8 742//______________________________________________________________________________________________
743Int_t AliShuttleConfig::GetMultiSplit(const char* detector, Int_t iServ) const
744{
745 //
746 // returns i-th DCS "multi split" value
747 //
748
749
750 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
751 if (!aHolder) {
752 AliError(Form("There isn't configuration for detector: %s",
753 detector));
754 return 0;
755 }
756
757 return aHolder->GetMultiSplit(iServ);
758}
759
1d172743 760//______________________________________________________________________________________________
761const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector, Int_t iServ) const
762{
763 //
764 // returns collection of TObjString which represents the i-th set of aliases
765 // which used for data retrieval for particular detector
766 //
767
768 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
769 if (!aHolder) {
770 AliError(Form("There isn't configuration for detector: %s",
771 detector));
772 return NULL;
773 }
774
775 return aHolder->GetDCSAliases(iServ);
776}
777
778//______________________________________________________________________________________________
779const TObjArray* AliShuttleConfig::GetDCSDataPoints(const char* detector, Int_t iServ) const
780{
781 //
782 // returns collection of TObjString which represents the set of aliases
783 // which used for data retrieval for particular detector
784 //
785
786 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
787 if (!aHolder) {
788 AliError(Form("There isn't configuration for detector: %s",
789 detector));
790 return NULL;
791 }
792
793 return aHolder->GetDCSDataPoints(iServ);
794}
795
796//______________________________________________________________________________________________
797const TObjArray* AliShuttleConfig::GetCompactDCSAliases(const char* detector, Int_t iServ) const
798{
799 //
800 // returns collection of TObjString which represents the i-th set of aliases
801 // which used for data retrieval for particular detector (Compact style)
802 //
803
804 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
805 if (!aHolder) {
806 AliError(Form("There isn't configuration for detector: %s",
807 detector));
808 return NULL;
809 }
810
811 return aHolder->GetCompactDCSAliases(iServ);
812}
813
814//______________________________________________________________________________________________
815const TObjArray* AliShuttleConfig::GetCompactDCSDataPoints(const char* detector, Int_t iServ) const
816{
817 //
818 // returns collection of TObjString which represents the set of aliases
819 // which used for data retrieval for particular detector (Compact style)
820 //
821
822 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
823 if (!aHolder) {
824 AliError(Form("There isn't configuration for detector: %s",
825 detector));
826 return NULL;
827 }
828
829 return aHolder->GetCompactDCSDataPoints(iServ);
830}
831
832//______________________________________________________________________________________________
833const TObjArray* AliShuttleConfig::GetResponsibles(const char* detector) const
834{
835 //
836 // returns collection of TObjString which represents the list of mail addresses
837 // of the detector's responsible(s)
838 //
839
840 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
841 if (!aHolder) {
842 AliError(Form("There isn't configuration for detector: %s",
843 detector));
844 return NULL;
845 }
846
847 return aHolder->GetResponsibles();
848}
849
fb40ead4 850//______________________________________________________________________________________________
851const TObjArray* AliShuttleConfig::GetAdmins(Int_t sys) const
852{
853 //
854 // returns collection of TObjString which represents the list of mail addresses
855 // of the system's administrator(s) (DAQ, DCS, HLT, Global, Amanda)
856 //
857
858 if (sys < 0 || sys > 4) return 0;
859 return fAdmin[sys];
860}
861
1d172743 862//______________________________________________________________________________________________
863Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
864{
865 // return TRUE if detector is handled by host or if fProcessAll is TRUE
866
867 if(fProcessAll) return kTRUE;
868 TIter iter(&fProcessedDetectors);
869 TObjString* detName;
870 while((detName = (TObjString*) iter.Next())){
871 if(detName->String() == detector) return kTRUE;
d477ad88 872 }
1d172743 873 return kFALSE;
874}
875
876//______________________________________________________________________________________________
877Bool_t AliShuttleConfig::StrictRunOrder(const char* detector) const
878{
879 // return TRUE if detector wants strict run ordering of stored data
880
881 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
882 if (!aHolder)
883 {
884 AliError(Form("There isn't configuration for detector: %s",
885 detector));
886 return kTRUE;
887 }
d477ad88 888
1d172743 889 return aHolder->StrictRunOrder();
890}
57f50b3c 891
1d172743 892//______________________________________________________________________________________________
893UInt_t AliShuttleConfig::SetGlobalConfig(TList* list)
894{
895 // Set the global configuration (DAQ Logbook + preprocessor monitoring settings)
896
897 TLDAPEntry* anEntry = 0;
898 TLDAPAttribute* anAttribute = 0;
899
900 if (list->GetEntries() == 0)
901 {
902 AliError("Global configuration not found!");
903 return 1;
904 }
905 else if (list->GetEntries() > 1)
906 {
907 AliError("More than one global configuration found!");
908 return 2;
909 }
910
911 anEntry = dynamic_cast<TLDAPEntry*> (list->At(0));
912
913 if (!anEntry)
914 {
915 AliError("Unexpected! Global list does not contain a TLDAPEntry");
916 return 3;
917 }
918
919
920 anAttribute = anEntry->GetAttribute("daqLbHost");
d477ad88 921 if (!anAttribute) {
1d172743 922 AliError("Can't find daqLbHost attribute!");
923 return 4;
d477ad88 924 }
57f50b3c 925 fDAQlbHost = anAttribute->GetValue();
d477ad88 926
1d172743 927 anAttribute = anEntry->GetAttribute("daqLbPort"); // MAY
fc5a4708 928 if (anAttribute)
929 {
930 fDAQlbPort = ((TString) anAttribute->GetValue()).Atoi();
931 } else {
932 fDAQlbPort = 3306; // mysql
933 }
934
1d172743 935 anAttribute = anEntry->GetAttribute("daqLbUser");
d477ad88 936 if (!anAttribute) {
1d172743 937 AliError("Can't find daqLbUser attribute!");
938 return 4;
d477ad88 939 }
57f50b3c 940 fDAQlbUser = anAttribute->GetValue();
941
1d172743 942 anAttribute = anEntry->GetAttribute("daqLbPasswd");
d477ad88 943 if (!anAttribute) {
1d172743 944 AliError("Can't find daqLbPasswd attribute!");
945 return 4;
d477ad88 946 }
57f50b3c 947 fDAQlbPass = anAttribute->GetValue();
d477ad88 948
1d172743 949 anAttribute = anEntry->GetAttribute("daqLbDB");
2c15234c 950 if (!anAttribute) {
1d172743 951 AliError("Can't find daqLbDB attribute!");
952 return 4;
2c15234c 953 }
954 fDAQlbDB = anAttribute->GetValue();
955
1d172743 956 anAttribute = anEntry->GetAttribute("daqLbTable");
2c15234c 957 if (!anAttribute) {
1d172743 958 AliError("Can't find daqLbTable attribute!");
959 return 4;
2c15234c 960 }
961 fDAQlbTable = anAttribute->GetValue();
962
1d172743 963 anAttribute = anEntry->GetAttribute("shuttleLbTable");
441b0e9c 964 if (!anAttribute) {
1d172743 965 AliError("Can't find shuttleLbTable attribute!");
966 return 4;
441b0e9c 967 }
968 fShuttlelbTable = anAttribute->GetValue();
969
1d172743 970 anAttribute = anEntry->GetAttribute("runTypeLbTable");
441b0e9c 971 if (!anAttribute) {
1d172743 972 AliError("Can't find runTypeLbTable attribute!");
973 return 4;
441b0e9c 974 }
975 fRunTypelbTable = anAttribute->GetValue();
2c15234c 976
1d172743 977 anAttribute = anEntry->GetAttribute("ppmaxRetries");
5164a766 978 if (!anAttribute) {
1d172743 979 AliError("Can't find ppmaxRetries attribute!");
980 return 4;
5164a766 981 }
982 TString tmpStr = anAttribute->GetValue();
cb343cfd 983 fMaxRetries = tmpStr.Atoi();
5164a766 984
1d172743 985 anAttribute = anEntry->GetAttribute("ppTimeOut");
5164a766 986 if (!anAttribute) {
1d172743 987 AliError("Can't find ppTimeOut attribute!");
988 return 4;
5164a766 989 }
990 tmpStr = anAttribute->GetValue();
cb343cfd 991 fPPTimeOut = tmpStr.Atoi();
5164a766 992
1d172743 993 anAttribute = anEntry->GetAttribute("ppMaxMem");
9827400b 994 if (!anAttribute) {
1d172743 995 AliError("Can't find ppMaxMem attribute!");
996 return 4;
9827400b 997 }
998 tmpStr = anAttribute->GetValue();
999 fPPMaxMem = tmpStr.Atoi();
1000
b832ec02 1001 anAttribute = anEntry->GetAttribute("monitorHost");
1002 if (!anAttribute) {
1003 AliError("Can't find monitorHost attribute!");
1004 return 4;
1005 }
1006 fMonitorHost = anAttribute->GetValue();
1007
1008 anAttribute = anEntry->GetAttribute("monitorTable");
1009 if (!anAttribute) {
1010 AliError("Can't find monitorTable attribute!");
1011 return 4;
1012 }
1013 fMonitorTable = anAttribute->GetValue();
7d4cf768 1014
1015 anAttribute = anEntry->GetAttribute("triggerWait"); // MAY
1016 if (!anAttribute) {
1017 AliWarning(Form("triggerWait not set! default = ", fTriggerWait));
1018 }
1019 tmpStr = anAttribute->GetValue();
1020 fTriggerWait = tmpStr.Atoi();
b832ec02 1021
7d4cf768 1022 anAttribute = anEntry->GetAttribute("mode");
1023 if (!anAttribute) {
1024 AliWarning("Run mode not set! Running in test mode.");
7d4cf768 1025 } else {
4508ab8b 1026 tmpStr = anAttribute->GetValue();
1027 if (tmpStr == "test")
1028 {
1029 fRunMode = kTest;
1030 } else if (tmpStr == "prod") {
1031 fRunMode = kProd;
1032 } else {
1033 AliWarning(Form("Not a valid run mode: %s", tmpStr.Data()));
1034 AliWarning("Valid run modes are \"test\" and \"prod\". Running in test mode.");
1035 }
7d4cf768 1036 }
fb40ead4 1037
1038 anAttribute = anEntry->GetAttribute("keepDCSMap"); // MAY
1039 if (!anAttribute)
1040 {
1041 AliWarning("keepDCSMap flag not set - default is FALSE");
1042 } else {
1043 TString keepDCSMapStr = anAttribute->GetValue();
1044 if (!(keepDCSMapStr == "0" || keepDCSMapStr == "1"))
1045 {
1046 AliError("keepDCSMap flag must be 0 or 1!");
1047 return 4;
1048 }
1049 fKeepDCSMap = (Bool_t) keepDCSMapStr.Atoi();
1050 }
1051
1052 anAttribute = anEntry->GetAttribute("keepTempFolder"); // MAY
1053 if (!anAttribute)
1054 {
1055 AliWarning("keepTempFolder flag not set - default is FALSE");
1056 } else {
1057 TString keepTempFolderStr = anAttribute->GetValue();
1058 if (!(keepTempFolderStr == "0" || keepTempFolderStr == "1"))
1059 {
1060 AliError("keepTempFolder flag must be 0 or 1!");
1061 return 4;
1062 }
1063 fKeepTempFolder = (Bool_t) keepTempFolderStr.Atoi();
1064 }
1065
1066
1067 anAttribute = anEntry->GetAttribute("shuttleAdmin"); // MAY
1068 if (!anAttribute)
1069 {
1070 AliDebug(2, "Warning! No \"shuttleAdmin\" attribute!");
1071 }
1072 else
1073 {
1074 const char* anAdmin;
1075 while ((anAdmin = anAttribute->GetValue()))
1076 {
1077 fAdmin[kGlobal]->AddLast(new TObjString(anAdmin));
1078 }
1079 }
1080
1081 anAttribute = anEntry->GetAttribute("amandaAdmin"); // MAY
1082 if (!anAttribute)
1083 {
1084 AliDebug(2, "Warning! No \"amandaAdmin\" attribute!");
1085 }
1086 else
1087 {
1088 const char* anAdmin;
1089 while ((anAdmin = anAttribute->GetValue()))
1090 {
1091 fAdmin[kAmanda]->AddLast(new TObjString(anAdmin));
1092 }
1093 }
1094
1095 anAttribute = anEntry->GetAttribute("sendMail"); // MAY
1096 if (!anAttribute)
1097 {
1098 AliWarning("sendMail flag not set - default is FALSE");
1099 } else {
1100 TString sendMailStr = anAttribute->GetValue();
1101 if (!(sendMailStr == "0" || sendMailStr == "1"))
1102 {
1103 AliError("sendMail flag must be 0 or 1!");
1104 return 4;
1105 }
1106 fSendMail = (Bool_t) sendMailStr.Atoi();
1107 }
1108
1d172743 1109 return 0;
1d172743 1110}
57f50b3c 1111
1d172743 1112//______________________________________________________________________________________________
1113UInt_t AliShuttleConfig::SetSysConfig(TList* list)
1114{
1115 // Set the online FXS configuration (DAQ + DCS + HLT)
1116
1117 TLDAPEntry* anEntry = 0;
1118 TLDAPAttribute* anAttribute = 0;
1119
1120 if (list->GetEntries() != 3)
1121 {
1122 AliError(Form("Wrong number of online systems found: %d !", list->GetEntries()));
1123 return 1;
1124 }
57f50b3c 1125
1d172743 1126 TIter iter(list);
fb40ead4 1127 Int_t count = 0;
1128 SystemCode iSys=kDAQ;
1129
1d172743 1130 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1131 {
1132 anAttribute = anEntry->GetAttribute("system");
1133 TString sysName = anAttribute->GetValue();
1134
1135 if (sysName == "DAQ")
1136 {
fb40ead4 1137 iSys = kDAQ;
1d172743 1138 count += 1;
57f50b3c 1139 }
1d172743 1140 else if (sysName == "DCS")
1141 {
fb40ead4 1142 iSys = kDCS;
1d172743 1143 count += 10;
57f50b3c 1144 }
1d172743 1145 else if (sysName == "HLT")
1146 {
fb40ead4 1147 iSys = kHLT;
1d172743 1148 count += 100;
1149 }
1150
1151 anAttribute = anEntry->GetAttribute("dbHost");
57f50b3c 1152 if (!anAttribute) {
1d172743 1153 AliError(Form ("Can't find dbHost attribute for %s!!",
eba76848 1154 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1155 return 5;
57f50b3c 1156 }
2c15234c 1157 fFXSdbHost[iSys] = anAttribute->GetValue();
57f50b3c 1158
1d172743 1159 anAttribute = anEntry->GetAttribute("dbPort"); // MAY
fc5a4708 1160 if (anAttribute)
1161 {
1162 fFXSdbPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1163 } else {
1164 fFXSdbPort[iSys] = 3306; // mysql
1165 }
1166
1d172743 1167 anAttribute = anEntry->GetAttribute("dbUser");
57f50b3c 1168 if (!anAttribute) {
1d172743 1169 AliError(Form ("Can't find dbUser attribute for %s!!",
eba76848 1170 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1171 return 5;
57f50b3c 1172 }
2c15234c 1173 fFXSdbUser[iSys] = anAttribute->GetValue();
57f50b3c 1174
1d172743 1175 anAttribute = anEntry->GetAttribute("dbPasswd");
57f50b3c 1176 if (!anAttribute) {
1d172743 1177 AliError(Form ("Can't find dbPasswd attribute for %s!!",
eba76848 1178 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1179 return 5;
57f50b3c 1180 }
2c15234c 1181 fFXSdbPass[iSys] = anAttribute->GetValue();
1182
1d172743 1183 anAttribute = anEntry->GetAttribute("dbName");
2c15234c 1184 if (!anAttribute) {
1d172743 1185 AliError(Form ("Can't find dbName attribute for %s!!",
2c15234c 1186 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1187 return 5;
2c15234c 1188 }
1189
1190 fFXSdbName[iSys] = anAttribute->GetValue();
1d172743 1191 anAttribute = anEntry->GetAttribute("dbTable");
2c15234c 1192 if (!anAttribute) {
1d172743 1193 AliError(Form ("Can't find dbTable attribute for %s!!",
2c15234c 1194 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1195 return 5;
2c15234c 1196 }
1197 fFXSdbTable[iSys] = anAttribute->GetValue();
57f50b3c 1198
1d172743 1199 anAttribute = anEntry->GetAttribute("fxsHost");
57f50b3c 1200 if (!anAttribute) {
1d172743 1201 AliError(Form ("Can't find fxsHost attribute for %s!!",
eba76848 1202 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1203 return 5;
57f50b3c 1204 }
2c15234c 1205 fFXSHost[iSys] = anAttribute->GetValue();
57f50b3c 1206
1d172743 1207 anAttribute = anEntry->GetAttribute("fxsPort"); // MAY
fc5a4708 1208 if (anAttribute)
1209 {
1210 fFXSPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1211 } else {
1212 fFXSPort[iSys] = 22; // scp port number
1213 }
1214
1d172743 1215 anAttribute = anEntry->GetAttribute("fxsUser");
57f50b3c 1216 if (!anAttribute) {
1d172743 1217 AliError(Form ("Can't find fxsUser attribute for %s!!",
eba76848 1218 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1219 return 5;
57f50b3c 1220 }
2c15234c 1221 fFXSUser[iSys] = anAttribute->GetValue();
57f50b3c 1222
1d172743 1223 anAttribute = anEntry->GetAttribute("fxsPasswd");
2c15234c 1224 if (anAttribute) fFXSPass[iSys] = anAttribute->GetValue();
fb40ead4 1225
1226 anAttribute = anEntry->GetAttribute("fxsAdmin"); // MAY
1227 if (!anAttribute)
1228 {
1229 AliDebug(2, "Warning! No \"fxsAdmin\" attribute!");
1230 }
1231 else
1232 {
1233 const char* anAdmin;
1234 while ((anAdmin = anAttribute->GetValue()))
1235 {
1236 fAdmin[iSys]->AddLast(new TObjString(anAdmin));
1237 }
1238 }
1239
57f50b3c 1240 }
73abe331 1241
1d172743 1242 if(count != 111) {
1243 AliError(Form("Wrong system configuration! (code = %d)", count));
1244 return 6;
73abe331 1245 }
1d172743 1246
1247 return 0;
2c15234c 1248}
1249
57c1a579 1250//______________________________________________________________________________________________
1d172743 1251UInt_t AliShuttleConfig::SetDetConfig(TList* detList, TList* dcsList)
57c1a579 1252{
1d172743 1253 // Set the detector configuration (general settings + DCS amanda server and alias/DP lists)
57c1a579 1254
1d172743 1255 TLDAPEntry* anEntry = 0;
1256
1257 TIter iter(detList);
1258 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1259 {
1260
1261 AliShuttleDetConfigHolder* detHolder = new AliShuttleDetConfigHolder(anEntry);
57c1a579 1262
1d172743 1263 if (!detHolder->IsValid()) {
1264 AliError("Detector configuration error!");
1265 delete detHolder;
1266 return 7;
1267 }
b948db8d 1268
1d172743 1269 TObjString* detStr = new TObjString(detHolder->GetDetector());
1270
1271 // Look for DCS Configuration
1272 TIter dcsIter(dcsList);
1273 TLDAPEntry *dcsEntry = 0;
1274 while ((dcsEntry = dynamic_cast<TLDAPEntry*> (dcsIter.Next())))
1275 {
1276 TString dn = dcsEntry->GetDn();
1277 if(dn.Contains(detStr->GetName())) {
1278 AliDebug(2, Form("Found DCS configuration: dn = %s",dn.Data()));
1279 AliShuttleDCSConfigHolder* dcsHolder = new AliShuttleDCSConfigHolder(dcsEntry);
1280 if (!dcsHolder->IsValid()) {
1281 AliError("DCS configuration error!");
1282 delete detHolder;
1283 delete dcsHolder;
1284 return 7;
1285 }
1286 detHolder->AddDCSConfig(dcsHolder);
1287 }
1288 }
1289
1290
1291 fDetectorMap.Add(detStr, detHolder);
1292 fDetectorList.AddLast(detStr);
b948db8d 1293 }
1d172743 1294
1295 return 0;
73abe331 1296}
1297
be48e3ea 1298//______________________________________________________________________________________________
1d172743 1299UInt_t AliShuttleConfig::SetHostConfig(TList* list)
be48e3ea 1300{
1d172743 1301 // Set the Shuttle machines configuration (which detectors processes each machine)
1302
1303 TLDAPEntry* anEntry = 0;
1304 TLDAPAttribute* anAttribute = 0;
1305
1306 fShuttleInstanceHost = gSystem->HostName();
1307
1308 TIter iter(list);
1309 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
be48e3ea 1310 {
1d172743 1311
1312 TString dn(anEntry->GetDn());
1313 if (!dn.Contains(Form("shuttleHost=%s", fShuttleInstanceHost.Data()))) continue;
1314
1315 if (!fProcessAll)
1316 {
1317 anAttribute = anEntry->GetAttribute("detectors");
1318 const char *detName;
1319 while((detName = anAttribute->GetValue())){
1320 TObjString *objDet= new TObjString(detName);
1321 fProcessedDetectors.Add(objDet);
1322 }
1323 }
1324 }
1325
1326 return 0;
be48e3ea 1327}
1328
1d172743 1329
a7160fe9 1330//______________________________________________________________________________________________
36c99a6a 1331void AliShuttleConfig::Print(Option_t* option) const
58bc3020 1332{
1333// print configuration
36c99a6a 1334// options : "": print configuration for all detectors, aliases and DPs in compacted format
1335// "uncompact": print configuration for all detectors, aliases and DPs in uncompacted format
1336// "DET": print configuration for DET, aliases and DPs in compacted format
1337// "DET, uncompact": print configuration for DET, aliases and DPs in uncompacted format
1338
73abe331 1339 TString result;
1340 result += '\n';
7d4cf768 1341
1342 TString mode = "test";
1343 if (fRunMode == kProd) mode = "production";
d477ad88 1344
7d4cf768 1345 result += "########################################################################\n";
1346 result += Form(" Shuttle configuration from %s - Run Mode: <%s> \n",
1347 fConfigHost.Data(), mode.Data());
1348 result += "########################################################################\n";
57c1a579 1349 result += Form("\nShuttle running on %s \n", fShuttleInstanceHost.Data());
57f50b3c 1350
1351 if(fProcessAll) {
57c1a579 1352 result += Form("All detectors will be processed! \n");
57f50b3c 1353 } else {
1354 result += "Detectors processed by this host: ";
1355 TIter it(&fProcessedDetectors);
1356 TObjString* aDet;
1357 while ((aDet = (TObjString*) it.Next())) {
1358 result += Form("%s ", aDet->String().Data());
1359 }
57c1a579 1360 result += "\n";
b948db8d 1361 }
b948db8d 1362
7d4cf768 1363 result += Form("PP time out = %d - max PP mem size = %d KB - max retries = %d "
fb40ead4 1364 "- DIM trigger waiting timeout = %d\n",
7d4cf768 1365 fPPTimeOut, fPPMaxMem, fMaxRetries, fTriggerWait);
fb40ead4 1366 result += Form("FLAGS: keepDCSMap = %d - keepTempFolder = %d - SendMail = %d \n",
1367 fKeepDCSMap, fKeepTempFolder, fSendMail);
1368 const TObjArray* shuttleAdmins = GetAdmins(kGlobal);
1369 if (shuttleAdmins->GetEntries() != 0)
1370 {
1371 result += "SHUTTLE administrator(s): ";
1372 TIter it(shuttleAdmins);
1373 TObjString* anAdmin;
1374 while ((anAdmin = (TObjString*) it.Next()))
1375 {
1376 result += Form("%s ", anAdmin->String().Data());
1377 }
1378 result += "\n";
1379 }
1380 const TObjArray* amandaAdmins = GetAdmins(kAmanda);
1381 if (amandaAdmins->GetEntries() != 0)
1382 {
1383 result += "Amanda server administrator(s): ";
1384 TIter it(amandaAdmins);
1385 TObjString* anAdmin;
1386 while ((anAdmin = (TObjString*) it.Next()))
1387 {
1388 result += Form("%s ", anAdmin->String().Data());
1389 }
1390 result += "\n\n";
1391 }
57c1a579 1392 result += "------------------------------------------------------\n";
2bb7b766 1393
57c1a579 1394 result += Form("Logbook Configuration \n\n \tHost: %s:%d; \tUser: %s; ",
fc5a4708 1395 fDAQlbHost.Data(), fDAQlbPort, fDAQlbUser.Data());
b948db8d 1396
2c15234c 1397// result += "Password: ";
1398// result.Append('*', fDAQlbPass.Length());
b832ec02 1399 result += Form("\tDB: %s; \tTables: %s, %s, %s\n",
441b0e9c 1400 fDAQlbDB.Data(), fDAQlbTable.Data(), fShuttlelbTable.Data(), fRunTypelbTable.Data());
2c15234c 1401
57f50b3c 1402 result += "\n\n";
fb40ead4 1403
57c1a579 1404 result += "------------------------------------------------------\n";
1405 result += "FXS configuration\n\n";
1406
57f50b3c 1407 for(int iSys=0;iSys<3;iSys++){
57c1a579 1408 result += Form("*** %s ***\n", AliShuttleInterface::GetSystemName(iSys));
fc5a4708 1409 result += Form("\tDB host: %s:%d; \tUser: %s; \tName: %s; \tTable: %s\n",
1410 fFXSdbHost[iSys].Data(), fFXSdbPort[iSys], fFXSdbUser[iSys].Data(),
2c15234c 1411 fFXSdbName[iSys].Data(), fFXSdbTable[iSys].Data());
1412 // result += Form("DB Password:",fFXSdbPass[iSys].Data());
fb40ead4 1413 result += Form("\tFXS host: %s:%d; \tUser: %s\n", fFXSHost[iSys].Data(), fFXSPort[iSys],
fc5a4708 1414 fFXSUser[iSys].Data());
2c15234c 1415 // result += Form("FXS Password:",fFXSPass[iSys].Data());
fb40ead4 1416 const TObjArray* fxsAdmins = GetAdmins(iSys);
1417 if (fxsAdmins->GetEntries() != 0)
1418 {
1419 result += "\tAdministrator(s): ";
1420 TIter it(fxsAdmins);
1421 TObjString* anAdmin;
1422 while ((anAdmin = (TObjString*) it.Next()))
1423 {
1424 result += Form("%s ", anAdmin->String().Data());
1425 }
1426 result += "\n\n";
1427 }
57f50b3c 1428 }
b948db8d 1429
b832ec02 1430 result += "------------------------------------------------------\n";
1431 result += "MonaLisa configuration\n\n";
1432
1433 result += Form("\tHost: %s; \tTable name: %s",
1434 fMonitorHost.Data(), fMonitorTable.Data());
1435
1436 result += "\n\n";
fb40ead4 1437
36c99a6a 1438 TString optStr(option);
1439
57c1a579 1440 result += "------------------------------------------------------\n";
1441 result += "Detector-specific configuration\n\n";
1d172743 1442
73abe331 1443 TIter iter(fDetectorMap.GetTable());
1d172743 1444 TPair* aPair = 0;
1445
73abe331 1446 while ((aPair = (TPair*) iter.Next())) {
1d172743 1447 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) aPair->Value();
1448 if (optStr != "" && !optStr.Contains(aHolder->GetDetector()) &&
1449 optStr.CompareTo("uncompact",TString::kIgnoreCase) != 0 )
36c99a6a 1450 continue;
1d172743 1451
57c1a579 1452 result += Form("*** %s *** \n", aHolder->GetDetector());
1453
1454 const TObjArray* responsibles = aHolder->GetResponsibles();
1455 if (responsibles->GetEntries() != 0)
1456 {
1457 result += "\tDetector responsible(s): ";
1458 TIter it(responsibles);
1459 TObjString* aResponsible;
1460 while ((aResponsible = (TObjString*) it.Next()))
1461 {
1462 result += Form("%s ", aResponsible->String().Data());
1463 }
1464 result += "\n";
1465 }
1466
1d172743 1467 result += Form("\tStrict run ordering: %s \n\n", aHolder->StrictRunOrder() ? "YES" : "NO");
1468
1469 const TObjArray* dcsConfig = aHolder->GetDCSConfig();
1470
1471 AliShuttleDCSConfigHolder* dcsHolder = 0;
1472 TIter dcsIter(dcsConfig);
1473 Int_t count=0;
1474 while ((dcsHolder = dynamic_cast<AliShuttleDCSConfigHolder*> (dcsIter.Next())))
be48e3ea 1475 {
542b6cc8 1476 result += Form("\tAmanda server [%d]: %s:%d - MultiSplit = %d\n", count,
1477 dcsHolder->GetDCSHost(), dcsHolder->GetDCSPort(), dcsHolder->GetMultiSplit());
57f50b3c 1478
1d172743 1479 const TObjArray* aliases = 0;
1480 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1481 {
1482 aliases = dcsHolder->GetDCSAliases();
1483 } else {
1484 aliases = dcsHolder->GetCompactDCSAliases();
1485 }
36c99a6a 1486
1d172743 1487 if (aliases->GetEntries() != 0)
2c15234c 1488 {
1d172743 1489 result += Form("\tDCS Aliases [%d]: ", count);
1490 TIter it(aliases);
1491 TObjString* anAlias;
1492 while ((anAlias = (TObjString*) it.Next()))
1493 {
1494 result += Form("%s ", anAlias->String().Data());
1495 }
1496 result += "\n";
2c15234c 1497 }
57f50b3c 1498
1d172743 1499 const TObjArray* dataPoints = 0;
1500 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1501 {
1502 dataPoints = dcsHolder->GetDCSDataPoints();
1503 } else {
1504 dataPoints = dcsHolder->GetCompactDCSDataPoints();
2c15234c 1505 }
1d172743 1506 if (dataPoints->GetEntries() != 0)
1507 {
1508 result += Form("\tDCS Data Points [%d]: ", count);
1509 TIter it(dataPoints);
1510 TObjString* aDataPoint;
1511 while ((aDataPoint = (TObjString*) it.Next())) {
1512 result += Form("%s ", aDataPoint->String().Data());
1513 }
2c15234c 1514 result += "\n";
1d172743 1515 }
1516 count++;
1517 result += "\n";
2c15234c 1518 }
73abe331 1519 }
57f50b3c 1520 if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n";
1521
73abe331 1522 AliInfo(result);
1523}