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