]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/AliShuttle.cxx
Check md5sum of retrieved FXS file inside "retry loop"; clean temp folder after
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttle.cxx
index fd19c08e6371b48f745559253f7a7a4e54f8582e..3b8f726ca78145093f1f09241ad35bf095eaaea6 100644 (file)
@@ -736,6 +736,11 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
                                if (UpdateTable() == kFALSE) returnCode = 1;
                        }
 
+                       for (UInt_t iSys=0; iSys<3; iSys++)
+                       {
+                               if (fFXSCalled[iSys]) fFXSlist[iSys].Clear();
+                       }
+
                        AliInfo(Form("Client process of %d - %s is exiting now with %d.",
                                                        GetCurrentRun(), aDetector->GetName(), returnCode));
 
@@ -744,11 +749,6 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
 
                        AliError("We should never get here!!!");
                }
-
-               for (UInt_t iSys=0; iSys<3; iSys++)
-               {
-                       if (fFXSCalled[iSys]) fFXSlist[iSys].Clear();
-               }
        }
 
        AliInfo(Form("\n\n \t\t\t^*^*^*^*^*^*^*^*^*^*^*^* run %d: FINISH ^*^*^*^*^*^*^*^*^*^*^*^* \n",
@@ -1328,31 +1328,44 @@ const char* AliShuttle::GetFile(Int_t system, const char* detector,
 
 
        // file retrieval from FXS
-       Bool_t result = RetrieveFile(system, filePath.Data(), localFileName.Data());
-       if(!result)
-       {
-               Log(detector, Form("GetFileName - Copy of file %s from %s FXS failed",
+       UInt_t nRetries = 0;
+       UInt_t maxRetries = 3;
+       Bool_t result = kFALSE;
+
+       // copy!! if successful TSystem::Exec returns 0
+       while(nRetries++ < maxRetries) {
+               AliDebug(2, Form("Trying to copy file. Retry # %d", nRetries));
+               result = RetrieveFile(system, filePath.Data(), localFileName.Data());
+               if(!result)
+               {
+                       Log(detector, Form("GetFileName - Copy of file %s from %s FXS failed",
                                        filePath.Data(), GetSystemName(system)));
-               return 0;
-       } else {
-               AliInfo(Form("File %s copied from %s FXS into %s/%s",
-                       filePath.Data(), GetSystemName(system), GetShuttleTempDir(), localFileName.Data()));
-       }
+                       continue;
+               } else {
+                       AliInfo(Form("File %s copied from %s FXS into %s/%s",
+                                               filePath.Data(), GetSystemName(system),
+                                               GetShuttleTempDir(), localFileName.Data()));
+               }
 
-       if (system == kHLT)
-       {
-               // compare md5sum of local file with the one stored in the FXS DB
-               Int_t md5Comp = gSystem->Exec(Form("md5sum %s/%s |grep %s 2>&1 > /dev/null",
+               if (system == kHLT)
+               {
+                       // compare md5sum of local file with the one stored in the FXS DB
+                       Int_t md5Comp = gSystem->Exec(Form("md5sum %s/%s |grep %s 2>&1 > /dev/null",
                                                GetShuttleTempDir(), localFileName.Data(), fileMd5Sum.Data()));
 
-               if (md5Comp != 0)
-               {
-                       Log(detector, Form("GetFileName - md5sum of file %s does not match with local copy!",
-                                               filePath.Data()));
-                       return 0;
+                       if (md5Comp != 0)
+                       {
+                               Log(detector, Form("GetFileName - md5sum of file %s does not match with local copy!",
+                                                       filePath.Data()));
+                               result = kFALSE;
+                               continue;
+                       }
                }
+               if (result) break;
        }
 
+       if(!result) return 0;
+
        fFXSCalled[system]=kTRUE;
        TObjString *fileParams = new TObjString(Form("%s#!?!#%s", id, sourceName.Data()));
        fFXSlist[system].Add(fileParams);
@@ -1412,16 +1425,9 @@ Bool_t AliShuttle::RetrieveFile(UInt_t system, const char* fxsFileName, const ch
 
        AliDebug(2, Form("%s",command.Data()));
 
-       UInt_t nRetries = 0;
-       UInt_t maxRetries = 3;
+       Bool_t result = (gSystem->Exec(command.Data()) == 0);
 
-       // copy!! if successful TSystem::Exec returns 0
-       while(nRetries++ < maxRetries) {
-               AliDebug(2, Form("Trying to copy file. Retry # %d", nRetries));
-               if(gSystem->Exec(command.Data()) == 0) return kTRUE;
-       }
-
-       return kFALSE;
+       return result;
 }
 
 //______________________________________________________________________________________________
@@ -1855,6 +1861,10 @@ Bool_t AliShuttle::RetrieveConditionsData(const TObjArray& dateEntries)
                if (!Process(anEntry)){
                        hasError = kTRUE;
                }
+
+               // clean SHUTTLE temp directory
+               TString command = Form("rm -f %s/*.shuttle", GetShuttleTempDir());
+               gSystem->Exec(command.Data());
        }
 
        return hasError == kFALSE;