1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.8 2006/08/15 10:50:00 jgrosseo
19 effc++ corrections (alberto)
21 Revision 1.7 2006/07/20 09:54:40 jgrosseo
22 introducing status management: The processing per subdetector is divided into several steps,
23 after each step the status is stored on disk. If the system crashes in any of the steps the Shuttle
24 can keep track of the number of failures and skips further processing after a certain threshold is
25 exceeded. These thresholds can be configured in LDAP.
27 Revision 1.6 2006/07/19 10:09:55 jgrosseo
28 new configuration, accesst to DAQ FES (Alberto)
30 Revision 1.5 2006/07/10 13:01:41 jgrosseo
31 enhanced storing of last sucessfully processed run (alberto)
33 Revision 1.4 2006/06/12 09:11:16 jgrosseo
34 coding conventions (Alberto)
36 Revision 1.3 2006/06/06 14:26:40 jgrosseo
37 o) removed files that were moved to STEER
38 o) shuttle updated to follow the new interface (Alberto)
40 Revision 1.7 2006/05/12 09:07:16 colla
42 New configuration complete
44 Revision 1.2 2006/03/07 07:52:34 hristov
45 New version (B.Yordanov)
47 Revision 1.4 2005/11/19 14:20:31 byordano
48 logbook config added to AliShuttleConfig
50 Revision 1.3 2005/11/17 19:24:25 byordano
51 TList changed to TObjArray in AliShuttleConfig
53 Revision 1.2 2005/11/17 14:43:23 byordano
56 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
57 Initial import as subdirectory in AliRoot
59 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
62 Revision 1.3 2005/08/30 09:13:02 byordano
69 // This class keeps the AliShuttle configuration.
70 // It reads the configuration for LDAP server.
71 // For every child entry in basedn which has schema type 'shuttleConfig'
72 // it creates a detector configuration. This configuration includes:
73 // DCS server host and port and the set of aliases for which data from
74 // will be retrieved (used by AliShuttle).
78 #include "AliShuttleConfig.h"
79 #include "AliShuttleInterface.h"
84 #include <TObjString.h>
85 #include <TLDAPResult.h>
86 #include <TLDAPEntry.h>
87 #include <TLDAPAttribute.h>
90 AliShuttleConfig::AliShuttleConfigHolder::AliShuttleConfigHolder(const TLDAPEntry* entry):
97 // constructor of the shuttle configuration holder
99 TLDAPAttribute* anAttribute;
100 fDCSAliases = new TObjArray();
101 fDCSAliases->SetOwner(1);
103 anAttribute = entry->GetAttribute("det"); // MUST
104 fDetector = anAttribute->GetValue();
106 anAttribute = entry->GetAttribute("DCSHost"); // MAY
109 Form("%s has not DCS host entry - Shuttle will skip DCS data query!",
112 fSkipDCSQuery = kTRUE;
116 fDCSHost = anAttribute->GetValue();
118 anAttribute = entry->GetAttribute("DCSPort"); // MAY
120 AliError(Form("Invalid configuration! %s has DCS Host but no port number!",
124 TString portStr = anAttribute->GetValue();
125 fDCSPort = portStr.Atoi();
127 anAttribute = entry->GetAttribute("DCSAlias"); // MAY
129 AliError(Form("Invalid configuration! %s has DCS host settings but no DCSAlias entries!",
135 while ((anAlias = anAttribute->GetValue())) {
136 fDCSAliases->AddLast(new TObjString(anAlias));
144 //______________________________________________________________________________________________
145 AliShuttleConfig::AliShuttleConfigHolder::~AliShuttleConfigHolder()
147 // destructor of the shuttle configuration holder
152 ClassImp(AliShuttleConfig)
154 //______________________________________________________________________________________________
155 AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
156 const char* binddn, const char* password, const char* basedn):
158 fDAQlbHost(""), fDAQlbUser(""), fDAQlbPass(""),
159 fMaxPPRetries(0), fMaxRetries(0), fDetectorMap(), fDetectorList(),
160 fShuttleInstanceHost(""), fProcessedDetectors(), fProcessAll(kFALSE)
163 // host: ldap server host
164 // port: ldap server port
165 // binddn: binddn used for ldap binding (simple bind is used!).
166 // password: password for binddn
167 // basedn: this is basedn whose childeren entries which have
168 // (objectClass=shuttleConfig) will be used as detector configurations.
171 fDetectorMap.SetOwner();
172 fDetectorList.SetOwner(0); //fDetectorList and fDetectorMap share the same object!
173 fProcessedDetectors.SetOwner();
175 TLDAPServer aServer(host, port, binddn, password, 3);
177 if (!aServer.IsConnected()) {
178 AliError(Form("Can't connect to ldap server %s:%d",
183 // reads configuration for the shuttle running on this machine
185 fShuttleInstanceHost = gSystem->HostName();
186 TString queryFilter = Form("(ShuttleHost=%s)", fShuttleInstanceHost.Data());
188 TLDAPResult* aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, queryFilter.Data());
191 AliError(Form("Can't find configuration with base DN: %s",
196 if (aResult->GetCount() == 0) {
197 AliError(Form("No Shuttle instance for host = %s!",
198 fShuttleInstanceHost.Data()));
199 AliError(Form("All detectors will be processed."));
203 if (aResult->GetCount() > 1) {
204 AliError(Form("More than one Shuttle instance for host %s!",
205 fShuttleInstanceHost.Data()));
210 TLDAPEntry* anEntry = 0;
211 TLDAPAttribute* anAttribute = 0;
214 anEntry = aResult->GetNext();
215 anAttribute = anEntry->GetAttribute("detectors");
217 while((detName = anAttribute->GetValue())){
218 TObjString *objDet= new TObjString(detName);
219 fProcessedDetectors.Add(objDet);
223 delete anEntry; delete aResult;
225 // Detector configuration (DCS Archive DB settings)
227 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, "(objectClass=AliShuttleDetector)");
229 AliError(Form("Can't find configuration with base DN: %s", basedn));
234 while ((anEntry = aResult->GetNext())) {
235 AliShuttleConfigHolder* aHolder = new AliShuttleConfigHolder(anEntry);
238 if (!aHolder->IsValid()) {
239 AliError("Detector configuration error!");
245 TObjString* detStr = new TObjString(aHolder->GetDetector());
246 fDetectorMap.Add(detStr, aHolder);
247 fDetectorList.AddLast(detStr);
252 // Global configuration (DAQ logbook)
254 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL,
255 "(objectClass=AliShuttleGlobalConfig)");
257 AliError(Form("Can't find configuration with base DN: %s",
262 if (aResult->GetCount() == 0) {
263 AliError("Can't find DAQ logbook configuration!");
268 if (aResult->GetCount() > 1) {
269 AliError("More than one DAQ logbook configuration found!");
274 anEntry = aResult->GetNext();
276 anAttribute = anEntry->GetAttribute("DAQLogbookHost");
278 AliError("Can't find DAQLogbookHost attribute!");
279 delete anEntry; delete aResult;
282 fDAQlbHost = anAttribute->GetValue();
284 anAttribute = anEntry->GetAttribute("DAQLogbookUser");
286 AliError("Can't find DAQLogbookUser attribute!");
287 delete aResult; delete anEntry;
290 fDAQlbUser = anAttribute->GetValue();
292 anAttribute = anEntry->GetAttribute("DAQLogbookPassword");
294 AliError("Can't find DAQLogbookPassword attribute!");
295 delete aResult; delete anEntry;
298 fDAQlbPass = anAttribute->GetValue();
300 anAttribute = anEntry->GetAttribute("MaxPPRetries");
302 AliError("Can't find MaxPPRetries attribute!");
303 delete aResult; delete anEntry;
306 TString tmpStr = anAttribute->GetValue();
307 fMaxPPRetries = tmpStr.Atoi();
309 anAttribute = anEntry->GetAttribute("MaxRetries");
311 AliError("Can't find MaxRetries attribute!");
312 delete aResult; delete anEntry;
315 tmpStr = anAttribute->GetValue();
316 fMaxRetries = tmpStr.Atoi();
318 delete aResult; delete anEntry;
320 // FES configuration (FES logbook and hosts)
322 for(int iSys=0;iSys<3;iSys++){
323 queryFilter = Form("(system=%s)", AliShuttleInterface::fkSystemNames[iSys]);
324 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, queryFilter.Data());
326 AliError(Form("Can't find configuration for system: %s",
327 AliShuttleInterface::fkSystemNames[iSys]));
331 if (aResult->GetCount() != 1 ) {
332 AliError("Error in FES configuration!");
337 anEntry = aResult->GetNext();
339 anAttribute = anEntry->GetAttribute("LogbookHost");
341 AliError(Form ("Can't find LogbookHost attribute for %s!!",
342 AliShuttleInterface::fkSystemNames[iSys]));
343 delete aResult; delete anEntry;
346 fFESlbHost[iSys] = anAttribute->GetValue();
348 anAttribute = anEntry->GetAttribute("LogbookUser");
350 AliError(Form ("Can't find LogbookUser attribute for %s!!",
351 AliShuttleInterface::fkSystemNames[iSys]));
352 delete aResult; delete anEntry;
355 fFESlbUser[iSys] = anAttribute->GetValue();
357 anAttribute = anEntry->GetAttribute("LogbookPassword");
359 AliError(Form ("Can't find LogbookPassword attribute for %s!!",
360 AliShuttleInterface::fkSystemNames[iSys]));
361 delete aResult; delete anEntry;
364 fFESlbPass[iSys] = anAttribute->GetValue();
366 anAttribute = anEntry->GetAttribute("FSHost");
368 AliError(Form ("Can't find FSHost attribute for %s!!",
369 AliShuttleInterface::fkSystemNames[iSys]));
370 delete aResult; delete anEntry;
373 fFESHost[iSys] = anAttribute->GetValue();
375 anAttribute = anEntry->GetAttribute("FSUser");
377 AliError(Form ("Can't find FSUser attribute for %s!!",
378 AliShuttleInterface::fkSystemNames[iSys]));
379 delete aResult; delete anEntry;
382 fFESUser[iSys] = anAttribute->GetValue();
384 anAttribute = anEntry->GetAttribute("FSPassword");
385 if (anAttribute) fFESPass[iSys] = anAttribute->GetValue();
387 delete aResult; delete anEntry;
393 //______________________________________________________________________________________________
394 AliShuttleConfig::~AliShuttleConfig()
398 fDetectorMap.DeleteAll();
399 fDetectorList.Clear();
400 fProcessedDetectors.Delete();
403 //______________________________________________________________________________________________
404 const TObjArray* AliShuttleConfig::GetDetectors() const
407 // returns collection of TObjString which contains the name
408 // of every detector which is in the configuration.
411 return &fDetectorList;
414 //______________________________________________________________________________________________
415 Bool_t AliShuttleConfig::HasDetector(const char* detector) const
418 // checks for paricular detector in the configuration.
420 return fDetectorMap.GetValue(detector) != NULL;
423 //______________________________________________________________________________________________
424 const char* AliShuttleConfig::GetDCSHost(const char* detector) const
427 // returns DCS server host used by particular detector
430 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
432 AliError(Form("There isn't configuration for detector: %s",
437 return aHolder->GetDCSHost();
440 //______________________________________________________________________________________________
441 Int_t AliShuttleConfig::GetDCSPort(const char* detector) const
444 // returns DCS server port used by particular detector
448 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
450 AliError(Form("There isn't configuration for detector: %s",
455 return aHolder->GetDCSPort();
458 //______________________________________________________________________________________________
459 const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector) const
462 // returns collection of TObjString which represents the set of aliases
463 // which used for data retrieval for particular detector
466 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
468 AliError(Form("There isn't configuration for detector: %s",
473 return aHolder->GetDCSAliases();
476 //______________________________________________________________________________________________
477 Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
479 // return TRUE if detector is handled by host or if fProcessAll is TRUE
481 if(fProcessAll) return kTRUE;
482 TIter iter(&fProcessedDetectors);
484 while((detName = (TObjString*) iter.Next())){
485 if(detName->String() == detector) return kTRUE;
490 //______________________________________________________________________________________________
491 void AliShuttleConfig::Print(Option_t* /*option*/) const
493 // print configuration
498 result += Form("\nShuttle running on %s \n\n", fShuttleInstanceHost.Data());
501 result += Form("All detectors will be processed! \n\n");
503 result += "Detectors processed by this host: ";
504 TIter it(&fProcessedDetectors);
506 while ((aDet = (TObjString*) it.Next())) {
507 result += Form("%s ", aDet->String().Data());
512 result += Form("Max PP retries = %d - Max total retries = %d\n\n", fMaxPPRetries, fMaxRetries);
514 result += Form("DAQ Logbook Configuration \n \tHost: %s - User: %s - ",
515 fDAQlbHost.Data(), fDAQlbUser.Data());
517 result += "Password: ";
518 result.Append('*', fDAQlbPass.Length());
521 for(int iSys=0;iSys<3;iSys++){
522 result += Form("FES Configuration for %s system\n", AliShuttleInterface::fkSystemNames[iSys]);
523 result += Form("\tLogbook host: \t%s - \tUser: %s\n",
524 fFESlbHost[iSys].Data(), fFESlbUser[iSys].Data());
525 // result += Form("Logbook Password:",fFESlbPass[iSys].Data());
526 result += Form("\tFES host: \t%s - \tUser: %s\n\n", fFESHost[iSys].Data(), fFESUser[iSys].Data());
527 // result += Form("FES Password:",fFESPass[iSys].Data());
530 TIter iter(fDetectorMap.GetTable());
532 while ((aPair = (TPair*) iter.Next())) {
533 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) aPair->Value();
534 if(aHolder->SkipDCSQuery()) continue;
535 result += Form("DCS archive DB configuration for *** %s *** \n", aHolder->GetDetector());
536 result += Form("\tAmanda server: %s:%d \n", aHolder->GetDCSHost(), aHolder->GetDCSPort());
538 result += "\tDCS Aliases: ";
539 const TObjArray* aliases = aHolder->GetDCSAliases();
542 while ((anAlias = (TObjString*) it.Next())) {
543 result += Form("%s ", anAlias->String().Data());
550 if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n";