Warnings suppressed
[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];
309 fFXSdbHost[i]=other.fFXSdbHost[i];
310 fFXSdbPort[i]=other.fFXSdbPort[i];
311 fFXSdbUser[i]=other.fFXSdbUser[i];
312 fFXSdbPass[i]=other.fFXSdbPass[i];
313 fFXSdbName[i]=other.fFXSdbName[i];
314 fFXSdbTable[i]=other.fFXSdbTable[i];
315 }
316 for (Int_t i = 0; i<5; i++){
317 fAdmin[i] = new TObjArray();
318 fAdmin[i]->AddAt(other.fAdmin[i]->At(i),i);
319 }
320
321 TIter iter((other.fDetectorMap).GetTable());
322 TPair* aPair = 0;
323
324 while ((aPair = (TPair*) iter.Next())) {
325 AliShuttleDetConfigHolder *holder =(AliShuttleDetConfigHolder *)aPair->Value();
326 TKey *key = (TKey*)aPair->Key();
327 fDetectorMap.Add(key,holder);
328 }
329
330
331}
332//_____________________________________________________________________________________________
333AliShuttleConfig& AliShuttleConfig::operator=(const AliShuttleConfig &other)
334{
335 //
336 //assignment operator
337 //
338 this->fConfigHost=other.fConfigHost;
339 this->fDAQlbHost=other.fDAQlbHost;
340 this->fDAQlbPort=other.fDAQlbPort;
341 this->fDAQlbUser=other.fDAQlbUser;
342 this->fDAQlbPass=other.fDAQlbPass;
343 this->fDAQlbDB=other.fDAQlbDB;
344 this->fDAQlbTable=other.fDAQlbTable;
345 this->fShuttlelbTable=other.fShuttlelbTable;
346 this->fRunTypelbTable=other.fRunTypelbTable;
347 this->fMaxRetries=other.fMaxRetries;
348 this->fPPTimeOut=other.fPPTimeOut;
349 this->fDCSTimeOut=other.fDCSTimeOut;
350 this->fDCSRetries=other.fDCSRetries;
351 this->fPPMaxMem=other.fPPMaxMem;
352 this->fMonitorHost=other.fMonitorHost;
353 this->fMonitorTable=other.fMonitorTable;
354 this->fTriggerWait=other.fTriggerWait;
355 this->fRunMode=other.fRunMode;
356 this->fDetectorList=other.fDetectorList;
357 this->fShuttleInstanceHost=other.fShuttleInstanceHost;
358 this->fProcessedDetectors=other.fProcessedDetectors;
359 this->fKeepDCSMap=other.fKeepDCSMap;
360 this->fKeepTempFolder=other.fKeepTempFolder;
361 this->fSendMail=other.fSendMail;
362 this->fProcessAll=other.fProcessAll;
363 this->fIsValid=other.fIsValid;
364 for (Int_t i = 0; i<3; i++){
365 this->fFXSHost[i]=other.fFXSHost[i];
366 this->fFXSPort[i]=other.fFXSPort[i];
367 this->fFXSUser[i]=other.fFXSUser[i];
368 this->fFXSPass[i]=other.fFXSPass[i];
369 this->fFXSdbHost[i]=other.fFXSdbHost[i];
370 this->fFXSdbPort[i]=other.fFXSdbPort[i];
371 this->fFXSdbUser[i]=other.fFXSdbUser[i];
372 this->fFXSdbPass[i]=other.fFXSdbPass[i];
373 this->fFXSdbName[i]=other.fFXSdbName[i];
374 this->fFXSdbTable[i]=other.fFXSdbTable[i];
375 }
376 for (Int_t i = 0; i<5; i++){
377 this->fAdmin[i] = new TObjArray();
378 this->fAdmin[i]->AddAt(other.fAdmin[i]->At(i),i);
379 }
380
381 TIter iter((other.fDetectorMap).GetTable());
382 TPair* aPair = 0;
383
384 while ((aPair = (TPair*) iter.Next())) {
385 AliShuttleDetConfigHolder *holder =(AliShuttleDetConfigHolder *)aPair->Value();
386 TKey *key = (TKey*)aPair->Key();
387 this->fDetectorMap.Add(key,holder);
388 }
389 return *this;
390}
40150741 391//______________________________________________________________________________________________
1d172743 392void AliShuttleConfig::AliShuttleDCSConfigHolder::ExpandAndAdd(TObjArray* target, const char* entry)
40150741 393{
f59d2f8f 394 //
395 // adds <entry> to <target> applying expanding of the name
396 // [N..M] creates M-N+1 names with the corresponding digits
397 //
40150741 398
f59d2f8f 399 TString entryStr(entry);
40150741 400
f59d2f8f 401 Int_t begin = entryStr.Index("[");
402 Int_t end = entryStr.Index("]");
403 if (begin != -1 && end != -1 && end > begin)
404 {
405 TString before(entryStr(0, begin));
406 TString after(entryStr(end+1, entryStr.Length()));
40150741 407
f59d2f8f 408 AliDebug(2, Form("Found [] pattern. Splitted input string %s %s", before.Data(), after.Data()));
40150741 409
f59d2f8f 410 Int_t dotdot = entryStr.Index("..");
40150741 411
f59d2f8f 412 TString nStr(entryStr(begin+1, dotdot-begin-1));
413 TString mStr(entryStr(dotdot+2, end-dotdot-2));
40150741 414
f59d2f8f 415 AliDebug(2, Form("Found [N..M] pattern. %s %s", nStr.Data(), mStr.Data()));
40150741 416
f59d2f8f 417 if (nStr.IsDigit() && mStr.IsDigit())
418 {
419 Int_t n = nStr.Atoi();
420 Int_t m = mStr.Atoi();
40150741 421
f59d2f8f 422 Int_t nDigits = nStr.Length();
423 TString formatStr;
424 formatStr.Form("%%s%%0%dd%%s", nDigits);
40150741 425
f59d2f8f 426 AliDebug(2, Form("Format string is %s", formatStr.Data()));
40150741 427
f59d2f8f 428 for (Int_t current = n; current<=m; ++current)
429 {
430 TString newEntry;
431 newEntry.Form(formatStr.Data(), before.Data(), current, after.Data());
40150741 432
f59d2f8f 433 AliDebug(2, Form("Calling recursive with %s", newEntry.Data()));
40150741 434
f59d2f8f 435 // and go recursive
436 ExpandAndAdd(target, newEntry);
437 }
40150741 438
f59d2f8f 439 // return here because we processed the entries already recursively.
440 return;
441 }
442 }
40150741 443
f59d2f8f 444 AliDebug(2, Form("Adding name %s", entry));
445 target->AddLast(new TObjString(entry));
40150741 446}
447
a7160fe9 448//______________________________________________________________________________________________
1d172743 449AliShuttleConfig::AliShuttleDCSConfigHolder::~AliShuttleDCSConfigHolder()
58bc3020 450{
451// destructor of the shuttle configuration holder
452
2bb7b766 453 delete fDCSAliases;
2c15234c 454 delete fDCSDataPoints;
1d172743 455 delete fDCSAliasesComp;
456 delete fDCSDataPointsComp;
457}
458
459//______________________________________________________________________________________________
460AliShuttleConfig::AliShuttleDetConfigHolder::AliShuttleDetConfigHolder(const TLDAPEntry* entry):
461fDetector(""),
462fDCSConfig(),
463fResponsibles(0),
464fIsValid(kFALSE),
465fSkipDCSQuery(kFALSE),
466fStrictRunOrder(kFALSE)
467{
468// constructor of the shuttle configuration holder
469
470 TLDAPAttribute* anAttribute;
471
472 fResponsibles = new TObjArray();
473 fResponsibles->SetOwner(1);
474 fDCSConfig = new TObjArray();
475 fDCSConfig->SetOwner(1);
476
477 anAttribute = entry->GetAttribute("det"); // MUST
478 if (!anAttribute)
479 {
480 AliError(Form("No \"det\" attribute!"));
481 return;
482 }
483 fDetector = anAttribute->GetValue();
484
485 anAttribute = entry->GetAttribute("strictRunOrder"); // MAY
486 if (!anAttribute)
487 {
488 AliWarning(Form("%s did not set strictRunOrder flag - the default is FALSE",
489 fDetector.Data()));
490 } else {
491 TString strictRunStr = anAttribute->GetValue();
492 if (!(strictRunStr == "0" || strictRunStr == "1"))
493 {
494 AliError("strictRunOrder flag must be 0 or 1!");
495 return;
496 }
497 fStrictRunOrder = (Bool_t) strictRunStr.Atoi();
498 }
499
500 anAttribute = entry->GetAttribute("responsible"); // MAY
501 if (!anAttribute)
502 {
503 AliDebug(2, "Warning! No \"responsible\" attribute!");
504 }
505 else
506 {
507 const char* aResponsible;
508 while ((aResponsible = anAttribute->GetValue()))
509 {
510 fResponsibles->AddLast(new TObjString(aResponsible));
511 }
512 }
513
514 fIsValid = kTRUE;
515}
516
517//______________________________________________________________________________________________
518AliShuttleConfig::AliShuttleDetConfigHolder::~AliShuttleDetConfigHolder()
519{
520// destructor of the shuttle configuration holder
521
57c1a579 522 delete fResponsibles;
1d172743 523 delete fDCSConfig;
524}
525
526//______________________________________________________________________________________________
527const char* AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSHost(Int_t iServ) const
528{
529 //
530 // returns DCS server host
531 //
532
533 if (iServ < 0 || iServ >= GetNServers()) return 0;
534
535 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
536 (fDCSConfig->At(iServ));
537
538 return aHolder->GetDCSHost();
539}
540
541//______________________________________________________________________________________________
542Int_t AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSPort(Int_t iServ) const
543{
544 //
545 // returns DCS server port
546 //
547
548 if (iServ < 0 || iServ >= GetNServers()) return 0;
549
550 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
551 (fDCSConfig->At(iServ));
552
553 return aHolder->GetDCSPort();
554}
555
542b6cc8 556//______________________________________________________________________________________________
557Int_t AliShuttleConfig::AliShuttleDetConfigHolder::GetMultiSplit(Int_t iServ) const
558{
559 //
560 // returns DCS "multi split" value
561 //
562
563 if (iServ < 0 || iServ >= GetNServers()) return 0;
564
565 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
566 (fDCSConfig->At(iServ));
567
568 return aHolder->GetMultiSplit();
569}
570
1d172743 571//______________________________________________________________________________________________
572const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSAliases(Int_t iServ) const
573{
574 //
575 // returns collection of TObjString which represents the set of aliases
576 // which used for data retrieval for particular detector
577 //
578
579 if (iServ < 0 || iServ >= GetNServers()) return 0;
580
581 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
582 (fDCSConfig->At(iServ));
583
584 return aHolder->GetDCSAliases();
585}
586
587//______________________________________________________________________________________________
588const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetDCSDataPoints(Int_t iServ) const
589{
590 //
591 // returns collection of TObjString which represents the set of aliases
592 // which used for data retrieval for particular detector
593 //
594
595 if (iServ < 0 || iServ >= GetNServers()) return 0;
596
597 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
598 (fDCSConfig->At(iServ));
599
600 return aHolder->GetDCSDataPoints();
601}
602
603//______________________________________________________________________________________________
604const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetCompactDCSAliases(Int_t iServ) const
605{
606 //
607 // returns collection of TObjString which represents the set of aliases
608 // which used for data retrieval for particular detector (Compact style)
609 //
610
611 if (iServ < 0 || iServ >= GetNServers()) return 0;
612
613 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
614 (fDCSConfig->At(iServ));
615
616 return aHolder->GetCompactDCSAliases();
617}
618
619//______________________________________________________________________________________________
620const TObjArray* AliShuttleConfig::AliShuttleDetConfigHolder::GetCompactDCSDataPoints(Int_t iServ) const
621{
622 //
623 // returns collection of TObjString which represents the set of aliases
624 // which used for data retrieval for particular detector (Compact style)
625 //
626
627 if (iServ < 0 || iServ >= GetNServers()) return 0;
628
629 AliShuttleDCSConfigHolder *aHolder = dynamic_cast<AliShuttleDCSConfigHolder *>
630 (fDCSConfig->At(iServ));
631
632 return aHolder->GetCompactDCSDataPoints();
633}
634
635//______________________________________________________________________________________________
636void AliShuttleConfig::AliShuttleDetConfigHolder::AddDCSConfig(AliShuttleDCSConfigHolder* holder)
637{
638 //
639 // adds a DCS configuration set in the array of DCS configurations
640 //
641
642 if(!holder) return;
643 fDCSConfig->AddLast(holder);
73abe331 644}
645
646ClassImp(AliShuttleConfig)
647
a7160fe9 648//______________________________________________________________________________________________
649AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
73abe331 650 const char* binddn, const char* password, const char* basedn):
1d172743 651 fConfigHost(host),
652 fDAQlbHost(""),
653 fDAQlbPort(),
654 fDAQlbUser(""),
655 fDAQlbPass(""),
656 fDAQlbDB(""),
657 fDAQlbTable(""),
658 fShuttlelbTable(""),
659 fRunTypelbTable(""),
660 fMaxRetries(0),
661 fPPTimeOut(0),
ff3781ad 662 fDCSTimeOut(0),
a18e8fa6 663 fDCSRetries(0),
1d172743 664 fPPMaxMem(0),
b832ec02 665 fMonitorHost(""),
666 fMonitorTable(""),
7d4cf768 667 fTriggerWait(3600),
668 fRunMode(kTest),
1d172743 669 fDetectorMap(),
670 fDetectorList(),
fb40ead4 671 fAdmin(),
1d172743 672 fShuttleInstanceHost(""),
673 fProcessedDetectors(),
fb40ead4 674 fKeepDCSMap(kFALSE),
675 fKeepTempFolder(kFALSE),
676 fSendMail(kFALSE),
1d172743 677 fProcessAll(kFALSE),
678 fIsValid(kFALSE)
fb40ead4 679
73abe331 680{
681 //
682 // host: ldap server host
683 // port: ldap server port
684 // binddn: binddn used for ldap binding (simple bind is used!).
685 // password: password for binddn
b948db8d 686 // basedn: this is basedn whose childeren entries which have
73abe331 687 //
688
1d172743 689 fDetectorMap.SetOwner(1);
2bb7b766 690 fDetectorList.SetOwner(0); //fDetectorList and fDetectorMap share the same object!
691 fProcessedDetectors.SetOwner();
fb40ead4 692
693 for (int i=0; i<5; i++)
694 {
695 fAdmin[i] = new TObjArray();
696 fAdmin[i]->SetOwner();
697 }
2bb7b766 698
b948db8d 699 TLDAPServer aServer(host, port, binddn, password, 3);
57f50b3c 700
73abe331 701 if (!aServer.IsConnected()) {
2bb7b766 702 AliError(Form("Can't connect to ldap server %s:%d",
73abe331 703 host, port));
704 return;
705 }
706
b948db8d 707 // reads configuration for the shuttle running on this machine
1d172743 708
709 TLDAPResult* aResult = 0;
710 TLDAPEntry* anEntry = 0;
711
712 TList dcsList;
713 dcsList.SetOwner(1);
714 TList detList;
715 detList.SetOwner(1);
716 TList globalList;
717 globalList.SetOwner(1);
718 TList sysList;
719 sysList.SetOwner(1);
720 TList hostList;
721 hostList.SetOwner(1);
722
723 aResult = aServer.Search(basedn, LDAP_SCOPE_SUBTREE, 0, 0);
724
725 if (!aResult)
726 {
727 AliError(Form("Can't find configuration with base DN: %s !", basedn));
73abe331 728 return;
729 }
1d172743 730
731 while ((anEntry = aResult->GetNext()))
732 {
733 TString dn = anEntry->GetDn();
734
735 if (dn.BeginsWith("dcsHost="))
736 {
737 dcsList.Add(anEntry);
738 }
739 else if (dn.BeginsWith("det="))
740 {
741 detList.Add(anEntry);
742 }
743 else if (dn.BeginsWith("name=globalConfig"))
744 {
745 globalList.Add(anEntry);
746 }
747 else if (dn.BeginsWith("system="))
748 {
749 sysList.Add(anEntry);
750 }
751 else if (dn.BeginsWith("shuttleHost="))
752 {
753 hostList.Add(anEntry);
754 }
755 else
756 {
757 delete anEntry;
758 }
759
b948db8d 760 }
1d172743 761 delete aResult;
762
763 Int_t result=0;
764
765 result += SetGlobalConfig(&globalList);
766 result += SetSysConfig(&sysList);
767 result += SetDetConfig(&detList,&dcsList);
768 result += SetHostConfig(&hostList);
769
770 if(result)
771 {
772 AliError("Configuration is INVALID!");
b948db8d 773 }
1d172743 774 else
775 {
776 fIsValid = kTRUE;
b948db8d 777 }
1d172743 778}
b948db8d 779
1d172743 780//______________________________________________________________________________________________
781AliShuttleConfig::~AliShuttleConfig()
782{
783// destructor
57f50b3c 784
1d172743 785 fDetectorMap.DeleteAll();
786 fDetectorList.Clear();
787 fProcessedDetectors.Delete();
fb40ead4 788
789 delete[] fAdmin;
790
1d172743 791}
b948db8d 792
1d172743 793//______________________________________________________________________________________________
794const TObjArray* AliShuttleConfig::GetDetectors() const
795{
796 //
797 // returns collection of TObjString which contains the name
798 // of every detector which is in the configuration.
799 //
57f50b3c 800
1d172743 801 return &fDetectorList;
802}
73abe331 803
1d172743 804//______________________________________________________________________________________________
805Bool_t AliShuttleConfig::HasDetector(const char* detector) const
806{
807 //
808 // checks for paricular detector in the configuration.
809 //
810 return fDetectorMap.GetValue(detector) != NULL;
811}
73abe331 812
1d172743 813//______________________________________________________________________________________________
814Int_t AliShuttleConfig::GetNServers(const char* detector) const
815{
816 //
817 // returns number of DCS servers for detector
818 //
819
820 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
821 if (!aHolder) {
822 AliError(Form("There isn't configuration for detector: %s",
823 detector));
824 return 0;
57f50b3c 825 }
826
1d172743 827 return aHolder->GetNServers();
828}
d477ad88 829
d477ad88 830
1d172743 831//______________________________________________________________________________________________
832const char* AliShuttleConfig::GetDCSHost(const char* detector, Int_t iServ) const
833{
834 //
835 // returns i-th DCS server host used by particular detector
836 //
837
838 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
839 if (!aHolder) {
840 AliError(Form("There isn't configuration for detector: %s",
841 detector));
842 return NULL;
d477ad88 843 }
844
1d172743 845 return aHolder->GetDCSHost(iServ);
846}
847
848//______________________________________________________________________________________________
849Int_t AliShuttleConfig::GetDCSPort(const char* detector, Int_t iServ) const
850{
851 //
852 // returns i-th DCS server port used by particular detector
853 //
854
855
856 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
857 if (!aHolder) {
858 AliError(Form("There isn't configuration for detector: %s",
859 detector));
860 return 0;
861 }
862
863 return aHolder->GetDCSPort(iServ);
864}
865
542b6cc8 866//______________________________________________________________________________________________
867Int_t AliShuttleConfig::GetMultiSplit(const char* detector, Int_t iServ) const
868{
869 //
870 // returns i-th DCS "multi split" value
871 //
872
873
874 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
875 if (!aHolder) {
876 AliError(Form("There isn't configuration for detector: %s",
877 detector));
878 return 0;
879 }
880
881 return aHolder->GetMultiSplit(iServ);
882}
883
1d172743 884//______________________________________________________________________________________________
885const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector, Int_t iServ) const
886{
887 //
888 // returns collection of TObjString which represents the i-th set of aliases
889 // which used for data retrieval for particular detector
890 //
891
892 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
893 if (!aHolder) {
894 AliError(Form("There isn't configuration for detector: %s",
895 detector));
896 return NULL;
897 }
898
899 return aHolder->GetDCSAliases(iServ);
900}
901
902//______________________________________________________________________________________________
903const TObjArray* AliShuttleConfig::GetDCSDataPoints(const char* detector, Int_t iServ) const
904{
905 //
906 // returns collection of TObjString which represents the set of aliases
907 // which used for data retrieval for particular detector
908 //
909
910 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
911 if (!aHolder) {
912 AliError(Form("There isn't configuration for detector: %s",
913 detector));
914 return NULL;
915 }
916
917 return aHolder->GetDCSDataPoints(iServ);
918}
919
920//______________________________________________________________________________________________
921const TObjArray* AliShuttleConfig::GetCompactDCSAliases(const char* detector, Int_t iServ) const
922{
923 //
924 // returns collection of TObjString which represents the i-th set of aliases
925 // which used for data retrieval for particular detector (Compact style)
926 //
927
928 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
929 if (!aHolder) {
930 AliError(Form("There isn't configuration for detector: %s",
931 detector));
932 return NULL;
933 }
934
935 return aHolder->GetCompactDCSAliases(iServ);
936}
937
938//______________________________________________________________________________________________
939const TObjArray* AliShuttleConfig::GetCompactDCSDataPoints(const char* detector, Int_t iServ) const
940{
941 //
942 // returns collection of TObjString which represents the set of aliases
943 // which used for data retrieval for particular detector (Compact style)
944 //
945
946 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
947 if (!aHolder) {
948 AliError(Form("There isn't configuration for detector: %s",
949 detector));
950 return NULL;
951 }
952
953 return aHolder->GetCompactDCSDataPoints(iServ);
954}
955
956//______________________________________________________________________________________________
957const TObjArray* AliShuttleConfig::GetResponsibles(const char* detector) const
958{
959 //
960 // returns collection of TObjString which represents the list of mail addresses
961 // of the detector's responsible(s)
962 //
963
964 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
965 if (!aHolder) {
966 AliError(Form("There isn't configuration for detector: %s",
967 detector));
968 return NULL;
969 }
970
971 return aHolder->GetResponsibles();
972}
973
fb40ead4 974//______________________________________________________________________________________________
975const TObjArray* AliShuttleConfig::GetAdmins(Int_t sys) const
976{
977 //
978 // returns collection of TObjString which represents the list of mail addresses
979 // of the system's administrator(s) (DAQ, DCS, HLT, Global, Amanda)
980 //
981
982 if (sys < 0 || sys > 4) return 0;
983 return fAdmin[sys];
984}
985
1d172743 986//______________________________________________________________________________________________
987Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
988{
989 // return TRUE if detector is handled by host or if fProcessAll is TRUE
990
991 if(fProcessAll) return kTRUE;
992 TIter iter(&fProcessedDetectors);
993 TObjString* detName;
994 while((detName = (TObjString*) iter.Next())){
995 if(detName->String() == detector) return kTRUE;
d477ad88 996 }
1d172743 997 return kFALSE;
998}
999
1000//______________________________________________________________________________________________
1001Bool_t AliShuttleConfig::StrictRunOrder(const char* detector) const
1002{
1003 // return TRUE if detector wants strict run ordering of stored data
1004
1005 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) fDetectorMap.GetValue(detector);
1006 if (!aHolder)
1007 {
1008 AliError(Form("There isn't configuration for detector: %s",
1009 detector));
1010 return kTRUE;
1011 }
d477ad88 1012
1d172743 1013 return aHolder->StrictRunOrder();
1014}
57f50b3c 1015
1d172743 1016//______________________________________________________________________________________________
1017UInt_t AliShuttleConfig::SetGlobalConfig(TList* list)
1018{
1019 // Set the global configuration (DAQ Logbook + preprocessor monitoring settings)
1020
1021 TLDAPEntry* anEntry = 0;
1022 TLDAPAttribute* anAttribute = 0;
1023
1024 if (list->GetEntries() == 0)
1025 {
1026 AliError("Global configuration not found!");
1027 return 1;
1028 }
1029 else if (list->GetEntries() > 1)
1030 {
1031 AliError("More than one global configuration found!");
1032 return 2;
1033 }
1034
1035 anEntry = dynamic_cast<TLDAPEntry*> (list->At(0));
1036
1037 if (!anEntry)
1038 {
1039 AliError("Unexpected! Global list does not contain a TLDAPEntry");
1040 return 3;
1041 }
1042
1043
1044 anAttribute = anEntry->GetAttribute("daqLbHost");
d477ad88 1045 if (!anAttribute) {
1d172743 1046 AliError("Can't find daqLbHost attribute!");
1047 return 4;
d477ad88 1048 }
57f50b3c 1049 fDAQlbHost = anAttribute->GetValue();
d477ad88 1050
1d172743 1051 anAttribute = anEntry->GetAttribute("daqLbPort"); // MAY
fc5a4708 1052 if (anAttribute)
1053 {
1054 fDAQlbPort = ((TString) anAttribute->GetValue()).Atoi();
1055 } else {
1056 fDAQlbPort = 3306; // mysql
1057 }
1058
1d172743 1059 anAttribute = anEntry->GetAttribute("daqLbUser");
d477ad88 1060 if (!anAttribute) {
1d172743 1061 AliError("Can't find daqLbUser attribute!");
1062 return 4;
d477ad88 1063 }
57f50b3c 1064 fDAQlbUser = anAttribute->GetValue();
1065
1d172743 1066 anAttribute = anEntry->GetAttribute("daqLbPasswd");
d477ad88 1067 if (!anAttribute) {
1d172743 1068 AliError("Can't find daqLbPasswd attribute!");
1069 return 4;
d477ad88 1070 }
57f50b3c 1071 fDAQlbPass = anAttribute->GetValue();
d477ad88 1072
1d172743 1073 anAttribute = anEntry->GetAttribute("daqLbDB");
2c15234c 1074 if (!anAttribute) {
1d172743 1075 AliError("Can't find daqLbDB attribute!");
1076 return 4;
2c15234c 1077 }
1078 fDAQlbDB = anAttribute->GetValue();
1079
1d172743 1080 anAttribute = anEntry->GetAttribute("daqLbTable");
2c15234c 1081 if (!anAttribute) {
1d172743 1082 AliError("Can't find daqLbTable attribute!");
1083 return 4;
2c15234c 1084 }
1085 fDAQlbTable = anAttribute->GetValue();
1086
1d172743 1087 anAttribute = anEntry->GetAttribute("shuttleLbTable");
441b0e9c 1088 if (!anAttribute) {
1d172743 1089 AliError("Can't find shuttleLbTable attribute!");
1090 return 4;
441b0e9c 1091 }
1092 fShuttlelbTable = anAttribute->GetValue();
1093
1d172743 1094 anAttribute = anEntry->GetAttribute("runTypeLbTable");
441b0e9c 1095 if (!anAttribute) {
1d172743 1096 AliError("Can't find runTypeLbTable attribute!");
1097 return 4;
441b0e9c 1098 }
1099 fRunTypelbTable = anAttribute->GetValue();
2c15234c 1100
1d172743 1101 anAttribute = anEntry->GetAttribute("ppmaxRetries");
5164a766 1102 if (!anAttribute) {
1d172743 1103 AliError("Can't find ppmaxRetries attribute!");
1104 return 4;
5164a766 1105 }
1106 TString tmpStr = anAttribute->GetValue();
cb343cfd 1107 fMaxRetries = tmpStr.Atoi();
5164a766 1108
1d172743 1109 anAttribute = anEntry->GetAttribute("ppTimeOut");
5164a766 1110 if (!anAttribute) {
1d172743 1111 AliError("Can't find ppTimeOut attribute!");
1112 return 4;
5164a766 1113 }
1114 tmpStr = anAttribute->GetValue();
cb343cfd 1115 fPPTimeOut = tmpStr.Atoi();
5164a766 1116
ff3781ad 1117 anAttribute = anEntry->GetAttribute("dcsTimeOut");
1118 if (!anAttribute) {
1119 AliError("Can't find dcsTimeOut attribute!");
1120 return 4;
1121 }
1122 tmpStr = anAttribute->GetValue();
1123 fDCSTimeOut = tmpStr.Atoi();
1124
1125 anAttribute = anEntry->GetAttribute("nDCSretries");
1126 if (!anAttribute) {
1127 AliError("Can't find dcsTimeOut attribute!");
1128 return 4;
1129 }
1130 tmpStr = anAttribute->GetValue();
1131 fDCSRetries = tmpStr.Atoi();
1132
1d172743 1133 anAttribute = anEntry->GetAttribute("ppMaxMem");
9827400b 1134 if (!anAttribute) {
1d172743 1135 AliError("Can't find ppMaxMem attribute!");
1136 return 4;
9827400b 1137 }
1138 tmpStr = anAttribute->GetValue();
1139 fPPMaxMem = tmpStr.Atoi();
1140
b832ec02 1141 anAttribute = anEntry->GetAttribute("monitorHost");
1142 if (!anAttribute) {
1143 AliError("Can't find monitorHost attribute!");
1144 return 4;
1145 }
1146 fMonitorHost = anAttribute->GetValue();
1147
1148 anAttribute = anEntry->GetAttribute("monitorTable");
1149 if (!anAttribute) {
1150 AliError("Can't find monitorTable attribute!");
1151 return 4;
1152 }
1153 fMonitorTable = anAttribute->GetValue();
7d4cf768 1154
1155 anAttribute = anEntry->GetAttribute("triggerWait"); // MAY
1156 if (!anAttribute) {
1157 AliWarning(Form("triggerWait not set! default = ", fTriggerWait));
1158 }
1159 tmpStr = anAttribute->GetValue();
1160 fTriggerWait = tmpStr.Atoi();
b832ec02 1161
7d4cf768 1162 anAttribute = anEntry->GetAttribute("mode");
1163 if (!anAttribute) {
1164 AliWarning("Run mode not set! Running in test mode.");
7d4cf768 1165 } else {
4508ab8b 1166 tmpStr = anAttribute->GetValue();
1167 if (tmpStr == "test")
1168 {
1169 fRunMode = kTest;
1170 } else if (tmpStr == "prod") {
1171 fRunMode = kProd;
1172 } else {
1173 AliWarning(Form("Not a valid run mode: %s", tmpStr.Data()));
1174 AliWarning("Valid run modes are \"test\" and \"prod\". Running in test mode.");
1175 }
7d4cf768 1176 }
fb40ead4 1177
1178 anAttribute = anEntry->GetAttribute("keepDCSMap"); // MAY
1179 if (!anAttribute)
1180 {
1181 AliWarning("keepDCSMap flag not set - default is FALSE");
1182 } else {
1183 TString keepDCSMapStr = anAttribute->GetValue();
1184 if (!(keepDCSMapStr == "0" || keepDCSMapStr == "1"))
1185 {
1186 AliError("keepDCSMap flag must be 0 or 1!");
1187 return 4;
1188 }
1189 fKeepDCSMap = (Bool_t) keepDCSMapStr.Atoi();
1190 }
1191
1192 anAttribute = anEntry->GetAttribute("keepTempFolder"); // MAY
1193 if (!anAttribute)
1194 {
1195 AliWarning("keepTempFolder flag not set - default is FALSE");
1196 } else {
1197 TString keepTempFolderStr = anAttribute->GetValue();
1198 if (!(keepTempFolderStr == "0" || keepTempFolderStr == "1"))
1199 {
1200 AliError("keepTempFolder flag must be 0 or 1!");
1201 return 4;
1202 }
1203 fKeepTempFolder = (Bool_t) keepTempFolderStr.Atoi();
1204 }
1205
1206
1207 anAttribute = anEntry->GetAttribute("shuttleAdmin"); // MAY
1208 if (!anAttribute)
1209 {
1210 AliDebug(2, "Warning! No \"shuttleAdmin\" attribute!");
1211 }
1212 else
1213 {
1214 const char* anAdmin;
1215 while ((anAdmin = anAttribute->GetValue()))
1216 {
1217 fAdmin[kGlobal]->AddLast(new TObjString(anAdmin));
1218 }
1219 }
1220
1221 anAttribute = anEntry->GetAttribute("amandaAdmin"); // MAY
1222 if (!anAttribute)
1223 {
1224 AliDebug(2, "Warning! No \"amandaAdmin\" attribute!");
1225 }
1226 else
1227 {
1228 const char* anAdmin;
1229 while ((anAdmin = anAttribute->GetValue()))
1230 {
1231 fAdmin[kAmanda]->AddLast(new TObjString(anAdmin));
1232 }
1233 }
1234
1235 anAttribute = anEntry->GetAttribute("sendMail"); // MAY
1236 if (!anAttribute)
1237 {
1238 AliWarning("sendMail flag not set - default is FALSE");
1239 } else {
1240 TString sendMailStr = anAttribute->GetValue();
1241 if (!(sendMailStr == "0" || sendMailStr == "1"))
1242 {
1243 AliError("sendMail flag must be 0 or 1!");
1244 return 4;
1245 }
1246 fSendMail = (Bool_t) sendMailStr.Atoi();
1247 }
1248
1d172743 1249 return 0;
1d172743 1250}
57f50b3c 1251
1d172743 1252//______________________________________________________________________________________________
1253UInt_t AliShuttleConfig::SetSysConfig(TList* list)
1254{
1255 // Set the online FXS configuration (DAQ + DCS + HLT)
1256
1257 TLDAPEntry* anEntry = 0;
1258 TLDAPAttribute* anAttribute = 0;
1259
1260 if (list->GetEntries() != 3)
1261 {
1262 AliError(Form("Wrong number of online systems found: %d !", list->GetEntries()));
1263 return 1;
1264 }
57f50b3c 1265
1d172743 1266 TIter iter(list);
fb40ead4 1267 Int_t count = 0;
1268 SystemCode iSys=kDAQ;
1269
1d172743 1270 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1271 {
1272 anAttribute = anEntry->GetAttribute("system");
1273 TString sysName = anAttribute->GetValue();
1274
1275 if (sysName == "DAQ")
1276 {
fb40ead4 1277 iSys = kDAQ;
1d172743 1278 count += 1;
57f50b3c 1279 }
1d172743 1280 else if (sysName == "DCS")
1281 {
fb40ead4 1282 iSys = kDCS;
1d172743 1283 count += 10;
57f50b3c 1284 }
1d172743 1285 else if (sysName == "HLT")
1286 {
fb40ead4 1287 iSys = kHLT;
1d172743 1288 count += 100;
1289 }
1290
1291 anAttribute = anEntry->GetAttribute("dbHost");
57f50b3c 1292 if (!anAttribute) {
1d172743 1293 AliError(Form ("Can't find dbHost attribute for %s!!",
eba76848 1294 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1295 return 5;
57f50b3c 1296 }
2c15234c 1297 fFXSdbHost[iSys] = anAttribute->GetValue();
57f50b3c 1298
1d172743 1299 anAttribute = anEntry->GetAttribute("dbPort"); // MAY
fc5a4708 1300 if (anAttribute)
1301 {
1302 fFXSdbPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1303 } else {
1304 fFXSdbPort[iSys] = 3306; // mysql
1305 }
1306
1d172743 1307 anAttribute = anEntry->GetAttribute("dbUser");
57f50b3c 1308 if (!anAttribute) {
1d172743 1309 AliError(Form ("Can't find dbUser attribute for %s!!",
eba76848 1310 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1311 return 5;
57f50b3c 1312 }
2c15234c 1313 fFXSdbUser[iSys] = anAttribute->GetValue();
57f50b3c 1314
1d172743 1315 anAttribute = anEntry->GetAttribute("dbPasswd");
57f50b3c 1316 if (!anAttribute) {
1d172743 1317 AliError(Form ("Can't find dbPasswd attribute for %s!!",
eba76848 1318 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1319 return 5;
57f50b3c 1320 }
2c15234c 1321 fFXSdbPass[iSys] = anAttribute->GetValue();
1322
1d172743 1323 anAttribute = anEntry->GetAttribute("dbName");
2c15234c 1324 if (!anAttribute) {
1d172743 1325 AliError(Form ("Can't find dbName attribute for %s!!",
2c15234c 1326 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1327 return 5;
2c15234c 1328 }
1329
1330 fFXSdbName[iSys] = anAttribute->GetValue();
1d172743 1331 anAttribute = anEntry->GetAttribute("dbTable");
2c15234c 1332 if (!anAttribute) {
1d172743 1333 AliError(Form ("Can't find dbTable attribute for %s!!",
2c15234c 1334 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1335 return 5;
2c15234c 1336 }
1337 fFXSdbTable[iSys] = anAttribute->GetValue();
57f50b3c 1338
1d172743 1339 anAttribute = anEntry->GetAttribute("fxsHost");
57f50b3c 1340 if (!anAttribute) {
1d172743 1341 AliError(Form ("Can't find fxsHost attribute for %s!!",
eba76848 1342 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1343 return 5;
57f50b3c 1344 }
2c15234c 1345 fFXSHost[iSys] = anAttribute->GetValue();
57f50b3c 1346
1d172743 1347 anAttribute = anEntry->GetAttribute("fxsPort"); // MAY
fc5a4708 1348 if (anAttribute)
1349 {
1350 fFXSPort[iSys] = ((TString) anAttribute->GetValue()).Atoi();
1351 } else {
1352 fFXSPort[iSys] = 22; // scp port number
1353 }
1354
1d172743 1355 anAttribute = anEntry->GetAttribute("fxsUser");
57f50b3c 1356 if (!anAttribute) {
1d172743 1357 AliError(Form ("Can't find fxsUser attribute for %s!!",
eba76848 1358 AliShuttleInterface::GetSystemName(iSys)));
1d172743 1359 return 5;
57f50b3c 1360 }
2c15234c 1361 fFXSUser[iSys] = anAttribute->GetValue();
57f50b3c 1362
1d172743 1363 anAttribute = anEntry->GetAttribute("fxsPasswd");
2c15234c 1364 if (anAttribute) fFXSPass[iSys] = anAttribute->GetValue();
fb40ead4 1365
1366 anAttribute = anEntry->GetAttribute("fxsAdmin"); // MAY
1367 if (!anAttribute)
1368 {
1369 AliDebug(2, "Warning! No \"fxsAdmin\" attribute!");
1370 }
1371 else
1372 {
1373 const char* anAdmin;
1374 while ((anAdmin = anAttribute->GetValue()))
1375 {
1376 fAdmin[iSys]->AddLast(new TObjString(anAdmin));
1377 }
1378 }
1379
57f50b3c 1380 }
73abe331 1381
1d172743 1382 if(count != 111) {
1383 AliError(Form("Wrong system configuration! (code = %d)", count));
1384 return 6;
73abe331 1385 }
1d172743 1386
1387 return 0;
2c15234c 1388}
1389
57c1a579 1390//______________________________________________________________________________________________
1d172743 1391UInt_t AliShuttleConfig::SetDetConfig(TList* detList, TList* dcsList)
57c1a579 1392{
1d172743 1393 // Set the detector configuration (general settings + DCS amanda server and alias/DP lists)
57c1a579 1394
1d172743 1395 TLDAPEntry* anEntry = 0;
1396
1397 TIter iter(detList);
1398 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
1399 {
1400
1401 AliShuttleDetConfigHolder* detHolder = new AliShuttleDetConfigHolder(anEntry);
57c1a579 1402
1d172743 1403 if (!detHolder->IsValid()) {
1404 AliError("Detector configuration error!");
1405 delete detHolder;
1406 return 7;
1407 }
b948db8d 1408
1d172743 1409 TObjString* detStr = new TObjString(detHolder->GetDetector());
1410
1411 // Look for DCS Configuration
1412 TIter dcsIter(dcsList);
1413 TLDAPEntry *dcsEntry = 0;
1414 while ((dcsEntry = dynamic_cast<TLDAPEntry*> (dcsIter.Next())))
1415 {
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!");
1422 delete detHolder;
1423 delete dcsHolder;
1424 return 7;
1425 }
1426 detHolder->AddDCSConfig(dcsHolder);
1427 }
1428 }
1429
1430
1431 fDetectorMap.Add(detStr, detHolder);
1432 fDetectorList.AddLast(detStr);
b948db8d 1433 }
1d172743 1434
1435 return 0;
73abe331 1436}
1437
be48e3ea 1438//______________________________________________________________________________________________
1d172743 1439UInt_t AliShuttleConfig::SetHostConfig(TList* list)
be48e3ea 1440{
1d172743 1441 // Set the Shuttle machines configuration (which detectors processes each machine)
1442
1443 TLDAPEntry* anEntry = 0;
1444 TLDAPAttribute* anAttribute = 0;
1445
1446 fShuttleInstanceHost = gSystem->HostName();
1447
1448 TIter iter(list);
1449 while ((anEntry = dynamic_cast<TLDAPEntry*> (iter.Next())))
be48e3ea 1450 {
1d172743 1451
1452 TString dn(anEntry->GetDn());
1453 if (!dn.Contains(Form("shuttleHost=%s", fShuttleInstanceHost.Data()))) continue;
1454
1455 if (!fProcessAll)
1456 {
1457 anAttribute = anEntry->GetAttribute("detectors");
1458 const char *detName;
1459 while((detName = anAttribute->GetValue())){
1460 TObjString *objDet= new TObjString(detName);
1461 fProcessedDetectors.Add(objDet);
1462 }
1463 }
1464 }
1465
1466 return 0;
be48e3ea 1467}
1468
1d172743 1469
a7160fe9 1470//______________________________________________________________________________________________
36c99a6a 1471void AliShuttleConfig::Print(Option_t* option) const
58bc3020 1472{
1473// print configuration
36c99a6a 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
1478
73abe331 1479 TString result;
1480 result += '\n';
7d4cf768 1481
1482 TString mode = "test";
1483 if (fRunMode == kProd) mode = "production";
d477ad88 1484
7d4cf768 1485 result += "########################################################################\n";
1486 result += Form(" Shuttle configuration from %s - Run Mode: <%s> \n",
1487 fConfigHost.Data(), mode.Data());
1488 result += "########################################################################\n";
57c1a579 1489 result += Form("\nShuttle running on %s \n", fShuttleInstanceHost.Data());
57f50b3c 1490
1491 if(fProcessAll) {
57c1a579 1492 result += Form("All detectors will be processed! \n");
57f50b3c 1493 } else {
1494 result += "Detectors processed by this host: ";
1495 TIter it(&fProcessedDetectors);
1496 TObjString* aDet;
1497 while ((aDet = (TObjString*) it.Next())) {
1498 result += Form("%s ", aDet->String().Data());
1499 }
57c1a579 1500 result += "\n";
b948db8d 1501 }
b948db8d 1502
ff3781ad 1503 result += Form("PP time out = %d - DCS time out = %d - max PP mem size = %d KB - max retries = %d "
fb40ead4 1504 "- DIM trigger waiting timeout = %d\n",
ff3781ad 1505 fPPTimeOut, fDCSTimeOut, fPPMaxMem, fMaxRetries, fTriggerWait);
fb40ead4 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)
1510 {
1511 result += "SHUTTLE administrator(s): ";
1512 TIter it(shuttleAdmins);
1513 TObjString* anAdmin;
1514 while ((anAdmin = (TObjString*) it.Next()))
1515 {
1516 result += Form("%s ", anAdmin->String().Data());
1517 }
1518 result += "\n";
1519 }
1520 const TObjArray* amandaAdmins = GetAdmins(kAmanda);
1521 if (amandaAdmins->GetEntries() != 0)
1522 {
1523 result += "Amanda server administrator(s): ";
1524 TIter it(amandaAdmins);
1525 TObjString* anAdmin;
1526 while ((anAdmin = (TObjString*) it.Next()))
1527 {
1528 result += Form("%s ", anAdmin->String().Data());
1529 }
1530 result += "\n\n";
1531 }
57c1a579 1532 result += "------------------------------------------------------\n";
2bb7b766 1533
57c1a579 1534 result += Form("Logbook Configuration \n\n \tHost: %s:%d; \tUser: %s; ",
fc5a4708 1535 fDAQlbHost.Data(), fDAQlbPort, fDAQlbUser.Data());
b948db8d 1536
2c15234c 1537// result += "Password: ";
1538// result.Append('*', fDAQlbPass.Length());
b832ec02 1539 result += Form("\tDB: %s; \tTables: %s, %s, %s\n",
441b0e9c 1540 fDAQlbDB.Data(), fDAQlbTable.Data(), fShuttlelbTable.Data(), fRunTypelbTable.Data());
2c15234c 1541
57f50b3c 1542 result += "\n\n";
fb40ead4 1543
57c1a579 1544 result += "------------------------------------------------------\n";
1545 result += "FXS configuration\n\n";
1546
57f50b3c 1547 for(int iSys=0;iSys<3;iSys++){
57c1a579 1548 result += Form("*** %s ***\n", AliShuttleInterface::GetSystemName(iSys));
fc5a4708 1549 result += Form("\tDB host: %s:%d; \tUser: %s; \tName: %s; \tTable: %s\n",
1550 fFXSdbHost[iSys].Data(), fFXSdbPort[iSys], fFXSdbUser[iSys].Data(),
2c15234c 1551 fFXSdbName[iSys].Data(), fFXSdbTable[iSys].Data());
1552 // result += Form("DB Password:",fFXSdbPass[iSys].Data());
fb40ead4 1553 result += Form("\tFXS host: %s:%d; \tUser: %s\n", fFXSHost[iSys].Data(), fFXSPort[iSys],
fc5a4708 1554 fFXSUser[iSys].Data());
2c15234c 1555 // result += Form("FXS Password:",fFXSPass[iSys].Data());
fb40ead4 1556 const TObjArray* fxsAdmins = GetAdmins(iSys);
1557 if (fxsAdmins->GetEntries() != 0)
1558 {
1559 result += "\tAdministrator(s): ";
1560 TIter it(fxsAdmins);
1561 TObjString* anAdmin;
1562 while ((anAdmin = (TObjString*) it.Next()))
1563 {
1564 result += Form("%s ", anAdmin->String().Data());
1565 }
1566 result += "\n\n";
1567 }
57f50b3c 1568 }
b948db8d 1569
b832ec02 1570 result += "------------------------------------------------------\n";
1571 result += "MonaLisa configuration\n\n";
1572
1573 result += Form("\tHost: %s; \tTable name: %s",
1574 fMonitorHost.Data(), fMonitorTable.Data());
1575
1576 result += "\n\n";
fb40ead4 1577
36c99a6a 1578 TString optStr(option);
1579
57c1a579 1580 result += "------------------------------------------------------\n";
1581 result += "Detector-specific configuration\n\n";
1d172743 1582
73abe331 1583 TIter iter(fDetectorMap.GetTable());
1d172743 1584 TPair* aPair = 0;
1585
73abe331 1586 while ((aPair = (TPair*) iter.Next())) {
1d172743 1587 AliShuttleDetConfigHolder* aHolder = (AliShuttleDetConfigHolder*) aPair->Value();
1588 if (optStr != "" && !optStr.Contains(aHolder->GetDetector()) &&
1589 optStr.CompareTo("uncompact",TString::kIgnoreCase) != 0 )
36c99a6a 1590 continue;
1d172743 1591
57c1a579 1592 result += Form("*** %s *** \n", aHolder->GetDetector());
1593
1594 const TObjArray* responsibles = aHolder->GetResponsibles();
1595 if (responsibles->GetEntries() != 0)
1596 {
1597 result += "\tDetector responsible(s): ";
1598 TIter it(responsibles);
1599 TObjString* aResponsible;
1600 while ((aResponsible = (TObjString*) it.Next()))
1601 {
1602 result += Form("%s ", aResponsible->String().Data());
1603 }
1604 result += "\n";
1605 }
1606
1d172743 1607 result += Form("\tStrict run ordering: %s \n\n", aHolder->StrictRunOrder() ? "YES" : "NO");
1608
1609 const TObjArray* dcsConfig = aHolder->GetDCSConfig();
1610
1611 AliShuttleDCSConfigHolder* dcsHolder = 0;
1612 TIter dcsIter(dcsConfig);
1613 Int_t count=0;
1614 while ((dcsHolder = dynamic_cast<AliShuttleDCSConfigHolder*> (dcsIter.Next())))
be48e3ea 1615 {
542b6cc8 1616 result += Form("\tAmanda server [%d]: %s:%d - MultiSplit = %d\n", count,
1617 dcsHolder->GetDCSHost(), dcsHolder->GetDCSPort(), dcsHolder->GetMultiSplit());
57f50b3c 1618
1d172743 1619 const TObjArray* aliases = 0;
1620 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1621 {
1622 aliases = dcsHolder->GetDCSAliases();
1623 } else {
1624 aliases = dcsHolder->GetCompactDCSAliases();
1625 }
36c99a6a 1626
1d172743 1627 if (aliases->GetEntries() != 0)
2c15234c 1628 {
1d172743 1629 result += Form("\tDCS Aliases [%d]: ", count);
1630 TIter it(aliases);
1631 TObjString* anAlias;
1632 while ((anAlias = (TObjString*) it.Next()))
1633 {
1634 result += Form("%s ", anAlias->String().Data());
1635 }
1636 result += "\n";
2c15234c 1637 }
57f50b3c 1638
1d172743 1639 const TObjArray* dataPoints = 0;
1640 if (optStr.Contains("uncompact",TString::kIgnoreCase))
1641 {
1642 dataPoints = dcsHolder->GetDCSDataPoints();
1643 } else {
1644 dataPoints = dcsHolder->GetCompactDCSDataPoints();
2c15234c 1645 }
1d172743 1646 if (dataPoints->GetEntries() != 0)
1647 {
1648 result += Form("\tDCS Data Points [%d]: ", count);
1649 TIter it(dataPoints);
1650 TObjString* aDataPoint;
1651 while ((aDataPoint = (TObjString*) it.Next())) {
1652 result += Form("%s ", aDataPoint->String().Data());
1653 }
2c15234c 1654 result += "\n";
1d172743 1655 }
1656 count++;
1657 result += "\n";
2c15234c 1658 }
73abe331 1659 }
57f50b3c 1660 if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n";
1661
73abe331 1662 AliInfo(result);
1663}