adding terminate function
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 9 Nov 2009 16:37:12 +0000 (16:37 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 9 Nov 2009 16:37:12 +0000 (16:37 +0000)
SHUTTLE/AliShuttleConfig.cxx
SHUTTLE/AliShuttleConfig.h
SHUTTLE/AliShuttleTrigger.cxx
SHUTTLE/AliShuttleTrigger.h
SHUTTLE/schema/shuttle.schema

index 4eac7cc..af7931e 100644 (file)
@@ -537,7 +537,8 @@ AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port,
        fShuttlelbTable(""), 
        fRunTypelbTable(""),
        fPasswdFilePath(""),
-       fMaxRetries(0), 
+       fTerminateFilePath(""), 
+       fMaxRetries(0),
        fPPTimeOut(0), 
        fDCSTimeOut(0), 
        fDCSRetries(0), 
@@ -990,6 +991,11 @@ UInt_t AliShuttleConfig::SetGlobalConfig(TList* list)
        TString tmpStr = anAttribute->GetValue();
        fMaxRetries = tmpStr.Atoi();
 
+       anAttribute = anEntry->GetAttribute("terminateFilePath");
+       if (anAttribute) {
+               fTerminateFilePath = anAttribute->GetValue();
+       }
+
        anAttribute = anEntry->GetAttribute("ppTimeOut");
        if (!anAttribute) {
                AliError("Can't find ppTimeOut attribute!");
@@ -1518,11 +1524,11 @@ void AliShuttleConfig::Print(Option_t* option) const
        result += Form("Logbook Configuration \n\n \tHost: %s:%d; \tUser: %s; ",
                fDAQlbHost.Data(), fDAQlbPort, fDAQlbUser.Data());
 
-//     result += "Password: ";
-//     result.Append('*', fDAQlbPass.Length());
        result += Form("\tDB: %s; \tTables: %s, %s, %s\n",
                fDAQlbDB.Data(), fDAQlbTable.Data(), fShuttlelbTable.Data(), fRunTypelbTable.Data());
 
+       result += Form("Terminate file path: %s\n", fTerminateFilePath.Data());
+
        result += "\n\n";
        
        result += "------------------------------------------------------\n";
@@ -1533,10 +1539,8 @@ void AliShuttleConfig::Print(Option_t* option) const
                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());
-               // result += Form("DB Password:",fFXSdbPass[iSys].Data());
                result += Form("\tFXS host: %s:%d; \tUser: %s\n", fFXSHost[iSys].Data(), fFXSPort[iSys],
                                                fFXSUser[iSys].Data());
-               // result += Form("FXS Password:",fFXSPass[iSys].Data());
                const TObjArray* fxsAdmins = GetAdmins(iSys);
                if (fxsAdmins->GetEntries() != 0)
                {
index 0d4e394..40ba456 100644 (file)
@@ -69,6 +69,8 @@ public:
        UInt_t GetDCSDelay() const { return fDCSDelay; }
        Int_t GetPPMaxMem() const { return fPPMaxMem; }
 
+       const char* GetTerminateFilePath() const { return fTerminateFilePath; }
+
        Bool_t KeepDCSMap() const { return fKeepDCSMap; }
        Bool_t KeepTempFolder() const { return fKeepTempFolder; }
        
@@ -219,6 +221,8 @@ private:
        TString fFXSdbName[3];          // name of the [DAQ, DCS, HLT] FXS database
        TString fFXSdbTable[3];         // Table name of the [DAQ, DCS, HLT] FXS database
 
+       TString fTerminateFilePath;     // File for inter-process communcation to terminate the Shuttle
+
        Int_t fMaxRetries;              // number of retries of a failed preprocessor
        
        Int_t fPPTimeOut;               // timeout until a preprocessor is killed
index d7ab8fe..e4225b9 100644 (file)
@@ -207,6 +207,24 @@ void AliShuttleTrigger::Terminate() {
 }
 
 //______________________________________________________________________________________________
+void AliShuttleTrigger::CheckTerminate() 
+{
+       // 
+       // Checks if the Shuttle got an external terminate request by a created file 
+       // This is an alternative to the signal which causes problems with the API libraries
+       //
+
+       if (strlen(fConfig->GetTerminateFilePath()) == 0)
+               return;
+
+       if (gSystem->AccessPathName(fConfig->GetTerminateFilePath()))
+       {
+               AliInfo("Terminate file exists. Terminating Shuttle...");
+               fTerminate = kTRUE;
+       }
+}
+
+//______________________________________________________________________________________________
 void AliShuttleTrigger::Run() {
        //
        // AliShuttleTrigger main loop for asynchronized (listen) mode.
@@ -230,6 +248,7 @@ void AliShuttleTrigger::Run() {
 
                while (!(fNotified || fTerminate)) {
                        received=fCondition.TimedWaitRelative(1000*fConfig->GetTriggerWait());
+                       CheckTerminate();
                        if (received==1) break; // 1 = timeout
                }
 
index 4a1fb66..e79f432 100644 (file)
@@ -63,6 +63,7 @@ private:
        AliShuttleTrigger& operator= (const AliShuttleTrigger& other);
 
        Bool_t SendMailDiskSpace(Short_t percentage);
+       void CheckTerminate();
 
        const AliShuttleConfig* fConfig;
 
index 494b0a3..e8a6f4a 100644 (file)
@@ -82,6 +82,7 @@ attributetype ( GLOBAL_CONFIG:24 NAME 'DCSQueryOffset'        DESC 'DCS Query Offset (s
 attributetype ( GLOBAL_CONFIG:25 NAME 'DCSDelay'       DESC 'DCS Delay (s)'                 EQUALITY caseIgnoreMatch SUP name SINGLE-VALUE )
 attributetype ( GLOBAL_CONFIG:26 NAME 'ShuttleFileSystem'        DESC 'file system where the shuttle runs/writes/reads'   
                                                                                           EQUALITY caseIgnoreMatch    SUP name SINGLE-VALUE )
+attributetype ( GLOBAL_CONFIG:27 NAME 'terminateFilePath' DESC 'Terminate File Path (inter-process communication)'                  EQUALITY caseIgnoreMatch SUP name SINGLE-VALUE )
 attributetype ( GLOBAL_CONFIG:28 NAME 'FreeDiskWarningThreshold' DESC 'threshold for the free disk to send a warning mail'   
                                                                                           EQUALITY integerMatch    SUP uidNumber SINGLE-VALUE )
 attributetype ( GLOBAL_CONFIG:29 NAME 'FreeDiskFatalThreshold'   DESC 'threshold for the free disk to send a terminate signal to the Shuttle trigger'   
@@ -92,7 +93,7 @@ objectclass ( GLOBAL_CONFIG
         DESC 'ALICE: settings for DAQ logbook access'
         SUP top
         MUST (name $ passwdFilePath $ AlienPath $ daqLbHost $ daqLbUser $ daqLbDB $ daqLbTable $ shuttleLbTable $ runTypeLbTable $ ppMaxRetries $ ppTimeOut $ ppMaxMem $ dcsTimeOut $ nDCSretries $ DCSQueryOffset $ DCSDelay $ monitorHost $ monitorTable)
-        MAY ( daqLbPort $ triggerWait $ mode $ keepDCSMap $ keepTempFolder $ shuttleAdmin $ amandaAdmin $ sendMail $ ShuttleFileSystem $ FreeDiskWarningThreshold $ FreeDiskFatalThreshold) )
+        MAY ( daqLbPort $ triggerWait $ mode $ keepDCSMap $ keepTempFolder $ shuttleAdmin $ amandaAdmin $ sendMail $ ShuttleFileSystem $ terminateFilePath $ FreeDiskWarningThreshold $ FreeDiskFatalThreshold ) )
 
 
 objectidentifier INSTANCE_CONFIG SHUTTLE_BASE:5