]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/AliShuttleTrigger.cxx
Update for the QA task (Raphael).
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttleTrigger.cxx
index 149bef760d0335778d695fbba00337db1fe2f335..9105d3559442db34aef7f3158d4b0f351f7156e0 100644 (file)
@@ -206,6 +206,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() {
        //
@@ -230,6 +248,7 @@ void AliShuttleTrigger::Run() {
 
                while (!(fNotified || fTerminate)) {
                        received=fCondition.TimedWaitRelative(1000*fConfig->GetTriggerWait());
+                       CheckTerminate();
                        if (received==1) break; // 1 = timeout
                }
 
@@ -268,6 +287,7 @@ void AliShuttleTrigger::Run() {
                }
        
                Collect();
+               CheckTerminate();
        }
 
        delete notifier;
@@ -289,7 +309,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()) {
@@ -369,10 +389,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";