o) Adding time out to the execution of the preprocessors: The Shuttle forks and the...
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Oct 2006 15:22:59 +0000 (15:22 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Oct 2006 15:22:59 +0000 (15:22 +0000)
o) Merging Collect, CollectAll, CollectNew function
o) Removing implementation of empty copy constructors (declaration still there!)

SHUTTLE/AliShuttle.cxx
SHUTTLE/AliShuttle.h
SHUTTLE/AliShuttleConfig.cxx
SHUTTLE/AliShuttleConfig.h
SHUTTLE/AliShuttleTrigger.cxx
SHUTTLE/AliShuttleTrigger.h
SHUTTLE/Shuttle.C
SHUTTLE/schema/shuttle.schema

index af93335..68396bf 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.17  2006/10/05 16:20:55  jgrosseo
+adapting to new CDB classes
+
 Revision 1.16  2006/10/05 15:46:26  jgrosseo
 applying to the new interface
 
@@ -136,9 +139,13 @@ some docs added
 #include <TSQLServer.h>
 #include <TSQLResult.h>
 #include <TSQLRow.h>
+#include <TMutex.h>
 
 #include <fstream>
 
+#include <sys/types.h>
+#include <sys/wait.h>
+
 ClassImp(AliShuttle)
 
 TString AliShuttle::fgkMainCDB("alien://folder=ShuttleCDB");
@@ -167,7 +174,9 @@ fPreprocessorMap(),
 fLogbookEntry(0),
 fCurrentDetector(""),
 fStatusEntry(0),
-fGridError(kFALSE)
+fGridError(kFALSE),
+fMonitoringMutex(0),
+fLastActionTime(0)
 {
        //
        // config: AliShuttleConfig used
@@ -181,29 +190,8 @@ fGridError(kFALSE)
                fFESlist[iSys].SetOwner(kTRUE);
        }
        fPreprocessorMap.SetOwner(kTRUE);
-}
-
-//______________________________________________________________________
-AliShuttle::AliShuttle(const AliShuttle& /*other*/):
-AliShuttleInterface(),
-fConfig(0),
-fTimeout(0), fRetries(0),
-fPreprocessorMap(),
-fLogbookEntry(0),
-fCurrentDetector(""),
-fStatusEntry(0),
-fGridError(kFALSE)
-{
-// copy constructor (not implemented)
-
-}
-
-//______________________________________________________________________
-AliShuttle &AliShuttle::operator=(const AliShuttle& /*other*/)
-{
-// assignment operator (not implemented)
-
-return *this;
+       
+       fMonitoringMutex = new TMutex();
 }
 
 //______________________________________________________________________________________________
@@ -216,12 +204,19 @@ AliShuttle::~AliShuttle()
                if(fServer[iSys]) {
                        fServer[iSys]->Close();
                        delete fServer[iSys];
+      fServer[iSys] = 0;
                }
 
        if (fStatusEntry){
                delete fStatusEntry;
                fStatusEntry = 0;
        }
+       
+       if (fMonitoringMutex) 
+       {
+               delete fMonitoringMutex;
+               fMonitoringMutex = 0;
+       }
 }
 
 //______________________________________________________________________________________________
@@ -412,8 +407,11 @@ void AliShuttle::UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t
                return;
        }
 
-       Log("SHUTTLE", Form("UpdateShuttleStatus - %s: Changing state from %s to %s", fCurrentDetector.Data(),
-                               status->GetStatusName(), status->GetStatusName(newStatus)));
+       TString actionStr;
+       actionStr.Form("UpdateShuttleStatus - %s: Changing state from %s to %s", fCurrentDetector.Data(),
+                               status->GetStatusName(), status->GetStatusName(newStatus));
+       Log("SHUTTLE", actionStr);
+       SetLastAction(actionStr);
 
        status->SetStatus(newStatus);
        if (increaseCount) status->IncreaseCount();
@@ -485,10 +483,7 @@ Bool_t AliShuttle::ContinueProcessing()
 
        // abort conditions
        // TODO we should add two counters, one for PP and one for DCS!
