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.10 2006/10/20 15:22:59 jgrosseo
19 o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child
20 o) Merging Collect, CollectAll, CollectNew function
21 o) Removing implementation of empty copy constructors (declaration still there!)
23 Revision 1.9 2006/10/02 16:38:39 jgrosseo
26 storing of objects that failed to be stored to the grid before
27 interfacing of shuttle status table in daq system
29 Revision 1.8 2006/08/15 10:50:00 jgrosseo
30 effc++ corrections (alberto)
32 Revision 1.7 2006/07/20 09:54:40 jgrosseo
33 introducing status management: The processing per subdetector is divided into several steps,
34 after each step the status is stored on disk. If the system crashes in any of the steps the Shuttle
35 can keep track of the number of failures and skips further processing after a certain threshold is
36 exceeded. These thresholds can be configured in LDAP.
38 Revision 1.6 2006/07/19 10:09:55 jgrosseo
39 new configuration, accesst to DAQ FES (Alberto)
41 Revision 1.5 2006/07/10 13:01:41 jgrosseo
42 enhanced storing of last sucessfully processed run (alberto)
44 Revision 1.4 2006/06/12 09:11:16 jgrosseo
45 coding conventions (Alberto)
47 Revision 1.3 2006/06/06 14:26:40 jgrosseo
48 o) removed files that were moved to STEER
49 o) shuttle updated to follow the new interface (Alberto)
51 Revision 1.7 2006/05/12 09:07:16 colla
53 New configuration complete
55 Revision 1.2 2006/03/07 07:52:34 hristov
56 New version (B.Yordanov)
58 Revision 1.4 2005/11/19 14:20:31 byordano
59 logbook config added to AliShuttleConfig
61 Revision 1.3 2005/11/17 19:24:25 byordano
62 TList changed to TObjArray in AliShuttleConfig
64 Revision 1.2 2005/11/17 14:43:23 byordano
67 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
68 Initial import as subdirectory in AliRoot
70 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
73 Revision 1.3 2005/08/30 09:13:02 byordano
80 // This class keeps the AliShuttle configuration.
81 // It reads the configuration for LDAP server.
82 // For every child entry in basedn which has schema type 'shuttleConfig'
83 // it creates a detector configuration. This configuration includes:
84 // DCS server host and port and the set of aliases for which data from
85 // will be retrieved (used by AliShuttle).
89 #include "AliShuttleConfig.h"
90 #include "AliShuttleInterface.h"
95 #include <TObjString.h>
96 #include <TLDAPResult.h>
97 #include <TLDAPEntry.h>
98 #include <TLDAPAttribute.h>
101 AliShuttleConfig::AliShuttleConfigHolder::AliShuttleConfigHolder(const TLDAPEntry* entry):
106 fSkipDCSQuery(kFALSE)
108 // constructor of the shuttle configuration holder
110 TLDAPAttribute* anAttribute;
111 fDCSAliases = new TObjArray();
112 fDCSAliases->SetOwner(1);
114 anAttribute = entry->GetAttribute("det"); // MUST
115 fDetector = anAttribute->GetValue();
117 anAttribute = entry->GetAttribute("DCSHost"); // MAY
120 Form("%s has not DCS host entry - Shuttle will skip DCS data query!",
123 fSkipDCSQuery = kTRUE;
127 fDCSHost = anAttribute->GetValue();
129 anAttribute = entry->GetAttribute("DCSPort"); // MAY
131 AliError(Form("Invalid configuration! %s has DCS Host but no port number!",
135 TString portStr = anAttribute->GetValue();
136 fDCSPort = portStr.Atoi();
138 anAttribute = entry->GetAttribute("DCSAlias"); // MAY
140 AliError(Form("Invalid configuration! %s has DCS host settings but no DCSAlias entries!",
146 while ((anAlias = anAttribute->GetValue())) {
147 fDCSAliases->AddLast(new TObjString(anAlias));
155 //______________________________________________________________________________________________
156 AliShuttleConfig::AliShuttleConfigHolder::~AliShuttleConfigHolder()
158 // destructor of the shuttle configuration holder
163 ClassImp(AliShuttleConfig)
165 //______________________________________________________________________________________________
166 AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
167 const char* binddn, const char* password, const char* basedn):
169 fDAQlbHost(""), fDAQlbUser(""), fDAQlbPass(""),
170 fMaxRetries(0), fPPTimeOut(0), fDetectorMap(), fDetectorList(),
171 fShuttleInstanceHost(""), fProcessedDetectors(), fProcessAll(kFALSE)
174 // host: ldap server host
175 // port: ldap server port
176 // binddn: binddn used for ldap binding (simple bind is used!).
177 // password: password for binddn
178 // basedn: this is basedn whose childeren entries which have
179 // (objectClass=shuttleConfig) will be used as detector configurations.
182 fDetectorMap.SetOwner();
183 fDetectorList.SetOwner(0); //fDetectorList and fDetectorMap share the same object!
184 fProcessedDetectors.SetOwner();
186 TLDAPServer aServer(host, port, binddn, password, 3);
188 if (!aServer.IsConnected()) {
189 AliError(Form("Can't connect to ldap server %s:%d",
194 // reads configuration for the shuttle running on this machine
196 fShuttleInstanceHost = gSystem->HostName();
197 TString queryFilter = Form("(ShuttleHost=%s)", fShuttleInstanceHost.Data());
199 TLDAPResult* aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, queryFilter.Data());
202 AliError(Form("Can't find configuration with base DN: %s",
207 if (aResult->GetCount() == 0) {
208 AliError(Form("No Shuttle instance for host = %s!",
209 fShuttleInstanceHost.Data()));
210 AliError(Form("All detectors will be processed."));
214 if (aResult->GetCount() > 1) {
215 AliError(Form("More than one Shuttle instance for host %s!",
216 fShuttleInstanceHost.Data()));
221 TLDAPEntry* anEntry = 0;
222 TLDAPAttribute* anAttribute = 0;
225 anEntry = aResult->GetNext();
226 anAttribute = anEntry->GetAttribute("detectors");
228 while((detName = anAttribute->GetValue())){
229 TObjString *objDet= new TObjString(detName);
230 fProcessedDetectors.Add(objDet);
234 delete anEntry; delete aResult;
236 // Detector configuration (DCS Archive DB settings)
238 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, "(objectClass=AliShuttleDetector)");
240 AliError(Form("Can't find configuration with base DN: %s", basedn));
245 while ((anEntry = aResult->GetNext())) {
246 AliShuttleConfigHolder* aHolder = new AliShuttleConfigHolder(anEntry);
249 if (!aHolder->IsValid()) {
250 AliError("Detector configuration error!");
256 TObjString* detStr = new TObjString(aHolder->GetDetector());
257 fDetectorMap.Add(detStr, aHolder);
258 fDetectorList.AddLast(detStr);
263 // Global configuration (DAQ logbook)
265 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL,
266 "(objectClass=AliShuttleGlobalConfig)");
268 AliError(Form("Can't find configuration with base DN: %s",
273 if (aResult->GetCount() == 0) {
274 AliError("Can't find DAQ logbook configuration!");
279 if (aResult->GetCount() > 1) {
280 AliError("More than one DAQ logbook configuration found!");
285 anEntry = aResult->GetNext();
287 anAttribute = anEntry->GetAttribute("DAQLogbookHost");
289 AliError("Can't find DAQLogbookHost attribute!");
290 delete anEntry; delete aResult;
293 fDAQlbHost = anAttribute->GetValue();
295 anAttribute = anEntry->GetAttribute("DAQLogbookUser");
297 AliError("Can't find DAQLogbookUser attribute!");
298 delete aResult; delete anEntry;
301 fDAQlbUser = anAttribute->GetValue();
303 anAttribute = anEntry->GetAttribute("DAQLogbookPassword");
305 AliError("Can't find DAQLogbookPassword attribute!");
306 delete aResult; delete anEntry;
309 fDAQlbPass = anAttribute->GetValue();
311 anAttribute = anEntry->GetAttribute("MaxRetries");
313 AliError("Can't find MaxRetries attribute!");
314 delete aResult; delete anEntry;
317 TString tmpStr = anAttribute->GetValue();
318 fMaxRetries = tmpStr.Atoi();
320 anAttribute = anEntry->GetAttribute("PPTimeOut");
322 AliError("Can't find PPTimeOut attribute!");
323 delete aResult; delete anEntry;
326 tmpStr = anAttribute->GetValue();
327 fPPTimeOut = tmpStr.Atoi();
329 delete aResult; delete anEntry;
331 // FES configuration (FES logbook and hosts)
333 for(int iSys=0;iSys<3;iSys++){
334 queryFilter = Form("(system=%s)", AliShuttleInterface::GetSystemName(iSys));
335 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, queryFilter.Data());
337 AliError(Form("Can't find configuration for system: %s",
338 AliShuttleInterface::GetSystemName(iSys)));
342 if (aResult->GetCount() != 1 ) {
343 AliError("Error in FES configuration!");
348 anEntry = aResult->GetNext();
350 anAttribute = anEntry->GetAttribute("LogbookHost");
352 AliError(Form ("Can't find LogbookHost attribute for %s!!",
353 AliShuttleInterface::GetSystemName(iSys)));
354 delete aResult; delete anEntry;
357 fFESlbHost[iSys] = anAttribute->GetValue();
359 anAttribute = anEntry->GetAttribute("LogbookUser");
361 AliError(Form ("Can't find LogbookUser attribute for %s!!",
362 AliShuttleInterface::GetSystemName(iSys)));
363 delete aResult; delete anEntry;
366 fFESlbUser[iSys] = anAttribute->GetValue();
368 anAttribute = anEntry->GetAttribute("LogbookPassword");
370 AliError(Form ("Can't find LogbookPassword attribute for %s!!",
371 AliShuttleInterface::GetSystemName(iSys)));
372 delete aResult; delete anEntry;
375 fFESlbPass[iSys] = anAttribute->GetValue();
377 anAttribute = anEntry->GetAttribute("FSHost");
379 AliError(Form ("Can't find FSHost attribute for %s!!",
380 AliShuttleInterface::GetSystemName(iSys)));
381 delete aResult; delete anEntry;
384 fFESHost[iSys] = anAttribute->GetValue();
386 anAttribute = anEntry->GetAttribute("FSUser");
388 AliError(Form ("Can't find FSUser attribute for %s!!",
389 AliShuttleInterface::GetSystemName(iSys)));
390 delete aResult; delete anEntry;
393 fFESUser[iSys] = anAttribute->GetValue();
395 anAttribute = anEntry->GetAttribute("FSPassword");
396 if (anAttribute) fFESPass[iSys] = anAttribute->GetValue();
398 delete aResult; delete anEntry;
404 //______________________________________________________________________________________________
405 AliShuttleConfig::~AliShuttleConfig()
409 fDetectorMap.DeleteAll();
410 fDetectorList.Clear();
411 fProcessedDetectors.Delete();
414 //______________________________________________________________________________________________
415 const TObjArray* AliShuttleConfig::GetDetectors() const
418 // returns collection of TObjString which contains the name
419 // of every detector which is in the configuration.
422 return &fDetectorList;
425 //______________________________________________________________________________________________
426 Bool_t AliShuttleConfig::HasDetector(const char* detector) const
429 // checks for paricular detector in the configuration.
431 return fDetectorMap.GetValue(detector) != NULL;
434 //______________________________________________________________________________________________
435 const char* AliShuttleConfig::GetDCSHost(const char* detector) const
438 // returns DCS server host used by particular detector
441 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
443 AliError(Form("There isn't configuration for detector: %s",
448 return aHolder->GetDCSHost();
451 //______________________________________________________________________________________________
452 Int_t AliShuttleConfig::GetDCSPort(const char* detector) const
455 // returns DCS server port used by particular detector
459 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
461 AliError(Form("There isn't configuration for detector: %s",
466 return aHolder->GetDCSPort();
469 //______________________________________________________________________________________________
470 const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector) const
473 // returns collection of TObjString which represents the set of aliases
474 // which used for data retrieval for particular detector
477 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
479 AliError(Form("There isn't configuration for detector: %s",
484 return aHolder->GetDCSAliases();
487 //______________________________________________________________________________________________
488 Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
490 // return TRUE if detector is handled by host or if fProcessAll is TRUE
492 if(fProcessAll) return kTRUE;
493 TIter iter(&fProcessedDetectors);
495 while((detName = (TObjString*) iter.Next())){
496 if(detName->String() == detector) return kTRUE;
501 //______________________________________________________________________________________________
502 void AliShuttleConfig::Print(Option_t* /*option*/) const
504 // print configuration
509 result += Form("\nShuttle running on %s \n\n", fShuttleInstanceHost.Data());
512 result += Form("All detectors will be processed! \n\n");
514 result += "Detectors processed by this host: ";
515 TIter it(&fProcessedDetectors);
517 while ((aDet = (TObjString*) it.Next())) {
518 result += Form("%s ", aDet->String().Data());
523 result += Form("PP time out = %d - Max total retries = %d\n\n", fPPTimeOut, fMaxRetries);
525 result += Form("DAQ Logbook Configuration \n \tHost: %s - User: %s - ",
526 fDAQlbHost.Data(), fDAQlbUser.Data());
528 result += "Password: ";
529 result.Append('*', fDAQlbPass.Length());
532 for(int iSys=0;iSys<3;iSys++){
533 result += Form("FES Configuration for %s system\n", AliShuttleInterface::GetSystemName(iSys));
534 result += Form("\tLogbook host: \t%s - \tUser: %s\n",
535 fFESlbHost[iSys].Data(), fFESlbUser[iSys].Data());
536 // result += Form("Logbook Password:",fFESlbPass[iSys].Data());
537 result += Form("\tFES host: \t%s - \tUser: %s\n\n", fFESHost[iSys].Data(), fFESUser[iSys].Data());
538 // result += Form("FES Password:",fFESPass[iSys].Data());
541 TIter iter(fDetectorMap.GetTable());
543 while ((aPair = (TPair*) iter.Next())) {
544 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) aPair->Value();
545 if(aHolder->SkipDCSQuery()) continue;
546 result += Form("DCS archive DB configuration for *** %s *** \n", aHolder->GetDetector());
547 result += Form("\tAmanda server: %s:%d \n", aHolder->GetDCSHost(), aHolder->GetDCSPort());
549 result += "\tDCS Aliases: ";
550 const TObjArray* aliases = aHolder->GetDCSAliases();
553 while ((anAlias = (TObjString*) it.Next())) {
554 result += Form("%s ", anAlias->String().Data());
561 if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n";