]>
Commit | Line | Data |
---|---|---|
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$ | |
36c99a6a | 18 | Revision 1.17 2007/01/18 11:17:47 jgrosseo |
19 | changing spaces to tabs ;-) | |
20 | ||
f59d2f8f | 21 | Revision 1.16 2007/01/18 11:10:35 jgrosseo |
22 | adding the possibility of defining DCS alias and data points with patterns | |
23 | first pattern introduced: [N..M] to add all names between the two digits, this works also recursively. | |
24 | ||
40150741 | 25 | Revision 1.15 2007/01/15 18:27:11 acolla |
26 | implementation of sending mail to subdetector expert in case the preprocessor fails. | |
27 | shuttle.schema updated with expert's email entry | |
28 | ||
fc5a4708 | 29 | Revision 1.13 2006/12/07 08:51:26 jgrosseo |
30 | update (alberto): | |
31 | table, db names in ldap configuration | |
32 | added GRP preprocessor | |
33 | DCS data can also be retrieved by data point | |
34 | ||
2c15234c | 35 | Revision 1.12 2006/11/16 16:16:48 jgrosseo |
36 | introducing strict run ordering flag | |
37 | removed giving preprocessor name to preprocessor, they have to know their name themselves ;-) | |
38 | ||
be48e3ea | 39 | Revision 1.11 2006/11/06 14:23:04 jgrosseo |
40 | major update (Alberto) | |
41 | o) reading of run parameters from the logbook | |
42 | o) online offline naming conversion | |
43 | o) standalone DCSclient package | |
44 | ||
eba76848 | 45 | Revision 1.10 2006/10/20 15:22:59 jgrosseo |
46 | o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child | |
47 | o) Merging Collect, CollectAll, CollectNew function | |
48 | o) Removing implementation of empty copy constructors (declaration still there!) | |
49 | ||
cb343cfd | 50 | Revision 1.9 2006/10/02 16:38:39 jgrosseo |
51 | update (alberto): | |
52 | fixed memory leaks | |
53 | storing of objects that failed to be stored to the grid before | |
54 | interfacing of shuttle status table in daq system | |
55 | ||
2bb7b766 | 56 | Revision 1.8 2006/08/15 10:50:00 jgrosseo |
57 | effc++ corrections (alberto) | |
58 | ||
4f0ab988 | 59 | Revision 1.7 2006/07/20 09:54:40 jgrosseo |
60 | introducing status management: The processing per subdetector is divided into several steps, | |
61 | after each step the status is stored on disk. If the system crashes in any of the steps the Shuttle | |
62 | can keep track of the number of failures and skips further processing after a certain threshold is | |
63 | exceeded. These thresholds can be configured in LDAP. | |
64 | ||
5164a766 | 65 | Revision 1.6 2006/07/19 10:09:55 jgrosseo |
66 | new configuration, accesst to DAQ FES (Alberto) | |
67 | ||
57f50b3c | 68 | Revision 1.5 2006/07/10 13:01:41 jgrosseo |
69 | enhanced storing of last sucessfully processed run (alberto) | |
70 | ||
a7160fe9 | 71 | Revision 1.4 2006/06/12 09:11:16 jgrosseo |
72 | coding conventions (Alberto) | |
73 | ||
58bc3020 | 74 | Revision 1.3 2006/06/06 14:26:40 jgrosseo |
75 | o) removed files that were moved to STEER | |
76 | o) shuttle updated to follow the new interface (Alberto) | |
77 | ||
b948db8d | 78 | Revision 1.7 2006/05/12 09:07:16 colla |
79 | 12/05/06 | |
80 | New configuration complete | |
81 | ||
82 | Revision 1.2 2006/03/07 07:52:34 hristov | |
83 | New version (B.Yordanov) | |
84 | ||
d477ad88 | 85 | Revision 1.4 2005/11/19 14:20:31 byordano |
86 | logbook config added to AliShuttleConfig | |
87 | ||
88 | Revision 1.3 2005/11/17 19:24:25 byordano | |
89 | TList changed to TObjArray in AliShuttleConfig | |
90 | ||
91 | Revision 1.2 2005/11/17 14:43:23 byordano | |
92 | import to local CVS | |
93 | ||
94 | Revision 1.1.1.1 2005/10/28 07:33:58 hristov | |
95 | Initial import as subdirectory in AliRoot | |
96 | ||
73abe331 | 97 | Revision 1.1.1.1 2005/09/12 22:11:40 byordano |
98 | SHUTTLE package | |
99 | ||
100 | Revision 1.3 2005/08/30 09:13:02 byordano | |
101 | some docs added | |
102 | ||
103 | */ | |
104 | ||
105 | ||
106 | // | |
107 | // This class keeps the AliShuttle configuration. | |
108 | // It reads the configuration for LDAP server. | |
109 | // For every child entry in basedn which has schema type 'shuttleConfig' | |
110 | // it creates a detector configuration. This configuration includes: | |
111 | // DCS server host and port and the set of aliases for which data from | |
112 | // will be retrieved (used by AliShuttle). | |
113 | // | |
114 | ||
115 | ||
116 | #include "AliShuttleConfig.h" | |
57f50b3c | 117 | #include "AliShuttleInterface.h" |
73abe331 | 118 | |
119 | #include "AliLog.h" | |
120 | ||
b948db8d | 121 | #include <TSystem.h> |
73abe331 | 122 | #include <TObjString.h> |
123 | #include <TLDAPResult.h> | |
124 | #include <TLDAPEntry.h> | |
125 | #include <TLDAPAttribute.h> | |
126 | ||
57f50b3c | 127 | |
58bc3020 | 128 | AliShuttleConfig::AliShuttleConfigHolder::AliShuttleConfigHolder(const TLDAPEntry* entry): |
57f50b3c | 129 | fDetector(""), |
130 | fDCSHost(""), | |
131 | fDCSPort(0), | |
fc5a4708 | 132 | fDCSAliases(0), |
133 | fDCSDataPoints(0), | |
36c99a6a | 134 | fDCSAliasesComp(0), |
135 | fDCSDataPointsComp(0), | |
57c1a579 | 136 | fResponsibles(0), |
57f50b3c | 137 | fIsValid(kFALSE), |
be48e3ea | 138 | fSkipDCSQuery(kFALSE), |
139 | fStrictRunOrder(kFALSE) | |
73abe331 | 140 | { |
58bc3020 | 141 | // constructor of the shuttle configuration holder |
142 | ||
73abe331 | 143 | TLDAPAttribute* anAttribute; |
2bb7b766 | 144 | fDCSAliases = new TObjArray(); |
145 | fDCSAliases->SetOwner(1); | |
2c15234c | 146 | fDCSDataPoints = new TObjArray(); |
147 | fDCSDataPoints->SetOwner(1); | |
36c99a6a | 148 | fDCSAliasesComp = new TObjArray(); |
149 | fDCSAliasesComp->SetOwner(1); | |
150 | fDCSDataPointsComp = new TObjArray(); | |
151 | fDCSDataPointsComp->SetOwner(1); | |
57c1a579 | 152 | fResponsibles = new TObjArray(); |
153 | fResponsibles->SetOwner(1); | |
57f50b3c | 154 | |
155 | anAttribute = entry->GetAttribute("det"); // MUST | |
2c15234c | 156 | if (!anAttribute) |
157 | { | |
158 | AliError(Form("Invalid configuration! No \"det\" attribute!")); | |
159 | return; | |
160 | } | |
73abe331 | 161 | fDetector = anAttribute->GetValue(); |
73abe331 | 162 | |
be48e3ea | 163 | anAttribute = entry->GetAttribute("StrictRunOrder"); // MAY |
164 | if (!anAttribute) | |
165 | { | |
166 | AliWarning(Form("%s did not set StrictRunOrder flag - the default is FALSE", | |
167 | fDetector.Data())); | |
168 | } else { | |
169 | TString strictRunStr = anAttribute->GetValue(); | |
170 | if (!(strictRunStr == "0" || strictRunStr == "1")) | |
171 | { | |
172 | AliError("Invalid configuration! StrictRunOrder flag must be 0 or 1!"); | |
173 | return; | |
174 | } | |
175 | fStrictRunOrder = (Bool_t) strictRunStr.Atoi(); | |
176 | } | |
177 | ||
57c1a579 | 178 | anAttribute = entry->GetAttribute("responsible"); // MUST |
179 | if (!anAttribute) | |
180 | { | |
181 | AliError(Form("Invalid configuration! No \"responsible\" attribute!")); | |
182 | return; | |
183 | } | |
184 | const char* aResponsible; | |
185 | while ((aResponsible = anAttribute->GetValue())) | |
186 | { | |
187 | fResponsibles->AddLast(new TObjString(aResponsible)); | |
188 | } | |
189 | ||
57f50b3c | 190 | anAttribute = entry->GetAttribute("DCSHost"); // MAY |
2c15234c | 191 | if (!anAttribute) |
192 | { | |
57c1a579 | 193 | AliDebug(2, |
57f50b3c | 194 | Form("%s has not DCS host entry - Shuttle will skip DCS data query!", |
195 | fDetector.Data())); | |
196 | fIsValid = kTRUE; | |
197 | fSkipDCSQuery = kTRUE; | |
73abe331 | 198 | return; |
199 | } | |
57f50b3c | 200 | |
b948db8d | 201 | fDCSHost = anAttribute->GetValue(); |
73abe331 | 202 | |
57f50b3c | 203 | anAttribute = entry->GetAttribute("DCSPort"); // MAY |
2c15234c | 204 | if (!anAttribute) |
205 | { | |
57f50b3c | 206 | AliError(Form("Invalid configuration! %s has DCS Host but no port number!", |
207 | fDetector.Data())); | |
73abe331 | 208 | return; |
209 | } | |
210 | TString portStr = anAttribute->GetValue(); | |
b948db8d | 211 | fDCSPort = portStr.Atoi(); |
73abe331 | 212 | |
2c15234c | 213 | anAttribute = entry->GetAttribute("DCSalias"); // MAY |
214 | if (anAttribute) | |
215 | { | |
216 | const char* anAlias; | |
217 | while ((anAlias = anAttribute->GetValue())) | |
218 | { | |
36c99a6a | 219 | fDCSAliasesComp->AddLast(new TObjString(anAlias)); |
40150741 | 220 | ExpandAndAdd(fDCSAliases, anAlias); |
2c15234c | 221 | } |
73abe331 | 222 | } |
57f50b3c | 223 | |
2c15234c | 224 | anAttribute = entry->GetAttribute("DCSdatapoint"); // MAY |
225 | if (anAttribute) | |
226 | { | |
227 | const char* aDataPoint; | |
228 | while ((aDataPoint = anAttribute->GetValue())) | |
229 | { | |
36c99a6a | 230 | fDCSDataPointsComp->AddLast(new TObjString(aDataPoint)); |
231 | ExpandAndAdd(fDCSDataPoints, aDataPoint); | |
2c15234c | 232 | } |
b948db8d | 233 | } |
234 | ||
73abe331 | 235 | fIsValid = kTRUE; |
236 | } | |
237 | ||
40150741 | 238 | //______________________________________________________________________________________________ |
239 | void AliShuttleConfig::AliShuttleConfigHolder::ExpandAndAdd(TObjArray* target, const char* entry) | |
240 | { | |
f59d2f8f | 241 | // |
242 | // adds <entry> to <target> applying expanding of the name | |
243 | // [N..M] creates M-N+1 names with the corresponding digits | |
244 | // | |
40150741 | 245 | |
f59d2f8f | 246 | TString entryStr(entry); |
40150741 | 247 | |
f59d2f8f | 248 | Int_t begin = entryStr.Index("["); |
249 | Int_t end = entryStr.Index("]"); | |
250 | if (begin != -1 && end != -1 && end > begin) | |
251 | { | |
252 | TString before(entryStr(0, begin)); | |
253 | TString after(entryStr(end+1, entryStr.Length())); | |
40150741 | 254 | |
f59d2f8f | 255 | AliDebug(2, Form("Found [] pattern. Splitted input string %s %s", before.Data(), after.Data())); |
40150741 | 256 | |
f59d2f8f | 257 | Int_t dotdot = entryStr.Index(".."); |
40150741 | 258 | |
f59d2f8f | 259 | TString nStr(entryStr(begin+1, dotdot-begin-1)); |
260 | TString mStr(entryStr(dotdot+2, end-dotdot-2)); | |
40150741 | 261 | |
f59d2f8f | 262 | AliDebug(2, Form("Found [N..M] pattern. %s %s", nStr.Data(), mStr.Data())); |
40150741 | 263 | |
f59d2f8f | 264 | if (nStr.IsDigit() && mStr.IsDigit()) |
265 | { | |
266 | Int_t n = nStr.Atoi(); | |
267 | Int_t m = mStr.Atoi(); | |
40150741 | 268 | |
f59d2f8f | 269 | Int_t nDigits = nStr.Length(); |
270 | TString formatStr; | |
271 | formatStr.Form("%%s%%0%dd%%s", nDigits); | |
40150741 | 272 | |
f59d2f8f | 273 | AliDebug(2, Form("Format string is %s", formatStr.Data())); |
40150741 | 274 | |
f59d2f8f | 275 | for (Int_t current = n; current<=m; ++current) |
276 | { | |
277 | TString newEntry; | |
278 | newEntry.Form(formatStr.Data(), before.Data(), current, after.Data()); | |
40150741 | 279 | |
f59d2f8f | 280 | AliDebug(2, Form("Calling recursive with %s", newEntry.Data())); |
40150741 | 281 | |
f59d2f8f | 282 | // and go recursive |
283 | ExpandAndAdd(target, newEntry); | |
284 | } | |
40150741 | 285 | |
f59d2f8f | 286 | // return here because we processed the entries already recursively. |
287 | return; | |
288 | } | |
289 | } | |
40150741 | 290 | |
f59d2f8f | 291 | AliDebug(2, Form("Adding name %s", entry)); |
292 | target->AddLast(new TObjString(entry)); | |
40150741 | 293 | } |
294 | ||
a7160fe9 | 295 | //______________________________________________________________________________________________ |
296 | AliShuttleConfig::AliShuttleConfigHolder::~AliShuttleConfigHolder() | |
58bc3020 | 297 | { |
298 | // destructor of the shuttle configuration holder | |
299 | ||
2bb7b766 | 300 | delete fDCSAliases; |
2c15234c | 301 | delete fDCSDataPoints; |
57c1a579 | 302 | delete fResponsibles; |
73abe331 | 303 | } |
304 | ||
305 | ClassImp(AliShuttleConfig) | |
306 | ||
a7160fe9 | 307 | //______________________________________________________________________________________________ |
308 | AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port, | |
73abe331 | 309 | const char* binddn, const char* password, const char* basedn): |
57c1a579 | 310 | fIsValid(kFALSE), fConfigHost(host), |
fc5a4708 | 311 | fDAQlbHost(""), fDAQlbPort(), fDAQlbUser(""), fDAQlbPass(""), |
312 | fDAQlbDB(""), fDAQlbTable(""), | |
cb343cfd | 313 | fMaxRetries(0), fPPTimeOut(0), fDetectorMap(), fDetectorList(), |
2bb7b766 | 314 | fShuttleInstanceHost(""), fProcessedDetectors(), fProcessAll(kFALSE) |
73abe331 | 315 | { |
316 | // | |
317 | // host: ldap server host | |
318 | // port: ldap server port | |
319 | // binddn: binddn used for ldap binding (simple bind is used!). | |
320 | // password: password for binddn | |
b948db8d | 321 | // basedn: this is basedn whose childeren entries which have |
73abe331 | 322 | // (objectClass=shuttleConfig) will be used as detector configurations. |
323 | // | |
324 | ||
2bb7b766 | 325 | fDetectorMap.SetOwner(); |
326 | fDetectorList.SetOwner(0); //fDetectorList and fDetectorMap share the same object! | |
327 | fProcessedDetectors.SetOwner(); | |
328 | ||
b948db8d | 329 | TLDAPServer aServer(host, port, binddn, password, 3); |
57f50b3c | 330 | |
73abe331 | 331 | if (!aServer.IsConnected()) { |
2bb7b766 | 332 | AliError(Form("Can't connect to ldap server %s:%d", |
73abe331 | 333 | host, port)); |
334 | return; | |
335 | } | |
336 | ||
b948db8d | 337 | // reads configuration for the shuttle running on this machine |
2bb7b766 | 338 | |
b948db8d | 339 | fShuttleInstanceHost = gSystem->HostName(); |
2bb7b766 | 340 | TString queryFilter = Form("(ShuttleHost=%s)", fShuttleInstanceHost.Data()); |
341 | ||
342 | TLDAPResult* aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, queryFilter.Data()); | |
b948db8d | 343 | |
73abe331 | 344 | if (!aResult) { |
345 | AliError(Form("Can't find configuration with base DN: %s", | |
346 | basedn)); | |
347 | return; | |
348 | } | |
b948db8d | 349 | |
350 | if (aResult->GetCount() == 0) { | |
57f50b3c | 351 | AliError(Form("No Shuttle instance for host = %s!", |
352 | fShuttleInstanceHost.Data())); | |
b948db8d | 353 | AliError(Form("All detectors will be processed.")); |
354 | fProcessAll=kTRUE; | |
355 | } | |
356 | ||
357 | if (aResult->GetCount() > 1) { | |
57f50b3c | 358 | AliError(Form("More than one Shuttle instance for host %s!", |
359 | fShuttleInstanceHost.Data())); | |
2bb7b766 | 360 | delete aResult; |
b948db8d | 361 | return; |
362 | } | |
57f50b3c | 363 | |
2bb7b766 | 364 | TLDAPEntry* anEntry = 0; |
365 | TLDAPAttribute* anAttribute = 0; | |
b948db8d | 366 | |
367 | if(!fProcessAll){ | |
368 | anEntry = aResult->GetNext(); | |
369 | anAttribute = anEntry->GetAttribute("detectors"); | |
370 | const char *detName; | |
371 | while((detName = anAttribute->GetValue())){ | |
372 | TObjString *objDet= new TObjString(detName); | |
373 | fProcessedDetectors.Add(objDet); | |
374 | } | |
375 | } | |
376 | ||
2bb7b766 | 377 | delete anEntry; delete aResult; |
378 | ||
57f50b3c | 379 | // Detector configuration (DCS Archive DB settings) |
380 | ||
2bb7b766 | 381 | aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, "(objectClass=AliShuttleDetector)"); |
b948db8d | 382 | if (!aResult) { |
2bb7b766 | 383 | AliError(Form("Can't find configuration with base DN: %s", basedn)); |
b948db8d | 384 | return; |
385 | } | |
386 | ||
57f50b3c | 387 | |
73abe331 | 388 | while ((anEntry = aResult->GetNext())) { |
58bc3020 | 389 | AliShuttleConfigHolder* aHolder = new AliShuttleConfigHolder(anEntry); |
73abe331 | 390 | delete anEntry; |
391 | ||
392 | if (!aHolder->IsValid()) { | |
57f50b3c | 393 | AliError("Detector configuration error!"); |
73abe331 | 394 | delete aHolder; |
2bb7b766 | 395 | delete aResult; |
57f50b3c | 396 | return; |
73abe331 | 397 | } |
398 | ||
399 | TObjString* detStr = new TObjString(aHolder->GetDetector()); | |
400 | fDetectorMap.Add(detStr, aHolder); | |
d477ad88 | 401 | fDetectorList.AddLast(detStr); |
57f50b3c | 402 | } |
403 | ||
73abe331 | 404 | delete aResult; |
405 | ||
57f50b3c | 406 | // Global configuration (DAQ logbook) |
d477ad88 | 407 | |
408 | aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, | |
b948db8d | 409 | "(objectClass=AliShuttleGlobalConfig)"); |
d477ad88 | 410 | if (!aResult) { |
411 | AliError(Form("Can't find configuration with base DN: %s", | |
412 | basedn)); | |
413 | return; | |
414 | } | |
415 | ||
416 | if (aResult->GetCount() == 0) { | |
b948db8d | 417 | AliError("Can't find DAQ logbook configuration!"); |
2bb7b766 | 418 | delete aResult; |
d477ad88 | 419 | return; |
420 | } | |
421 | ||
422 | if (aResult->GetCount() > 1) { | |
b948db8d | 423 | AliError("More than one DAQ logbook configuration found!"); |
2bb7b766 | 424 | delete aResult; |
d477ad88 | 425 | return; |
426 | } | |
427 | ||
428 | anEntry = aResult->GetNext(); | |
57f50b3c | 429 | |
b948db8d | 430 | anAttribute = anEntry->GetAttribute("DAQLogbookHost"); |
d477ad88 | 431 | if (!anAttribute) { |
b948db8d | 432 | AliError("Can't find DAQLogbookHost attribute!"); |
2bb7b766 | 433 | delete anEntry; delete aResult; |
d477ad88 | 434 | return; |
435 | } | |
57f50b3c | 436 | fDAQlbHost = anAttribute->GetValue(); |
d477ad88 | 437 | |
fc5a4708 | 438 | anAttribute = anEntry->GetAttribute("DAQLogbookPort"); // MAY |
439 | if (anAttribute) | |
440 | { | |
441 | fDAQlbPort = ((TString) anAttribute->GetValue()).Atoi(); | |
442 | } else { | |
443 | fDAQlbPort = 3306; // mysql | |
444 | } | |
445 | ||
b948db8d | 446 | anAttribute = anEntry->GetAttribute("DAQLogbookUser"); |
d477ad88 | 447 | if (!anAttribute) { |
b948db8d | 448 | AliError("Can't find DAQLogbookUser attribute!"); |
2bb7b766 | 449 | delete aResult; delete anEntry; |
d477ad88 | 450 | return; |
451 | } | |
57f50b3c | 452 | fDAQlbUser = anAttribute->GetValue(); |
453 | ||
b948db8d | 454 | anAttribute = anEntry->GetAttribute("DAQLogbookPassword"); |
d477ad88 | 455 | if (!anAttribute) { |
b948db8d | 456 | AliError("Can't find DAQLogbookPassword attribute!"); |
2bb7b766 | 457 | delete aResult; delete anEntry; |
d477ad88 | 458 | return; |
459 | } | |
57f50b3c | 460 | fDAQlbPass = anAttribute->GetValue(); |
d477ad88 | 461 | |
2c15234c | 462 | anAttribute = anEntry->GetAttribute("DAQLogbookDB"); |
463 | if (!anAttribute) { | |
464 | AliError("Can't find DAQLogbookDB attribute!"); | |
465 | delete aResult; delete anEntry; | |
466 | return; | |
467 | } | |
468 | fDAQlbDB = anAttribute->GetValue(); | |
469 | ||
470 | anAttribute = anEntry->GetAttribute("DAQLogbookTable"); | |
471 | if (!anAttribute) { | |
472 | AliError("Can't find DAQLogbookTable attribute!"); | |
473 | delete aResult; delete anEntry; | |
474 | return; | |
475 | } | |
476 | fDAQlbTable = anAttribute->GetValue(); | |
477 | ||
478 | ||
cb343cfd | 479 | anAttribute = anEntry->GetAttribute("MaxRetries"); |
5164a766 | 480 | if (!anAttribute) { |
cb343cfd | 481 | AliError("Can't find MaxRetries attribute!"); |
2bb7b766 | 482 | delete aResult; delete anEntry; |
5164a766 | 483 | return; |
484 | } | |
485 | TString tmpStr = anAttribute->GetValue(); | |
cb343cfd | 486 | fMaxRetries = tmpStr.Atoi(); |
5164a766 | 487 | |
cb343cfd | 488 | anAttribute = anEntry->GetAttribute("PPTimeOut"); |
5164a766 | 489 | if (!anAttribute) { |
cb343cfd | 490 | AliError("Can't find PPTimeOut attribute!"); |
2bb7b766 | 491 | delete aResult; delete anEntry; |
5164a766 | 492 | return; |
493 | } | |
494 | tmpStr = anAttribute->GetValue(); | |
cb343cfd | 495 | fPPTimeOut = tmpStr.Atoi(); |
5164a766 | 496 | |
2bb7b766 | 497 | delete aResult; delete anEntry; |
57f50b3c | 498 | |
2c15234c | 499 | // FXS configuration (FXS logbook and hosts) |
57f50b3c | 500 | |
57f50b3c | 501 | for(int iSys=0;iSys<3;iSys++){ |
eba76848 | 502 | queryFilter = Form("(system=%s)", AliShuttleInterface::GetSystemName(iSys)); |
57f50b3c | 503 | aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, queryFilter.Data()); |
504 | if (!aResult) { | |
505 | AliError(Form("Can't find configuration for system: %s", | |
eba76848 | 506 | AliShuttleInterface::GetSystemName(iSys))); |
57f50b3c | 507 | return; |
508 | } | |
509 | ||
510 | if (aResult->GetCount() != 1 ) { | |
2c15234c | 511 | AliError("Error in FXS configuration!"); |
2bb7b766 | 512 | delete aResult; |
57f50b3c | 513 | return; |
514 | } | |
515 | ||
516 | anEntry = aResult->GetNext(); | |
517 | ||
2c15234c | 518 | anAttribute = anEntry->GetAttribute("DBHost"); |
57f50b3c | 519 | if (!anAttribute) { |
fc5a4708 | 520 | AliError(Form ("Can't find DBHost attribute for %s!!", |
eba76848 | 521 | AliShuttleInterface::GetSystemName(iSys))); |
2bb7b766 | 522 | delete aResult; delete anEntry; |
57f50b3c | 523 | return; |
524 | } | |
2c15234c | 525 | fFXSdbHost[iSys] = anAttribute->GetValue(); |
57f50b3c | 526 | |
fc5a4708 | 527 | anAttribute = anEntry->GetAttribute("DBPort"); // MAY |
528 | if (anAttribute) | |
529 | { | |
530 | fFXSdbPort[iSys] = ((TString) anAttribute->GetValue()).Atoi(); | |
531 | } else { | |
532 | fFXSdbPort[iSys] = 3306; // mysql | |
533 | } | |
534 | ||
2c15234c | 535 | anAttribute = anEntry->GetAttribute("DBUser"); |
57f50b3c | 536 | if (!anAttribute) { |
2c15234c | 537 | AliError(Form ("Can't find DBUser attribute for %s!!", |
eba76848 | 538 | AliShuttleInterface::GetSystemName(iSys))); |
2bb7b766 | 539 | delete aResult; delete anEntry; |
57f50b3c | 540 | return; |
541 | } | |
2c15234c | 542 | fFXSdbUser[iSys] = anAttribute->GetValue(); |
57f50b3c | 543 | |
2c15234c | 544 | anAttribute = anEntry->GetAttribute("DBPassword"); |
57f50b3c | 545 | if (!anAttribute) { |
2c15234c | 546 | AliError(Form ("Can't find DBPassword attribute for %s!!", |
eba76848 | 547 | AliShuttleInterface::GetSystemName(iSys))); |
2bb7b766 | 548 | delete aResult; delete anEntry; |
57f50b3c | 549 | return; |
550 | } | |
2c15234c | 551 | fFXSdbPass[iSys] = anAttribute->GetValue(); |
552 | ||
553 | anAttribute = anEntry->GetAttribute("DBName"); | |
554 | if (!anAttribute) { | |
555 | AliError(Form ("Can't find DBName attribute for %s!!", | |
556 | AliShuttleInterface::GetSystemName(iSys))); | |
557 | delete aResult; delete anEntry; | |
558 | return; | |
559 | } | |
560 | ||
561 | fFXSdbName[iSys] = anAttribute->GetValue(); | |
562 | anAttribute = anEntry->GetAttribute("DBTable"); | |
563 | if (!anAttribute) { | |
564 | AliError(Form ("Can't find DBTable attribute for %s!!", | |
565 | AliShuttleInterface::GetSystemName(iSys))); | |
566 | delete aResult; delete anEntry; | |
567 | return; | |
568 | } | |
569 | fFXSdbTable[iSys] = anAttribute->GetValue(); | |
57f50b3c | 570 | |
571 | anAttribute = anEntry->GetAttribute("FSHost"); | |
572 | if (!anAttribute) { | |
573 | AliError(Form ("Can't find FSHost attribute for %s!!", | |
eba76848 | 574 | AliShuttleInterface::GetSystemName(iSys))); |
2bb7b766 | 575 | delete aResult; delete anEntry; |
57f50b3c | 576 | return; |
577 | } | |
2c15234c | 578 | fFXSHost[iSys] = anAttribute->GetValue(); |
57f50b3c | 579 | |
fc5a4708 | 580 | anAttribute = anEntry->GetAttribute("FSPort"); // MAY |
581 | if (anAttribute) | |
582 | { | |
583 | fFXSPort[iSys] = ((TString) anAttribute->GetValue()).Atoi(); | |
584 | } else { | |
585 | fFXSPort[iSys] = 22; // scp port number | |
586 | } | |
587 | ||
57f50b3c | 588 | anAttribute = anEntry->GetAttribute("FSUser"); |
589 | if (!anAttribute) { | |
590 | AliError(Form ("Can't find FSUser attribute for %s!!", | |
eba76848 | 591 | AliShuttleInterface::GetSystemName(iSys))); |
2bb7b766 | 592 | delete aResult; delete anEntry; |
57f50b3c | 593 | return; |
594 | } | |
2c15234c | 595 | fFXSUser[iSys] = anAttribute->GetValue(); |
57f50b3c | 596 | |
597 | anAttribute = anEntry->GetAttribute("FSPassword"); | |
2c15234c | 598 | if (anAttribute) fFXSPass[iSys] = anAttribute->GetValue(); |
57f50b3c | 599 | |
2bb7b766 | 600 | delete aResult; delete anEntry; |
57f50b3c | 601 | } |
602 | ||
73abe331 | 603 | fIsValid = kTRUE; |
604 | } | |
605 | ||
a7160fe9 | 606 | //______________________________________________________________________________________________ |
607 | AliShuttleConfig::~AliShuttleConfig() | |
58bc3020 | 608 | { |
609 | // destructor | |
610 | ||
73abe331 | 611 | fDetectorMap.DeleteAll(); |
2bb7b766 | 612 | fDetectorList.Clear(); |
613 | fProcessedDetectors.Delete(); | |
73abe331 | 614 | } |
615 | ||
a7160fe9 | 616 | //______________________________________________________________________________________________ |
617 | const TObjArray* AliShuttleConfig::GetDetectors() const | |
58bc3020 | 618 | { |
73abe331 | 619 | // |
620 | // returns collection of TObjString which contains the name | |
621 | // of every detector which is in the configuration. | |
622 | // | |
623 | ||
624 | return &fDetectorList; | |
625 | } | |
626 | ||
a7160fe9 | 627 | //______________________________________________________________________________________________ |
628 | Bool_t AliShuttleConfig::HasDetector(const char* detector) const | |
58bc3020 | 629 | { |
73abe331 | 630 | // |
631 | // checks for paricular detector in the configuration. | |
632 | // | |
633 | return fDetectorMap.GetValue(detector) != NULL; | |
634 | } | |
635 | ||
a7160fe9 | 636 | //______________________________________________________________________________________________ |
637 | const char* AliShuttleConfig::GetDCSHost(const char* detector) const | |
58bc3020 | 638 | { |
73abe331 | 639 | // |
640 | // returns DCS server host used by particular detector | |
641 | // | |
642 | ||
58bc3020 | 643 | AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector); |
73abe331 | 644 | if (!aHolder) { |
645 | AliError(Form("There isn't configuration for detector: %s", | |
646 | detector)); | |
647 | return NULL; | |
648 | } | |
649 | ||
b948db8d | 650 | return aHolder->GetDCSHost(); |
73abe331 | 651 | } |
652 | ||
a7160fe9 | 653 | //______________________________________________________________________________________________ |
654 | Int_t AliShuttleConfig::GetDCSPort(const char* detector) const | |
58bc3020 | 655 | { |
73abe331 | 656 | // |
657 | // returns DCS server port used by particular detector | |
658 | // | |
659 | ||
660 | ||
58bc3020 | 661 | AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector); |
73abe331 | 662 | if (!aHolder) { |
663 | AliError(Form("There isn't configuration for detector: %s", | |
664 | detector)); | |
665 | return 0; | |
666 | } | |
667 | ||
b948db8d | 668 | return aHolder->GetDCSPort(); |
73abe331 | 669 | } |
670 | ||
a7160fe9 | 671 | //______________________________________________________________________________________________ |
672 | const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector) const | |
58bc3020 | 673 | { |
73abe331 | 674 | // |
675 | // returns collection of TObjString which represents the set of aliases | |
676 | // which used for data retrieval for particular detector | |
677 | // | |
678 | ||
58bc3020 | 679 | AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector); |
73abe331 | 680 | if (!aHolder) { |
681 | AliError(Form("There isn't configuration for detector: %s", | |
682 | detector)); | |
683 | return NULL; | |
684 | } | |
685 | ||
b948db8d | 686 | return aHolder->GetDCSAliases(); |
687 | } | |
688 | ||
2c15234c | 689 | //______________________________________________________________________________________________ |
690 | const TObjArray* AliShuttleConfig::GetDCSDataPoints(const char* detector) const | |
691 | { | |
692 | // | |
693 | // returns collection of TObjString which represents the set of aliases | |
694 | // which used for data retrieval for particular detector | |
695 | // | |
696 | ||
697 | AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector); | |
698 | if (!aHolder) { | |
699 | AliError(Form("There isn't configuration for detector: %s", | |
700 | detector)); | |
701 | return NULL; | |
702 | } | |
703 | ||
704 | return aHolder->GetDCSDataPoints(); | |
705 | } | |
706 | ||
57c1a579 | 707 | //______________________________________________________________________________________________ |
708 | const TObjArray* AliShuttleConfig::GetResponsibles(const char* detector) const | |
709 | { | |
710 | // | |
711 | // returns collection of TObjString which represents the list of mail addresses | |
712 | // of the detector's responsible(s) | |
713 | // | |
714 | ||
715 | AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector); | |
716 | if (!aHolder) { | |
717 | AliError(Form("There isn't configuration for detector: %s", | |
718 | detector)); | |
719 | return NULL; | |
720 | } | |
721 | ||
722 | return aHolder->GetResponsibles(); | |
723 | } | |
724 | ||
a7160fe9 | 725 | //______________________________________________________________________________________________ |
726 | Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const | |
58bc3020 | 727 | { |
b948db8d | 728 | // return TRUE if detector is handled by host or if fProcessAll is TRUE |
729 | ||
730 | if(fProcessAll) return kTRUE; | |
731 | TIter iter(&fProcessedDetectors); | |
732 | TObjString* detName; | |
733 | while((detName = (TObjString*) iter.Next())){ | |
734 | if(detName->String() == detector) return kTRUE; | |
735 | } | |
736 | return kFALSE; | |
73abe331 | 737 | } |
738 | ||
be48e3ea | 739 | //______________________________________________________________________________________________ |
740 | Bool_t AliShuttleConfig::StrictRunOrder(const char* detector) const | |
741 | { | |
742 | // return TRUE if detector wants strict run ordering of stored data | |
743 | ||
744 | AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector); | |
745 | if (!aHolder) | |
746 | { | |
747 | AliError(Form("There isn't configuration for detector: %s", | |
748 | detector)); | |
749 | return kTRUE; | |
750 | } | |
751 | ||
752 | return aHolder->StrictRunOrder(); | |
753 | } | |
754 | ||
a7160fe9 | 755 | //______________________________________________________________________________________________ |
36c99a6a | 756 | void AliShuttleConfig::Print(Option_t* option) const |
58bc3020 | 757 | { |
758 | // print configuration | |
36c99a6a | 759 | // options : "": print configuration for all detectors, aliases and DPs in compacted format |
760 | // "uncompact": print configuration for all detectors, aliases and DPs in uncompacted format | |
761 | // "DET": print configuration for DET, aliases and DPs in compacted format | |
762 | // "DET, uncompact": print configuration for DET, aliases and DPs in uncompacted format | |
763 | ||
73abe331 | 764 | TString result; |
765 | result += '\n'; | |
d477ad88 | 766 | |
57c1a579 | 767 | result += "####################################################\n"; |
768 | result += Form(" Shuttle configuration from %s \n", fConfigHost.Data()); | |
769 | result += "####################################################\n"; | |
770 | result += Form("\nShuttle running on %s \n", fShuttleInstanceHost.Data()); | |
57f50b3c | 771 | |
772 | if(fProcessAll) { | |
57c1a579 | 773 | result += Form("All detectors will be processed! \n"); |
57f50b3c | 774 | } else { |
775 | result += "Detectors processed by this host: "; | |
776 | TIter it(&fProcessedDetectors); | |
777 | TObjString* aDet; | |
778 | while ((aDet = (TObjString*) it.Next())) { | |
779 | result += Form("%s ", aDet->String().Data()); | |
780 | } | |
57c1a579 | 781 | result += "\n"; |
b948db8d | 782 | } |
b948db8d | 783 | |
cb343cfd | 784 | result += Form("PP time out = %d - Max total retries = %d\n\n", fPPTimeOut, fMaxRetries); |
57c1a579 | 785 | result += "------------------------------------------------------\n"; |
2bb7b766 | 786 | |
57c1a579 | 787 | result += Form("Logbook Configuration \n\n \tHost: %s:%d; \tUser: %s; ", |
fc5a4708 | 788 | fDAQlbHost.Data(), fDAQlbPort, fDAQlbUser.Data()); |
b948db8d | 789 | |
2c15234c | 790 | // result += "Password: "; |
791 | // result.Append('*', fDAQlbPass.Length()); | |
792 | result += Form("\tDB: %s; \tTable: %s", | |
793 | fDAQlbDB.Data(), fDAQlbTable.Data()); | |
794 | ||
57f50b3c | 795 | result += "\n\n"; |
796 | ||
57c1a579 | 797 | result += "------------------------------------------------------\n"; |
798 | result += "FXS configuration\n\n"; | |
799 | ||
57f50b3c | 800 | for(int iSys=0;iSys<3;iSys++){ |
57c1a579 | 801 | result += Form("*** %s ***\n", AliShuttleInterface::GetSystemName(iSys)); |
fc5a4708 | 802 | result += Form("\tDB host: %s:%d; \tUser: %s; \tName: %s; \tTable: %s\n", |
803 | fFXSdbHost[iSys].Data(), fFXSdbPort[iSys], fFXSdbUser[iSys].Data(), | |
2c15234c | 804 | fFXSdbName[iSys].Data(), fFXSdbTable[iSys].Data()); |
805 | // result += Form("DB Password:",fFXSdbPass[iSys].Data()); | |
fc5a4708 | 806 | result += Form("\tFXS host: %s:%d; \tUser: %s\n\n", fFXSHost[iSys].Data(), fFXSPort[iSys], |
807 | fFXSUser[iSys].Data()); | |
2c15234c | 808 | // result += Form("FXS Password:",fFXSPass[iSys].Data()); |
57f50b3c | 809 | } |
b948db8d | 810 | |
36c99a6a | 811 | TString optStr(option); |
812 | ||
57c1a579 | 813 | result += "------------------------------------------------------\n"; |
814 | result += "Detector-specific configuration\n\n"; | |
73abe331 | 815 | TIter iter(fDetectorMap.GetTable()); |
816 | TPair* aPair; | |
817 | while ((aPair = (TPair*) iter.Next())) { | |
58bc3020 | 818 | AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) aPair->Value(); |
36c99a6a | 819 | if (option != 0 && !optStr.Contains(aHolder->GetDetector()) && optStr.CompareTo("uncompact",TString::kIgnoreCase) != 0 ) |
820 | continue; | |
57c1a579 | 821 | result += Form("*** %s *** \n", aHolder->GetDetector()); |
822 | ||
823 | const TObjArray* responsibles = aHolder->GetResponsibles(); | |
824 | if (responsibles->GetEntries() != 0) | |
825 | { | |
826 | result += "\tDetector responsible(s): "; | |
827 | TIter it(responsibles); | |
828 | TObjString* aResponsible; | |
829 | while ((aResponsible = (TObjString*) it.Next())) | |
830 | { | |
831 | result += Form("%s ", aResponsible->String().Data()); | |
832 | } | |
833 | result += "\n"; | |
834 | } | |
835 | ||
836 | result += Form("\tStrict run ordering: %s \n", aHolder->StrictRunOrder() ? "YES" : "NO"); | |
be48e3ea | 837 | if(aHolder->SkipDCSQuery()) |
838 | { | |
2c15234c | 839 | result += "\n"; |
be48e3ea | 840 | continue; |
841 | } | |
57f50b3c | 842 | result += Form("\tAmanda server: %s:%d \n", aHolder->GetDCSHost(), aHolder->GetDCSPort()); |
843 | ||
36c99a6a | 844 | const TObjArray* aliases = 0; |
845 | if (optStr.Contains("uncompact",TString::kIgnoreCase)) | |
846 | { | |
847 | aliases = aHolder->GetDCSAliases(); | |
848 | } else { | |
849 | aliases = aHolder->GetCompactDCSAliases(); | |
850 | } | |
851 | ||
2c15234c | 852 | if (aliases->GetEntries() != 0) |
853 | { | |
854 | result += "\tDCS Aliases: "; | |
855 | TIter it(aliases); | |
856 | TObjString* anAlias; | |
857 | while ((anAlias = (TObjString*) it.Next())) | |
858 | { | |
859 | result += Form("%s ", anAlias->String().Data()); | |
860 | } | |
861 | result += "\n"; | |
57f50b3c | 862 | } |
863 | ||
36c99a6a | 864 | const TObjArray* dataPoints = 0; |
865 | if (optStr.Contains("uncompact",TString::kIgnoreCase)) | |
866 | { | |
867 | dataPoints = aHolder->GetDCSDataPoints(); | |
868 | } else { | |
869 | dataPoints = aHolder->GetCompactDCSDataPoints(); | |
870 | } | |
2c15234c | 871 | if (dataPoints->GetEntries() != 0) |
872 | { | |
873 | result += "\tDCS Data Points: "; | |
874 | TIter it(dataPoints); | |
875 | TObjString* aDataPoint; | |
876 | while ((aDataPoint = (TObjString*) it.Next())) { | |
877 | result += Form("%s ", aDataPoint->String().Data()); | |
878 | } | |
879 | result += "\n"; | |
880 | } | |
881 | result += "\n"; | |
73abe331 | 882 | } |
883 | ||
57f50b3c | 884 | if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n"; |
885 | ||
73abe331 | 886 | AliInfo(result); |
887 | } |