#include <TFile.h>
#include <TGrid.h>
#include <TGridResult.h>
+#include <TMap.h>
#include <TMonaLisaWriter.h>
lhcPeriod.Data()));
}
- TString target = Form("%s/GRP/RunMetadata/alice/data/%d/%s/%09d/raw/%s",
- localBaseFolder.Data(), GetCurrentYear(),
+ TString target = Form("%s/GRP/RunMetadata%s%d/%s/%09d/raw/%s",
+ localBaseFolder.Data(), fConfig->GetAlienPath(), GetCurrentYear(),
lhcPeriod.Data(), GetCurrentRun(), gridFileName);
return CopyFileLocally(localFile, target);
lhcPeriod.Append(Form("_%s", partition.Data()));
}
- dir = Form("%s/GRP/RunMetadata/alice/data/%d/%s/%09d/raw",
- localBaseFolder.Data(), GetCurrentYear(),
+ dir = Form("%s/GRP/RunMetadata%s%d/%s/%09d/raw",
+ localBaseFolder.Data(), fConfig->GetAlienPath(), GetCurrentYear(),
lhcPeriod.Data(), GetCurrentRun());
- alienDir = dir(dir.Index("/alice/data/"), dir.Length());
+ alienDir = dir(dir.Index(fConfig->GetAlienPath()), dir.Length());
begin = "";
}
return WriteShuttleStatus(status);
}
- // The following two cases shouldn't happen if Shuttle Logbook was correctly updated.
+ // The following case shouldn't happen if Shuttle Logbook was correctly updated.
// If it happens it may mean Logbook updating failed... let's do it now!
if (status->GetStatus() == AliShuttleStatus::kDone ||
- status->GetStatus() == AliShuttleStatus::kFailed){
+ status->GetStatus() == AliShuttleStatus::kFailed ||
+ status->GetStatus() == AliShuttleStatus::kSkipped) {
Log("SHUTTLE", Form("ContinueProcessing - %s is already %s. Updating Shuttle Logbook",
fCurrentDetector.Data(),
status->GetStatusName(status->GetStatus())));
- UpdateShuttleLogbook(fCurrentDetector.Data(),
- status->GetStatusName(status->GetStatus()));
+
+ if (status->GetStatus() == AliShuttleStatus::kSkipped)
+ {
+ UpdateShuttleLogbook(fCurrentDetector.Data(), "DONE");
+ }
+ else
+ UpdateShuttleLogbook(fCurrentDetector.Data(), status->GetStatusName(status->GetStatus()));
+
return kFALSE;
}
}
if (fgkMainCDB.Length() == 0)
- fgkMainCDB = Form("alien://folder=/alice/data/%d/%s/OCDB?user=alidaq?cacheFold=/tmp/OCDBCache",
- GetCurrentYear(), lhcPeriod.Data());
+ fgkMainCDB = Form("alien://folder=%s%d/%s/OCDB?user=alidaq?cacheFold=/tmp/OCDBCache",
+ fConfig->GetAlienPath(), GetCurrentYear(), lhcPeriod.Data());
if (fgkMainRefStorage.Length() == 0)
- fgkMainRefStorage = Form("alien://folder=/alice/data/%d/%s/Reference?user=alidaq?cacheFold=/tmp/OCDBCache",
- GetCurrentYear(), lhcPeriod.Data());
+ fgkMainRefStorage = Form("alien://folder=%s%d/%s/Reference?user=alidaq?cacheFold=/tmp/OCDBCache",
+ fConfig->GetAlienPath(), GetCurrentYear(), lhcPeriod.Data());
// Loop on detectors in the configuration
TIter iter(fConfig->GetDetectors());
kill(pid, 9);
- UpdateShuttleStatus(AliShuttleStatus::kPPTimeOut);
+ UpdateShuttleStatus(AliShuttleStatus::kPPTimeOut);
hasError = kTRUE;
gSystem->Sleep(1000);
}
else if (pid == 0)
{
- // client
- Log("SHUTTLE", Form("Process - In client process of %d - %s", GetCurrentRun(),
+ // child
+ Log("SHUTTLE", Form("Process - In child process of %d - %s", GetCurrentRun(),
aDetector->GetName()));
Log("SHUTTLE", Form("Process - Redirecting output to %s log",fCurrentDetector.Data()));
gSystem->Exit(1);
}
- Bool_t success = ProcessCurrentDetector();
-
+ Int_t success = ProcessCurrentDetector();
+
gSystem->ChangeDirectory(wd.Data());
- if (success) // Preprocessor finished successfully!
+ if (success == 1) // Preprocessor finished successfully!
{
// remove temporary folder or DCS map
if (!fConfig->KeepTempFolder())
if (StoreOCDB() == kFALSE)
success = kFALSE;
}
- else
+ else if (success == 0)
{
Log("SHUTTLE",
Form("\t\t\t****** run %d - %s: PP ERROR ******",
}
//______________________________________________________________________________________________
-Bool_t AliShuttle::ProcessCurrentDetector()
+Int_t AliShuttle::ProcessCurrentDetector()
{
//
// Makes data retrieval just for a specific detector (fCurrentDetector).
TString wd = gSystem->WorkingDirectory();
if (!CleanReferenceStorage(fCurrentDetector.Data()))
- return kFALSE;
+ return 0;
gSystem->ChangeDirectory(wd.Data());
- TMap* dcsMap = new TMap();
-
// call preprocessor
AliPreprocessor* aPreprocessor =
dynamic_cast<AliPreprocessor*> (fPreprocessorMap.GetValue(fCurrentDetector));
+ // check if the preprocessor wants to process this run type
+ if (aPreprocessor->ProcessRunType() == kFALSE)
+ {
+ UpdateShuttleStatus(AliShuttleStatus::kSkipped);
+ UpdateShuttleLogbook(fCurrentDetector, "DONE");
+ Log(fCurrentDetector, Form("ProcessCurrentDetector - %s preprocessor is not interested in this run type", fCurrentDetector.Data()));
+
+ return 2;
+ }
+
+ TMap* dcsMap = new TMap();
+
aPreprocessor->Initialize(GetCurrentRun(), GetCurrentStartTime(), GetCurrentEndTime());
Bool_t processDCS = aPreprocessor->ProcessDCS();
UpdateShuttleStatus(AliShuttleStatus::kDCSStarted);
UpdateShuttleStatus(AliShuttleStatus::kDCSError);
delete dcsMap;
- return kFALSE;
+ return 0;
} else {
UpdateShuttleStatus(AliShuttleStatus::kDCSStarted);
TMap* aliasMap = 0;
TMap* dpMap = 0;
-
+
if (fConfig->GetDCSAliases(fCurrentDetector, iServ)->GetEntries() > 0)
{
aliasMap = GetValueSet(host, port,
"Could not send mail to DCS experts!"));
delete dcsMap;
- return kFALSE;
+ return 0;
}
}
if (aliasMap) delete aliasMap;
delete dcsMap;
- return kFALSE;
+ return 0;
}
}
SendMail(kFXSEMail, fFXSError);
dcsMap->DeleteAll();
delete dcsMap;
- return kFALSE;
+ return 0;
}
if (returnValue > 0) // Preprocessor error!
UpdateShuttleStatus(AliShuttleStatus::kPPError);
dcsMap->DeleteAll();
delete dcsMap;
- return kFALSE;
+ return 0;
}
// preprocessor ok!
dcsMap->DeleteAll();
delete dcsMap;
- return kTRUE;
+ return 1;
}
//______________________________________________________________________________________________
for (Int_t ii = 0; ii < aResult->GetFieldCount(); ii++)
entry->SetRunParameter(aResult->GetFieldName(ii), aRow->GetField(ii));
+ delete aRow;
+ delete aResult;
+
UInt_t startTime = entry->GetStartTime();
UInt_t endTime = entry->GetEndTime();
-
-// if (!startTime || !endTime || startTime > endTime)
-// {
-// Log("SHUTTLE",
-// Form("QueryRunParameters - Invalid parameters for Run %d: startTime = %d, endTime = %d. Skipping!",
-// 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;
-//
-// delete entry;
-// delete aRow;
-// delete aResult;
-// return 0;
-// }
-
- if (!startTime)
- {
- Log("SHUTTLE",
- Form("QueryRunParameters - Invalid parameters for Run %d: "
- "startTime = %d, endTime = %d. Skipping!",
- run, startTime, endTime));
-
- Log("SHUTTLE", Form("Marking SHUTTLE done for run %d", run));
- fLogbookEntry = entry;
- if (!UpdateShuttleLogbook("shuttle_ignored"))
- {
- AliError(Form("Could not update logbook for run %d !", run));
- }
- fLogbookEntry = 0;
-
- delete entry;
- delete aRow;
- delete aResult;
- return 0;
- }
+ Bool_t ecsSuccess = entry->GetECSSuccess();
- if (startTime && !endTime)
- {
- // TODO Here we don't mark SHUTTLE done, because this may mean
- //the run is still ongoing!!
- Log("SHUTTLE",
- Form("QueryRunParameters - Invalid parameters for Run %d: "
- "startTime = %d, endTime = %d. Skipping (Shuttle won't be marked as DONE)!",
- run, startTime, endTime));
+ TString totEventsStr = entry->GetRunParameter("totalEvents");
+ Int_t totEvents = totEventsStr.Atoi();
+
+ if (startTime != 0 && endTime != 0 && endTime > startTime && totEvents > 0 && ecsSuccess)
+ return entry;
- //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;
-
- delete entry;
- delete aRow;
- delete aResult;
- return 0;
+ if (ecsSuccess == kFALSE)
+ {
+ Log("SHUTTLE", Form("Skipped run %d due to ECS failure, Reason: %s", run, entry->GetRunParameter("eor_reason")));
}
-
- if (startTime && endTime && (startTime > endTime))
+ else if (totEvents < 1)
{
- Log("SHUTTLE",
- Form("QueryRunParameters - Invalid parameters for Run %d: "
- "startTime = %d, endTime = %d. Skipping!",
- run, startTime, endTime));
-
- Log("SHUTTLE", Form("Marking SHUTTLE done for run %d", run));
- fLogbookEntry = entry;
- if (!UpdateShuttleLogbook("shuttle_ignored"))
- {
- AliError(Form("Could not update logbook for run %d !", run));
- }
- fLogbookEntry = 0;
-
- delete entry;
- delete aRow;
- delete aResult;
- return 0;
+ Log("SHUTTLE", Form("QueryRunParameters - Run %d has 0 events - Skipping!", run));
}
-
- TString totEventsStr = entry->GetRunParameter("totalEvents");
- Int_t totEvents = totEventsStr.Atoi();
- if (totEvents < 1)
+ else
{
- Log("SHUTTLE",
- Form("QueryRunParameters - Run %d has 0 events - Skipping!", run));
-
- Log("SHUTTLE", Form("Marking SHUTTLE done for run %d", run));
- fLogbookEntry = entry;
- if (!UpdateShuttleLogbook("shuttle_ignored"))
- {
- AliError(Form("Could not update logbook for run %d !", run));
- }
- fLogbookEntry = 0;
-
- delete entry;
- delete aRow;
- delete aResult;
- return 0;
+ Log("SHUTTLE", Form("QueryRunParameters - Invalid parameters for Run %d: "
+ "startTime = %d, endTime = %d. Skipping (Shuttle won't be marked as DONE)!",
+ run, startTime, endTime));
}
- delete aRow;
- delete aResult;
-
- return entry;
+ //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;
+
+ delete entry;
+ return 0;
}
//______________________________________________________________________________________________
if (detName == "shuttle_done")
{
- // Send the information to ML
- TMonaLisaText mlStatus("SHUTTLE_status", "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);
+ TList mlList;
+ mlList.Add(&mlStatus);
+
+ TString mlID;
+ mlID.Form("%d", GetCurrentRun());
+ fMonaLisa->SendParameters(&mlList, mlID);
+ }
+ else{
+ return kFALSE;
+ }
+
}
} else {
TString statusStr(status);
gSystem->FreeDirectory(dir);
}
- TString toLog = Form("%s (%d): %s - ", TTimeStamp(time(0)).AsString("s"), getpid(), detector);
+ TString toLog = Form("%s UTC (%d): %s - ", TTimeStamp(time(0)).AsString("s"), getpid(), detector);
if (GetCurrentRun() >= 0)
toLog += Form("run %d - ", GetCurrentRun());
toLog += Form("%s", message);
Bool_t AliShuttle::GetHLTStatus()
{
// Return HLT status (ON=1 OFF=0)
- // Converts the HLT status from the status string read in the run logbook (not just a bool)
+ // Converts the HLT status from the mode string read in the run logbook (not just a bool)
if(!fLogbookEntry) {
AliError("No logbook entry!");
return 0;
}
- // TODO implement when HLTStatus is inserted in run logbook
- //TString hltStatus = fLogbookEntry->GetRunParameter("HLTStatus");
- //if(hltStatus == "OFF") {return kFALSE};
+ // TODO implement when HLTMode is inserted in run logbook
+ TString hltMode = fLogbookEntry->GetRunParameter("HLTMode");
+ TSubString firstChar = hltMode(0,1);
+ AliDebug(2,Form("First char = %s ",firstChar.Data()));
+ if (firstChar == "A") {
+ return kFALSE;
+ }
+ else if ((firstChar == "B") || (firstChar == "C") || (firstChar == "D") || (firstChar == "E")) {
+ return kTRUE;
+ }
+ else {
+ Log("SHUTTLE","Unexpected HLT mode! Returning 0....");
+ return kFALSE;
+ }
+}
- return kTRUE;
+//______________________________________________________________________________________________
+const char* AliShuttle::GetTriggerConfiguration()
+{
+ // Receives the trigger configuration from the DAQ logbook for the current run
+
+ // check connection, if needed reconnect
+ if (!Connect(3))
+ return 0;
+
+ TString sqlQuery;
+ sqlQuery.Form("SELECT configFile FROM logbook_trigger_config WHERE run = %d", GetCurrentRun());
+ TSQLResult* result = fServer[3]->Query(sqlQuery);
+ if (!result)
+ {
+ Log("SHUTTLE", Form("ERROR: Can't execute query <%s>!", sqlQuery.Data()));
+ return 0;
+ }
+
+ if (result->GetRowCount() == 0)
+ {
+ Log("SHUTTLE", "ERROR: Trigger configuration not found in logbook_trigger_config");
+ delete result;
+ return 0;
+ }
+
+ TSQLRow* row = result->Next();
+ if (!row)
+ {
+ Log("SHUTTLE", "ERROR: Could not receive logbook_trigger_config data");
+ delete result;
+ return 0;
+ }
+
+ // static, so that pointer remains valid when it is returned to the calling class
+ static TString triggerConfig(row->GetField(0));
+
+ delete row;
+ row = 0;
+
+ delete result;
+ result = 0;
+
+ Log("SHUTTLE", Form("Found trigger configuration: %s", triggerConfig.Data()));
+
+ return triggerConfig;
}
//______________________________________________________________________________________________
fgkShuttleLogDir = gSystem->ExpandPathName(logDir);
}
+//______________________________________________________________________________________________
+Bool_t AliShuttle::TouchFile()
+{
+ //
+ // touching a file on the grid if run has been DONE
+ //
+
+ if (!gGrid)
+ {
+ Log("SHUTTLE",Form("No TGrid connection estabilished!"));
+ Log("SHUTTLE",Form("Could not touch file for run %i",GetCurrentRun()));
+ return kFALSE;
+ }
+
+ TString dir;
+ dir.Form("%s%d/%s/SHUTTLE_DONE", fConfig->GetAlienPath(), GetCurrentYear(), GetLHCPeriod());
+ // checking whether directory for touch command exists
+ TString commandLs;
+ commandLs.Form("ls %s",dir.Data());
+ TGridResult *resultLs = dynamic_cast<TGridResult*>(gGrid->Command(commandLs));
+ if (!resultLs){
+ Log("SHUTTLE",Form("No result for %s command, returning without touching",commandLs.Data()));
+ return kFALSE;
+ }
+ TMap *mapLs = dynamic_cast<TMap*>(resultLs->At(0));
+ if (!mapLs){
+ Log("SHUTTLE",Form("No map for %s command, returning without touching",commandLs.Data()));
+ return kFALSE;
+ }
+ TObjString *valueLsPath = dynamic_cast<TObjString*>(mapLs->GetValue("path"));
+ if (!valueLsPath || (TString)(valueLsPath->GetString()).CompareTo(dir)!=1){
+ Log("SHUTTLE",Form("No directory %s found, creating it",dir.Data()));
+
+ // creating the directory
+
+ 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()));
+ return kFALSE;
+ }
+ Log("SHUTTLE",Form("Directory %s successfully created in alien catalogue for run %i",dir.Data(),GetCurrentRun()));
+ }
+ else {
+ Log("SHUTTLE",Form("Directory %s correctly found for run %i",dir.Data(),GetCurrentRun()));
+ }
+
+ TString command;
+ command.Form("touch %s/%i", dir.Data(), GetCurrentRun());
+ Log("SHUTTLE", Form("Creating entry in file catalog: %s", command.Data()));
+ TGridResult *resultTouch = dynamic_cast<TGridResult*>(gGrid->Command(command));
+ if (!resultTouch){
+ Log("SHUTTLE",Form("No result for touching command, returning without touching for run %i",GetCurrentRun()));
+ return kFALSE;
+ }
+ 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()));
+ 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()));
+ return kFALSE;
+ }
+ if (valueTouch->GetString()!="1"){
+ Log("SHUTTLE",Form("Failing the touching command, returning without touching for run %i",GetCurrentRun()));
+ return kFALSE;
+ }
+ return kTRUE;
+}
+
+