]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/AliShuttleConfig.cxx
Removed old ldif files, added TOF, MCH ldif files. Added some options in
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttleConfig.cxx
index f147632454bcb781d3c15c075052a150cb376353..04c11ebb7efb80da1807663b4cc7e0bd0f42ecde 100644 (file)
 
 /*
 $Log$
+Revision 1.17  2007/01/18 11:17:47  jgrosseo
+changing spaces to tabs ;-)
+
+Revision 1.16  2007/01/18 11:10:35  jgrosseo
+adding the possibility of defining DCS alias and data points with patterns
+first pattern introduced: [N..M] to add all names between the two digits, this works also recursively.
+
+Revision 1.15  2007/01/15 18:27:11  acolla
+implementation of sending mail to subdetector expert in case the preprocessor fails.
+shuttle.schema updated with expert's email entry
+
 Revision 1.13  2006/12/07 08:51:26  jgrosseo
 update (alberto):
 table, db names in ldap configuration
@@ -120,6 +131,9 @@ fDCSHost(""),
 fDCSPort(0),
 fDCSAliases(0),
 fDCSDataPoints(0),
+fDCSAliasesComp(0),
+fDCSDataPointsComp(0),
+fResponsibles(0),
 fIsValid(kFALSE),
 fSkipDCSQuery(kFALSE),
 fStrictRunOrder(kFALSE)
@@ -131,6 +145,12 @@ fStrictRunOrder(kFALSE)
        fDCSAliases->SetOwner(1);
        fDCSDataPoints = new TObjArray();
        fDCSDataPoints->SetOwner(1);
+       fDCSAliasesComp = new TObjArray();
+       fDCSAliasesComp->SetOwner(1);
+       fDCSDataPointsComp = new TObjArray();
+       fDCSDataPointsComp->SetOwner(1);
+       fResponsibles = new TObjArray();
+       fResponsibles->SetOwner(1);
 
        anAttribute = entry->GetAttribute("det"); // MUST
         if (!anAttribute)
@@ -155,10 +175,22 @@ fStrictRunOrder(kFALSE)
                fStrictRunOrder = (Bool_t) strictRunStr.Atoi();
        }
 
+       anAttribute = entry->GetAttribute("responsible"); // MUST
+        if (!anAttribute)
+       {
+               AliError(Form("Invalid configuration! No \"responsible\" attribute!"));
+               return;
+        }
+       const char* aResponsible;
+       while ((aResponsible = anAttribute->GetValue()))
+       {
+               fResponsibles->AddLast(new TObjString(aResponsible));
+       }
+
        anAttribute = entry->GetAttribute("DCSHost"); // MAY
        if (!anAttribute)
        {
-               AliWarning(
+               AliDebug(2,
                        Form("%s has not DCS host entry - Shuttle will skip DCS data query!",
                                fDetector.Data()));
                fIsValid = kTRUE;
@@ -184,7 +216,8 @@ fStrictRunOrder(kFALSE)
                const char* anAlias;
                while ((anAlias = anAttribute->GetValue()))
                {
-                       fDCSAliases->AddLast(new TObjString(anAlias));
+                       fDCSAliasesComp->AddLast(new TObjString(anAlias));
+                       ExpandAndAdd(fDCSAliases, anAlias);
                }
        }
 
@@ -194,13 +227,69 @@ fStrictRunOrder(kFALSE)
                const char* aDataPoint;
                while ((aDataPoint = anAttribute->GetValue()))
                {
-                       fDCSDataPoints->AddLast(new TObjString(aDataPoint));
+               fDCSDataPointsComp->AddLast(new TObjString(aDataPoint));
+               ExpandAndAdd(fDCSDataPoints, aDataPoint);
                }
        }
 
        fIsValid = kTRUE;
+}
 
+//______________________________________________________________________________________________
+void AliShuttleConfig::AliShuttleConfigHolder::ExpandAndAdd(TObjArray* target, const char* entry)
+{
+       //
+       // adds <entry> to <target> applying expanding of the name
+       // [N..M] creates M-N+1 names with the corresponding digits
+       //
+
+       TString entryStr(entry);
+
+       Int_t begin = entryStr.Index("[");
+       Int_t end = entryStr.Index("]");
+       if (begin != -1 && end != -1 && end > begin)
+       {
+               TString before(entryStr(0, begin));
+               TString after(entryStr(end+1, entryStr.Length()));
+
+               AliDebug(2, Form("Found [] pattern. Splitted input string %s %s", before.Data(), after.Data()));
+
+               Int_t dotdot = entryStr.Index("..");
+
+               TString nStr(entryStr(begin+1, dotdot-begin-1));
+               TString mStr(entryStr(dotdot+2, end-dotdot-2));
+
+               AliDebug(2, Form("Found [N..M] pattern. %s %s", nStr.Data(), mStr.Data()));
+
+               if (nStr.IsDigit() && mStr.IsDigit())
+               {
+                       Int_t n = nStr.Atoi();
+                       Int_t m = mStr.Atoi();
+
+                       Int_t nDigits = nStr.Length();
+                       TString formatStr;
+                       formatStr.Form("%%s%%0%dd%%s", nDigits);
+
+                       AliDebug(2, Form("Format string is %s", formatStr.Data()));
+
+                       for (Int_t current = n; current<=m; ++current)
+                       {
+                               TString newEntry;
+                               newEntry.Form(formatStr.Data(), before.Data(), current, after.Data());
+
+                               AliDebug(2, Form("Calling recursive with %s", newEntry.Data()));
+
+                               // and go recursive
+                               ExpandAndAdd(target, newEntry);
+                       }
+
+                       // return here because we processed the entries already recursively.
+                       return;
+               }
+       }
 
+       AliDebug(2, Form("Adding name %s", entry));
+       target->AddLast(new TObjString(entry));
 }
 
 //______________________________________________________________________________________________
@@ -210,6 +299,7 @@ AliShuttleConfig::AliShuttleConfigHolder::~AliShuttleConfigHolder()
 
        delete fDCSAliases;
        delete fDCSDataPoints;
+       delete fResponsibles;
 }
 
 ClassImp(AliShuttleConfig)
@@ -217,7 +307,7 @@ ClassImp(AliShuttleConfig)
 //______________________________________________________________________________________________
 AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
        const char* binddn, const char* password, const char* basedn):
-       fIsValid(kFALSE),
+       fIsValid(kFALSE), fConfigHost(host),
        fDAQlbHost(""), fDAQlbPort(), fDAQlbUser(""), fDAQlbPass(""),
        fDAQlbDB(""), fDAQlbTable(""),
        fMaxRetries(0), fPPTimeOut(0), fDetectorMap(), fDetectorList(),
@@ -614,6 +704,24 @@ const TObjArray* AliShuttleConfig::GetDCSDataPoints(const char* detector) const
        return aHolder->GetDCSDataPoints();
 }
 
+//______________________________________________________________________________________________
+const TObjArray* AliShuttleConfig::GetResponsibles(const char* detector) const
+{
+       //
+       // returns collection of TObjString which represents the list of mail addresses
+       // of the detector's responsible(s)
+       //
+
+       AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) fDetectorMap.GetValue(detector);
+        if (!aHolder) {
+                AliError(Form("There isn't configuration for detector: %s",
+                        detector));
+                return NULL;
+        }
+
+       return aHolder->GetResponsibles();
+}
+
 //______________________________________________________________________________________________
 Bool_t AliShuttleConfig::HostProcessDetector(const char* detector) const
 {
@@ -645,17 +753,24 @@ Bool_t AliShuttleConfig::StrictRunOrder(const char* detector) const
 }
 
 //______________________________________________________________________________________________
-void AliShuttleConfig::Print(Option_t* /*option*/) const
+void AliShuttleConfig::Print(Option_t* option) const
 {
 // print configuration
-       
+// options : "": print configuration for all detectors, aliases and DPs in compacted format
+//          "uncompact": print configuration for all detectors, aliases and DPs in uncompacted format
+//          "DET": print configuration for DET, aliases and DPs in compacted format
+//          "DET, uncompact": print configuration for DET, aliases and DPs in uncompacted format
+
        TString result;
        result += '\n';
 
-       result += Form("\nShuttle running on %s \n\n", fShuttleInstanceHost.Data());
+       result += "####################################################\n";
+       result += Form(" Shuttle configuration from %s \n", fConfigHost.Data());
+       result += "####################################################\n";
+       result += Form("\nShuttle running on %s \n", fShuttleInstanceHost.Data());
 
        if(fProcessAll) {
-               result += Form("All detectors will be processed! \n\n");
+               result += Form("All detectors will be processed! \n");
        } else {
                result += "Detectors processed by this host: ";
                TIter it(&fProcessedDetectors);
@@ -663,12 +778,13 @@ void AliShuttleConfig::Print(Option_t* /*option*/) const
                while ((aDet = (TObjString*) it.Next())) {
                        result += Form("%s ", aDet->String().Data());
                }
-               result += "\n\n";
+               result += "\n";
        }
 
        result += Form("PP time out = %d - Max total retries = %d\n\n", fPPTimeOut, fMaxRetries);
+       result += "------------------------------------------------------\n";
 
-       result += Form("DAQ Logbook Configuration \n \tHost: %s:%d; \tUser: %s; ",
+       result += Form("Logbook Configuration \n\n \tHost: %s:%d; \tUser: %s; ",
                fDAQlbHost.Data(), fDAQlbPort, fDAQlbUser.Data());
 
 //     result += "Password: ";
@@ -678,8 +794,11 @@ void AliShuttleConfig::Print(Option_t* /*option*/) const
 
        result += "\n\n";
 
+       result += "------------------------------------------------------\n";
+       result += "FXS configuration\n\n";
+
        for(int iSys=0;iSys<3;iSys++){
-               result += Form("FXS Configuration for %s system\n", AliShuttleInterface::GetSystemName(iSys));
+               result += Form("*** %s ***\n", AliShuttleInterface::GetSystemName(iSys));
                result += Form("\tDB  host: %s:%d; \tUser: %s; \tName: %s; \tTable: %s\n",
                                                fFXSdbHost[iSys].Data(), fFXSdbPort[iSys], fFXSdbUser[iSys].Data(),
                                                fFXSdbName[iSys].Data(), fFXSdbTable[iSys].Data());
@@ -689,12 +808,32 @@ void AliShuttleConfig::Print(Option_t* /*option*/) const
                // result += Form("FXS Password:",fFXSPass[iSys].Data());
        }
 
+       TString optStr(option);
+
+       result += "------------------------------------------------------\n";
+       result += "Detector-specific configuration\n\n";
        TIter iter(fDetectorMap.GetTable());
        TPair* aPair;
        while ((aPair = (TPair*) iter.Next())) {
                AliShuttleConfigHolder* aHolder = (AliShuttleConfigHolder*) aPair->Value();
-               result += Form("Detector-specific configuration: *** %s *** \n", aHolder->GetDetector());
-               result += Form("\tStrict run ordering flag: %s \n", aHolder->StrictRunOrder() ? "TRUE" : "FALSE");
+               if (option != 0 && !optStr.Contains(aHolder->GetDetector()) && optStr.CompareTo("uncompact",TString::kIgnoreCase) != 0 )
+                               continue;
+               result += Form("*** %s *** \n", aHolder->GetDetector());
+
+               const TObjArray* responsibles = aHolder->GetResponsibles();
+               if (responsibles->GetEntries() != 0)
+               {
+                       result += "\tDetector responsible(s): ";
+                       TIter it(responsibles);
+                       TObjString* aResponsible;
+                       while ((aResponsible = (TObjString*) it.Next()))
+                       {
+                               result += Form("%s ", aResponsible->String().Data());
+                       }
+                       result += "\n";
+               }
+
+               result += Form("\tStrict run ordering: %s \n", aHolder->StrictRunOrder() ? "YES" : "NO");
                if(aHolder->SkipDCSQuery())
                {
                        result += "\n";
@@ -702,7 +841,14 @@ void AliShuttleConfig::Print(Option_t* /*option*/) const
                }
                result += Form("\tAmanda server: %s:%d \n", aHolder->GetDCSHost(), aHolder->GetDCSPort());
 
-               const TObjArray* aliases = aHolder->GetDCSAliases();
+               const TObjArray* aliases = 0;
+               if (optStr.Contains("uncompact",TString::kIgnoreCase))
+               {
+                       aliases = aHolder->GetDCSAliases();
+               } else {
+                       aliases = aHolder->GetCompactDCSAliases();
+               }
+
                if (aliases->GetEntries() != 0)
                {
                        result += "\tDCS Aliases: ";
@@ -715,8 +861,13 @@ void AliShuttleConfig::Print(Option_t* /*option*/) const
                        result += "\n";
                }
 
-
-               const TObjArray* dataPoints = aHolder->GetDCSDataPoints();
+               const TObjArray* dataPoints = 0;
+               if (optStr.Contains("uncompact",TString::kIgnoreCase))
+               {
+                       dataPoints = aHolder->GetDCSDataPoints();
+               } else {
+                       dataPoints = aHolder->GetCompactDCSDataPoints();
+               }
                if (dataPoints->GetEntries() != 0)
                {
                        result += "\tDCS Data Points: ";
@@ -728,7 +879,6 @@ void AliShuttleConfig::Print(Option_t* /*option*/) const
                                result += "\n";
                }
                result += "\n";
-               
        }
 
        if(!fIsValid) result += "\n\n********** !!!!! Configuration is INVALID !!!!! **********\n";