]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/AliShuttle.cxx
Deleting pointers in touching of the alien file created at every successful run.
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttle.cxx
index 9385047de85b9ba9320148e3540a2d9ecab849a1..33da89055e25bc3f201389e76011c2e6100f04f6 100644 (file)
@@ -982,7 +982,7 @@ Bool_t AliShuttle::WriteShuttleStatus(AliShuttleStatus* status)
                return kFALSE;
        }
        
-       SendMLInfo();
+       SendMLDetInfo();
 
        return kTRUE;
 }
@@ -1018,11 +1018,11 @@ void AliShuttle::UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t
 
        AliCDBManager::Instance()->GetStorage(fgkLocalCDB)->Put(fStatusEntry);
 
-       SendMLInfo();
+       SendMLDetInfo();
 }
 
 //______________________________________________________________________________________________
-void AliShuttle::SendMLInfo()
+void AliShuttle::SendMLDetInfo()
 {
        //
        // sends ML information about the current status of the current detector being processed
@@ -1031,7 +1031,7 @@ void AliShuttle::SendMLInfo()
        AliShuttleStatus* status = dynamic_cast<AliShuttleStatus*> (fStatusEntry->GetObject());
        
        if (!status){
-               Log("SHUTTLE", "SendMLInfo - UNEXPECTED: status could not be read from current CDB entry");
+               Log("SHUTTLE", "SendMLDetInfo - UNEXPECTED: status could not be read from current CDB entry");
                return;
        }
        
@@ -1180,6 +1180,31 @@ Bool_t AliShuttle::ContinueProcessing()
        return cont;
 }
 
+//______________________________________________________________________________________________
+void AliShuttle::SendMLRunInfo(const char* status)
+{
+       // 
+       // Send information about this run to ML
+       
+       TMonaLisaText  mlStatus("SHUTTLE_status", status);
+       TString runType(fLogbookEntry->GetRunType());
+       if (strlen(fLogbookEntry->GetRunParameter("log")) > 0){
+
+               runType += "(";
+               runType += fLogbookEntry->GetRunParameter("log");
+               runType += ")";
+       }
+       TMonaLisaText  mlRunType("SHUTTLE_runtype", runType);
+
+       TList mlList;
+       mlList.Add(&mlStatus);
+       mlList.Add(&mlRunType);
+
+       TString mlID;
+       mlID.Form("%d", GetCurrentRun());
+       fMonaLisa->SendParameters(&mlList, mlID);       
+}
+
 //______________________________________________________________________________________________
 Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
 {
@@ -1197,26 +1222,10 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
        Log("SHUTTLE", Form("\t\t\t^*^*^*^*^*^*^*^*^*^*^*^* run %d: START ^*^*^*^*^*^*^*^*^*^*^*^*",
                                        GetCurrentRun()));
 
-       // Send the information to ML
        CountOpenRuns();
        
-       TMonaLisaText  mlStatus("SHUTTLE_status", "Processing");
-       TString runType(entry->GetRunType());
-       if (strlen(entry->GetRunParameter("log")) > 0){
-
-               runType += "(";
-               runType += entry->GetRunParameter("log");
-               runType += ")";
-       }
-       TMonaLisaText  mlRunType("SHUTTLE_runtype", runType);
-
-       TList mlList;
-       mlList.Add(&mlStatus);
-       mlList.Add(&mlRunType);
-
-       TString mlID;
-       mlID.Form("%d", GetCurrentRun());
-       fMonaLisa->SendParameters(&mlList, mlID);
+       // Send the information to ML
+       SendMLRunInfo("Processing");
 
        if (fLogbookEntry->IsDone())
        {
@@ -1541,10 +1550,7 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
                                        fFirstUnprocessed[iDet] = kFALSE;
                                }
                        }
-                       TMonaLisaText  mlStatusPending("SHUTTLE_status", "Pending");
-                       mlList.Clear();
-                       mlList.Add(&mlStatusPending);
-                       fMonaLisa->SendParameters(&mlList, mlID);
+                       SendMLRunInfo("Pending");
                }
        }
 