-       if ((status->GetStatus() == AliShuttleStatus::kPPStarted ||
-            status->GetStatus() == AliShuttleStatus::kPPError) &&
-           (status->GetCount() >= fConfig->GetMaxPPRetries() ||
-            status->GetCount() >= fConfig->GetMaxRetries())) {
+       if (status->GetCount() >= fConfig->GetMaxRetries()) {
                Log("SHUTTLE",
                        Form("ContinueProcessing - %s failed %d times in status %s - Updating Shuttle Logbook",
                                fCurrentDetector.Data(),
@@ -501,7 +496,7 @@ Bool_t AliShuttle::ContinueProcessing()
                        fCurrentDetector.Data(),
                        status->GetStatusName(), status->GetCount()));
 
-       UpdateShuttleStatus(AliShuttleStatus::kStarted);
+       UpdateShuttleStatus(AliShuttleStatus::kStarted, kTRUE);
 
        return kTRUE;
 }
@@ -554,7 +549,7 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
                AliPreprocessor* aPreprocessor =
                        dynamic_cast<AliPreprocessor*> (fPreprocessorMap.GetValue(fCurrentDetector));
                if(!aPreprocessor){
-                       Log("SHUTTLE",Form("Process - %s: no preprocessor registered. Skipping"));
+                       Log("SHUTTLE",Form("Process: no preprocessor registered. Skipping %s", fCurrentDetector.Data()));
                        continue;
                }
 
@@ -563,37 +558,105 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
                AliInfo(Form("\n\n \t\t\t****** run %d - %s: START  ******",
                                                GetCurrentRun(), aDetector->GetName()));
 
-               UInt_t result = ProcessCurrentDetector();
 
-               if(!result) {
-                       hasError = kTRUE;
-                       AliInfo(Form("\n \t\t\t****** run %d - %s: PREPROCESSOR ERROR ****** \n\n",
-                                                       GetCurrentRun(), aDetector->GetName()));
-                       continue;
-               }
+    Int_t pid = fork();
 
-               if(result == 2) {
-                       AliInfo(Form("\n \t\t\t****** run %d - %s: STORAGE ERROR ****** \n\n",
-                                                       GetCurrentRun(), aDetector->GetName()));
-               } else {
-                       AliInfo(Form("\n \t\t\t****** run %d - %s: DONE ****** \n\n",
-                                                       GetCurrentRun(), aDetector->GetName()));
-               }
+    if (pid < 0)
+    {
+      Log("SHUTTLE", "ERROR: Forking failed");
+    }
+    else if (pid > 0)
+    {
+      // parent
+      AliInfo(Form("In parent process of %d - %s: Starting monitoring", GetCurrentRun(), aDetector->GetName()));
 
-               // Process successful: Update time_processed field in FES logbooks!
-               if(fFESCalled[kDAQ]) {
-                       hasError = (UpdateDAQTable() == kFALSE);
-                       fFESlist[kDAQ].Clear();
-               }
-               //if(fFESCalled[kDCS]) {
-               //      hasError = UpdateDCSTable(aDetector->GetName());
-               //      fFESlist[kDCS].Clear();
-               //}
-               //if(fFESCalled[kHLT]) {
-               //      hasError = UpdateHLTTable(aDetector->GetName());
-               //      fFESlist[kHLT].Clear();
-               //}
+      Long_t begin = time(0);
+
+      int status; // to be used with waitpid, on purpose an int (not Int_t)!
+      while (waitpid(pid, &status, WNOHANG) == 0)
+      {
+        Long_t expiredTime = time(0) - begin;
+
+        if (expiredTime > fConfig->GetPPTimeOut())
+        {
+          Log("SHUTTLE", Form("Process time out. Run time: %d seconds. Killing...", expiredTime));
 
+          kill(pid, 9);
+
+          hasError = kTRUE;
+
+          gSystem->Sleep(1000);
+        }
+        else
+        {
+          if (expiredTime % 60 == 0)
+            Log("SHUTTLE", Form("Checked process. Run time: %d seconds.", expiredTime));
+
+          gSystem->Sleep(1000);
+        }
+      }
+
+      AliInfo(Form("In parent process of %d - %s: Client has terminated.", GetCurrentRun(), aDetector->GetName()));
+
+      if (WIFEXITED(status))
+      {
+        Int_t returnCode = WEXITSTATUS(status);
+
+        Log("SHUTTLE", Form("The return code is %d", returnCode));
+
+        if (returnCode != 0)
+          hasError = kTRUE;
+      }
+    }
+    else if (pid == 0)
+    {
+      // client
+      AliInfo(Form("In client process of %d - %s", GetCurrentRun(), aDetector->GetName()));
+
+      UInt_t result = ProcessCurrentDetector();
+
+      Int_t returnCode = 0; // will be set to 1 in case of an error
+
+      if (!result) {
+        returnCode = 1;
+        AliInfo(Form("\n \t\t\t****** run %d - %s: PREPROCESSOR ERROR ****** \n\n",
+                GetCurrentRun(), aDetector->GetName()));
+      }
+      else if(result == 2) {
+        AliInfo(Form("\n \t\t\t****** run %d - %s: STORAGE ERROR ****** \n\n",
+                GetCurrentRun(), aDetector->GetName()));
+      } else {
+        AliInfo(Form("\n \t\t\t****** run %d - %s: DONE ****** \n\n",
+                GetCurrentRun(), aDetector->GetName()));
+      }
+
+      if (result > 0)
+      {
+        // Process successful: Update time_processed field in FES logbooks!
+        if(fFESCalled[kDAQ]) {
+          if (UpdateDAQTable() == kFALSE)
+            returnCode = 1;
+          fFESlist[kDAQ].Clear();
+        }
+        //if(fFESCalled[kDCS]) {
+        //  if (UpdateDCSTable(aDetector->GetName()) == kFALSE)
+        //    returnCode = 1;
+        //  fFESlist[kDCS].Clear();
+        //}
+        //if(fFESCalled[kHLT]) {
+        //  if (UpdateHLTTable(aDetector->GetName()) == kFALSE)
+        //    returnCode = 1;
+        //     fFESlist[kHLT].Clear();
+        //}
+      }
+
+      AliInfo(Form("Client process of %d - %s is exiting now with %d.", GetCurrentRun(), aDetector->GetName(), returnCode));
+
+      // the client exits here
+      gSystem->Exit(returnCode);
+
+      AliError("We should never get here!!!");
+    }
        }
 
        AliInfo(Form("\n\n \t\t\t^*^*^*^*^*^*^*^*^*^*^*^* run %d: FINISH ^*^*^*^*^*^*^*^*^*^*^*^* \n",
@@ -671,12 +734,11 @@ UInt_t AliShuttle::ProcessCurrentDetector()
                dynamic_cast<AliPreprocessor*> (fPreprocessorMap.GetValue(fCurrentDetector));
 
        aPreprocessor->Initialize(GetCurrentRun(), GetCurrentStartTime(), GetCurrentEndTime());
-
        UInt_t aPPResult = aPreprocessor->Process(&aliasMap);
 
        UInt_t returnValue = 0;
        if (aPPResult == 0) { // Preprocessor error
-               UpdateShuttleStatus(AliShuttleStatus::kPPError, kTRUE);
+               UpdateShuttleStatus(AliShuttleStatus::kPPError);
                returnValue = 0;
        } else if (fGridError == kFALSE) { // process and Grid storage ok!
                UpdateShuttleStatus(AliShuttleStatus::kDone);
@@ -1462,7 +1524,7 @@ void AliShuttle::Log(const char* detector, const char* message)
                gSystem->FreeDirectory(dir);
        }
 
-       TString toLog = Form("%s: %s - ", TTimeStamp(time(0)).AsString("s"), detector);
+       TString toLog = Form("%s (%d): %s - ", TTimeStamp(time(0)).AsString("s"), getpid(), detector);
        if(GetCurrentRun()>=0 ) toLog += Form("run %d - ", GetCurrentRun());
        toLog += Form("%s", message);
 
@@ -1485,93 +1547,41 @@ void AliShuttle::Log(const char* detector, const char* message)
        logFile.close();
 }
 
-
 //______________________________________________________________________________________________
 Bool_t AliShuttle::Collect(Int_t run)
 {
        //
-       // Collects conditions data for the given run.
-       //
-
-       AliInfo(Form("Collecting conditions data for run %d", run));
-
-       TString whereClause("where run=");
-       whereClause += run;
-
-       TObjArray dateEntries;
-       if (!QueryShuttleLogbook(whereClause, dateEntries)) {
-               AliError("Can't retrieve entries from Shuttle logbook!");
-               return kFALSE;
-        }
-
-       if (!dateEntries.GetEntriesFast()) {
-               AliError(Form("Retrieval of parameters for run %d failed!", run));
-               return kFALSE;
-       }
-
-       if (dateEntries.GetEntriesFast() > 1) {
-               AliError(Form("There is more than one entry for run <%d> in Shuttle logbook!", run));
-               return kFALSE;
-       }
-
-       if (!RetrieveConditionsData(dateEntries)) {
-               AliError("An error occured during conditions data retrieval!");
-               return kFALSE;
-       }
-
-       return kTRUE;
-}
-
-//______________________________________________________________________________________________
-Bool_t AliShuttle::CollectNew()
-{
-       //
-       // Collects conditions data for all UNPROCESSED run written to DAQ LogBook.
+       // Collects conditions data for all UNPROCESSED run written to DAQ LogBook in case of run = -1 (default)
+  // If a dedicated run is given this run is processed
+  //
        // In operational mode, this is the Shuttle function triggered by the EOR signal.
        //
 
-       Log("SHUTTLE","CollectNew - Shuttle called. Collecting conditions data for unprocessed runs");
+  if (run == -1)
+       Log("SHUTTLE","Collect - Shuttle called. Collecting conditions data for unprocessed runs");
+  else
+       Log("SHUTTLE", Form("Collect - Shuttle called. Collecting conditions data for run %d", run));
+
+       SetLastAction("Starting");
 
        TString whereClause("where shuttle_done=0");
+  if (run != -1)
+    whereClause += Form(" and run=%d", run);
 
        TObjArray shuttleLogbookEntries;
        if (!QueryShuttleLogbook(whereClause, shuttleLogbookEntries)) {
-               Log("SHUTTLE", "CollectNew - Can't retrieve entries from Shuttle logbook");
+               Log("SHUTTLE", "Collect - Can't retrieve entries from Shuttle logbook");
                return kFALSE;
        }
 
        if (!RetrieveConditionsData(shuttleLogbookEntries)) {
-               Log("SHUTTLE", "CollectNew - Process of at least one run failed");
-               return kFALSE;
-       }
-
-       return kTRUE;
-}
-
-//______________________________________________________________________________________________
-Bool_t AliShuttle::CollectAll()
-{
-       //
-       // Collects conditions data for all runs (even if they're already done!) written in Shuttle LogBook.
-       //
-
-       AliInfo("Collecting conditions data for all runs ...");
-
-       TObjArray dateEntries;
-       if (!QueryShuttleLogbook("", dateEntries)) {
-               AliError("Can't retrieve entries from Shuttle logbook");
-               return kFALSE;
-       }
-
-       if (!RetrieveConditionsData(dateEntries)) {
-               AliError("An error occured during conditions data retrieval!");
+               Log("SHUTTLE", "Collect - Process of at least one run failed");
                return kFALSE;
        }
 
-       return kTRUE;
+  return kTRUE;
 }
 
-
 //______________________________________________________________________________________________
 Bool_t AliShuttle::RetrieveConditionsData(const TObjArray& dateEntries)
 {
@@ -1590,3 +1600,46 @@ Bool_t AliShuttle::RetrieveConditionsData(const TObjArray& dateEntries)
 
        return hasError == kFALSE;
 }
+
+//______________________________________________________________________________________________
+ULong_t AliShuttle::GetTimeOfLastAction() const
+{
+       ULong_t tmp;
+       
+       fMonitoringMutex->Lock();
+       
+       tmp = fLastActionTime;
+       
+       fMonitoringMutex->UnLock();
+       
+       return tmp;
+}
+
+//______________________________________________________________________________________________
+const TString AliShuttle::GetLastAction() const
+{
+       // returns a string description of the last action
+
+       TString tmp;
+       
+       fMonitoringMutex->Lock();
+       
+       tmp = fLastAction;
+       
+       fMonitoringMutex->UnLock();
+
+       return tmp;     
+}
+
+//______________________________________________________________________________________________
+void AliShuttle::SetLastAction(const char* action)
+{
+       // updates the monitoring variables
+       
+       fMonitoringMutex->Lock();
+       
+       fLastAction = action;
+       fLastActionTime = time(0);
+       
+       fMonitoringMutex->UnLock();
+}
index ecdde4c..9e0ba6c 100644 (file)
@@ -29,6 +29,7 @@ class AliCDBMetaData;
 class TSQLServer;
 class AliCDBEntry;
 class AliCDBPath;
+class TMutex;
 
 class AliShuttle: public AliShuttleInterface {
 public:
@@ -39,12 +40,14 @@ public:
 
        virtual void RegisterPreprocessor(AliPreprocessor* preprocessor);
 
-       Bool_t Collect(Int_t run);
-       Bool_t CollectNew();
-       Bool_t CollectAll();
+       Bool_t Collect(Int_t run = -1);
 
        Bool_t Process(AliShuttleLogbookEntry* entry);
 
+       // monitoring functions
+       ULong_t GetTimeOfLastAction() const;
+       const TString GetLastAction() const;
+
        Int_t GetCurrentRun() const;
        UInt_t GetCurrentStartTime() const;
        UInt_t GetCurrentEndTime() const;
@@ -115,6 +118,8 @@ private:
        Bool_t ContinueProcessing();
        void UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t increaseCount = kFALSE);
        Bool_t UpdateShuttleLogbook(const char* detector, const char* status=0);
+       
+       void SetLastAction(const char* action);
 
        const AliShuttleConfig* fConfig;        // pointer to configuration object
 
@@ -142,6 +147,10 @@ private:
 
        AliCDBEntry* fStatusEntry; // last CDB entry containing a AliShuttleStatus retrieved
        Bool_t fGridError;         // Grid storage error flag
+       
+       TMutex* fMonitoringMutex;   // mutex to lock the monitoring class members
+       UInt_t fLastActionTime;    // time of last action for monitoring
+       TString fLastAction;       // string description for last action
 
        //TODO Test only, remove later !
        static Bool_t fgkProcessDCS; // flag to enable DCS archive data processing
index bbdb821..3cb77d9 100644 (file)
 
 /*
 $Log$
+Revision 1.9  2006/10/02 16:38:39  jgrosseo
+update (alberto):
+fixed memory leaks
+storing of objects that failed to be stored to the grid before
+interfacing of shuttle status table in daq system
+
 Revision 1.8  2006/08/15 10:50:00  jgrosseo
 effc++ corrections (alberto)
 
@@ -156,7 +162,7 @@ AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
        const char* binddn, const char* password, const char* basedn):
        fIsValid(kFALSE),
        fDAQlbHost(""), fDAQlbUser(""), fDAQlbPass(""),
-       fMaxPPRetries(0), fMaxRetries(0), fDetectorMap(), fDetectorList(),
+       fMaxRetries(0), fPPTimeOut(0), fDetectorMap(), fDetectorList(),
        fShuttleInstanceHost(""), fProcessedDetectors(), fProcessAll(kFALSE)
 {
        //
@@ -297,23 +303,23 @@ AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
        }
        fDAQlbPass = anAttribute->GetValue();
 
-       anAttribute = anEntry->GetAttribute("MaxPPRetries");
+       anAttribute = anEntry->GetAttribute("MaxRetries");
        if (!anAttribute) {
-               AliError("Can't find MaxPPRetries attribute!");
+               AliError("Can't find MaxRetries attribute!");
                delete aResult; delete anEntry;
                return;
        }
        TString tmpStr = anAttribute->GetValue();
-       fMaxPPRetries = tmpStr.Atoi();
+       fMaxRetries = tmpStr.Atoi();
 
-       anAttribute = anEntry->GetAttribute("MaxRetries");
+       anAttribute = anEntry->GetAttribute("PPTimeOut");
        if (!anAttribute) {
-               AliError("Can't find MaxRetries attribute!");
+               AliError("Can't find PPTimeOut attribute!");
                delete aResult; delete anEntry;
                return;
        }
        tmpStr = anAttribute->GetValue();
-       fMaxRetries = tmpStr.Atoi();
+       fPPTimeOut = tmpStr.Atoi();
 
        delete aResult; delete anEntry;
 
@@ -509,7 +515,7 @@ void AliShuttleConfig::Print(Option_t* /*option*/) const
                result += "\n\n";
        }
 
