]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/AliShuttleTrigger.cxx
CMake: Retrieve Git information
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttleTrigger.cxx
index 149bef760d0335778d695fbba00337db1fe2f335..732e60edf84348b3e8b7847a4930aa42c7bfd138 100644 (file)
 #include "AliShuttleTrigger.h"
 
 #include <TSystem.h>
+#include <TGrid.h>
 #include <TObjString.h>
 
 #include "AliLog.h"
@@ -206,6 +207,24 @@ void AliShuttleTrigger::Terminate() {
        fCondition.Signal();
 }
 
+//______________________________________________________________________________________________
+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()) == kFALSE)
+       {
+               AliInfo("Terminate file exists. Terminating Shuttle...");
+               fTerminate = kTRUE;
+       }
+}
+
 //______________________________________________________________________________________________
 void AliShuttleTrigger::Run() {
        //
@@ -229,8 +248,21 @@ void AliShuttleTrigger::Run() {
                fMutex.Lock();
 
                while (!(fNotified || fTerminate)) {
-                       received=fCondition.TimedWaitRelative(1000*fConfig->GetTriggerWait());
-                       if (received==1) break; // 1 = timeout
+                 for (Int_t iwait = 0; iwait < 10; iwait++){
+                   received = fCondition.TimedWaitRelative(1000*fConfig->GetTriggerWait()/10); // to keep the connection to the server alive every minute while waiting for new runs
+                   if (received == 1) {
+                     if (gGrid) {
+                       AliInfo(Form("Keeping the connection to the server alive while waiting for new runs - %d waited from last one", fConfig->GetTriggerWait()/10*iwait));
+                       gGrid->Pwd();
+                     }
+                     else {
+                       AliInfo("No gGrid initialized so far, we cannot keep the connection to the server alive while waiting for new runs");
+                     }
+                   }
+                 }
+                 //received=fCondition.TimedWaitRelative(1000*fConfig->GetTriggerWait());
+                 CheckTerminate();
+                 if (received==1) break; // 1 = timeout
                }
 
                fNotified = kFALSE;
@@ -268,6 +300,7 @@ void AliShuttleTrigger::Run() {
                }
        
                Collect();
+               CheckTerminate();
        }
 
        delete notifier;
@@ -289,7 +322,7 @@ Bool_t AliShuttleTrigger::Collect(Int_t run)
 
        gSystem->GetFsInfo(fConfig->GetShuttleFileSystem(), &id, &bsize, &blocks, &bfree);
 
-       AliInfo(Form("n. of free blocks = %d, total n. of blocks = %d",bfree,blocks));
+       AliInfo(Form("n. of free blocks = %ld, total n. of blocks = %ld",bfree,blocks));
        Int_t spaceFree = (Int_t)(((Float_t)bfree/(Float_t)blocks)*100);
 
        if (spaceFree < fConfig->GetFreeDiskWarningThreshold()) {
@@ -352,7 +385,7 @@ Bool_t AliShuttleTrigger::SendMailDiskSpace(Short_t percentage)
          to.Remove(to.Length()-1);
        AliDebug(2, Form("to: %s",to.Data()));
 
-       // mail body 
+       // mail body 
        TString bodyFileName;
        bodyFileName.Form("%s/mail.body", fShuttle->GetShuttleLogDir());
        gSystem->ExpandPathName(bodyFileName);
@@ -369,10 +402,10 @@ Bool_t AliShuttleTrigger::SendMailDiskSpace(Short_t percentage)
        TString subject;
        TString body;
 
+       Int_t percentage_used = 100 - percentage;       
        subject = Form("%s CRITICAL Disk Space usage exceeds %d%c!",
-                      tmpStr.Data(),percentage,'%');
+                      tmpStr.Data(),percentage_used,'%');
        AliDebug(2, Form("subject: %s", subject.Data()));
-       Int_t percentage_used = 100 - percentage;       
 
        body = "Dear SHUTTLE experts, \n\n";
        body += "The usage of the disk space on the shuttle machine has overcome \n";