@@ -1905,31 +1911,38 @@ AliShuttleLogbookEntry* AliShuttle::QueryRunParameters(Int_t run)
        TString totEventsStr = entry->GetRunParameter("totalEvents");  
        Int_t totEvents = totEventsStr.Atoi();
        
-       if (startTime != 0 && endTime != 0 && endTime > startTime && totEvents > 0 && ecsSuccess)
-               return entry;
-               
-       if (ecsSuccess == kFALSE)
+       // runs are accepted if they have ecsSuccess set or more than 1 event
+       if (startTime != 0 && endTime != 0 && endTime > startTime && (totEvents > 1 || ecsSuccess))
        {
-               Log("SHUTTLE", Form("Skipped run %d due to ECS failure, Reason: %s", run, entry->GetRunParameter("eor_reason")));
+               if (ecsSuccess == kFALSE)
+                       Log("SHUTTLE", Form("Processing run %d although in status ECS failure, Reason: %s", run, entry->GetRunParameter("eor_reason")));
+               return entry;
        }
-       else if (totEvents < 1) 
+
+       Bool_t skip = kFALSE;
+                               
+       if (totEvents <= 1) 
        {
-               Log("SHUTTLE", Form("QueryRunParameters - Run %d has 0 events - Skipping!", run));
-       }
+               Log("SHUTTLE", Form("QueryRunParameters - Run %d has 1 event or less - Skipping!", run));
+               skip = kTRUE;
+       } 
        else
        {
                Log("SHUTTLE", Form("QueryRunParameters - Invalid parameters for Run %d: "
                        "startTime = %d, endTime = %d. Skipping (Shuttle won't be marked as DONE)!",
                        run, startTime, endTime));
        }
-
-       //Log("SHUTTLE", Form("Marking SHUTTLE done for run %d", run));
-       //fLogbookEntry = entry;        
-       //if (!UpdateShuttleLogbook("shuttle_done"))
-       //{
-       //      AliError(Form("Could not update logbook for run %d !", run));
-       //}
-       //fLogbookEntry = 0;
+       
+       if (skip)
+       {
+               Log("SHUTTLE", Form("Marking SHUTTLE skipped for run %d", run));
+               fLogbookEntry = entry;
+               if (!UpdateShuttleLogbook("shuttle_skipped"))
+               {
+                       AliError(Form("Could not update logbook for run %d !", run));
+               }
+               fLogbookEntry = 0;
+       }
                        
        delete entry;
        return 0;