-       result += Form("Max PP retries = %d - Max total retries = %d\n\n", fMaxPPRetries, fMaxRetries);
+       result += Form("PP time out = %d - Max total retries = %d\n\n", fPPTimeOut, fMaxRetries);
 
        result += Form("DAQ Logbook Configuration \n \tHost: %s - User: %s - ",
                fDAQlbHost.Data(), fDAQlbUser.Data());
index 7e31e16..9906c3b 100644 (file)
@@ -39,10 +39,11 @@ public:
        const char* GetFESlbUser(Int_t system) const {return fFESlbUser[system].Data();}
        const char* GetFESlbPass(Int_t system) const {return fFESlbPass[system].Data();}
 
-       Int_t GetMaxPPRetries() const { return fMaxPPRetries; }
        Int_t GetMaxRetries() const { return fMaxRetries; }
 
-       const TObjArray* GetDetectors() const;
+       Int_t GetPPTimeOut() const { return fPPTimeOut; }
+
+  const TObjArray* GetDetectors() const;
 
        Bool_t HasDetector(const char* detector) const;
        const char* GetDCSHost(const char* detector) const;
@@ -98,10 +99,11 @@ private:
        TString fFESlbUser[3];          //! username of the [DAQ, DCS, HLT] FES logbook
        TString fFESlbPass[3];          //! password of the [DAQ, DCS, HLT] FES logbook
 
