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