]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/AliShuttleConfig.cxx
Taking into account the time information of the hit in the digitization
[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
6ea86315 178#include <Riostream.h>
73abe331 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>
a18e8fa6 189#include <TKey.h>
73abe331 190
57f50b3c 191
1d172743 192AliShuttleConfig::AliShuttleDCSConfigHolder::AliShuttleDCSConfigHolder(const TLDAPEntry* entry):
57f50b3c 193fDCSHost(""),
194fDCSPort(0),
542b6cc8 195fMultiSplit(100),
fc5a4708 196fDCSAliases(0),
197fDCSDataPoints(0),
36c99a6a 198fDCSAliasesComp(0),
199fDCSDataPointsComp(0),
1d172743 200fIsValid(kFALSE)
73abe331 201{
1d172743 202// constructor of the shuttle DCS configuration holder
58bc3020 203
73abe331 204 TLDAPAttribute* anAttribute;
2bb7b766 205 fDCSAliases = new TObjArray();
206 fDCSAliases->SetOwner(1);
2c15234c 207 fDCSDataPoints = new TObjArray();
208 fDCSDataPoints->SetOwner(1);
36c99a6a 209 fDCSAliasesComp = new TObjArray();
210 fDCSAliasesComp->SetOwner(1);
211 fDCSDataPointsComp = new TObjArray();
212 fDCSDataPointsComp->SetOwner(1);
73abe331 213
86aa42c3 214
1d172743 215 anAttribute = entry->GetAttribute("dcsHost");
2c15234c 216 if (!anAttribute)
217 {
1d172743 218 AliError("Unexpected: no DCS host!");
73abe331 219 return;
220 }
57f50b3c 221
b948db8d 222 fDCSHost = anAttribute->GetValue();
73abe331 223
1d172743 224 anAttribute = entry->GetAttribute("dcsPort");
2c15234c 225 if (!anAttribute)
226 {
1d172743 227 AliError("Unexpected: no DCS port!");
73abe331 228 return;
229 }
230 TString portStr = anAttribute->GetValue();
b948db8d 231 fDCSPort = portStr.Atoi();
73abe331 232
542b6cc8 233 anAttribute = entry->GetAttribute("multiSplit"); // MAY
234 if (anAttribute)
235 {
236 TString multiSplitStr = anAttribute->GetValue();
237 fMultiSplit = multiSplitStr.Atoi();
238 if(fMultiSplit == 0) {
239 AliError("MultiSplit must be a positive integer!");
240 return;
241 }
242
243 }
244
1d172743 245 anAttribute = entry->GetAttribute("dcsAlias"); // MAY
2c15234c 246 if (anAttribute)
247 {
248 const char* anAlias;
249 while ((anAlias = anAttribute->GetValue()))
250 {
36c99a6a 251 fDCSAliasesComp->AddLast(new TObjString(anAlias));
40150741 252 ExpandAndAdd(fDCSAliases, anAlias);
2c15234c 253 }
73abe331 254 }
57f50b3c 255
1d172743 256 anAttribute = entry->GetAttribute("dcsDP"); // MAY
2c15234c 257 if (anAttribute)
258 {
259 const char* aDataPoint;
260 while ((aDataPoint = anAttribute->GetValue()))
261 {
36c99a6a 262 fDCSDataPointsComp->AddLast(new TObjString(aDataPoint));
263 ExpandAndAdd(fDCSDataPoints, aDataPoint);
2c15234c 264 }
b948db8d 265 }
fb40ead4 266
73abe331 267 fIsValid = kTRUE;
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),
28a94b8e 530 fAlienPath(""),
1d172743 531 fDAQlbHost(""),
532 fDAQlbPort(),
533 fDAQlbUser(""),
534 fDAQlbPass(""),
535 fDAQlbDB(""),
536 fDAQlbTable(""),
537 fShuttlelbTable(""),
538 fRunTypelbTable(""),
6ea86315 539 fPasswdFilePath(""),
1d172743 540 fMaxRetries(0),
541 fPPTimeOut(0),
ff3781ad 542 fDCSTimeOut(0),
a18e8fa6 543 fDCSRetries(0),
2eb98462 544 fDCSQueryOffset(0),
545 fDCSDelay(0),
1d172743 546 fPPMaxMem(0),
b832ec02 547 fMonitorHost(""),
548 fMonitorTable(""),
7d4cf768 549 fTriggerWait(3600),
fb2975a2 550 fShuttleFileSystem("/"),
551 fFreeDiskWarningThreshold(20),
552 fFreeDiskFatalThreshold(10),
7d4cf768 553 fRunMode(kTest),
1d172743 554 fDetectorMap(),
555 fDetectorList(),
fb40ead4 556 fAdmin(),
1d172743 557 fShuttleInstanceHost(""),
558 fProcessedDetectors(),
fb40ead4 559 fKeepDCSMap(kFALSE),
560 fKeepTempFolder(kFALSE),
561 fSendMail(kFALSE),
1d172743 562 fProcessAll(kFALSE),
563 fIsValid(kFALSE)
fb40ead4 564
73abe331 565{
566 //
567 // host: ldap server host
568 // port: ldap server port
569 // binddn: binddn used for ldap binding (simple bind is used!).
570 // password: password for binddn
b948db8d 571 // basedn: this is basedn whose childeren entries which have
73abe331 572 //
573
1d172743 574 fDetectorMap.SetOwner(1);
2bb7b766 575 fDetectorList.SetOwner(0); //fDetectorList and fDetectorMap share the same object!
576 fProcessedDetectors.SetOwner();
fb40ead4 577
578 for (int i=0; i<5; i++)
579 {
580 fAdmin[i] = new TObjArray();
581 fAdmin[i]->SetOwner();
582 }
2bb7b766 583
b948db8d 584 TLDAPServer aServer(host, port, binddn, password, 3);
57f50b3c 585
73abe331 586 if (!aServer.IsConnected()) {
2bb7b766 587 AliError(Form("Can't connect to ldap server %s:%d",
73abe331 588 host, port));
589 return;
590 }
591
b948db8d 592 // reads configuration for the shuttle running on this machine
1d172743 593
594 TLDAPResult* aResult = 0;
595 TLDAPEntry* anEntry = 0;
596
597 TList dcsList;
598 dcsList.SetOwner(1);
599 TList detList;
600 detList.SetOwner(1);
601 TList globalList;
602 globalList.SetOwner(1);
603 TList sysList;
604 sysList.SetOwner(1);
605 TList hostList;
606 hostList.SetOwner(1);
607
608 aResult = aServer.Search(basedn, LDAP_SCOPE_SUBTREE, 0, 0);
609
610 if (!aResult)
611 {
612 AliError(Form("Can't find configuration with base DN: %s !", basedn));
73abe331 613 return;
614 }
1d172743 615
616 while ((anEntry = aResult->GetNext()))
617 {
618 TString dn = anEntry->GetDn();
619
620 if (dn.BeginsWith("dcsHost="))
621 {
622 dcsList.Add(anEntry);
623 }
624 else if (dn.BeginsWith("det="))
625 {
626 detList.Add(anEntry);
627 }
628 else if (dn.BeginsWith("name=globalConfig"))
629 {
630 globalList.Add(anEntry);
631 }
632 else if (dn.BeginsWith("system="))
633 {
634 sysList.Add(anEntry);
635 }
636 else if (dn.BeginsWith("shuttleHost="))
637 {
638 hostList.Add(anEntry);
639 }
640 else
641 {
642 delete anEntry;
643 }
644
b948db8d 645 }
1d172743 646 delete aResult;
647
648 Int_t result=0;
649
650 result += SetGlobalConfig(&globalList);
651 result += SetSysConfig(&sysList);
6ea86315 652 result += SetPasswords();
1d172743 653 result += SetDetConfig(&detList,&dcsList);
654 result += SetHostConfig(&hostList);
655
656 if(result)
657 {
658 AliError("Configuration is INVALID!");
b948db8d 659 }
1d172743 660 else
661 {
662 fIsValid = kTRUE;
b948db8d 663 }
1d172743 664}
b948db8d 665
1d172743 666//______________________________________________________________________________________________
667AliShuttleConfig::~AliShuttleConfig()
668{
669// destructor
57f50b3c 670
1d172743 671 fDetectorMap.DeleteAll();
672 fDetectorList.Clear();
673 fProcessedDetectors.Delete();
674}
b948db8d 675
1d172743 676//______________________________________________________________________________________________
677const TObjArray* AliShuttleConfig::GetDetectors() const
678{
679 //
680 // returns collection of TObjString which contains the name
681 // of every detector which is in the configuration.
682 //
57f50b3c 683
1d172743 684 return &fDetectorList;
685}
73abe331 686
1d172743 687//______________________________________________________________________________________________
688Bool_t AliShuttleConfig::HasDetector(const char* detector) const
689{
690 //
691 // checks for paricular detector in the configuration.
692 //
693 return fDetectorMap.GetValue(detector) != NULL;
694}
73abe331 695
1d172743 696//______________________________________________________________________________________________
697Int_t AliShuttleConfig::GetNServers(const char* detector) const
698{
699 //
700 // returns number of DCS servers for detector
701 //
702
703 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
704 if (!aHolder) {
705 AliError(Form("There isn't configuration for detector: %s",
706 detector));
707 return 0;
57f50b3c 708 }
709
1d172743 710 return aHolder->GetNServers();
711}
d477ad88 712
d477ad88 713
1d172743 714//______________________________________________________________________________________________
715const char* AliShuttleConfig::GetDCSHost(const char* detector, Int_t iServ) const
716{
717 //
718 // returns i-th DCS server host used by particular detector
719 //
720
721 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
722 if (!aHolder) {
723 AliError(Form("There isn't configuration for detector: %s",
724 detector));
725 return NULL;
d477ad88 726 }
727
1d172743 728 return aHolder->GetDCSHost(iServ);
729}
730
731//______________________________________________________________________________________________
732Int_t AliShuttleConfig::GetDCSPort(const char* detector, Int_t iServ) const
733{
734 //
735 // returns i-th DCS server port used by particular detector
736 //
737
738
739 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
740 if (!aHolder) {
741 AliError(Form("There isn't configuration for detector: %s",
742 detector));
743 return 0;
744 }
745
746 return aHolder->GetDCSPort(iServ);
747}
748
542b6cc8 749//______________________________________________________________________________________________
750Int_t AliShuttleConfig::GetMultiSplit(const char* detector, Int_t iServ) const
751{
752 //
753 // returns i-th DCS "multi split" value
754 //
755
756
757 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
758 if (!aHolder) {
759 AliError(Form("There isn't configuration for detector: %s",
760 detector));
761 return 0;
762 }
763
764 return aHolder->GetMultiSplit(iServ);
765}
766
1d172743 767//______________________________________________________________________________________________
768const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector, Int_t iServ) const
769{
770 //
771 // returns collection of TObjString which represents the i-th set of aliases
772 // which used for data retrieval for particular detector
773 //
774
775 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
776 if (!aHolder) {
777 AliError(Form("There isn't configuration for detector: %s",
778 detector));
779 return NULL;
780 }
781
782 return aHolder->GetDCSAliases(iServ);
783}
784
785//______________________________________________________________________________________________
786const TObjArray* AliShuttleConfig::GetDCSDataPoints(const char* detector, Int_t iServ) const
787{
788 //
789 // returns collection of TObjString which represents the set of aliases
790 // which used for data retrieval for particular detector
791 //
792
793 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
794 if (!aHolder) {
795 AliError(Form("There isn't configuration for detector: %s",
796 detector));
797 return NULL;
798 }
799
800 return aHolder->GetDCSDataPoints(iServ);
801}
802
803//______________________________________________________________________________________________
804const TObjArray* AliShuttleConfig::GetCompactDCSAliases(const char* detector, Int_t iServ) const
805{
806 //
807 // returns collection of TObjString which represents the i-th set of aliases
808 // which used for data retrieval for particular detector (Compact style)
809 //
810
811 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
812 if (!aHolder) {
813 AliError(Form("There isn't configuration for detector: %s",
814 detector));
815 return NULL;
816 }
817
818 return aHolder->GetCompactDCSAliases(iServ);
819}
820
821//______________________________________________________________________________________________
822const TObjArray* AliShuttleConfig::GetCompactDCSDataPoints(const char* detector, Int_t iServ) const
823{
824 //
825 // returns collection of TObjString which represents the set of aliases
826 // which used for data retrieval for particular detector (Compact style)
827 //
828
829 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
830 if (!aHolder) {
831 AliError(Form("There isn't configuration for detector: %s",
832 detector));
833 return NULL;
834 }
835
836 return aHolder->GetCompactDCSDataPoints(iServ);
837}
838
839//______________________________________________________________________________________________
840const TObjArray* AliShuttleConfig::GetResponsibles(const char* detector) const
841{
842 //
843 // returns collection of TObjString which represents the list of mail addresses
844 // of the detector's responsible(s)
845 //
846
847 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
848 if (!aHolder) {
849 AliError(Form("There isn't configuration for detector: %s",
850 detector));
851 return NULL;
852 }
853
854 return aHolder->GetResponsibles();
855}
856
fb40ead4 857//______________________________________________________________________________________________
858const TObjArray* AliShuttleConfig::GetAdmins(Int_t sys) const
859{
860 //
861 // returns collection of TObjString which represents the list of mail addresses
862 // of the system's administrator(s) (DAQ, DCS, HLT, Global, Amanda)
863 //
864
865 if (sys < 0 || sys > 4) return 0;
866 return fAdmin[sys];
867}
868
1d172743 869//______________________________________________________________________________________________
870Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
871{
872 // return TRUE if detector is handled by host or if fProcessAll is TRUE
873
874 if(fProcessAll) return kTRUE;
875 TIter iter(&fProcessedDetectors);
876 TObjString* detName;
877 while((detName = (TObjString*) iter.Next())){
878 if(detName->String() == detector) return kTRUE;
d477ad88 879 }
1d172743 880 return kFALSE;
881}
882
883//______________________________________________________________________________________________
884Bool_t AliShuttleConfig::StrictRunOrder(const char* detector) const
885{
886 // return TRUE if detector wants strict run ordering of stored data
887
888 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
889 if (!aHolder)
890 {
891 AliError(Form("There isn't configuration for detector: %s",
892 detector));
893 return kTRUE;
894 }
d477ad88 895
1d172743 896 return aHolder->StrictRunOrder();
897}
57f50b3c 898
1d172743 899//______________________________________________________________________________________________
900UInt_t AliShuttleConfig::SetGlobalConfig(TList* list)
901{
902 // Set the global configuration (DAQ Logbook + preprocessor monitoring settings)
903
6ea86315 904
1d172743 905 TLDAPEntry* anEntry = 0;
906 TLDAPAttribute* anAttribute = 0;
907
908 if (list->GetEntries() == 0)
909 {
910 AliError("Global configuration not found!");
911 return 1;
912 }
913 else if (list->GetEntries() > 1)
914 {
915 AliError("More than one global configuration found!");
916 return 2;
917 }
918
919 anEntry = dynamic_cast<TLDAPEntry*> (list->At(0));
920
921 if (!anEntry)
922 {
923 AliError("Unexpected! Global list does not contain a TLDAPEntry");
924 return 3;
925 }
926
927
b8cf5e0f 928 anAttribute = anEntry->GetAttribute("AlienPath");
929 if (!anAttribute) {
930 AliError("Can't find AlienPath attribute!");
931 return 4;
932 }
933 fAlienPath = anAttribute->GetValue();
934
1d172743 935 anAttribute = anEntry->GetAttribute("daqLbHost");
d477ad88 936 if (!anAttribute) {
1d172743 937 AliError("Can't find daqLbHost attribute!");
938 return 4;
d477ad88 939 }
57f50b3c 940 fDAQlbHost = anAttribute->GetValue();
d477ad88 941
1d172743 942 anAttribute = anEntry->GetAttribute("daqLbPort"); // MAY
fc5a4708 943 if (anAttribute)
944 {
945 fDAQlbPort = ((TString) anAttribute->GetValue()).Atoi();
946 } else {
947 fDAQlbPort = 3306; // mysql
948 }
949
1d172743 950 anAttribute = anEntry->GetAttribute("daqLbUser");
d477ad88 951 if (!anAttribute) {
1d172743 952 AliError("Can't find daqLbUser attribute!");
953 return 4;
d477ad88 954 }
57f50b3c 955 fDAQlbUser = anAttribute->GetValue();
956
1d172743 957 anAttribute = anEntry->GetAttribute("daqLbDB");
2c15234c 958 if (!anAttribute) {
1d172743 959 AliError("Can't find daqLbDB attribute!");
960 return 4;
2c15234c 961 }
962 fDAQlbDB = anAttribute->GetValue();
963
1d172743 964 anAttribute = anEntry->GetAttribute("daqLbTable");
2c15234c 965 if (!anAttribute) {
1d172743 966 AliError("Can't find daqLbTable attribute!");
967 return 4;
2c15234c 968 }
969 fDAQlbTable = anAttribute->GetValue();
970
1d172743 971 anAttribute = anEntry->GetAttribute("shuttleLbTable");
441b0e9c 972 if (!anAttribute) {
1d172743 973 AliError("Can't find shuttleLbTable attribute!");
974 return 4;
441b0e9c 975 }
976 fShuttlelbTable = anAttribute->GetValue();
977
1d172743 978 anAttribute = anEntry->GetAttribute("runTypeLbTable");
441b0e9c 979 if (!anAttribute) {
1d172743 980 AliError("Can't find runTypeLbTable attribute!");
981 return 4;
441b0e9c 982 }
983 fRunTypelbTable = anAttribute->GetValue();
2c15234c 984
1d172743 985 anAttribute = anEntry->GetAttribute("ppmaxRetries");
5164a766 986 if (!anAttribute) {
1d172743 987 AliError("Can't find ppmaxRetries attribute!");
988 return 4;
5164a766 989 }
990 TString tmpStr = anAttribute->GetValue();
cb343cfd 991 fMaxRetries = tmpStr.Atoi();
5164a766 992
1d172743 993 anAttribute = anEntry->GetAttribute("ppTimeOut");
5164a766 994 if (!anAttribute) {
1d172743 995 AliError("Can't find ppTimeOut attribute!");
996 return 4;
5164a766 997 }
998 tmpStr = anAttribute->GetValue();
cb343cfd 999 fPPTimeOut = tmpStr.Atoi();
5164a766 1000
ff3781ad 1001 anAttribute = anEntry->GetAttribute("dcsTimeOut");
1002 if (!anAttribute) {
1003 AliError("Can't find dcsTimeOut attribute!");
1004 return 4;
1005 }
1006 tmpStr = anAttribute->GetValue();
1007 fDCSTimeOut = tmpStr.Atoi();
1008
1009 anAttribute = anEntry->GetAttribute("nDCSretries");
1010 if (!anAttribute) {
1011 AliError("Can't find dcsTimeOut attribute!");
1012 return 4;
1013 }
1014 tmpStr = anAttribute->GetValue();
1015 fDCSRetries = tmpStr.Atoi();
1016
2eb98462 1017 anAttribute = anEntry->GetAttribute("DCSQueryOffset");
1018 if (!anAttribute) {
1019 AliError("Can't find DCSQueryOffset attribute!");
1020 return 4;
1021 }
1022 tmpStr = anAttribute->GetValue();
1023 fDCSQueryOffset = tmpStr.Atoi();
1024
1025 anAttribute = anEntry->GetAttribute("DCSDelay");
1026 if (!anAttribute) {
1027 AliError("Can't find DCSDelay attribute!");
1028 return 4;
1029 }
1030 tmpStr = anAttribute->GetValue();
1031 fDCSDelay = tmpStr.Atoi();
1032
1d172743 1033 anAttribute = anEntry->GetAttribute("ppMaxMem");
9827400b 1034 if (!anAttribute) {
1d172743 1035 AliError("Can't find ppMaxMem attribute!");
1036 return 4;
9827400b 1037 }
1038 tmpStr = anAttribute->GetValue();
1039 fPPMaxMem = tmpStr.Atoi();
1040
b832ec02 1041 anAttribute = anEntry->GetAttribute("monitorHost");
1042 if (!anAttribute) {
1043 AliError("Can't find monitorHost attribute!");
1044 return 4;
1045 }
1046 fMonitorHost = anAttribute->GetValue();
1047
1048 anAttribute = anEntry->GetAttribute("monitorTable");
1049 if (!anAttribute) {
1050 AliError("Can't find monitorTable attribute!");
1051 return 4;
1052 }
1053 fMonitorTable = anAttribute->GetValue();
7d4cf768 1054
1055 anAttribute = anEntry->GetAttribute("triggerWait"); // MAY
1056 if (!anAttribute) {
fb2975a2 1057 AliWarning(Form("triggerWait not set! default = %d", fTriggerWait));
7d4cf768 1058 }
1059 tmpStr = anAttribute->GetValue();
1060 fTriggerWait = tmpStr.Atoi();
fb2975a2 1061
1062 anAttribute = anEntry->GetAttribute("ShuttleFileSystem");
1063 if (!anAttribute) {
1064 AliWarning(Form("ShuttleFileSystem not set! default = %s", fShuttleFileSystem.Data()));
1065 }
1066 fShuttleFileSystem = anAttribute->GetValue();
1067
1068 anAttribute = anEntry->GetAttribute("FreeDiskWarningThreshold"); // MAY
1069 if (!anAttribute) {
1070 AliWarning(Form("FreeDiskWarningThreshold not set! default = %d", fFreeDiskWarningThreshold));
1071 }
1072 tmpStr = anAttribute->GetValue();
1073 fFreeDiskWarningThreshold = tmpStr.Atoi();
1074
1075 anAttribute = anEntry->GetAttribute("FreeDiskFatalThreshold"); // MAY
1076 if (!anAttribute) {
1077 AliWarning(Form("FreeDiskFatalThreshold not set! default = %d", fFreeDiskFatalThreshold));
1078 }
1079 tmpStr = anAttribute->GetValue();
1080 fFreeDiskFatalThreshold = tmpStr.Atoi();
1081
7d4cf768 1082 anAttribute = anEntry->GetAttribute("mode");
1083 if (!anAttribute) {
1084 AliWarning("Run mode not set! Running in test mode.");
7d4cf768 1085 } else {
4508ab8b 1086 tmpStr = anAttribute->GetValue();
1087 if (tmpStr == "test")
1088 {
1089 fRunMode = kTest;
1090 } else if (tmpStr == "prod") {
1091 fRunMode = kProd;
1092 } else {
1093 AliWarning(Form("Not a valid run mode: %s", tmpStr.Data()));
1094 AliWarning("Valid run modes are \"test\" and \"prod\". Running in test mode.");
1095 }
7d4cf768 1096 }
fb40ead4 1097
1098 anAttribute = anEntry->GetAttribute("keepDCSMap"); // MAY
1099 if (!anAttribute)
1100 {
1101 AliWarning("keepDCSMap flag not set - default is FALSE");
1102 } else {
1103 TString keepDCSMapStr = anAttribute->GetValue();
1104 if (!(keepDCSMapStr == "0" || keepDCSMapStr == "1"))
1105 {
1106 AliError("keepDCSMap flag must be 0 or 1!");
1107 return 4;
1108 }
1109 fKeepDCSMap = (Bool_t) keepDCSMapStr.Atoi();
1110 }
1111
1112 anAttribute = anEntry->GetAttribute("keepTempFolder"); // MAY
1113 if (!anAttribute)
1114 {
1115 AliWarning("keepTempFolder flag not set - default is FALSE");
1116 } else {
1117 TString keepTempFolderStr = anAttribute->GetValue();
1118 if (!(keepTempFolderStr == "0" || keepTempFolderStr == "1"))
1119 {
1120 AliError("keepTempFolder flag must be 0 or 1!");
1121 return 4;
1122 }
1123 fKeepTempFolder = (Bool_t) keepTempFolderStr.Atoi();
1124 }
1125
1126
1127 anAttribute = anEntry->GetAttribute("shuttleAdmin"); // MAY
1128 if (!anAttribute)
1129 {
1130 AliDebug(2, "Warning! No \"shuttleAdmin\" attribute!");
1131 }
1132 else
1133 {
1134 const char* anAdmin;
1135 while ((anAdmin = anAttribute->GetValue()))
1136 {
1137 fAdmin[kGlobal]->AddLast(new TObjString(anAdmin));
1138 }
1139 }
1140
1141 anAttribute = anEntry->GetAttribute("amandaAdmin"); // MAY
1142 if (!anAttribute)
1143 {
1144 AliDebug(2, "Warning! No \"amandaAdmin\" attribute!");
1145 }
1146 else
1147 {
1148 const char* anAdmin;
1149 while ((anAdmin = anAttribute->GetValue()))
1150 {
1151 fAdmin[kAmanda]->AddLast(new TObjString(anAdmin));
1152 }
1153 }
1154
1155 anAttribute = anEntry->GetAttribute("sendMail"); // MAY
1156 if (!anAttribute)
1157 {
1158 AliWarning("sendMail flag not set - default is FALSE");
1159 } else {
1160 TString sendMailStr = anAttribute->GetValue();
1161 if (!(sendMailStr == "0" || sendMailStr == "1"))
1162 {
1163 AliError("sendMail flag must be 0 or 1!");
1164 return 4;
1165 }
1166 fSendMail = (Bool_t) sendMailStr.Atoi();
1167 }
1168
6ea86315 1169 anAttribute = anEntry->GetAttribute("passwdFilePath");
1170 if (!anAttribute) {
1171 AliError("Can't find Passwords File Path attribute!");
1172 return 4;
1173 }
1174 fPasswdFilePath = anAttribute->GetValue();
1175
1d172743 1176 return 0;
1d172743 1177}
57f50b3c 1178
1d172743 1179//______________________________________________________________________________________________
1180UInt_t AliShuttleConfig::SetSysConfig(TList* list)
1181{
1182 // Set the online FXS configuration (DAQ + DCS + HLT)
6ea86315 1183
1184
1d172743 1185 TLDAPEntry* anEntry = 0;
1186 TLDAPAttribute* anAttribute = 0;
1187
1188 if (list->GetEntries() != 3)
1189 {
1190 AliError(Form("Wrong number of online systems found: %d !", list->GetEntries()));
1191 return 1;
1192 }
57f50b3c 1193
1d172743 1194 TIter iter(list);
fb40ead4 1195 Int_t count = 0;
1196 SystemCode iSys=kDAQ;
1197
1d172743 1198 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1199 {
1200 anAttribute = anEntry->GetAttribute("system");
1201 TString sysName = anAttribute->GetValue();
1202
1203 if (sysName == "DAQ")
1204 {
fb40ead4 1205 iSys = kDAQ;
1d172743 1206 count += 1;
57f50b3c 1207 }
1d172743 1208 else if (sysName == "DCS")
1209 {
fb40ead4 1210 iSys = kDCS;
1d172743 1211 count += 10;
57f50b3c 1212 }
1d172743 1213 else if (sysName == "HLT")
1214 {
fb40ead4 1215 iSys = kHLT;
1d172743 1216 count += 100;
1217 }
1218
1219 anAttribute = anEntry->GetAttribute("dbHost");
57f50b3c 1220 if (!anAttribute) {
1d172743 1221 AliError(Form ("Can't find dbHost attribute for %s!!",
eba76848 1222 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1223 return 5;
57f50b3c 1224 }
2c15234c 1225 fFXSdbHost[iSys] = anAttribute->GetValue();
57f50b3c 1226
1d172743 1227 anAttribute = anEntry->GetAttribute("dbPort"); // MAY
fc5a4708 1228 if (anAttribute)
1229 {
1230 fFXSdbPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1231 } else {
1232 fFXSdbPort[iSys] = 3306; // mysql
1233 }
1234
1d172743 1235 anAttribute = anEntry->GetAttribute("dbUser");
57f50b3c 1236 if (!anAttribute) {
1d172743 1237 AliError(Form ("Can't find dbUser attribute for %s!!",
eba76848 1238 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1239 return 5;
57f50b3c 1240 }
2c15234c 1241 fFXSdbUser[iSys] = anAttribute->GetValue();
57f50b3c 1242
1d172743 1243 anAttribute = anEntry->GetAttribute("dbName");
2c15234c 1244 if (!anAttribute) {
1d172743 1245 AliError(Form ("Can't find dbName attribute for %s!!",
2c15234c 1246 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1247 return 5;
2c15234c 1248 }
1249
1250 fFXSdbName[iSys] = anAttribute->GetValue();
1d172743 1251 anAttribute = anEntry->GetAttribute("dbTable");
2c15234c 1252 if (!anAttribute) {
1d172743 1253 AliError(Form ("Can't find dbTable attribute for %s!!",
2c15234c 1254 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1255 return 5;
2c15234c 1256 }
1257 fFXSdbTable[iSys] = anAttribute->GetValue();
57f50b3c 1258
1d172743 1259 anAttribute = anEntry->GetAttribute("fxsHost");
57f50b3c 1260 if (!anAttribute) {
1d172743 1261 AliError(Form ("Can't find fxsHost attribute for %s!!",
eba76848 1262 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1263 return 5;
57f50b3c 1264 }
2c15234c 1265 fFXSHost[iSys] = anAttribute->GetValue();
57f50b3c 1266
1d172743 1267 anAttribute = anEntry->GetAttribute("fxsPort"); // MAY
fc5a4708 1268 if (anAttribute)
1269 {
1270 fFXSPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1271 } else {
1272 fFXSPort[iSys] = 22; // scp port number
1273 }
1274
1d172743 1275 anAttribute = anEntry->GetAttribute("fxsUser");
57f50b3c 1276 if (!anAttribute) {
1d172743 1277 AliError(Form ("Can't find fxsUser attribute for %s!!",
eba76848 1278 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1279 return 5;
57f50b3c 1280 }
2c15234c 1281 fFXSUser[iSys] = anAttribute->GetValue();
57f50b3c 1282
1d172743 1283 anAttribute = anEntry->GetAttribute("fxsPasswd");
2c15234c 1284 if (anAttribute) fFXSPass[iSys] = anAttribute->GetValue();
339adafa 1285
1286 anAttribute = anEntry->GetAttribute("fxsBaseFolder");
1287 if (anAttribute) fFXSBaseFolder[iSys] = anAttribute->GetValue();
fb40ead4 1288
1289 anAttribute = anEntry->GetAttribute("fxsAdmin"); // MAY
1290 if (!anAttribute)
1291 {
1292 AliDebug(2, "Warning! No \"fxsAdmin\" attribute!");
1293 }
1294 else
1295 {
1296 const char* anAdmin;
1297 while ((anAdmin = anAttribute->GetValue()))
1298 {
1299 fAdmin[iSys]->AddLast(new TObjString(anAdmin));
1300 }
1301 }
1302
57f50b3c 1303 }
73abe331 1304
1d172743 1305 if(count != 111) {
1306 AliError(Form("Wrong system configuration! (code = %d)", count));
1307 return 6;
73abe331 1308 }
1d172743 1309
1310 return 0;
2c15234c 1311}
1312
6ea86315 1313//______________________________________________________________________________________________
1314UInt_t AliShuttleConfig::SetPasswords(){
1315
1316 AliInfo("Setting Passwords");
1317
1318 // Retrieving Passwords for DAQ lb, DAQ/DCS/HLT FXS
1319
1320 ifstream *inputfile = new ifstream(fPasswdFilePath.Data());
1321 if (!*inputfile) {
1322 AliError(Form("Error opening file %s !", fPasswdFilePath.Data()));
1323 inputfile->close();
1324 delete inputfile;
1325 return 1;
1326 }
1327
1328 TString line;
1329 Int_t nPwd=0;
1330 Int_t nPwdFake=0;
1331 while (line.ReadLine(*inputfile)) {
1332 TObjArray *tokens = line.Tokenize(" \t");
1333 TString system = ((TObjString *)tokens->At(0))->String();
1334 TString password = ((TObjString *)tokens->At(1))->String();
1335 if (system.Contains("DAQ_LB")){
1336 fDAQlbPass=password;
1337 nPwd++;
1338 AliDebug(3,Form("DAQ_LB: Password %s for %s found", password.Data(), system.Data()));
1339 }
1340 else if (system.Contains("DAQ_DB")){
1341 fFXSdbPass[0]=password;
1342 nPwd++;
1343 AliDebug(3,Form("DAQ_DB: Password %s for %s found", password.Data(), system.Data()));
1344 }
1345 else if (system.Contains("DCS_DB")){
1346 fFXSdbPass[1]=password;
1347 nPwd++;
1348 AliDebug(3,Form("DCS_DB: Password %s for %s found", password.Data(), system.Data()));
1349 }
1350 else if (system.Contains("HLT_DB")){
1351 fFXSdbPass[2]=password;
1352 nPwd++;
1353 AliDebug(3,Form("HLT_DB: Password %s for %s found", password.Data(), system.Data()));
1354 }
1355 else {
1356 nPwdFake++;
1357 AliDebug(3,Form("%i fake line(s) found in file %s", nPwdFake, fPasswdFilePath.Data()));
1358 continue;
1359 }
1360 delete tokens;
1361 }
1362
1363 inputfile->close();
1364 delete inputfile;
1365
1366 if (nPwd!=4){
1367 AliError(Form("Wrong file for DAQ Logbook password found %s (some passwors missing), please Check!", fPasswdFilePath.Data()));
1368 return 2;
1369 }
1370
1371 return 0;
1372
1373}
57c1a579 1374//______________________________________________________________________________________________
1d172743 1375UInt_t AliShuttleConfig::SetDetConfig(TList* detList, TList* dcsList)
57c1a579 1376{
1d172743 1377 // Set the detector configuration (general settings + DCS amanda server and alias/DP lists)
57c1a579 1378
1d172743 1379 TLDAPEntry* anEntry = 0;
1380
1381 TIter iter(detList);
1382 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1383 {
1384
1385 AliShuttleDetConfigHolder* detHolder = new AliShuttleDetConfigHolder(anEntry);
57c1a579 1386
1d172743 1387 if (!detHolder->IsValid()) {
1388 AliError("Detector configuration error!");
1389 delete detHolder;
1390 return 7;
1391 }
b948db8d 1392
1d172743 1393 TObjString* detStr = new TObjString(detHolder->GetDetector());
1394
1395 // Look for DCS Configuration
1396 TIter dcsIter(dcsList);
1397 TLDAPEntry *dcsEntry = 0;
1398 while ((dcsEntry = dynamic_cast<TLDAPEntry*> (dcsIter.Next())))
1399 {
1400 TString dn = dcsEntry->GetDn();
1401 if(dn.Contains(detStr->GetName())) {
1402 AliDebug(2, Form("Found DCS configuration: dn = %s",dn.Data()));
1403 AliShuttleDCSConfigHolder* dcsHolder = new AliShuttleDCSConfigHolder(dcsEntry);
1404 if (!dcsHolder->IsValid()) {
1405 AliError("DCS configuration error!");
1406 delete detHolder;
1407 delete dcsHolder;
1408 return 7;
1409 }
1410 detHolder->AddDCSConfig(dcsHolder);
1411 }
1412 }
1413
1414
1415 fDetectorMap.Add(detStr, detHolder);
1416 fDetectorList.AddLast(detStr);
b948db8d 1417 }
1d172743 1418
1419 return 0;
73abe331 1420}
1421
be48e3ea 1422//______________________________________________________________________________________________
1d172743 1423UInt_t AliShuttleConfig::SetHostConfig(TList* list)
be48e3ea 1424{
1d172743 1425 // Set the Shuttle machines configuration (which detectors processes each machine)
1426
1427 TLDAPEntry* anEntry = 0;
1428 TLDAPAttribute* anAttribute = 0;
1429
1430 fShuttleInstanceHost = gSystem->HostName();
1431
1432 TIter iter(list);
1433 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
be48e3ea 1434 {
1d172743 1435
1436 TString dn(anEntry->GetDn());
1437 if (!dn.Contains(Form("shuttleHost=%s", fShuttleInstanceHost.Data()))) continue;
1438
1439 if (!fProcessAll)
1440 {
1441 anAttribute = anEntry->GetAttribute("detectors");
1442 const char *detName;
1443 while((detName = anAttribute->GetValue())){
1444 TObjString *objDet= new TObjString(detName);
1445 fProcessedDetectors.Add(objDet);
1446 }
1447 }
1448 }
1449
1450 return 0;
be48e3ea 1451}
1452
1d172743 1453
a7160fe9 1454//______________________________________________________________________________________________
36c99a6a 1455void AliShuttleConfig::Print(Option_t* option) const
58bc3020 1456{
1457// print configuration
36c99a6a 1458// options : "": print configuration for all detectors, aliases and DPs in compacted format
1459// "uncompact": print configuration for all detectors, aliases and DPs in uncompacted format
1460// "DET": print configuration for DET, aliases and DPs in compacted format
1461// "DET, uncompact": print configuration for DET, aliases and DPs in uncompacted format
1462
73abe331 1463 TString result;
1464 result += '\n';
7d4cf768 1465
1466 TString mode = "test";
1467 if (fRunMode == kProd) mode = "production";
d477ad88 1468
7d4cf768 1469 result += "########################################################################\n";
1470 result += Form(" Shuttle configuration from %s - Run Mode: <%s> \n",
1471 fConfigHost.Data(), mode.Data());
1472 result += "########################################################################\n";
57c1a579 1473 result += Form("\nShuttle running on %s \n", fShuttleInstanceHost.Data());
57f50b3c 1474
1475 if(fProcessAll) {
57c1a579 1476 result += Form("All detectors will be processed! \n");
57f50b3c 1477 } else {
1478 result += "Detectors processed by this host: ";
1479 TIter it(&fProcessedDetectors);
1480 TObjString* aDet;
1481 while ((aDet = (TObjString*) it.Next())) {
1482 result += Form("%s ", aDet->String().Data());
1483 }
57c1a579 1484 result += "\n";
b948db8d 1485 }
b948db8d 1486
ff3781ad 1487 result += Form("PP time out = %d - DCS time out = %d - max PP mem size = %d KB - max retries = %d "
fb40ead4 1488 "- DIM trigger waiting timeout = %d\n",
ff3781ad 1489 fPPTimeOut, fDCSTimeOut, fPPMaxMem, fMaxRetries, fTriggerWait);
fb40ead4 1490 result += Form("FLAGS: keepDCSMap = %d - keepTempFolder = %d - SendMail = %d \n",
1491 fKeepDCSMap, fKeepTempFolder, fSendMail);
1492 const TObjArray* shuttleAdmins = GetAdmins(kGlobal);
1493 if (shuttleAdmins->GetEntries() != 0)
1494 {
1495 result += "SHUTTLE administrator(s): ";
1496 TIter it(shuttleAdmins);
1497 TObjString* anAdmin;
1498 while ((anAdmin = (TObjString*) it.Next()))
1499 {
1500 result += Form("%s ", anAdmin->String().Data());
1501 }
1502 result += "\n";
1503 }
1504 const TObjArray* amandaAdmins = GetAdmins(kAmanda);
1505 if (amandaAdmins->GetEntries() != 0)
1506 {
1507 result += "Amanda server administrator(s): ";
1508 TIter it(amandaAdmins);
1509 TObjString* anAdmin;
1510 while ((anAdmin = (TObjString*) it.Next()))
1511 {
1512 result += Form("%s ", anAdmin->String().Data());
1513 }
1514 result += "\n\n";
1515 }
57c1a579 1516 result += "------------------------------------------------------\n";
2bb7b766 1517
57c1a579 1518 result += Form("Logbook Configuration \n\n \tHost: %s:%d; \tUser: %s; ",
fc5a4708 1519 fDAQlbHost.Data(), fDAQlbPort, fDAQlbUser.Data());
b948db8d 1520
2c15234c 1521// result += "Password: ";
1522// result.Append('*', fDAQlbPass.Length());
b832ec02 1523 result += Form("\tDB: %s; \tTables: %s, %s, %s\n",
441b0e9c 1524 fDAQlbDB.Data(), fDAQlbTable.Data(), fShuttlelbTable.Data(), fRunTypelbTable.Data());
2c15234c 1525
57f50b3c 1526 result += "\n\n";
fb40ead4 1527
57c1a579 1528 result += "------------------------------------------------------\n";
1529 result += "FXS configuration\n\n";
1530
57f50b3c 1531 for(int iSys=0;iSys<3;iSys++){
57c1a579 1532 result += Form("*** %s ***\n", AliShuttleInterface::GetSystemName(iSys));
fc5a4708 1533 result += Form("\tDB host: %s:%d; \tUser: %s; \tName: %s; \tTable: %s\n",
1534 fFXSdbHost[iSys].Data(), fFXSdbPort[iSys], fFXSdbUser[iSys].Data(),
2c15234c 1535 fFXSdbName[iSys].Data(), fFXSdbTable[iSys].Data());
1536 // result += Form("DB Password:",fFXSdbPass[iSys].Data());
fb40ead4 1537 result += Form("\tFXS host: %s:%d; \tUser: %s\n", fFXSHost[iSys].Data(), fFXSPort[iSys],
fc5a4708 1538 fFXSUser[iSys].Data());
2c15234c 1539 // result += Form("FXS Password:",fFXSPass[iSys].Data());
fb40ead4 1540 const TObjArray* fxsAdmins = GetAdmins(iSys);
1541 if (fxsAdmins->GetEntries() != 0)
1542 {
1543 result += "\tAdministrator(s): ";
1544 TIter it(fxsAdmins);
1545 TObjString* anAdmin;
1546 while ((anAdmin = (TObjString*) it.Next()))
1547 {
1548 result += Form("%s ", anAdmin->String().Data());
1549 }
1550 result += "\n\n";
1551 }
57f50b3c 1552 }
b948db8d 1553
b832ec02 1554 result += "------------------------------------------------------\n";
1555 result += "MonaLisa configuration\n\n";
1556
1557 result += Form("\tHost: %s; \tTable name: %s",
1558 fMonitorHost.Data(), fMonitorTable.Data());
1559
1560 result += "\n\n";
fb40ead4 1561
36c99a6a 1562 TString optStr(option);
1563
57c1a579 1564 result += "------------------------------------------------------\n";
1565 result += "Detector-specific configuration\n\n";
1d172743 1566
73abe331 1567 TIter iter(fDetectorMap.GetTable());
1d172743 1568 TPair* aPair = 0;
1569
73abe331 1570 while ((aPair = (TPair*) iter.Next())) {
1d172743 1571 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) aPair->Value();
1572 if (optStr != "" && !optStr.Contains(aHolder->GetDetector()) &&
1573 optStr.CompareTo("uncompact",TString::kIgnoreCase) != 0 )
36c99a6a 1574 continue;
1d172743 1575
57c1a579 1576 result += Form("*** %s *** \n", aHolder->GetDetector());
1577
1578 const TObjArray* responsibles = aHolder->GetResponsibles();
1579 if (responsibles->GetEntries() != 0)
1580 {
1581 result += "\tDetector responsible(s): ";
1582 TIter it(responsibles);
1583 TObjString* aResponsible;
1584 while ((aResponsible = (TObjString*) it.Next()))
1585 {
1586 result += Form("%s ", aResponsible->String().Data());
1587 }
1588 result += "\n";
1589 }
1590
1d172743 1591 result += Form("\tStrict run ordering: %s \n\n", aHolder->StrictRunOrder() ? "YES" : "NO");
1592
1593 const TObjArray* dcsConfig = aHolder->GetDCSConfig();
1594
1595 AliShuttleDCSConfigHolder* dcsHolder = 0;
1596 TIter dcsIter(dcsConfig);
1597 Int_t count=0;
1598 while ((dcsHolder = dynamic_cast<AliShuttleDCSConfigHolder*> (dcsIter.Next())))
be48e3ea 1599 {
542b6cc8 1600 result += Form("\tAmanda server [%d]: %s:%d - MultiSplit = %d\n", count,
1601 dcsHolder->GetDCSHost(), dcsHolder->GetDCSPort(), dcsHolder->GetMultiSplit());
57f50b3c 1602
1d172743 1603 const TObjArray* aliases = 0;
1604 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1605 {
1606 aliases = dcsHolder->GetDCSAliases();
1607 } else {
1608 aliases = dcsHolder->GetCompactDCSAliases();
1609 }
36c99a6a 1610
1d172743 1611 if (aliases->GetEntries() != 0)
2c15234c 1612 {
1d172743 1613 result += Form("\tDCS Aliases [%d]: ", count);
1614 TIter it(aliases);
1615 TObjString* anAlias;
1616 while ((anAlias = (TObjString*) it.Next()))
1617 {
1618 result += Form("%s ", anAlias->String().Data());
1619 }
1620 result += "\n";
2c15234c 1621 }
57f50b3c 1622
1d172743 1623 const TObjArray* dataPoints = 0;
1624 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1625 {
1626 dataPoints = dcsHolder->GetDCSDataPoints();
1627 } else {
1628 dataPoints = dcsHolder->GetCompactDCSDataPoints();
2c15234c 1629 }
1d172743 1630 if (dataPoints->GetEntries() != 0)
1631 {
1632 result += Form("\tDCS Data Points [%d]: ", count);
1633 TIter it(dataPoints);
1634 TObjString* aDataPoint;
1635 while ((aDataPoint = (TObjString*) it.Next())) {
1636 result += Form("%s ", aDataPoint->String().Data());
1637 }
2c15234c 1638 result += "\n";
1d172743 1639 }
1640 count++;
1641 result += "\n";
2c15234c 1642 }
73abe331 1643 }
57f50b3c 1644 if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n";
1645
73abe331 1646 AliInfo(result);
1647}