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).
178 #include <Riostream.h>
179 #include "AliShuttleConfig.h"
180 #include "AliShuttleInterface.h"
185 #include <TObjString.h>
186 #include <TLDAPResult.h>
187 #include <TLDAPEntry.h>
188 #include <TLDAPAttribute.h>
192 AliShuttleConfig::AliShuttleDCSConfigHolder::AliShuttleDCSConfigHolder(const TLDAPEntry* entry):
199 fDCSDataPointsComp(0),
202 // constructor of the shuttle DCS configuration holder
204 TLDAPAttribute* anAttribute;
205 fDCSAliases = new TObjArray();
206 fDCSAliases->SetOwner(1);
207 fDCSDataPoints = new TObjArray();
208 fDCSDataPoints->SetOwner(1);
209 fDCSAliasesComp = new TObjArray();
210 fDCSAliasesComp->SetOwner(1);
211 fDCSDataPointsComp = new TObjArray();
212 fDCSDataPointsComp->SetOwner(1);
215 anAttribute = entry->GetAttribute("dcsHost");
218 AliError("Unexpected: no DCS host!");
222 fDCSHost = anAttribute->GetValue();
224 anAttribute = entry->GetAttribute("dcsPort");
227 AliError("Unexpected: no DCS port!");
230 TString portStr = anAttribute->GetValue();
231 fDCSPort = portStr.Atoi();
233 anAttribute = entry->GetAttribute("multiSplit"); // MAY
236 TString multiSplitStr = anAttribute->GetValue();
237 fMultiSplit = multiSplitStr.Atoi();
238 if(fMultiSplit == 0) {
239 AliError("MultiSplit must be a positive integer!");
245 anAttribute = entry->GetAttribute("dcsAlias"); // MAY
249 while ((anAlias = anAttribute->GetValue()))
251 fDCSAliasesComp->AddLast(new TObjString(anAlias));
252 ExpandAndAdd(fDCSAliases, anAlias);
256 anAttribute = entry->GetAttribute("dcsDP"); // MAY
259 const char* aDataPoint;
260 while ((aDataPoint = anAttribute->GetValue()))
262 fDCSDataPointsComp->AddLast(new TObjString(aDataPoint));
263 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):
540 fTerminateFilePath(""),
551 fShuttleFileSystem("/"),
552 fFreeDiskWarningThreshold(20),
553 fFreeDiskFatalThreshold(10),
558 fShuttleInstanceHost(""),
559 fProcessedDetectors(),
561 fKeepTempFolder(kFALSE),
568 // host: ldap server host
569 // port: ldap server port
570 // binddn: binddn used for ldap binding (simple bind is used!).
571 // password: password for binddn
572 // basedn: this is basedn whose childeren entries which have
575 fDetectorMap.SetOwner(1);
576 fDetectorList.SetOwner(0); //fDetectorList and fDetectorMap share the same object!
577 fProcessedDetectors.SetOwner();
579 for (int i=0; i<6; i++)
581 fAdmin[i] = new TObjArray();
582 fAdmin[i]->SetOwner();
585 TLDAPServer aServer(host, port, binddn, password, 3);
587 if (!aServer.IsConnected()) {
588 AliError(Form("Can't connect to ldap server %s:%d",
593 // reads configuration for the shuttle running on this machine
595 TLDAPResult* aResult = 0;
596 TLDAPEntry* anEntry = 0;
603 globalList.SetOwner(1);
607 hostList.SetOwner(1);
609 aResult = aServer.Search(basedn, LDAP_SCOPE_SUBTREE, 0, 0);
613 AliError(Form("Can't find configuration with base DN: %s !", basedn));
617 while ((anEntry = aResult->GetNext()))
619 TString dn = anEntry->GetDn();
621 if (dn.BeginsWith("dcsHost="))
623 dcsList.Add(anEntry);
625 else if (dn.BeginsWith("det="))
627 detList.Add(anEntry);
629 else if (dn.BeginsWith("name=globalConfig"))
631 globalList.Add(anEntry);
633 else if (dn.BeginsWith("system="))
635 sysList.Add(anEntry);
637 else if (dn.BeginsWith("shuttleHost="))
639 hostList.Add(anEntry);
651 result += SetGlobalConfig(&globalList);
652 result += SetSysConfig(&sysList);
653 result += SetPasswords();
654 result += SetDetConfig(&detList,&dcsList);
655 result += SetHostConfig(&hostList);
659 AliError("Configuration is INVALID!");
667 //______________________________________________________________________________________________
668 AliShuttleConfig::~AliShuttleConfig()
672 fDetectorMap.DeleteAll();
673 fDetectorList.Clear();
674 fProcessedDetectors.Delete();
677 //______________________________________________________________________________________________
678 const TObjArray* AliShuttleConfig::GetDetectors() const
681 // returns collection of TObjString which contains the name
682 // of every detector which is in the configuration.
685 return &fDetectorList;
688 //______________________________________________________________________________________________
689 Bool_t AliShuttleConfig::HasDetector(const char* detector) const
692 // checks for paricular detector in the configuration.
694 return fDetectorMap.GetValue(detector) != NULL;
697 //______________________________________________________________________________________________
698 Int_t AliShuttleConfig::GetNServers(const char* detector) const
701 // returns number of DCS servers for detector
704 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
706 AliError(Form("There isn't configuration for detector: %s",
711 return aHolder->GetNServers();
715 //______________________________________________________________________________________________
716 const char* AliShuttleConfig::GetDCSHost(const char* detector, Int_t iServ) const
719 // returns i-th DCS server host used by particular detector
722 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
724 AliError(Form("There isn't configuration for detector: %s",
729 return aHolder->GetDCSHost(iServ);
732 //______________________________________________________________________________________________
733 Int_t AliShuttleConfig::GetDCSPort(const char* detector, Int_t iServ) const
736 // returns i-th DCS server port used by particular detector
740 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
742 AliError(Form("There isn't configuration for detector: %s",
747 return aHolder->GetDCSPort(iServ);
750 //______________________________________________________________________________________________
751 Int_t AliShuttleConfig::GetMultiSplit(const char* detector, Int_t iServ) const
754 // returns i-th DCS "multi split" value
758 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
760 AliError(Form("There isn't configuration for detector: %s",
765 return aHolder->GetMultiSplit(iServ);
768 //______________________________________________________________________________________________
769 const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector, Int_t iServ) const
772 // returns collection of TObjString which represents the i-th set of aliases
773 // which used for data retrieval for particular detector
776 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
778 AliError(Form("There isn't configuration for detector: %s",
783 return aHolder->GetDCSAliases(iServ);
786 //______________________________________________________________________________________________
787 const TObjArray* AliShuttleConfig::GetDCSDataPoints(const char* detector, Int_t iServ) const
790 // returns collection of TObjString which represents the set of aliases
791 // which used for data retrieval for particular detector
794 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
796 AliError(Form("There isn't configuration for detector: %s",
801 return aHolder->GetDCSDataPoints(iServ);
804 //______________________________________________________________________________________________
805 const TObjArray* AliShuttleConfig::GetCompactDCSAliases(const char* detector, Int_t iServ) const
808 // returns collection of TObjString which represents the i-th set of aliases
809 // which used for data retrieval for particular detector (Compact style)
812 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
814 AliError(Form("There isn't configuration for detector: %s",
819 return aHolder->GetCompactDCSAliases(iServ);
822 //______________________________________________________________________________________________
823 const TObjArray* AliShuttleConfig::GetCompactDCSDataPoints(const char* detector, Int_t iServ) const
826 // returns collection of TObjString which represents the set of aliases
827 // which used for data retrieval for particular detector (Compact style)
830 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
832 AliError(Form("There isn't configuration for detector: %s",
837 return aHolder->GetCompactDCSDataPoints(iServ);
840 //______________________________________________________________________________________________
841 const TObjArray* AliShuttleConfig::GetResponsibles(const char* detector) const
844 // returns collection of TObjString which represents the list of mail addresses
845 // of the detector's responsible(s)
848 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
850 AliError(Form("There isn't configuration for detector: %s",
855 return aHolder->GetResponsibles();
858 //______________________________________________________________________________________________
859 const TObjArray* AliShuttleConfig::GetAdmins(Int_t sys) const
862 // returns collection of TObjString which represents the list of mail addresses
863 // of the system's administrator(s) (DAQ, DCS, HLT, Global, Amanda, DQM)
866 if (sys < 0 || sys > 5) return 0;
870 //______________________________________________________________________________________________
871 Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
873 // return TRUE if detector is handled by host or if fProcessAll is TRUE
875 if(fProcessAll) return kTRUE;
876 TIter iter(&fProcessedDetectors);
878 while((detName = (TObjString*) iter.Next())){
879 if(detName->String() == detector) return kTRUE;
884 //______________________________________________________________________________________________
885 Bool_t AliShuttleConfig::StrictRunOrder(const char* detector) const
887 // return TRUE if detector wants strict run ordering of stored data
889 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
892 AliError(Form("There isn't configuration for detector: %s",
897 return aHolder->StrictRunOrder();
900 //______________________________________________________________________________________________
901 UInt_t AliShuttleConfig::SetGlobalConfig(TList* list)
903 // Set the global configuration (DAQ Logbook + preprocessor monitoring settings)
906 TLDAPEntry* anEntry = 0;
907 TLDAPAttribute* anAttribute = 0;
909 if (list->GetEntries() == 0)
911 AliError("Global configuration not found!");
914 else if (list->GetEntries() > 1)
916 AliError("More than one global configuration found!");
920 anEntry = dynamic_cast<TLDAPEntry*> (list->At(0));
924 AliError("Unexpected! Global list does not contain a TLDAPEntry");
929 anAttribute = anEntry->GetAttribute("AlienPath");
931 AliError("Can't find AlienPath attribute!");
934 fAlienPath = anAttribute->GetValue();
936 anAttribute = anEntry->GetAttribute("daqLbHost");
938 AliError("Can't find daqLbHost attribute!");
941 fDAQlbHost = anAttribute->GetValue();
943 anAttribute = anEntry->GetAttribute("daqLbPort"); // MAY
946 fDAQlbPort = ((TString) anAttribute->GetValue()).Atoi();
948 fDAQlbPort = 3306; // mysql
951 anAttribute = anEntry->GetAttribute("daqLbUser");
953 AliError("Can't find daqLbUser attribute!");
956 fDAQlbUser = anAttribute->GetValue();
958 anAttribute = anEntry->GetAttribute("daqLbDB");
960 AliError("Can't find daqLbDB attribute!");
963 fDAQlbDB = anAttribute->GetValue();
965 anAttribute = anEntry->GetAttribute("daqLbTable");
967 AliError("Can't find daqLbTable attribute!");
970 fDAQlbTable = anAttribute->GetValue();
972 anAttribute = anEntry->GetAttribute("shuttleLbTable");
974 AliError("Can't find shuttleLbTable attribute!");
977 fShuttlelbTable = anAttribute->GetValue();
979 anAttribute = anEntry->GetAttribute("runTypeLbTable");
981 AliError("Can't find runTypeLbTable attribute!");
984 fRunTypelbTable = anAttribute->GetValue();
986 anAttribute = anEntry->GetAttribute("ppmaxRetries");
988 AliError("Can't find ppmaxRetries attribute!");
991 TString tmpStr = anAttribute->GetValue();
992 fMaxRetries = tmpStr.Atoi();
994 anAttribute = anEntry->GetAttribute("terminateFilePath");
996 fTerminateFilePath = anAttribute->GetValue();
999 anAttribute = anEntry->GetAttribute("ppTimeOut");
1001 AliError("Can't find ppTimeOut attribute!");
1004 tmpStr = anAttribute->GetValue();
1005 fPPTimeOut = tmpStr.Atoi();
1007 anAttribute = anEntry->GetAttribute("dcsTimeOut");
1009 AliError("Can't find dcsTimeOut attribute!");
1012 tmpStr = anAttribute->GetValue();
1013 fDCSTimeOut = tmpStr.Atoi();
1015 anAttribute = anEntry->GetAttribute("nDCSretries");
1017 AliError("Can't find dcsTimeOut attribute!");
1020 tmpStr = anAttribute->GetValue();
1021 fDCSRetries = tmpStr.Atoi();
1023 anAttribute = anEntry->GetAttribute("DCSQueryOffset");
1025 AliError("Can't find DCSQueryOffset attribute!");
1028 tmpStr = anAttribute->GetValue();
1029 fDCSQueryOffset = tmpStr.Atoi();
1031 anAttribute = anEntry->GetAttribute("DCSDelay");
1033 AliError("Can't find DCSDelay attribute!");
1036 tmpStr = anAttribute->GetValue();
1037 fDCSDelay = tmpStr.Atoi();
1039 anAttribute = anEntry->GetAttribute("ppMaxMem");
1041 AliError("Can't find ppMaxMem attribute!");
1044 tmpStr = anAttribute->GetValue();
1045 fPPMaxMem = tmpStr.Atoi();
1047 anAttribute = anEntry->GetAttribute("monitorHost");
1049 AliError("Can't find monitorHost attribute!");
1052 fMonitorHost = anAttribute->GetValue();
1054 anAttribute = anEntry->GetAttribute("monitorTable");
1056 AliError("Can't find monitorTable attribute!");
1059 fMonitorTable = anAttribute->GetValue();
1061 anAttribute = anEntry->GetAttribute("triggerWait"); // MAY
1063 AliWarning(Form("triggerWait not set! default = %d", fTriggerWait));
1065 tmpStr = anAttribute->GetValue();
1066 fTriggerWait = tmpStr.Atoi();
1068 anAttribute = anEntry->GetAttribute("ShuttleFileSystem");
1070 AliWarning(Form("ShuttleFileSystem not set! default = %s", fShuttleFileSystem.Data()));
1072 fShuttleFileSystem = anAttribute->GetValue();
1074 anAttribute = anEntry->GetAttribute("FreeDiskWarningThreshold"); // MAY
1076 AliWarning(Form("FreeDiskWarningThreshold not set! default = %d", fFreeDiskWarningThreshold));
1078 tmpStr = anAttribute->GetValue();
1079 fFreeDiskWarningThreshold = tmpStr.Atoi();
1081 anAttribute = anEntry->GetAttribute("FreeDiskFatalThreshold"); // MAY
1083 AliWarning(Form("FreeDiskFatalThreshold not set! default = %d", fFreeDiskFatalThreshold));
1085 tmpStr = anAttribute->GetValue();
1086 fFreeDiskFatalThreshold = tmpStr.Atoi();
1088 anAttribute = anEntry->GetAttribute("mode");
1090 AliWarning("Run mode not set! Running in test mode.");
1092 tmpStr = anAttribute->GetValue();
1093 if (tmpStr == "test")
1096 } else if (tmpStr == "prod") {
1099 AliWarning(Form("Not a valid run mode: %s", tmpStr.Data()));
1100 AliWarning("Valid run modes are \"test\" and \"prod\". Running in test mode.");
1104 anAttribute = anEntry->GetAttribute("keepDCSMap"); // MAY
1107 AliWarning("keepDCSMap flag not set - default is FALSE");
1109 TString keepDCSMapStr = anAttribute->GetValue();
1110 if (!(keepDCSMapStr == "0" || keepDCSMapStr == "1"))
1112 AliError("keepDCSMap flag must be 0 or 1!");
1115 fKeepDCSMap = (Bool_t) keepDCSMapStr.Atoi();
1118 anAttribute = anEntry->GetAttribute("keepTempFolder"); // MAY
1121 AliWarning("keepTempFolder flag not set - default is FALSE");
1123 TString keepTempFolderStr = anAttribute->GetValue();
1124 if (!(keepTempFolderStr == "0" || keepTempFolderStr == "1"))
1126 AliError("keepTempFolder flag must be 0 or 1!");
1129 fKeepTempFolder = (Bool_t) keepTempFolderStr.Atoi();
1133 anAttribute = anEntry->GetAttribute("shuttleAdmin"); // MAY
1136 AliDebug(2, "Warning! No \"shuttleAdmin\" attribute!");
1140 const char* anAdmin;
1141 while ((anAdmin = anAttribute->GetValue()))
1143 fAdmin[kGlobal]->AddLast(new TObjString(anAdmin));
1147 anAttribute = anEntry->GetAttribute("amandaAdmin"); // MAY
1150 AliDebug(2, "Warning! No \"amandaAdmin\" attribute!");
1154 const char* anAdmin;
1155 while ((anAdmin = anAttribute->GetValue()))
1157 fAdmin[kAmanda]->AddLast(new TObjString(anAdmin));
1161 anAttribute = anEntry->GetAttribute("sendMail"); // MAY
1164 AliWarning("sendMail flag not set - default is FALSE");
1166 TString sendMailStr = anAttribute->GetValue();
1167 if (!(sendMailStr == "0" || sendMailStr == "1"))
1169 AliError("sendMail flag must be 0 or 1!");
1172 fSendMail = (Bool_t) sendMailStr.Atoi();
1175 anAttribute = anEntry->GetAttribute("passwdFilePath");
1177 AliError("Can't find Passwords File Path attribute!");
1180 fPasswdFilePath = anAttribute->GetValue();
1185 //______________________________________________________________________________________________
1186 UInt_t AliShuttleConfig::SetSysConfig(TList* list)
1188 // Set the online FXS configuration (DAQ + DCS + HLT + DQM)
1191 TLDAPEntry* anEntry = 0;
1192 TLDAPAttribute* anAttribute = 0;
1194 if (list->GetEntries() != 4)
1196 AliError(Form("Wrong number of online systems found: %d !", list->GetEntries()));
1202 SystemCode iSys=kDAQ;
1204 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1206 anAttribute = anEntry->GetAttribute("system");
1207 TString sysName = anAttribute->GetValue();
1209 if (sysName == "DAQ")
1214 else if (sysName == "DCS")
1219 else if (sysName == "HLT")
1224 else if (sysName == "DQM")
1230 anAttribute = anEntry->GetAttribute("dbHost");
1232 AliError(Form ("Can't find dbHost attribute for %s!!",
1233 AliShuttleInterface::GetSystemName(iSys)));
1236 fFXSdbHost[iSys] = anAttribute->GetValue();
1238 anAttribute = anEntry->GetAttribute("dbPort"); // MAY
1241 fFXSdbPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1243 fFXSdbPort[iSys] = 3306; // mysql
1246 anAttribute = anEntry->GetAttribute("dbUser");
1248 AliError(Form ("Can't find dbUser attribute for %s!!",
1249 AliShuttleInterface::GetSystemName(iSys)));
1252 fFXSdbUser[iSys] = anAttribute->GetValue();
1254 anAttribute = anEntry->GetAttribute("dbName");
1256 AliError(Form ("Can't find dbName attribute for %s!!",
1257 AliShuttleInterface::GetSystemName(iSys)));
1261 fFXSdbName[iSys] = anAttribute->GetValue();
1262 anAttribute = anEntry->GetAttribute("dbTable");
1264 AliError(Form ("Can't find dbTable attribute for %s!!",
1265 AliShuttleInterface::GetSystemName(iSys)));
1268 fFXSdbTable[iSys] = anAttribute->GetValue();
1270 anAttribute = anEntry->GetAttribute("fxsHost");
1272 AliError(Form ("Can't find fxsHost attribute for %s!!",
1273 AliShuttleInterface::GetSystemName(iSys)));
1276 fFXSHost[iSys] = anAttribute->GetValue();
1278 anAttribute = anEntry->GetAttribute("fxsPort"); // MAY
1281 fFXSPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1283 fFXSPort[iSys] = 22; // scp port number
1286 anAttribute = anEntry->GetAttribute("fxsUser");
1288 AliError(Form ("Can't find fxsUser attribute for %s!!",
1289 AliShuttleInterface::GetSystemName(iSys)));
1292 fFXSUser[iSys] = anAttribute->GetValue();
1294 anAttribute = anEntry->GetAttribute("fxsPasswd");
1295 if (anAttribute) fFXSPass[iSys] = anAttribute->GetValue();
1297 anAttribute = anEntry->GetAttribute("fxsBaseFolder");
1298 if (anAttribute) fFXSBaseFolder[iSys] = anAttribute->GetValue();
1300 anAttribute = anEntry->GetAttribute("fxsAdmin"); // MAY
1303 AliDebug(2, "Warning! No \"fxsAdmin\" attribute!");
1307 const char* anAdmin;
1308 while ((anAdmin = anAttribute->GetValue()))
1310 fAdmin[iSys]->AddLast(new TObjString(anAdmin));
1317 AliError(Form("Wrong system configuration! (code = %d)", count));
1324 //______________________________________________________________________________________________
1325 UInt_t AliShuttleConfig::SetPasswords(){
1327 AliInfo("Setting Passwords");
1329 // Retrieving Passwords for DAQ lb, DAQ/DCS/HLT/DQM FXS
1331 ifstream *inputfile = new ifstream(fPasswdFilePath.Data());
1333 AliError(Form("Error opening file %s !", fPasswdFilePath.Data()));
1342 while (line.ReadLine(*inputfile)) {
1343 TObjArray *tokens = line.Tokenize(" \t");
1344 TString system = ((TObjString *)tokens->At(0))->String();
1345 TString password = ((TObjString *)tokens->At(1))->String();
1346 if (system.Contains("DAQ_LB")){
1347 fDAQlbPass=password;
1349 AliDebug(3,Form("DAQ_LB: Password %s for %s found", password.Data(), system.Data()));
1351 else if (system.Contains("DAQ_DB")){
1352 fFXSdbPass[0]=password;
1354 AliDebug(3,Form("DAQ_DB: Password %s for %s found", password.Data(), system.Data()));
1356 else if (system.Contains("DCS_DB")){
1357 fFXSdbPass[1]=password;
1359 AliDebug(3,Form("DCS_DB: Password %s for %s found", password.Data(), system.Data()));
1361 else if (system.Contains("HLT_DB")){
1362 fFXSdbPass[2]=password;
1364 AliDebug(3,Form("HLT_DB: Password %s for %s found", password.Data(), system.Data()));
1366 else if (system.Contains("DQM_DB")){
1367 fFXSdbPass[3]=password;
1369 AliDebug(3,Form("DQM_DB: Password %s for %s found", password.Data(), system.Data()));
1373 AliDebug(3,Form("%i fake line(s) found in file %s", nPwdFake, fPasswdFilePath.Data()));
1383 AliError(Form("Wrong file for DAQ Logbook password found %s (some passwors missing), please Check!", fPasswdFilePath.Data()));
1390 //______________________________________________________________________________________________
1391 UInt_t AliShuttleConfig::SetDetConfig(TList* detList, TList* dcsList)
1393 // Set the detector configuration (general settings + DCS amanda server and alias/DP lists)
1395 TLDAPEntry* anEntry = 0;
1397 TIter iter(detList);
1398 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1401 AliShuttleDetConfigHolder* detHolder = new AliShuttleDetConfigHolder(anEntry);
1403 if (!detHolder->IsValid()) {
1404 AliError("Detector configuration error!");
1409 TObjString* detStr = new TObjString(detHolder->GetDetector());
1411 // Look for DCS Configuration
1412 TIter dcsIter(dcsList);
1413 TLDAPEntry *dcsEntry = 0;
1414 while ((dcsEntry = dynamic_cast<TLDAPEntry*> (dcsIter.Next())))
1416 TString dn = dcsEntry->GetDn();
1417 if(dn.Contains(detStr->GetName())) {
1418 AliDebug(2, Form("Found DCS configuration: dn = %s",dn.Data()));
1419 AliShuttleDCSConfigHolder* dcsHolder = new AliShuttleDCSConfigHolder(dcsEntry);
1420 if (!dcsHolder->IsValid()) {
1421 AliError("DCS configuration error!");
1426 detHolder->AddDCSConfig(dcsHolder);
1431 fDetectorMap.Add(detStr, detHolder);
1432 fDetectorList.AddLast(detStr);
1438 //______________________________________________________________________________________________
1439 UInt_t AliShuttleConfig::SetHostConfig(TList* list)
1441 // Set the Shuttle machines configuration (which detectors processes each machine)
1443 TLDAPEntry* anEntry = 0;
1444 TLDAPAttribute* anAttribute = 0;
1446 fShuttleInstanceHost = gSystem->HostName();
1449 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1452 TString dn(anEntry->GetDn());
1453 if (!dn.Contains(Form("shuttleHost=%s", fShuttleInstanceHost.Data()))) continue;
1457 anAttribute = anEntry->GetAttribute("detectors");
1458 const char *detName;
1459 while((detName = anAttribute->GetValue())){
1460 TObjString *objDet= new TObjString(detName);
1461 fProcessedDetectors.Add(objDet);
1470 //______________________________________________________________________________________________
1471 void AliShuttleConfig::Print(Option_t* option) const
1473 // print configuration
1474 // options : "": print configuration for all detectors, aliases and DPs in compacted format
1475 // "uncompact": print configuration for all detectors, aliases and DPs in uncompacted format
1476 // "DET": print configuration for DET, aliases and DPs in compacted format
1477 // "DET, uncompact": print configuration for DET, aliases and DPs in uncompacted format
1482 TString mode = "test";
1483 if (fRunMode == kProd) mode = "production";
1485 result += "########################################################################\n";
1486 result += Form(" Shuttle configuration from %s - Run Mode: <%s> \n",
1487 fConfigHost.Data(), mode.Data());
1488 result += "########################################################################\n";
1489 result += Form("\nShuttle running on %s \n", fShuttleInstanceHost.Data());
1492 result += Form("All detectors will be processed! \n");
1494 result += "Detectors processed by this host: ";
1495 TIter it(&fProcessedDetectors);
1497 while ((aDet = (TObjString*) it.Next())) {
1498 result += Form("%s ", aDet->String().Data());
1503 result += Form("PP time out = %d - DCS time out = %d - max PP mem size = %d KB - max retries = %d "
1504 "- DIM trigger waiting timeout = %d\n",
1505 fPPTimeOut, fDCSTimeOut, fPPMaxMem, fMaxRetries, fTriggerWait);
1506 result += Form("FLAGS: keepDCSMap = %d - keepTempFolder = %d - SendMail = %d \n",
1507 fKeepDCSMap, fKeepTempFolder, fSendMail);
1508 const TObjArray* shuttleAdmins = GetAdmins(kGlobal);
1509 if (shuttleAdmins->GetEntries() != 0)
1511 result += "SHUTTLE administrator(s): ";
1512 TIter it(shuttleAdmins);
1513 TObjString* anAdmin;
1514 while ((anAdmin = (TObjString*) it.Next()))
1516 result += Form("%s ", anAdmin->String().Data());
1520 const TObjArray* amandaAdmins = GetAdmins(kAmanda);
1521 if (amandaAdmins->GetEntries() != 0)
1523 result += "Amanda server administrator(s): ";
1524 TIter it(amandaAdmins);
1525 TObjString* anAdmin;
1526 while ((anAdmin = (TObjString*) it.Next()))
1528 result += Form("%s ", anAdmin->String().Data());
1532 result += "------------------------------------------------------\n";
1534 result += Form("Logbook Configuration \n\n \tHost: %s:%d; \tUser: %s; ",
1535 fDAQlbHost.Data(), fDAQlbPort, fDAQlbUser.Data());
1537 result += Form("\tDB: %s; \tTables: %s, %s, %s\n",
1538 fDAQlbDB.Data(), fDAQlbTable.Data(), fShuttlelbTable.Data(), fRunTypelbTable.Data());
1540 result += Form("Terminate file path: %s\n", fTerminateFilePath.Data());
1544 result += "------------------------------------------------------\n";
1545 result += "FXS configuration\n\n";
1547 for(int iSys=0;iSys<4;iSys++){
1548 result += Form("*** %s ***\n", AliShuttleInterface::GetSystemName(iSys));
1549 result += Form("\tDB host: %s:%d; \tUser: %s; \tName: %s; \tTable: %s\n",
1550 fFXSdbHost[iSys].Data(), fFXSdbPort[iSys], fFXSdbUser[iSys].Data(),
1551 fFXSdbName[iSys].Data(), fFXSdbTable[iSys].Data());
1552 result += Form("\tFXS host: %s:%d; \tUser: %s\n", fFXSHost[iSys].Data(), fFXSPort[iSys],
1553 fFXSUser[iSys].Data());
1554 const TObjArray* fxsAdmins = GetAdmins(iSys);
1555 if (fxsAdmins->GetEntries() != 0)
1557 result += "\tAdministrator(s): ";
1558 TIter it(fxsAdmins);
1559 TObjString* anAdmin;
1560 while ((anAdmin = (TObjString*) it.Next()))
1562 result += Form("%s ", anAdmin->String().Data());
1568 result += "------------------------------------------------------\n";
1569 result += "MonaLisa configuration\n\n";
1571 result += Form("\tHost: %s; \tTable name: %s",
1572 fMonitorHost.Data(), fMonitorTable.Data());
1576 TString optStr(option);
1578 result += "------------------------------------------------------\n";
1579 result += "Detector-specific configuration\n\n";
1581 TIter iter(fDetectorMap.GetTable());
1584 while ((aPair = (TPair*) iter.Next())) {
1585 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) aPair->Value();
1586 if (optStr != "" && !optStr.Contains(aHolder->GetDetector()) &&
1587 optStr.CompareTo("uncompact",TString::kIgnoreCase) != 0 )
1590 result += Form("*** %s *** \n", aHolder->GetDetector());
1592 const TObjArray* responsibles = aHolder->GetResponsibles();
1593 if (responsibles->GetEntries() != 0)
1595 result += "\tDetector responsible(s): ";
1596 TIter it(responsibles);
1597 TObjString* aResponsible;
1598 while ((aResponsible = (TObjString*) it.Next()))
1600 result += Form("%s ", aResponsible->String().Data());
1605 result += Form("\tStrict run ordering: %s \n\n", aHolder->StrictRunOrder() ? "YES" : "NO");
1607 const TObjArray* dcsConfig = aHolder->GetDCSConfig();
1609 AliShuttleDCSConfigHolder* dcsHolder = 0;
1610 TIter dcsIter(dcsConfig);
1612 while ((dcsHolder = dynamic_cast<AliShuttleDCSConfigHolder*> (dcsIter.Next())))
1614 result += Form("\tAmanda server [%d]: %s:%d - MultiSplit = %d\n", count,
1615 dcsHolder->GetDCSHost(), dcsHolder->GetDCSPort(), dcsHolder->GetMultiSplit());
1617 const TObjArray* aliases = 0;
1618 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1620 aliases = dcsHolder->GetDCSAliases();
1622 aliases = dcsHolder->GetCompactDCSAliases();
1625 if (aliases->GetEntries() != 0)
1627 result += Form("\tDCS Aliases [%d]: ", count);
1629 TObjString* anAlias;
1630 while ((anAlias = (TObjString*) it.Next()))
1632 result += Form("%s ", anAlias->String().Data());
1637 const TObjArray* dataPoints = 0;
1638 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1640 dataPoints = dcsHolder->GetDCSDataPoints();
1642 dataPoints = dcsHolder->GetCompactDCSDataPoints();
1644 if (dataPoints->GetEntries() != 0)
1646 result += Form("\tDCS Data Points [%d]: ", count);
1647 TIter it(dataPoints);
1648 TObjString* aDataPoint;
1649 while ((aDataPoint = (TObjString*) it.Next())) {
1650 result += Form("%s ", aDataPoint->String().Data());
1658 if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n";