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.3 2006/06/06 14:26:40 jgrosseo
19 o) removed files that were moved to STEER
20 o) shuttle updated to follow the new interface (Alberto)
22 Revision 1.7 2006/05/12 09:07:16 colla
24 New configuration complete
26 Revision 1.2 2006/03/07 07:52:34 hristov
27 New version (B.Yordanov)
29 Revision 1.4 2005/11/19 14:20:31 byordano
30 logbook config added to AliShuttleConfig
32 Revision 1.3 2005/11/17 19:24:25 byordano
33 TList changed to TObjArray in AliShuttleConfig
35 Revision 1.2 2005/11/17 14:43:23 byordano
38 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
39 Initial import as subdirectory in AliRoot
41 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
44 Revision 1.3 2005/08/30 09:13:02 byordano
51 // This class keeps the AliShuttle configuration.
52 // It reads the configuration for LDAP server.
53 // For every child entry in basedn which has schema type 'shuttleConfig'
54 // it creates a detector configuration. This configuration includes:
55 // DCS server host and port and the set of aliases for which data from
56 // will be retrieved (used by AliShuttle).
60 #include "AliShuttleConfig.h"
65 #include <TObjString.h>
66 #include <TLDAPResult.h>
67 #include <TLDAPEntry.h>
68 #include <TLDAPAttribute.h>
70 AliShuttleConfig::AliShuttleConfigHolder::AliShuttleConfigHolder(const TLDAPEntry* entry):
73 // constructor of the shuttle configuration holder
75 TLDAPAttribute* anAttribute;
77 anAttribute = entry->GetAttribute("det");
79 AliError("Invalid configuration! Can't get detector name.");
82 fDetector = anAttribute->GetValue();
83 if (!fDetector.Length()) {
84 AliError("Detector name can't be an empty string!")
88 anAttribute = entry->GetAttribute("DCSHost");
90 AliError("Invalid configuration! Can't get DCSHost.");
93 fDCSHost = anAttribute->GetValue();
94 if (!fDCSHost.Length()) {
95 AliError("Host can't be an empty string!")
99 anAttribute = entry->GetAttribute("DCSPort");
101 AliError("Invalid configuration! Can't get DCSPort.");
104 TString portStr = anAttribute->GetValue();
105 if (!portStr.Length()) {
106 AliError("port can't be an empty string!")
109 fDCSPort = portStr.Atoi();
111 anAttribute = entry->GetAttribute("DCSAlias");
113 AliError("Invalid configuration! Can't get alias attribute.");
117 while ((anAlias = anAttribute->GetValue())) {
118 fDCSAliases.AddLast(new TObjString(anAlias));
121 anAttribute = entry->GetAttribute("DAQFileIDs");
123 AliError("Invalid configuration! Can't get DAQFileIDs attribute.");
127 while ((aFileID = anAttribute->GetValue())) {
128 fDAQFileIDs.AddLast(new TObjString(aFileID));
134 AliShuttleConfig::AliShuttleConfigHolder::~AliShuttleConfigHolder()
136 // destructor of the shuttle configuration holder
138 fDCSAliases.Delete();
141 ClassImp(AliShuttleConfig)
143 AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
144 const char* binddn, const char* password, const char* basedn):
149 // host: ldap server host
150 // port: ldap server port
151 // binddn: binddn used for ldap binding (simple bind is used!).
152 // password: password for binddn
153 // basedn: this is basedn whose childeren entries which have
154 // (objectClass=shuttleConfig) will be used as detector configurations.
157 TLDAPServer aServer(host, port, binddn, password, 3);
159 if (!aServer.IsConnected()) {
160 AliError(Form("Can't connect to ldap server %s:%d",
165 // reads configuration for the shuttle running on this machine
167 fShuttleInstanceHost = gSystem->HostName();
168 TString queryFilter = "(ShuttleHost=";
169 queryFilter += fShuttleInstanceHost;
172 TLDAPResult* aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL,
176 AliError(Form("Can't find configuration with base DN: %s",
181 if (aResult->GetCount() == 0) {
182 AliError(Form("No Shuttle instance for host = %s!",fShuttleInstanceHost.Data()));
183 AliError(Form("All detectors will be processed."));
187 if (aResult->GetCount() > 1) {
188 AliError(Form("More than one Shuttle instance for host %s!",fShuttleInstanceHost.Data()));
193 TLDAPAttribute* anAttribute;
196 anEntry = aResult->GetNext();
197 anAttribute = anEntry->GetAttribute("detectors");
199 while((detName = anAttribute->GetValue())){
200 TObjString *objDet= new TObjString(detName);
201 fProcessedDetectors.Add(objDet);
205 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL,
206 "(objectClass=AliShuttleDetector)");
208 AliError(Form("Can't find configuration with base DN: %s",
213 while ((anEntry = aResult->GetNext())) {
214 AliShuttleConfigHolder* aHolder = new AliShuttleConfigHolder(anEntry);
217 if (!aHolder->IsValid()) {
218 AliError("This entry is going to be skipped!");
224 TObjString* detStr = new TObjString(aHolder->GetDetector());
225 fDetectorMap.Add(detStr, aHolder);
226 fDetectorList.AddLast(detStr);
232 aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL,
233 "(objectClass=AliShuttleGlobalConfig)");
235 AliError(Form("Can't find configuration with base DN: %s",
240 if (aResult->GetCount() == 0) {
241 AliError("Can't find DAQ logbook configuration!");
245 if (aResult->GetCount() > 1) {
246 AliError("More than one DAQ logbook configuration found!");
250 anEntry = aResult->GetNext();
252 anAttribute = anEntry->GetAttribute("DAQLogbookHost");
254 AliError("Can't find DAQLogbookHost attribute!");
257 fDAQLogBookHost = anAttribute->GetValue();
259 anAttribute = anEntry->GetAttribute("DAQLogbookUser");
261 AliError("Can't find DAQLogbookUser attribute!");
264 fDAQLogBookUser = anAttribute->GetValue();
266 anAttribute = anEntry->GetAttribute("DAQLogbookPassword");
268 AliError("Can't find DAQLogbookPassword attribute!");
271 fDAQLogBookPassword = anAttribute->GetValue();
273 anAttribute = anEntry->GetAttribute("DAQFileSystemHost");
275 AliError("Can't find DAQFileSystemHost attribute!");
278 fDAQFSHost = anAttribute->GetValue();
286 AliShuttleConfig::~AliShuttleConfig()
290 fDetectorMap.DeleteAll();
293 const TObjArray* AliShuttleConfig::GetDetectors() const
296 // returns collection of TObjString which contains the name
297 // of every detector which is in the configuration.
300 return &fDetectorList;
303 Bool_t AliShuttleConfig::HasDetector(const char* detector) const
306 // checks for paricular detector in the configuration.
308 return fDetectorMap.GetValue(detector) != NULL;
311 const char* AliShuttleConfig::GetDCSHost(const char* detector) const
314 // returns DCS server host used by particular detector
317 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
319 AliError(Form("There isn't configuration for detector: %s",
324 return aHolder->GetDCSHost();
327 Int_t AliShuttleConfig::GetDCSPort(const char* detector) const
330 // returns DCS server port used by particular detector
334 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
336 AliError(Form("There isn't configuration for detector: %s",
341 return aHolder->GetDCSPort();
344 const TObjArray* AliShuttleConfig::GetDCSAliases(const char* detector) const
347 // returns collection of TObjString which represents the set of aliases
348 // which used for data retrieval for particular detector
351 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
353 AliError(Form("There isn't configuration for detector: %s",
358 return aHolder->GetDCSAliases();
361 const TObjArray* AliShuttleConfig::GetDAQFileIDs(const char* detector) const
364 // returns collection of TObjString which represents the set of DAQ file IDs
365 // which used for data retrieval for particular detector
368 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
370 AliError(Form("There isn't configuration for detector: %s",
375 return aHolder->GetDAQFileIDs();
378 Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
380 // return TRUE if detector is handled by host or if fProcessAll is TRUE
382 if(fProcessAll) return kTRUE;
383 TIter iter(&fProcessedDetectors);
385 while((detName = (TObjString*) iter.Next())){
386 if(detName->String() == detector) return kTRUE;
391 void AliShuttleConfig::Print(Option_t* /*option*/) const
393 // print configuration
398 result += "Shuttle running on host: ";
399 result += fShuttleInstanceHost;
401 result += "Detectors handled by this host: ";
402 TIter it(&fProcessedDetectors);
404 while ((aDet = (TObjString*) it.Next())) {
405 result += aDet->String();
409 if(fProcessAll) result += "ProcessAll is ON";
414 result += "DAQ LogBook Host: ";
415 result += fDAQLogBookHost;
417 result += "DAQ LogBook User: ";
418 result += fDAQLogBookUser;
420 result += "DAQ LogBook Password: ";
421 result.Append('*', fDAQLogBookPassword.Length());
424 result += "DAQ File System Host: ";
425 result += fDAQFSHost;
428 TIter iter(fDetectorMap.GetTable());
430 while ((aPair = (TPair*) iter.Next())) {
431 AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) aPair->Value();
433 result += " Detector: ";
434 result += aHolder->GetDetector();
436 result += " DCS Host: ";
437 result += aHolder->GetDCSHost();
439 result += " DCS Port: ";
440 result += aHolder->GetDCSPort();
443 result += " DCS Aliases: ";
444 const TObjArray* aliases = aHolder->GetDCSAliases();
447 while ((anAlias = (TObjString*) it.Next())) {
448 result += anAlias->String();
454 result += " DAQ File IDs: ";
455 const TObjArray* fileIDs = aHolder->GetDAQFileIDs();
458 while ((aFileID = (TObjString*) it2.Next())) {
459 result += aFileID->String();