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