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