1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.27 2007/12/17 03:23:32 jgrosseo
20 added "empty preprocessor" as placeholder for Acorde in FDR
22 Revision 1.26 2007/12/07 19:14:36 acolla
25 Added automatic collection of new runs on a regular time basis (settable from the configuration)
27 in AliShuttleConfig: new members
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)
34 - logs now stored in logs/#RUN/DET_#RUN.log
36 Revision 1.25 2007/11/26 16:58:37 acolla
37 Monalisa configuration added: host and table name
39 Revision 1.24 2007/10/24 10:44:08 acolla
43 Revision 1.23 2007/09/28 15:27:40 acolla
45 AliDCSClient "multiSplit" option added in the DCS configuration
46 in AliDCSMessage: variable MAX_BODY_SIZE set to 500000
48 Revision 1.22 2007/09/27 16:53:13 acolla
49 Detectors can have more than one AMANDA server. SHUTTLE queries the servers sequentially,
50 merges the dcs aliases/DPs in one TMap and sends it to the preprocessor.
52 Revision 1.21 2007/04/27 07:06:48 jgrosseo
53 GetFileSources returns empty list in case of no files, but successful query
54 No mails sent in testmode
56 Revision 1.20 2007/04/04 10:33:36 jgrosseo
57 1) 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.
58 In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
60 2) 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.
62 3) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
64 4) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
66 5) 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.
67 If you always need DCS data (like before), you do not need to implement it.
69 6) The run type has been added to the monitoring page
71 Revision 1.19 2007/02/28 10:41:56 acolla
72 Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
73 AliPreprocessor::GetRunType() function.
74 Added some ldap definition files.
76 Revision 1.18 2007/01/23 19:20:03 acolla
77 Removed old ldif files, added TOF, MCH ldif files. Added some options in
78 AliShuttleConfig::Print. Added in Ali Shuttle: SetShuttleTempDir and
81 Revision 1.17 2007/01/18 11:17:47 jgrosseo
82 changing spaces to tabs ;-)
84 Revision 1.16 2007/01/18 11:10:35 jgrosseo
85 adding the possibility of defining DCS alias and data points with patterns
86 first pattern introduced: [N..M] to add all names between the two digits, this works also recursively.
88 Revision 1.15 2007/01/15 18:27:11 acolla
89 implementation of sending mail to subdetector expert in case the preprocessor fails.
90 shuttle.schema updated with expert's email entry
92 Revision 1.13 2006/12/07 08:51:26 jgrosseo
94 table, db names in ldap configuration
95 added GRP preprocessor
96 DCS data can also be retrieved by data point
98 Revision 1.12 2006/11/16 16:16:48 jgrosseo
99 introducing strict run ordering flag
100 removed giving preprocessor name to preprocessor, they have to know their name themselves ;-)
102 Revision 1.11 2006/11/06 14:23:04 jgrosseo
103 major update (Alberto)
104 o) reading of run parameters from the logbook
105 o) online offline naming conversion
106 o) standalone DCSclient package
108 Revision 1.10 2006/10/20 15:22:59 jgrosseo
109 o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child
110 o) Merging Collect, CollectAll, CollectNew function
111 o) Removing implementation of empty copy constructors (declaration still there!)
113 Revision 1.9 2006/10/02 16:38:39 jgrosseo
116 storing of objects that failed to be stored to the grid before
117 interfacing of shuttle status table in daq system
119 Revision 1.8 2006/08/15 10:50:00 jgrosseo
120 effc++ corrections (alberto)
122 Revision 1.7 2006/07/20 09:54:40 jgrosseo
123 introducing status management: The processing per subdetector is divided into several steps,
124 after each step the status is stored on disk. If the system crashes in any of the steps the Shuttle
125 can keep track of the number of failures and skips further processing after a certain threshold is
126 exceeded. These thresholds can be configured in LDAP.
128 Revision 1.6 2006/07/19 10:09:55 jgrosseo
129 new configuration, accesst to DAQ FES (Alberto)
131 Revision 1.5 2006/07/10 13:01:41 jgrosseo
132 enhanced storing of last sucessfully processed run (alberto)
134 Revision 1.4 2006/06/12 09:11:16 jgrosseo
135 coding conventions (Alberto)
137 Revision 1.3 2006/06/06 14:26:40 jgrosseo
138 o) removed files that were moved to STEER
139 o) shuttle updated to follow the new interface (Alberto)
141 Revision 1.7 2006/05/12 09:07:16 colla
143 New configuration complete
145 Revision 1.2 2006/03/07 07:52:34 hristov
146 New version (B.Yordanov)
148 Revision 1.4 2005/11/19 14:20:31 byordano
149 logbook config added to AliShuttleConfig
151 Revision 1.3 2005/11/17 19:24:25 byordano
152 TList changed to TObjArray in AliShuttleConfig
154 Revision 1.2 2005/11/17 14:43:23 byordano
157 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
158 Initial import as subdirectory in AliRoot
160 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
163 Revision 1.3 2005/08/30 09:13:02 byordano
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).
179 #include "AliShuttleConfig.h"
180 #include "AliShuttleInterface.h"
185 #include <TObjString.h>
186 #include <TLDAPResult.h>
187 #include <TLDAPEntry.h>
188 #include <TLDAPAttribute.h>
191 AliShuttleConfig::AliShuttleDCSConfigHolder::AliShuttleDCSConfigHolder(const TLDAPEntry* entry):
198 fDCSDataPointsComp(0),
201 // constructor of the shuttle DCS configuration holder
203 TLDAPAttribute* anAttribute;
204 fDCSAliases = new TObjArray();
205 fDCSAliases->SetOwner(1);
206 fDCSDataPoints = new TObjArray();
207 fDCSDataPoints->SetOwner(1);
208 fDCSAliasesComp = new TObjArray();
209 fDCSAliasesComp->SetOwner(1);
210 fDCSDataPointsComp = new TObjArray();
211 fDCSDataPointsComp->SetOwner(1);
214 anAttribute = entry->GetAttribute("dcsHost");
217 AliError("Unexpected: no DCS host!");
221 fDCSHost = anAttribute->GetValue();
223 anAttribute = entry->GetAttribute("dcsPort");
226 AliError("Unexpected: no DCS port!");
229 TString portStr = anAttribute->GetValue();
230 fDCSPort = portStr.Atoi();
232 anAttribute = entry->GetAttribute("multiSplit"); // MAY
235 TString multiSplitStr = anAttribute->GetValue();
236 fMultiSplit = multiSplitStr.Atoi();
237 if(fMultiSplit == 0) {
238 AliError("MultiSplit must be a positive integer!");
244 anAttribute = entry->GetAttribute("dcsAlias"); // MAY
248 while ((anAlias = anAttribute->GetValue()))
250 fDCSAliasesComp->AddLast(new TObjString(anAlias));
251 ExpandAndAdd(fDCSAliases, anAlias);
255 anAttribute = entry->GetAttribute("dcsDP"); // MAY
258 const char* aDataPoint;
259 while ((aDataPoint = anAttribute->GetValue()))
261 fDCSDataPointsComp->AddLast(new TObjString(aDataPoint));
262 ExpandAndAdd(fDCSDataPoints, aDataPoint);
269 //______________________________________________________________________________________________
270 void AliShuttleConfig::AliShuttleDCSConfigHolder::ExpandAndAdd(TObjArray* target, const char* entry)
273 // adds <entry> to <target> applying expanding of the name
274 // [N..M] creates M-N+1 names with the corresponding digits
277 TString entryStr(entry);
279 Int_t begin = entryStr.Index("[");
280 Int_t end = entryStr.Index("]");
281 if (begin != -1 && end != -1 && end > begin)
283 TString before(entryStr(0, begin));
284 TString after(entryStr(end+1, entryStr.Length()));
286 AliDebug(2, Form("Found [] pattern. Splitted input string %s %s", before.Data(), after.Data()));
288 Int_t dotdot = entryStr.Index("..");
290 TString nStr(entryStr(begin+1, dotdot-begin-1));
291 TString mStr(entryStr(dotdot+2, end-dotdot-2));
293 AliDebug(2, Form("Found [N..M] pattern. %s %s", nStr.Data(), mStr.Data()));
295 if (nStr.IsDigit() && mStr.IsDigit())
297 Int_t n = nStr.Atoi();
298 Int_t m = mStr.Atoi();
300 Int_t nDigits = nStr.Length();
302 formatStr.Form("%%s%%0%dd%%s", nDigits);
304 AliDebug(2, Form("Format string is %s", formatStr.Data()));
306 for (Int_t current = n; current<=m; ++current)
309 newEntry.Form(formatStr.Data(), before.Data(), current, after.Data());
311 AliDebug(2, Form("Calling recursive with %s", newEntry.Data()));
314 ExpandAndAdd(target, newEntry);
317 // return here because we processed the entries already recursively.
322 AliDebug(2, Form("Adding name %s", entry));
323 target->AddLast(new TObjString(entry));
326 //______________________________________________________________________________________________
327 AliShuttleConfig::AliShuttleDCSConfigHolder::~AliShuttleDCSConfigHolder()
329 // destructor of the shuttle configuration holder
332 delete fDCSDataPoints;
333 delete fDCSAliasesComp;
334 delete fDCSDataPointsComp;
337 //______________________________________________________________________________________________
338 AliShuttleConfig::AliShuttleDetConfigHolder::AliShuttleDetConfigHolder(const TLDAPEntry* entry):
343 fSkipDCSQuery(kFALSE),
344 fStrictRunOrder(kFALSE)
346 // constructor of the shuttle configuration holder
348 TLDAPAttribute* anAttribute;
350 fResponsibles = new TObjArray();
351 fResponsibles->SetOwner(1);
352 fDCSConfig = new TObjArray();
353 fDCSConfig->SetOwner(1);
355 anAttribute = entry->GetAttribute("det"); // MUST
358 AliError(Form("No \"det\" attribute!"));
361 fDetector = anAttribute->GetValue();
363 anAttribute = entry->GetAttribute("strictRunOrder"); // MAY
366 AliWarning(Form("%s did not set strictRunOrder flag - the default is FALSE",
369 TString strictRunStr = anAttribute->GetValue();
370 if (!(strictRunStr == "0" || strictRunStr == "1"))
372 AliError("strictRunOrder flag must be 0 or 1!");
375 fStrictRunOrder = (Bool_t) strictRunStr.Atoi();
378 anAttribute = entry->GetAttribute("responsible"); // MAY
381 AliDebug(2, "Warning! No \"responsible\" attribute!");
385 const char* aResponsible;
386 while ((aResponsible = anAttribute->GetValue()))
388 fResponsibles->AddLast(new TObjString(aResponsible));
395 //______________________________________________________________________________________________
396 AliShuttleConfig::AliShuttleDetConfigHolder::~AliShuttleDetConfigHolder()
398 // destructor of the shuttle configuration holder
400 delete fResponsibles;
404 //______________________________________________________________________________________________
405 const char* AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSHost(Int_t iServ) const
408 // returns DCS server host
411 if (iServ < 0 || iServ >= GetNServers()) return 0;
413 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
414 (fDCSConfig->At(iServ));
416 return aHolder->GetDCSHost();
419 //______________________________________________________________________________________________
420 Int_t AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSPort(Int_t iServ) const
423 // returns DCS server port
426 if (iServ < 0 || iServ >= GetNServers()) return 0;
428 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
429 (fDCSConfig->At(iServ));
431 return aHolder->GetDCSPort();
434 //______________________________________________________________________________________________
435 Int_t AliShuttleConfig::AliShuttleDetConfigHolder::GetMultiSplit(Int_t iServ) const
438 // returns DCS "multi split" value
441 if (iServ < 0 || iServ >= GetNServers()) return 0;
443 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
444 (fDCSConfig->At(iServ));
446 return aHolder->GetMultiSplit();
449 //______________________________________________________________________________________________
450 const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSAliases(Int_t iServ) const
453 // returns collection of TObjString which represents the set of aliases
454 // which used for data retrieval for particular detector
457 if (iServ < 0 || iServ >= GetNServers()) return 0;
459 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
460 (fDCSConfig->At(iServ));
462 return aHolder->GetDCSAliases();
465 //______________________________________________________________________________________________
466 const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSDataPoints(Int_t iServ) const
469 // returns collection of TObjString which represents the set of aliases
470 // which used for data retrieval for particular detector
473 if (iServ < 0 || iServ >= GetNServers()) return 0;
475 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
476 (fDCSConfig->At(iServ));
478 return aHolder->GetDCSDataPoints();
481 //______________________________________________________________________________________________
482 const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetCompactDCSAliases(Int_t iServ) const
485 // returns collection of TObjString which represents the set of aliases
486 // which used for data retrieval for particular detector (Compact style)
489 if (iServ < 0 || iServ >= GetNServers()) return 0;
491 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
492 (fDCSConfig->At(iServ));
494 return aHolder->GetCompactDCSAliases();
497 //______________________________________________________________________________________________
498 const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetCompactDCSDataPoints(Int_t iServ) const
501 // returns collection of TObjString which represents the set of aliases
502 // which used for data retrieval for particular detector (Compact style)
505 if (iServ < 0 || iServ >= GetNServers()) return 0;
507 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
508 (fDCSConfig->At(iServ));
510 return aHolder->GetCompactDCSDataPoints();
513 //______________________________________________________________________________________________
514 void AliShuttleConfig::AliShuttleDetConfigHolder::AddDCSConfig(AliShuttleDCSConfigHolder* holder)
517 // adds a DCS configuration set in the array of DCS configurations
521 fDCSConfig->AddLast(holder);
524 ClassImp(AliShuttleConfig)
526 //______________________________________________________________________________________________
527 AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
528 const char* binddn, const char* password, const char* basedn):
548 fShuttleInstanceHost(""),
549 fProcessedDetectors(),
551 fKeepTempFolder(kFALSE),
558 // host: ldap server host
559 // port: ldap server port
560 // binddn: binddn used for ldap binding (simple bind is used!).
561 // password: password for binddn
562 // basedn: this is basedn whose childeren entries which have
565 fDetectorMap.SetOwner(1);
566 fDetectorList.SetOwner(0); //fDetectorList and fDetectorMap share the same object!
567 fProcessedDetectors.SetOwner();
569 for (int i=0; i<5; i++)
571 fAdmin[i] = new TObjArray();
572 fAdmin[i]->SetOwner();
575 TLDAPServer aServer(host, port, binddn, password, 3);
577 if (!aServer.IsConnected()) {
578 AliError(Form("Can't connect to ldap server %s:%d",
583 // reads configuration for the shuttle running on this machine
585 TLDAPResult* aResult = 0;
586 TLDAPEntry* anEntry = 0;
593 globalList.SetOwner(1);
597 hostList.SetOwner(1);
599 aResult = aServer.Search(basedn, LDAP_SCOPE_SUBTREE, 0, 0);
603 AliError(Form("Can't find configuration with base DN: %s !", basedn));
607 while ((anEntry = aResult->GetNext()))
609 TString dn = anEntry->GetDn();
611 if (dn.BeginsWith("dcsHost="))
613 dcsList.Add(anEntry);
615 else if (dn.BeginsWith("det="))
617 detList.Add(anEntry);
619 else if (dn.BeginsWith("name=globalConfig"))
621 globalList.Add(anEntry);
623 else if (dn.BeginsWith("system="))
625 sysList.Add(anEntry);
627 else if (dn.BeginsWith("shuttleHost="))
629 hostList.Add(anEntry);
641 result += SetGlobalConfig(&globalList);
642 result += SetSysConfig(&sysList);
643 result += SetDetConfig(&detList,&dcsList);
644 result += SetHostConfig(&hostList);
648 AliError("Configuration is INVALID!");
656 //______________________________________________________________________________________________
657 AliShuttleConfig::~AliShuttleConfig()
661 fDetectorMap.DeleteAll();
662 fDetectorList.Clear();
663 fProcessedDetectors.Delete();
669 //______________________________________________________________________________________________
670 const TObjArray* AliShuttleConfig::GetDetectors() const
673 // returns collection of TObjString which contains the name
674 // of every detector which is in the configuration.
677 return &fDetectorList;
680 //______________________________________________________________________________________________
681 Bool_t AliShuttleConfig::HasDetector(const char* detector) const
684 // checks for paricular detector in the configuration.
686 return fDetectorMap.GetValue(detector) != NULL;
689 //______________________________________________________________________________________________
690 Int_t AliShuttleConfig::GetNServers(const char* detector) const
693 // returns number of DCS servers for detector
696 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
698 AliError(Form("There isn't configuration for detector: %s",
703 return aHolder->GetNServers();
707 //______________________________________________________________________________________________
708 const char* AliShuttleConfig::GetDCSHost(const char* detector, Int_t iServ) const
711 // returns i-th DCS server host used by particular detector
714 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
716 AliError(Form("There isn't configuration for detector: %s",
721 return aHolder->GetDCSHost(iServ);
724 //______________________________________________________________________________________________
725 Int_t AliShuttleConfig::GetDCSPort(const char* detector, Int_t iServ) const
728 // returns i-th DCS server port used by particular detector
732 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
734 AliError(Form("There isn't configuration for detector: %s",
739 return aHolder->GetDCSPort(iServ);
742 //______________________________________________________________________________________________
743 Int_t AliShuttleConfig::GetMultiSplit(const char* detector, Int_t iServ) const
746 // returns i-th DCS "multi split" value
750 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
752 AliError(Form("There isn't configuration for detector: %s",
757 return aHolder->GetMultiSplit(iServ);
760 //______________________________________________________________________________________________
761 const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector, Int_t iServ) const
764 // returns collection of TObjString which represents the i-th set of aliases
765 // which used for data retrieval for particular detector
768 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
770 AliError(Form("There isn't configuration for detector: %s",
775 return aHolder->GetDCSAliases(iServ);
778 //______________________________________________________________________________________________
779 const TObjArray* AliShuttleConfig::GetDCSDataPoints(const char* detector, Int_t iServ) const
782 // returns collection of TObjString which represents the set of aliases
783 // which used for data retrieval for particular detector
786 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
788 AliError(Form("There isn't configuration for detector: %s",
793 return aHolder->GetDCSDataPoints(iServ);
796 //______________________________________________________________________________________________
797 const TObjArray* AliShuttleConfig::GetCompactDCSAliases(const char* detector, Int_t iServ) const
800 // returns collection of TObjString which represents the i-th set of aliases
801 // which used for data retrieval for particular detector (Compact style)
804 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
806 AliError(Form("There isn't configuration for detector: %s",
811 return aHolder->GetCompactDCSAliases(iServ);
814 //______________________________________________________________________________________________
815 const TObjArray* AliShuttleConfig::GetCompactDCSDataPoints(const char* detector, Int_t iServ) const
818 // returns collection of TObjString which represents the set of aliases
819 // which used for data retrieval for particular detector (Compact style)
822 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
824 AliError(Form("There isn't configuration for detector: %s",
829 return aHolder->GetCompactDCSDataPoints(iServ);
832 //______________________________________________________________________________________________
833 const TObjArray* AliShuttleConfig::GetResponsibles(const char* detector) const
836 // returns collection of TObjString which represents the list of mail addresses
837 // of the detector's responsible(s)
840 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
842 AliError(Form("There isn't configuration for detector: %s",
847 return aHolder->GetResponsibles();
850 //______________________________________________________________________________________________
851 const TObjArray* AliShuttleConfig::GetAdmins(Int_t sys) const
854 // returns collection of TObjString which represents the list of mail addresses
855 // of the system's administrator(s) (DAQ, DCS, HLT, Global, Amanda)
858 if (sys < 0 || sys > 4) return 0;
862 //______________________________________________________________________________________________
863 Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
865 // return TRUE if detector is handled by host or if fProcessAll is TRUE
867 if(fProcessAll) return kTRUE;
868 TIter iter(&fProcessedDetectors);
870 while((detName = (TObjString*) iter.Next())){
871 if(detName->String() == detector) return kTRUE;
876 //______________________________________________________________________________________________
877 Bool_t AliShuttleConfig::StrictRunOrder(const char* detector) const
879 // return TRUE if detector wants strict run ordering of stored data
881 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
884 AliError(Form("There isn't configuration for detector: %s",
889 return aHolder->StrictRunOrder();
892 //______________________________________________________________________________________________
893 UInt_t AliShuttleConfig::SetGlobalConfig(TList* list)
895 // Set the global configuration (DAQ Logbook + preprocessor monitoring settings)
897 TLDAPEntry* anEntry = 0;
898 TLDAPAttribute* anAttribute = 0;
900 if (list->GetEntries() == 0)
902 AliError("Global configuration not found!");
905 else if (list->GetEntries() > 1)
907 AliError("More than one global configuration found!");
911 anEntry = dynamic_cast<TLDAPEntry*> (list->At(0));
915 AliError("Unexpected! Global list does not contain a TLDAPEntry");
920 anAttribute = anEntry->GetAttribute("daqLbHost");
922 AliError("Can't find daqLbHost attribute!");
925 fDAQlbHost = anAttribute->GetValue();
927 anAttribute = anEntry->GetAttribute("daqLbPort"); // MAY
930 fDAQlbPort = ((TString) anAttribute->GetValue()).Atoi();
932 fDAQlbPort = 3306; // mysql
935 anAttribute = anEntry->GetAttribute("daqLbUser");
937 AliError("Can't find daqLbUser attribute!");
940 fDAQlbUser = anAttribute->GetValue();
942 anAttribute = anEntry->GetAttribute("daqLbPasswd");
944 AliError("Can't find daqLbPasswd attribute!");
947 fDAQlbPass = anAttribute->GetValue();
949 anAttribute = anEntry->GetAttribute("daqLbDB");
951 AliError("Can't find daqLbDB attribute!");
954 fDAQlbDB = anAttribute->GetValue();
956 anAttribute = anEntry->GetAttribute("daqLbTable");
958 AliError("Can't find daqLbTable attribute!");
961 fDAQlbTable = anAttribute->GetValue();
963 anAttribute = anEntry->GetAttribute("shuttleLbTable");
965 AliError("Can't find shuttleLbTable attribute!");
968 fShuttlelbTable = anAttribute->GetValue();
970 anAttribute = anEntry->GetAttribute("runTypeLbTable");
972 AliError("Can't find runTypeLbTable attribute!");
975 fRunTypelbTable = anAttribute->GetValue();
977 anAttribute = anEntry->GetAttribute("ppmaxRetries");
979 AliError("Can't find ppmaxRetries attribute!");
982 TString tmpStr = anAttribute->GetValue();
983 fMaxRetries = tmpStr.Atoi();
985 anAttribute = anEntry->GetAttribute("ppTimeOut");
987 AliError("Can't find ppTimeOut attribute!");
990 tmpStr = anAttribute->GetValue();
991 fPPTimeOut = tmpStr.Atoi();
993 anAttribute = anEntry->GetAttribute("ppMaxMem");
995 AliError("Can't find ppMaxMem attribute!");
998 tmpStr = anAttribute->GetValue();
999 fPPMaxMem = tmpStr.Atoi();
1001 anAttribute = anEntry->GetAttribute("monitorHost");
1003 AliError("Can't find monitorHost attribute!");
1006 fMonitorHost = anAttribute->GetValue();
1008 anAttribute = anEntry->GetAttribute("monitorTable");
1010 AliError("Can't find monitorTable attribute!");
1013 fMonitorTable = anAttribute->GetValue();
1015 anAttribute = anEntry->GetAttribute("triggerWait"); // MAY
1017 AliWarning(Form("triggerWait not set! default = ", fTriggerWait));
1019 tmpStr = anAttribute->GetValue();
1020 fTriggerWait = tmpStr.Atoi();
1022 anAttribute = anEntry->GetAttribute("mode");
1024 AliWarning("Run mode not set! Running in test mode.");
1026 tmpStr = anAttribute->GetValue();
1027 if (tmpStr == "test")
1030 } else if (tmpStr == "prod") {
1033 AliWarning(Form("Not a valid run mode: %s", tmpStr.Data()));
1034 AliWarning("Valid run modes are \"test\" and \"prod\". Running in test mode.");
1038 anAttribute = anEntry->GetAttribute("keepDCSMap"); // MAY
1041 AliWarning("keepDCSMap flag not set - default is FALSE");
1043 TString keepDCSMapStr = anAttribute->GetValue();
1044 if (!(keepDCSMapStr == "0" || keepDCSMapStr == "1"))
1046 AliError("keepDCSMap flag must be 0 or 1!");
1049 fKeepDCSMap = (Bool_t) keepDCSMapStr.Atoi();
1052 anAttribute = anEntry->GetAttribute("keepTempFolder"); // MAY
1055 AliWarning("keepTempFolder flag not set - default is FALSE");
1057 TString keepTempFolderStr = anAttribute->GetValue();
1058 if (!(keepTempFolderStr == "0" || keepTempFolderStr == "1"))
1060 AliError("keepTempFolder flag must be 0 or 1!");
1063 fKeepTempFolder = (Bool_t) keepTempFolderStr.Atoi();
1067 anAttribute = anEntry->GetAttribute("shuttleAdmin"); // MAY
1070 AliDebug(2, "Warning! No \"shuttleAdmin\" attribute!");
1074 const char* anAdmin;
1075 while ((anAdmin = anAttribute->GetValue()))
1077 fAdmin[kGlobal]->AddLast(new TObjString(anAdmin));
1081 anAttribute = anEntry->GetAttribute("amandaAdmin"); // MAY
1084 AliDebug(2, "Warning! No \"amandaAdmin\" attribute!");
1088 const char* anAdmin;
1089 while ((anAdmin = anAttribute->GetValue()))
1091 fAdmin[kAmanda]->AddLast(new TObjString(anAdmin));
1095 anAttribute = anEntry->GetAttribute("sendMail"); // MAY
1098 AliWarning("sendMail flag not set - default is FALSE");
1100 TString sendMailStr = anAttribute->GetValue();
1101 if (!(sendMailStr == "0" || sendMailStr == "1"))
1103 AliError("sendMail flag must be 0 or 1!");
1106 fSendMail = (Bool_t) sendMailStr.Atoi();
1112 //______________________________________________________________________________________________
1113 UInt_t AliShuttleConfig::SetSysConfig(TList* list)
1115 // Set the online FXS configuration (DAQ + DCS + HLT)
1117 TLDAPEntry* anEntry = 0;
1118 TLDAPAttribute* anAttribute = 0;
1120 if (list->GetEntries() != 3)
1122 AliError(Form("Wrong number of online systems found: %d !", list->GetEntries()));
1128 SystemCode iSys=kDAQ;
1130 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1132 anAttribute = anEntry->GetAttribute("system");
1133 TString sysName = anAttribute->GetValue();
1135 if (sysName == "DAQ")
1140 else if (sysName == "DCS")
1145 else if (sysName == "HLT")
1151 anAttribute = anEntry->GetAttribute("dbHost");
1153 AliError(Form ("Can't find dbHost attribute for %s!!",
1154 AliShuttleInterface::GetSystemName(iSys)));
1157 fFXSdbHost[iSys] = anAttribute->GetValue();
1159 anAttribute = anEntry->GetAttribute("dbPort"); // MAY
1162 fFXSdbPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1164 fFXSdbPort[iSys] = 3306; // mysql
1167 anAttribute = anEntry->GetAttribute("dbUser");
1169 AliError(Form ("Can't find dbUser attribute for %s!!",
1170 AliShuttleInterface::GetSystemName(iSys)));
1173 fFXSdbUser[iSys] = anAttribute->GetValue();
1175 anAttribute = anEntry->GetAttribute("dbPasswd");
1177 AliError(Form ("Can't find dbPasswd attribute for %s!!",
1178 AliShuttleInterface::GetSystemName(iSys)));
1181 fFXSdbPass[iSys] = anAttribute->GetValue();
1183 anAttribute = anEntry->GetAttribute("dbName");
1185 AliError(Form ("Can't find dbName attribute for %s!!",
1186 AliShuttleInterface::GetSystemName(iSys)));
1190 fFXSdbName[iSys] = anAttribute->GetValue();
1191 anAttribute = anEntry->GetAttribute("dbTable");
1193 AliError(Form ("Can't find dbTable attribute for %s!!",
1194 AliShuttleInterface::GetSystemName(iSys)));
1197 fFXSdbTable[iSys] = anAttribute->GetValue();
1199 anAttribute = anEntry->GetAttribute("fxsHost");
1201 AliError(Form ("Can't find fxsHost attribute for %s!!",
1202 AliShuttleInterface::GetSystemName(iSys)));
1205 fFXSHost[iSys] = anAttribute->GetValue();
1207 anAttribute = anEntry->GetAttribute("fxsPort"); // MAY
1210 fFXSPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1212 fFXSPort[iSys] = 22; // scp port number
1215 anAttribute = anEntry->GetAttribute("fxsUser");
1217 AliError(Form ("Can't find fxsUser attribute for %s!!",
1218 AliShuttleInterface::GetSystemName(iSys)));
1221 fFXSUser[iSys] = anAttribute->GetValue();
1223 anAttribute = anEntry->GetAttribute("fxsPasswd");
1224 if (anAttribute) fFXSPass[iSys] = anAttribute->GetValue();
1226 anAttribute = anEntry->GetAttribute("fxsAdmin"); // MAY
1229 AliDebug(2, "Warning! No \"fxsAdmin\" attribute!");
1233 const char* anAdmin;
1234 while ((anAdmin = anAttribute->GetValue()))
1236 fAdmin[iSys]->AddLast(new TObjString(anAdmin));
1243 AliError(Form("Wrong system configuration! (code = %d)", count));
1250 //______________________________________________________________________________________________
1251 UInt_t AliShuttleConfig::SetDetConfig(TList* detList, TList* dcsList)
1253 // Set the detector configuration (general settings + DCS amanda server and alias/DP lists)
1255 TLDAPEntry* anEntry = 0;
1257 TIter iter(detList);
1258 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1261 AliShuttleDetConfigHolder* detHolder = new AliShuttleDetConfigHolder(anEntry);
1263 if (!detHolder->IsValid()) {
1264 AliError("Detector configuration error!");
1269 TObjString* detStr = new TObjString(detHolder->GetDetector());
1271 // Look for DCS Configuration
1272 TIter dcsIter(dcsList);
1273 TLDAPEntry *dcsEntry = 0;
1274 while ((dcsEntry = dynamic_cast<TLDAPEntry*> (dcsIter.Next())))
1276 TString dn = dcsEntry->GetDn();
1277 if(dn.Contains(detStr->GetName())) {
1278 AliDebug(2, Form("Found DCS configuration: dn = %s",dn.Data()));
1279 AliShuttleDCSConfigHolder* dcsHolder = new AliShuttleDCSConfigHolder(dcsEntry);
1280 if (!dcsHolder->IsValid()) {
1281 AliError("DCS configuration error!");
1286 detHolder->AddDCSConfig(dcsHolder);
1291 fDetectorMap.Add(detStr, detHolder);
1292 fDetectorList.AddLast(detStr);
1298 //______________________________________________________________________________________________
1299 UInt_t AliShuttleConfig::SetHostConfig(TList* list)
1301 // Set the Shuttle machines configuration (which detectors processes each machine)
1303 TLDAPEntry* anEntry = 0;
1304 TLDAPAttribute* anAttribute = 0;
1306 fShuttleInstanceHost = gSystem->HostName();
1309 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1312 TString dn(anEntry->GetDn());
1313 if (!dn.Contains(Form("shuttleHost=%s", fShuttleInstanceHost.Data()))) continue;
1317 anAttribute = anEntry->GetAttribute("detectors");
1318 const char *detName;
1319 while((detName = anAttribute->GetValue())){
1320 TObjString *objDet= new TObjString(detName);
1321 fProcessedDetectors.Add(objDet);
1330 //______________________________________________________________________________________________
1331 void AliShuttleConfig::Print(Option_t* option) const
1333 // print configuration
1334 // options : "": print configuration for all detectors, aliases and DPs in compacted format
1335 // "uncompact": print configuration for all detectors, aliases and DPs in uncompacted format
1336 // "DET": print configuration for DET, aliases and DPs in compacted format
1337 // "DET, uncompact": print configuration for DET, aliases and DPs in uncompacted format
1342 TString mode = "test";
1343 if (fRunMode == kProd) mode = "production";
1345 result += "########################################################################\n";
1346 result += Form(" Shuttle configuration from %s - Run Mode: <%s> \n",
1347 fConfigHost.Data(), mode.Data());
1348 result += "########################################################################\n";
1349 result += Form("\nShuttle running on %s \n", fShuttleInstanceHost.Data());
1352 result += Form("All detectors will be processed! \n");
1354 result += "Detectors processed by this host: ";
1355 TIter it(&fProcessedDetectors);
1357 while ((aDet = (TObjString*) it.Next())) {
1358 result += Form("%s ", aDet->String().Data());
1363 result += Form("PP time out = %d - max PP mem size = %d KB - max retries = %d "
1364 "- DIM trigger waiting timeout = %d\n",
1365 fPPTimeOut, fPPMaxMem, fMaxRetries, fTriggerWait);
1366 result += Form("FLAGS: keepDCSMap = %d - keepTempFolder = %d - SendMail = %d \n",
1367 fKeepDCSMap, fKeepTempFolder, fSendMail);
1368 const TObjArray* shuttleAdmins = GetAdmins(kGlobal);
1369 if (shuttleAdmins->GetEntries() != 0)
1371 result += "SHUTTLE administrator(s): ";
1372 TIter it(shuttleAdmins);
1373 TObjString* anAdmin;
1374 while ((anAdmin = (TObjString*) it.Next()))
1376 result += Form("%s ", anAdmin->String().Data());
1380 const TObjArray* amandaAdmins = GetAdmins(kAmanda);
1381 if (amandaAdmins->GetEntries() != 0)
1383 result += "Amanda server administrator(s): ";
1384 TIter it(amandaAdmins);
1385 TObjString* anAdmin;
1386 while ((anAdmin = (TObjString*) it.Next()))
1388 result += Form("%s ", anAdmin->String().Data());
1392 result += "------------------------------------------------------\n";
1394 result += Form("Logbook Configuration \n\n \tHost: %s:%d; \tUser: %s; ",
1395 fDAQlbHost.Data(), fDAQlbPort, fDAQlbUser.Data());
1397 // result += "Password: ";
1398 // result.Append('*', fDAQlbPass.Length());
1399 result += Form("\tDB: %s; \tTables: %s, %s, %s\n",
1400 fDAQlbDB.Data(), fDAQlbTable.Data(), fShuttlelbTable.Data(), fRunTypelbTable.Data());
1404 result += "------------------------------------------------------\n";
1405 result += "FXS configuration\n\n";
1407 for(int iSys=0;iSys<3;iSys++){
1408 result += Form("*** %s ***\n", AliShuttleInterface::GetSystemName(iSys));
1409 result += Form("\tDB host: %s:%d; \tUser: %s; \tName: %s; \tTable: %s\n",
1410 fFXSdbHost[iSys].Data(), fFXSdbPort[iSys], fFXSdbUser[iSys].Data(),
1411 fFXSdbName[iSys].Data(), fFXSdbTable[iSys].Data());
1412 // result += Form("DB Password:",fFXSdbPass[iSys].Data());
1413 result += Form("\tFXS host: %s:%d; \tUser: %s\n", fFXSHost[iSys].Data(), fFXSPort[iSys],
1414 fFXSUser[iSys].Data());
1415 // result += Form("FXS Password:",fFXSPass[iSys].Data());
1416 const TObjArray* fxsAdmins = GetAdmins(iSys);
1417 if (fxsAdmins->GetEntries() != 0)
1419 result += "\tAdministrator(s): ";
1420 TIter it(fxsAdmins);
1421 TObjString* anAdmin;
1422 while ((anAdmin = (TObjString*) it.Next()))
1424 result += Form("%s ", anAdmin->String().Data());
1430 result += "------------------------------------------------------\n";
1431 result += "MonaLisa configuration\n\n";
1433 result += Form("\tHost: %s; \tTable name: %s",
1434 fMonitorHost.Data(), fMonitorTable.Data());
1438 TString optStr(option);
1440 result += "------------------------------------------------------\n";
1441 result += "Detector-specific configuration\n\n";
1443 TIter iter(fDetectorMap.GetTable());
1446 while ((aPair = (TPair*) iter.Next())) {
1447 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) aPair->Value();
1448 if (optStr != "" && !optStr.Contains(aHolder->GetDetector()) &&
1449 optStr.CompareTo("uncompact",TString::kIgnoreCase) != 0 )
1452 result += Form("*** %s *** \n", aHolder->GetDetector());
1454 const TObjArray* responsibles = aHolder->GetResponsibles();
1455 if (responsibles->GetEntries() != 0)
1457 result += "\tDetector responsible(s): ";
1458 TIter it(responsibles);
1459 TObjString* aResponsible;
1460 while ((aResponsible = (TObjString*) it.Next()))
1462 result += Form("%s ", aResponsible->String().Data());
1467 result += Form("\tStrict run ordering: %s \n\n", aHolder->StrictRunOrder() ? "YES" : "NO");
1469 const TObjArray* dcsConfig = aHolder->GetDCSConfig();
1471 AliShuttleDCSConfigHolder* dcsHolder = 0;
1472 TIter dcsIter(dcsConfig);
1474 while ((dcsHolder = dynamic_cast<AliShuttleDCSConfigHolder*> (dcsIter.Next())))
1476 result += Form("\tAmanda server [%d]: %s:%d - MultiSplit = %d\n", count,
1477 dcsHolder->GetDCSHost(), dcsHolder->GetDCSPort(), dcsHolder->GetMultiSplit());
1479 const TObjArray* aliases = 0;
1480 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1482 aliases = dcsHolder->GetDCSAliases();
1484 aliases = dcsHolder->GetCompactDCSAliases();
1487 if (aliases->GetEntries() != 0)
1489 result += Form("\tDCS Aliases [%d]: ", count);
1491 TObjString* anAlias;
1492 while ((anAlias = (TObjString*) it.Next()))
1494 result += Form("%s ", anAlias->String().Data());
1499 const TObjArray* dataPoints = 0;
1500 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1502 dataPoints = dcsHolder->GetDCSDataPoints();
1504 dataPoints = dcsHolder->GetCompactDCSDataPoints();
1506 if (dataPoints->GetEntries() != 0)
1508 result += Form("\tDCS Data Points [%d]: ", count);
1509 TIter it(dataPoints);
1510 TObjString* aDataPoint;
1511 while ((aDataPoint = (TObjString*) it.Next())) {
1512 result += Form("%s ", aDataPoint->String().Data());
1520 if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n";