@@ -2586,29 +2599,21 @@ Bool_t AliShuttle::UpdateShuttleLogbook(const char* detector, const char* status
 
        TString detName(detector);
        TString setClause;
-       if (detName == "shuttle_done" || detName == "shuttle_ignored")
+       if (detName == "shuttle_done" || detName == "shuttle_skipped")
        {
                setClause = "set shuttle_done=1";
-
+               
                if (detName == "shuttle_done")
                {
-                       if (TouchFile()==kTRUE){
-                               //Send the information to ML
-                               TMonaLisaText  mlStatus("SHUTTLE_status", "Done");
-
-                               TList mlList;
-                               mlList.Add(&mlStatus);
-                               
-                               TString mlID;
-                               mlID.Form("%d", GetCurrentRun());
-                               fMonaLisa->SendParameters(&mlList, mlID);
-                       }
-                       else{
+                       if (TouchFile() != kTRUE)
                                return kFALSE;
-                       }
-                                       
+                       
+                       SendMLRunInfo("Done");
                }
-       } else {
+               else 
+                       SendMLRunInfo("Skipped");
+       } 
+       else {
                TString statusStr(status);
                if(statusStr.Contains("done", TString::kIgnoreCase) ||
                   statusStr.Contains("failed", TString::kIgnoreCase)){
@@ -2833,9 +2838,9 @@ Bool_t AliShuttle::Collect(Int_t run)
        {
                // query Shuttle logbook for earlier runs, check if some detectors are unprocessed,
                // flag them into fFirstUnprocessed array
-               TString whereClause(Form("where shuttle_done=0 and run < %d", run));
+               TString whereClauseBis(Form("where shuttle_done=0 and run < %d", run));
                TObjArray tmpLogbookEntries;
-               if (!QueryShuttleLogbook(whereClause, tmpLogbookEntries))
+               if (!QueryShuttleLogbook(whereClauseBis, tmpLogbookEntries))
                {
                        Log("SHUTTLE", "Collect - Can't retrieve entries from Shuttle logbook");
                        return kFALSE;
@@ -3003,6 +3008,10 @@ Bool_t AliShuttle::SendMail(EMailTarget target, Int_t system)
                return kTRUE;
        }
 
+       Int_t runMode = (Int_t)fConfig->GetRunMode();
+       TString tmpStr;
+       if (runMode == 0) tmpStr = " Nightly Test:";
+       else tmpStr = " Data Taking:"; 
        void* dir = gSystem->OpenDirectory(GetShuttleLogDir());
        if (dir == NULL)
        {
@@ -3083,8 +3092,8 @@ Bool_t AliShuttle::SendMail(EMailTarget target, Int_t system)
        TString body;
 
        if (target == kDCSEMail){
-               subject = Form("Retrieval of data points for %s FAILED in run %d !",
-                               fCurrentDetector.Data(), GetCurrentRun());
+               subject = Form("%s Retrieval of data points for %s FAILED in run %d !",
+                               tmpStr.Data(), fCurrentDetector.Data(), GetCurrentRun());
                AliDebug(2, Form("subject: %s", subject.Data()));
                
                body = Form("Dear DCS experts, \n\n");
@@ -3092,8 +3101,8 @@ Bool_t AliShuttle::SendMail(EMailTarget target, Int_t system)
                             "in run %d!!\n\n", fCurrentDetector.Data(), GetCurrentRun());
        }
        else if (target == kFXSEMail){
-               subject = Form("FXS communication for %s FAILED in run %d !",
-                               fCurrentDetector.Data(), GetCurrentRun());
+               subject = Form("%s FXS communication for %s FAILED in run %d !",
+                               tmpStr.Data(), fCurrentDetector.Data(), GetCurrentRun());
                AliDebug(2, Form("subject: %s", subject.Data()));
                TString sys;
                if (system == kDAQ) sys="DAQ";
@@ -3105,8 +3114,8 @@ Bool_t AliShuttle::SendMail(EMailTarget target, Int_t system)
                             "in run %d!!\n\n", fCurrentDetector.Data(), GetCurrentRun());
        }
        else {
-               subject = Form("%s Shuttle preprocessor FAILED in run %d (run type = %s)!",
-                                      fCurrentDetector.Data(), GetCurrentRun(), GetRunType());
+               subject = Form("%s %s Shuttle preprocessor FAILED in run %d (run type = %s)!",
+                                      tmpStr.Data(), fCurrentDetector.Data(), GetCurrentRun(), GetRunType());
                AliDebug(2, Form("subject: %s", subject.Data()));
        
                body = Form("Dear %s expert(s), \n\n", fCurrentDetector.Data());
@@ -3119,9 +3128,9 @@ Bool_t AliShuttle::SendMail(EMailTarget target, Int_t system)
                                fCurrentDetector.Data());
        if (fConfig->GetRunMode() == AliShuttleConfig::kTest)
        {
-               body += Form("\thttp://pcalimonitor.cern.ch:8889/shuttle.jsp?time=168 \n\n");
+               body += Form("\thttp://pcalimonitor.cern.ch/shuttle.jsp?time=24 \n\n");
        } else {
-               body += Form("\thttp://pcalimonitor.cern.ch/shuttle.jsp?instance=PROD&time=168 \n\n");
+               body += Form("\thttp://pcalimonitor.cern.ch/shuttle.jsp?instance=PROD&time=24 \n\n");
        }
        
        
@@ -3201,7 +3210,7 @@ Bool_t AliShuttle::GetHLTStatus()
        }
 
        // TODO implement when HLTMode is inserted in run logbook
-       TString hltMode = fLogbookEntry->GetRunParameter("HLTMode");
+       TString hltMode = fLogbookEntry->GetRunParameter("HLTmode");
        TSubString firstChar = hltMode(0,1);
        AliDebug(2,Form("First char = %s ",firstChar.Data())); 
        if (firstChar == "A") {
@@ -3309,6 +3318,8 @@ Bool_t AliShuttle::TouchFile()
        TMap *mapLs = dynamic_cast<TMap*>(resultLs->At(0));
        if (!mapLs){
                Log("SHUTTLE",Form("No map for %s command, returning without touching",commandLs.Data()));
+               delete resultLs;
+               resultLs = 0x0;
                return kFALSE;
        }
        TObjString *valueLsPath = dynamic_cast<TObjString*>(mapLs->GetValue("path"));
@@ -3320,6 +3331,14 @@ Bool_t AliShuttle::TouchFile()
                Bool_t boolMkdir = gGrid->Mkdir(dir.Data());
                if (!boolMkdir) {
                        Log("SHUTTLE",Form("Impossible to create dir %s in alien catalogue for run %i!",dir.Data(),GetCurrentRun()));
+                       if (valueLsPath) {
+                               delete valueLsPath;
+                               valueLsPath = 0x0;
+                       }
+                       delete mapLs;
+                       mapLs = 0x0;
+                       delete resultLs;
+                       resultLs = 0x0;
                        return kFALSE;
                }
                Log("SHUTTLE",Form("Directory %s successfully created in alien catalogue for run %i",dir.Data(),GetCurrentRun()));
@@ -3328,6 +3347,13 @@ Bool_t AliShuttle::TouchFile()
                Log("SHUTTLE",Form("Directory %s correctly found for run %i",dir.Data(),GetCurrentRun()));
        }
 
+       delete valueLsPath;
+       valueLsPath = 0x0;
+       delete mapLs;
+       mapLs = 0x0;
+       delete resultLs;
+       resultLs = 0x0;
+
        TString command;
        command.Form("touch %s/%i", dir.Data(), GetCurrentRun());
        Log("SHUTTLE", Form("Creating entry in file catalog: %s", command.Data()));
@@ -3339,17 +3365,35 @@ Bool_t AliShuttle::TouchFile()
        TMap *mapTouch = dynamic_cast<TMap*>(resultTouch->At(0));
        if (!mapTouch){
                Log("SHUTTLE",Form("No map for touching command, returning without touching for run %i",GetCurrentRun()));
+               delete resultTouch;
+               resultTouch = 0x0; 
                return kFALSE;
        }
        TObjString *valueTouch = dynamic_cast<TObjString*>(mapTouch->GetValue("__result__"));
        if (!valueTouch){
                Log("SHUTTLE",Form("No value for \"__result__\" key set in the map for touching command, returning without touching for run %i",GetCurrentRun()));
+               delete mapTouch;
+               mapTouch = 0x0; 
+               delete resultTouch;
+               resultTouch = 0x0; 
                return kFALSE;
        }
        if (valueTouch->GetString()!="1"){
                Log("SHUTTLE",Form("Failing the touching command, returning without touching for run %i",GetCurrentRun()));
+               delete valueTouch;
+               valueTouch = 0x0; 
+               delete mapTouch;
+               mapTouch = 0x0; 
+               delete resultTouch;
+               resultTouch = 0x0; 
                return kFALSE;
        }
+       delete valueTouch;
+       valueTouch = 0x0; 
+       delete mapTouch;
+       mapTouch = 0x0; 
+       delete resultTouch;
+       resultTouch = 0x0; 
        return kTRUE;
 }