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