-       Int_t fMaxPPRetries;      // number of retries of a crashed preprocessor
-       Int_t fMaxRetries;        // number of retries for all other failures
+       Int_t fMaxRetries;        // number of retries of a failed preprocessor
+
+       Int_t fPPTimeOut;         // timeout until a preprocessor is canceled
 
-       TMap fDetectorMap;              //! Map of the detector-by-detector configuration
+  TMap fDetectorMap;           //! Map of the detector-by-detector configuration
        TObjArray fDetectorList;        //! List of detectors with valid configuration
 
        TString fShuttleInstanceHost;   //! Instance of the SHUTTLE
index 7ac5631..1716fd9 100644 (file)
 
 /*
  $Log$
+ Revision 1.11  2006/10/02 16:38:39  jgrosseo
+ update (alberto):
+ fixed memory leaks
+ storing of objects that failed to be stored to the grid before
+ interfacing of shuttle status table in daq system
+
  Revision 1.10  2006/08/15 10:50:00  jgrosseo
  effc++ corrections (alberto)
 
@@ -68,7 +74,7 @@
 // 
 // This class is to deal with DAQ LogBook and DAQ "end of run" notification.
 // It has severeal two modes:
-//     1) syncrhnized - Collect(), CollectNew() and CollectAll methods
+//     1) synchronized - Collect()
 //     2) asynchronized - Run() - starts listening for DAQ "end of run"
 //             notification by DIM service.
 //
 #include "AliShuttleTrigger.h"
 
 #include <TSystem.h>
+
 #include "AliLog.h"
 #include "AliShuttleConfig.h"
 #include "AliShuttle.h"
 #include "DATENotifier.h"
 
 ClassImp(TerminateSignalHandler)
-
-//______________________________________________________________________
-TerminateSignalHandler::TerminateSignalHandler(const TerminateSignalHandler& /*other*/):
-TSignalHandler(), fTrigger()
-{
-// copy constructor (not implemented)
-
-}
-
-//______________________________________________________________________
-TerminateSignalHandler &TerminateSignalHandler::operator=(const TerminateSignalHandler& /*other*/)
-{
-// assignment operator (not implemented)
-
-return *this;
-}
+ClassImp(AliShuttleTrigger)
 
 //______________________________________________________________________________________________
