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