-Bool_t TerminateSignalHandler::Notify() 
+Bool_t TerminateSignalHandler::Notify()
 {
 // Sentd terminate command to the Shuttle trigger
 
@@ -111,18 +103,13 @@ Bool_t TerminateSignalHandler::Notify()
 }
 
 //______________________________________________________________________________________________
-//______________________________________________________________________________________________
-
-ClassImp(AliShuttleTrigger)
-
-//______________________________________________________________________________________________
 AliShuttleTrigger::AliShuttleTrigger(const AliShuttleConfig* config,
                UInt_t timeout, Int_t retries):
        fConfig(config), fShuttle(NULL),
        fNotified(kFALSE), fTerminate(kFALSE),
        fMutex(), fCondition(&fMutex),
-       fQuitSignalHandler(this, kSigQuit),
-       fInterruptSignalHandler(this, kSigInterrupt)
+       fQuitSignalHandler(0),
+       fInterruptSignalHandler(0)
 {
        //
        // config - pointer to the AliShuttleConfig object which represents
@@ -133,53 +120,35 @@ AliShuttleTrigger::AliShuttleTrigger(const AliShuttleConfig* config,
 
        fShuttle = new AliShuttle(config, timeout, retries);
 
-       gSystem->AddSignalHandler(&fQuitSignalHandler);
-       gSystem->AddSignalHandler(&fInterruptSignalHandler);
-
-}
-
+  TerminateSignalHandler* fQuitSignalHandler = new TerminateSignalHandler(this, kSigQuit);
+  TerminateSignalHandler* fInterruptSignalHandler = new TerminateSignalHandler(this, kSigInterrupt);
 
-
-//______________________________________________________________________
-AliShuttleTrigger::AliShuttleTrigger(const AliShuttleTrigger& /*other*/):
-       TObject(), fConfig(), fShuttle(NULL),
-       fNotified(kFALSE), fTerminate(kFALSE),
-       fMutex(), fCondition(&fMutex),
-       fQuitSignalHandler(this, kSigQuit),
-       fInterruptSignalHandler(this, kSigInterrupt)
-
-{
-// copy constructor (not implemented)
+       gSystem->AddSignalHandler(fQuitSignalHandler);
+       gSystem->AddSignalHandler(fInterruptSignalHandler);
 
 }
 
-//______________________________________________________________________
-AliShuttleTrigger &AliShuttleTrigger::operator=(const AliShuttleTrigger& /*other*/)
-{
-// assignment operator (not implemented)
-
-return *this;
-}
-
-
-
-
-
 //______________________________________________________________________________________________
 AliShuttleTrigger::~AliShuttleTrigger() 
 {
-// destructor
+  // destructor
 
-       gSystem->RemoveSignalHandler(&fQuitSignalHandler);
-       gSystem->RemoveSignalHandler(&fInterruptSignalHandler);
+       gSystem->RemoveSignalHandler(fQuitSignalHandler);
+       gSystem->RemoveSignalHandler(fInterruptSignalHandler);
 
        delete fShuttle;
+
+  delete fQuitSignalHandler;
+  fQuitSignalHandler = 0;
+
+  delete fInterruptSignalHandler;
+  fInterruptSignalHandler = 0;
 }
 
 //______________________________________________________________________________________________
 Bool_t AliShuttleTrigger::Notify() {
        //
-       // Trigger CollectNew() methods in asynchronized (listen) mode.
+       // Trigger Collect() methods in asynchronized (listen) mode.
        // Usually called automaticly by DATENotifier on "end of run" 
        // notification event.
        //
@@ -210,7 +179,7 @@ void AliShuttleTrigger::Run() {
        //
        // AliShuttleTrigger main loop for asynchronized (listen) mode.
        // It spawns DIM service listener and waits for DAQ "end of run"
-       // notification. Calls CollectNew() on notification.
+       // notification. Calls Collect() on notification.
        //
 
        fTerminate = kFALSE;
@@ -234,7 +203,7 @@ void AliShuttleTrigger::Run() {
                        break;          
                }
        
-               CollectNew();
+               Collect();
        }
 
        delete notifier;
@@ -244,29 +213,9 @@ void AliShuttleTrigger::Run() {
 Bool_t AliShuttleTrigger::Collect(Int_t run)
 {
        //
-       // Collects conditions data for the given run.
-       //
-
-       return fShuttle->Collect(run);
-}
-
-//______________________________________________________________________________________________
-Bool_t AliShuttleTrigger::CollectNew()
-{
-       //
-       // Collects conditions data for all UNPROCESSED run written to DAQ LogBook.
-       //
-
-       return fShuttle->CollectNew();
-}
-
-//______________________________________________________________________________________________
-Bool_t AliShuttleTrigger::CollectAll()
-{
-       //
-       // Collects conditions data for all runs (even if they're already done!) written in Shuttle LogBook.
+       // this function creates a thread that runs the shuttle
+       // then it checks if the shuttle is still running by checking the monitoring functions of the shuttle
        //
 
-       return fShuttle->CollectAll();
+  return fShuttle->Collect(run);
 }
-
index db0b8e0..1e37ac2 100644 (file)
@@ -29,16 +29,15 @@ class TerminateSignalHandler: public TSignalHandler {
 public:
        TerminateSignalHandler(): TSignalHandler((ESignals) 0,0), fTrigger(0) { }
        TerminateSignalHandler(AliShuttleTrigger* trigger, ESignals signal):
-               TSignalHandler(signal, kFALSE), fTrigger(trigger) {}
+       TSignalHandler(signal, kFALSE), fTrigger(trigger) {}
 
        virtual ~TerminateSignalHandler() { }
        virtual Bool_t Notify();
 
 private:
-
-       TerminateSignalHandler(const TerminateSignalHandler& other);    
-       TerminateSignalHandler& operator= (const TerminateSignalHandler& other);        
-
+       TerminateSignalHandler(const TerminateSignalHandler& other);
+       TerminateSignalHandler& operator= (const TerminateSignalHandler& other);
+  
        AliShuttleTrigger* fTrigger;  // pointer to the current AliShuttleTrigger
 
        ClassDef(TerminateSignalHandler, 0)
@@ -52,9 +51,7 @@ public:
 
        AliShuttle* GetShuttle() {return fShuttle;}
 
-       Bool_t Collect(Int_t run);
-       Bool_t CollectNew();
-       Bool_t CollectAll();
+       Bool_t Collect(Int_t run = -1);
 
        virtual Bool_t Notify();
        void Terminate();
@@ -75,8 +72,8 @@ private:
        TMutex fMutex;                  // Mutex
        TCondition fCondition;          // Condition 
 
-       TerminateSignalHandler fQuitSignalHandler;              // Quit signal 
-       TerminateSignalHandler fInterruptSignalHandler;         // Interrupt signal
+       TerminateSignalHandler* fQuitSignalHandler;             // Quit signal
+       TerminateSignalHandler* fInterruptSignalHandler;        // Interrupt signal
 
 
        ClassDef(AliShuttleTrigger, 0)
index 657f198..2694db9 100644 (file)
@@ -1,4 +1,4 @@
-void Shuttle(const char* param = "listen") {
+Bool_t Shuttle(const char* param = "listen") {
 
        // WARNING: if ldap is built with ssl support it may cause confilcts with the 
        // AliEn interface. If this happens, grid storage activation must be done BEFORE 
@@ -48,23 +48,15 @@ void Shuttle(const char* param = "listen") {
                Int_t run = paramStr.Atoi();
                trigger.Collect(run);
        } else if (paramStr == "new") {
-               trigger.CollectNew();
-       } else if (paramStr == "all") {
-               trigger.CollectAll();
+               Bool_t result = trigger.Collect();
        } else if (paramStr == "listen") {
                trigger.Run();
-  } else if (paramStr.BeginsWith("lastrun=")) {
-    Int_t run = TString(paramStr(8, paramStr.Length()-7).Data()).Atoi();
-    cout << run << endl;
-    trigger.SetNewLastRun(run);
        } else {
                cout<<"Bad parameter: "<<param<<endl;
                cout<<"Parameter options: "<<endl;
                cout<<"<run> - collect data for the given run"<<endl;
                cout<<"new - collect data only for the new runs"<<endl;
-               cout<<"all - collect data for all runs"<<endl;
                cout<<"listen - start listening for DAQ notification"<<endl;
-               cout<<"lastrun=<run> - sets last run manually. use with caution!" << endl;
                cout<<"<empty parameter> - the same as 'listen'"<<endl;
        }
 
index da32177..9237764 100644 (file)
@@ -38,14 +38,14 @@ objectidentifier GLOBAL_CONFIG SHUTTLE_BASE:3
 attributetype ( GLOBAL_CONFIG:1 NAME 'DAQLogbookHost'      DESC ''    EQUALITY caseIgnoreMatch    SUP name )
 attributetype ( GLOBAL_CONFIG:2 NAME 'DAQLogbookUser'      DESC ''    EQUALITY caseIgnoreMatch    SUP name )
 attributetype ( GLOBAL_CONFIG:3 NAME 'DAQLogbookPassword'  DESC ''    EQUALITY caseIgnoreMatch    SUP name )
-attributetype ( GLOBAL_CONFIG:4 NAME 'MaxPPRetries'  DESC 'number of retries of a crashed preprocessor'    EQUALITY caseIgnoreMatch    SUP name )
-attributetype ( GLOBAL_CONFIG:5 NAME 'MaxRetries'  DESC 'number of retries for all other failures'    EQUALITY caseIgnoreMatch    SUP name )
+attributetype ( GLOBAL_CONFIG:4 NAME 'MaxRetries'  DESC 'number of retries for failures of a preprocessor'    EQUALITY caseIgnoreMatch    SUP name )
+attributetype ( GLOBAL_CONFIG:5 NAME 'PPTimeOut'  DESC 'number of seconds until preprocessor is aborted'    EQUALITY caseIgnoreMatch    SUP name )
 
 objectclass ( GLOBAL_CONFIG
         NAME 'AliShuttleGlobalConfig'
         DESC 'ALICE: Access to DAQ logbook settings'
         SUP top
-        MUST (name $ DAQLogbookHost $ DAQLogbookUser $ DAQLogbookPassword $ MaxPPRetries $ MaxRetries) )
+        MUST (name $ DAQLogbookHost $ DAQLogbookUser $ DAQLogbookPassword $ MaxRetries $ PPTimeOut) )
 
 
 objectidentifier INSTANCE_CONFIG SHUTTLE_BASE:4