//
// returns 0 if fail, 1 otherwise
+
if (fTestMode & kErrorStorage)
{
Log(fCurrentDetector, "StoreLocally - In TESTMODE - Simulating error while storing locally");
if (!(AliCDBManager::Instance()->GetStorage(localUri))) {
Log("SHUTTLE", Form("StoreLocally - Cannot activate local %s storage", cdbType));
} else {
+ Int_t logLevel = AliLog::GetGlobalLogLevel();
+ AliLog::SetGlobalLogLevel(AliLog::kError);
result = AliCDBManager::Instance()->GetStorage(localUri)
->Put(object, id, metaData);
+ AliLog::SetGlobalLogLevel((AliLog::EType_t)logLevel);
}
if(!result) {
Log(fCurrentDetector, Form("StoreLocally - Can't store object <%s>!", id.ToString().Data()));
}
+
return result;
}
Bool_t resultMetadata = kTRUE;
if(fCurrentDetector == "GRP")
{
- Log("StoreOCDB - SHUTTLE","Storing Run Metadata file ...");
+ Log("SHUTTLE","StoreOCDB - Storing Run Metadata file ...");
resultMetadata = CopyFilesToGrid("metadata");
}
//
TString offDetStr(GetOfflineDetName(detector));
- TString dir;
+ static TString dir;
if (offDetStr == "ITS" || offDetStr == "MUON" || offDetStr == "PHOS")
{
dir.Form("%s/%s/%s", base, offDetStr.Data(), detector);
}
return dir.Data();
-
-
}
//______________________________________________________________________________________________
fStatusEntry = 0;
}
+ Int_t path1 = GetCurrentRun()/10000;
fStatusEntry = AliCDBManager::Instance()->GetStorage(GetLocalCDB())
- ->Get(Form("/SHUTTLE/STATUS/%s", fCurrentDetector.Data()), GetCurrentRun());
+ ->Get(Form("/SHUTTLE/%s/%d", fCurrentDetector.Data(), path1), GetCurrentRun());
if (!fStatusEntry) return 0;
fStatusEntry->SetOwner(1);
}
Int_t run = GetCurrentRun();
+ Int_t path1 = run/10000;
+ TString path1_string = Form("%d",path1);
- AliCDBId id(AliCDBPath("SHUTTLE", "STATUS", fCurrentDetector), run, run);
+ AliCDBId id(AliCDBPath("SHUTTLE", fCurrentDetector, path1_string), run, run);
fStatusEntry = new AliCDBEntry(status, id, new AliCDBMetaData);
fStatusEntry->SetOwner(1);
+ Int_t logLevel = AliLog::GetGlobalLogLevel();
+ AliLog::SetGlobalLogLevel(AliLog::kError);
+
UInt_t result = AliCDBManager::Instance()->GetStorage(fgkLocalCDB)->Put(fStatusEntry);
- if (!result) {
+ AliLog::SetGlobalLogLevel((AliLog::EType_t)logLevel);
+
+ if (!result) {
Log("SHUTTLE", Form("WriteShuttleStatus - Failed for %s, run %d",
fCurrentDetector.Data(), run));
return kFALSE;
status->SetStatus(newStatus);
if (increaseCount) status->IncreaseCount();
+ Int_t logLevel = AliLog::GetGlobalLogLevel();
+ AliLog::SetGlobalLogLevel(AliLog::kError);
+
AliCDBManager::Instance()->GetStorage(fgkLocalCDB)->Put(fStatusEntry);
+ AliLog::SetGlobalLogLevel((AliLog::EType_t)logLevel);
+
SendMLDetInfo();
}
// Send mail to detector expert!
Log("SHUTTLE", Form("ContinueProcessing - Sending mail to %s expert...",
fCurrentDetector.Data()));
+ // det experts in to
+ TString to="";
+ TIter *iterExperts = 0;
+ iterExperts = new TIter(fConfig->GetResponsibles(fCurrentDetector));
+ TObjString *anExpert=0;
+ while ((anExpert = (TObjString*) iterExperts->Next()))
+ {
+ to += Form("%s, \n", anExpert->GetName());
+ }
+ delete iterExperts;
+
+ if (to.Length() > 0)
+ to.Remove(to.Length()-3);
+ AliDebug(2, Form("to: %s",to.Data()));
+
+ if (to.IsNull()) {
+ Log("SHUTTLE", Form("List of %s responsibles not set!", fCurrentDetector.Data()));
+ return kFALSE;
+ }
+
+ Log(fCurrentDetector.Data(), Form("ContinueProcessing - Sending mail to %s expert(s):",
+ fCurrentDetector.Data()));
+ Log(fCurrentDetector.Data(), Form("\n%s", to.Data()));
if (!SendMail(kPPEMail))
Log("SHUTTLE", Form("ContinueProcessing - Could not send mail to %s expert",
fCurrentDetector.Data()));
runType += fLogbookEntry->GetRunParameter("log");
runType += ")";
}
+ if (fLogbookEntry->GetDATestMode()){
+ runType += " (DATest)";
+ }
TMonaLisaText mlRunType("SHUTTLE_runtype", runType);
TList mlList;
// Initialization
Bool_t hasError = kFALSE;
- // Set the CDB and Reference folders according to the year and LHC period
- TString lhcPeriod(GetLHCPeriod());
- if (lhcPeriod.Length() == 0)
- {
- Log("SHUTTLE","Process - LHCPeriod not found in logbook!");
- return 0;
- }
-
- // build cdb paths (repeat each time, LHCperiod might have changed)
- fgkMainCDB.Form("alien://folder=%s%d/%s/OCDB?user=alidaq?cacheFold=/tmp/OCDBCache",
- fConfig->GetAlienPath(), GetCurrentYear(), lhcPeriod.Data());
-
- fgkMainRefStorage.Form("alien://folder=%s%d/%s/Reference?user=alidaq?cacheFold=/tmp/OCDBCache",
- fConfig->GetAlienPath(), GetCurrentYear(), lhcPeriod.Data());
-
+ // Set the CDB and Reference folders according to the year
+
+ // build cdb paths (repeat each time, run might be a DATest run)
+ if (!fLogbookEntry->GetDATestMode()){
+ fgkMainCDB.Form("alien://folder=%s%d/OCDB?user=alidaq?cacheFold=/tmp/OCDBCache",
+ fConfig->GetAlienPath(), GetCurrentYear());
+
+ fgkMainRefStorage.Form("alien://folder=%s%d/Reference?user=alidaq?cacheFold=/tmp/OCDBCache",
+ fConfig->GetAlienPath(), GetCurrentYear());
+ }
+ else {
+ fgkMainCDB.Form("alien://folder=%s%d/DATest/OCDB?user=alidaq?cacheFold=/tmp/OCDBCache",
+ fConfig->GetAlienPath(), GetCurrentYear());
+
+ fgkMainRefStorage.Form("alien://folder=%s%d/DATest/Reference?user=alidaq?cacheFold=/tmp/OCDBCache",
+ fConfig->GetAlienPath(), GetCurrentYear());
+ }
+
+ AliDebug(2,Form("Main CDB storage = %s",fgkMainCDB.Data()));
+ AliDebug(2,Form("Main Reference storage = %s",fgkMainRefStorage.Data()));
+
// Loop on detectors in the configuration
TIter iter(fConfig->GetDetectors());
TObjString* aDetector = 0;
}
TString wd = gSystem->WorkingDirectory();
- TString tmpDir = Form("%s/%s_%d_process", GetShuttleTempDir(),
- fCurrentDetector.Data(), GetCurrentRun());
+ Int_t dir_lev1 = GetCurrentRun()/10000;
+ TString tmpDir = Form("%s/%d/%d/%s_process", GetShuttleTempDir(),
+ dir_lev1, GetCurrentRun(), fCurrentDetector.Data());
Int_t result = gSystem->GetPathInfo(tmpDir.Data(), 0, (Long64_t*) 0, 0, 0);
if (!result) // temp dir already exists!
{
UpdateShuttleStatus(AliShuttleStatus::kSkipped);
UpdateShuttleLogbook(fCurrentDetector, "DONE");
+ if (!UpdateTableSkippedCase(fCurrentDetector.Data()))
+ {
+ AliError(Form("Could not update FXS tables for run %d !", GetCurrentRun()));
+ }
Log(fCurrentDetector, Form("ProcessCurrentDetector - %s preprocessor is not interested in this run type", fCurrentDetector.Data()));
return 2;
if (fConfig->GetDCSAliases(fCurrentDetector, iServ)->GetEntries() > 0)
{
+ Log(fCurrentDetector, Form("Querying %d DCS aliases", fConfig->GetDCSAliases(fCurrentDetector, iServ)->GetEntries()));
aliasMap = GetValueSet(host, port,
fConfig->GetDCSAliases(fCurrentDetector, iServ),
kAlias, multiSplit);
if (fConfig->GetDCSDataPoints(fCurrentDetector, iServ)->GetEntries() > 0)
{
+ Log(fCurrentDetector, Form("Querying %d DCS data points", fConfig->GetDCSDataPoints(fCurrentDetector, iServ)->GetEntries()));
dpMap = GetValueSet(host, port,
fConfig->GetDCSDataPoints(fCurrentDetector, iServ),
kDP, multiSplit);
{
// Query DAQ's Shuttle logbook and sends the number of open runs to ML
+ SendAlive();
+
// check connection, in case connect
if (!Connect(3))
return;
}
// TODO Check field count!
- const UInt_t nCols = 23;
+ const UInt_t nCols = 26;
if (aResult->GetFieldCount() != (Int_t) nCols) {
Log("SHUTTLE", "Invalid SQL result field number!");
delete aResult;
if (!entry)
continue;
+ // DA test mode flag
+ TString daTestModeString(aRow->GetField(2), aRow->GetFieldLength(2)); // field 2 = DA test mode flag
+ Bool_t daTestMode = (Bool_t)daTestModeString.Atoi();
+ entry->SetDATestMode(daTestMode);
+
// loop on detectors
for(UInt_t ii = 0; ii < nCols; ii++)
entry->SetDetectorStatus(aResult->GetFieldName(ii), aRow->GetField(ii));
UInt_t now = time(0);
// TODO make this a configuration parameter
- Int_t dcsDelay = 120;
+ Int_t dcsDelay = fConfig->GetDCSDelay()+fConfig->GetDCSQueryOffset();
// runs are accepted if they have ecsSuccess set or more than 1 event
if (startTime != 0 && endTime != 0 && endTime > startTime && (totEvents > 1 || ecsSuccess) && (endTime < now - dcsDelay))
Bool_t skip = kFALSE;
- if (totEvents <= 1)
+ if (endTime != 0 && endTime >= now - dcsDelay)
{
- Log("SHUTTLE", Form("QueryRunParameters - Run %d has 1 event or less - Skipping!", run));
- skip = kTRUE;
+ Log("SHUTTLE", Form("Skipping run %d for now, because DCS buffer time is not yet expired", run));
}
- else if (endTime != 0 && endTime >= now - dcsDelay)
+ else if (totEvents <= 1)
{
- Log("SHUTTLE", Form("Skipping run %d for now, because DCS buffer time is not yet expired", run));
+ Log("SHUTTLE", Form("QueryRunParameters - Run %d has 1 event or less - Skipping!", run));
+ skip = kTRUE;
}
else
{
{
AliError(Form("Could not update logbook for run %d !", run));
}
+ if (!UpdateTableSkippedCase("ALL"))
+ {
+ AliError(Form("Could not update FXS tables for run %d !", run));
+ }
fLogbookEntry = 0;
}
TMap* result = 0;
if (type == kAlias)
{
- result = client.GetAliasValues(entries, GetCurrentStartTime(),
- GetCurrentEndTime());
+ //result = client.GetAliasValues(entries, GetCurrentStartTime()-offset,
+ // GetCurrentEndTime()+offset);
+ result = client.GetAliasValues(entries, GetStartTimeDCSQuery(),
+ GetEndTimeDCSQuery());
}
else if (type == kDP)
{
- result = client.GetDPValues(entries, GetCurrentStartTime(),
- GetCurrentEndTime());
+ //result = client.GetDPValues(entries, GetCurrentStartTime()-offset,
+ // GetCurrentEndTime()+offset);
+ result = client.GetDPValues(entries, GetStartTimeDCSQuery(),
+ GetEndTimeDCSQuery());
}
if (result == 0)
filePath.Data(), fileSize.Data(), fileChecksum.Data()));
// retrieved file is renamed to make it unique
- TString localFileName = Form("%s/%s_%d_process/%s_%s_%d_%s_%s.shuttle",
- GetShuttleTempDir(), detector, GetCurrentRun(),
+ Int_t dir_lev1 = GetCurrentRun()/10000;
+ TString localFileName = Form("%s/%d/%d/%s_process/%s_%s_%d_%s_%s.shuttle",
+ GetShuttleTempDir(), dir_lev1, GetCurrentRun(), detector,
GetSystemName(system), detector, GetCurrentRun(),
id, sourceName.Data());
+ Log("SHUTTLE",Form("file from FXS = %s",localFileName.Data()));
// file retrieval from FXS
return NULL;
}
- TString sourceName = 0;
+ TString sourceName = "";
if (system == kDAQ)
{
sourceName = "DAQsource";
return NULL;
}
- TString sourceName = 0;
+ TString sourceName = "";
if (system == kDAQ)
{
sourceName = "DAQsource";
//
// check connection: if already connected return
- if(fServer[system] && fServer[system]->IsConnected()) return kTRUE;
+
+ if(fServer[system] && fServer[system]->IsConnected()) {
+ // ping the server
+ if (fServer[system]->PingVerify()==kTRUE){ // connection is still alive
+ return kTRUE;
+ }
+ else{
+ AliWarning(Form("Connection got lost to FXS database for %s. Closing and reconnecting.",
+ AliShuttleInterface::GetSystemName(system)));
+ fServer[system]->Close();
+ delete fServer[system];
+ fServer[system] = 0x0;
+ }
+ }
TString dbHost, dbUser, dbPass, dbName;
return result;
}
+//_______________________________________________________________________________
+Bool_t AliShuttle::UpdateTableSkippedCase(const char* detector)
+{
+ //
+ // Update FXS table filling time_processed field in all rows corresponding to current run and detector
+ // if detector = "ALL" update all detectors
+ //
+
+ Bool_t result = kTRUE;
+
+ TString detName(detector);
+
+ for (UInt_t system=0; system<3; system++)
+ {
+
+ // check connection, in case connect
+ if (!Connect(system))
+ {
+ Log(fCurrentDetector, Form("UpdateTableSkippedCase - Couldn't connect to %s FXS database", GetSystemName(system)));
+ result = kFALSE;
+ continue;
+ }
+
+ TTimeStamp now; // now
+
+ // Loop on FXS list entries
+ TIter iter(&fFXSlist[system]);
+
+ TString whereClause;
+ if (detName == "ALL") whereClause = Form("where run=%d and time_processed IS NULL;",GetCurrentRun());
+ else whereClause = Form("where run=%d and detector=\"%s\" and time_processed IS NULL;",GetCurrentRun(), detector);
+
+ //Log("SHUTTLE",Form(" whereClause = %s ",whereClause.Data()));
+
+ TString sqlQuery = Form("update %s set time_processed=%d %s", fConfig->GetFXSdbTable(system),
+ now.GetSec(), whereClause.Data());
+
+ AliDebug(2, Form("SQL query: \n%s",sqlQuery.Data()));
+
+ // Query execution
+ TSQLResult* aResult;
+ aResult = dynamic_cast<TSQLResult*> (fServer[system]->Query(sqlQuery));
+ if (!aResult)
+ {
+ Log("SHUTTLE", Form("UpdateTableSkippedCase - %s db: can't execute SQL query <%s>",
+ GetSystemName(system), sqlQuery.Data()));
+ result = kFALSE;
+ continue;
+ }
+ delete aResult;
+
+ }
+
+ return result;
+}
//______________________________________________________________________________________________
Bool_t AliShuttle::UpdateTableFailCase()
{
return fLogbookEntry ? fLogbookEntry->GetEndTime() : 0;
}
-
//______________________________________________________________________________________________
UInt_t AliShuttle::GetCurrentYear() const
{
//
// Fill log string with a message
//
-
- TString logRunDir = GetShuttleLogDir();
- if (GetCurrentRun() >=0)
- logRunDir += Form("/%d", GetCurrentRun());
+ TString logRunDir = GetShuttleLogDir();
+ if (GetCurrentRun() >=0) {
+ Int_t logDir_lev1 = GetCurrentRun()/10000;
+ logRunDir += Form("/%d/%d", logDir_lev1, GetCurrentRun());
+ }
void* dir = gSystem->OpenDirectory(logRunDir.Data());
if (dir == NULL) {
if (gSystem->mkdir(logRunDir.Data(), kTRUE)) {
if (GetCurrentRun() >= 0)
{
- fileName.Form("%s/%d/%s_%d.log", GetShuttleLogDir(), GetCurrentRun(),
- detector, GetCurrentRun());
+ Int_t logDir_lev1 = GetCurrentRun()/10000;
+ fileName.Form("%s/%d/%d/%s.log", GetShuttleLogDir(), logDir_lev1, GetCurrentRun(),
+ detector);
} else {
fileName.Form("%s/%s.log", GetShuttleLogDir(), detector);
}
if (!fMonaLisa)
fMonaLisa = new TMonaLisaWriter(fConfig->GetMonitorHost(), fConfig->GetMonitorTable());
- SendAlive();
CountOpenRuns();
TString whereClause("where shuttle_done=0");
if (target == kDCSEMail || target == kFXSEMail) {
if (!fFirstProcessing)
- return kTRUE;
+ return kTRUE;
}
Int_t runMode = (Int_t)fConfig->GetRunMode();
body = Form("Dear %s FXS experts, \n\n",sys.Data());
body += Form("SHUTTLE couldn\'t retrieve data from the FXS for detector %s "
"in run %d!!\n\n", fCurrentDetector.Data(), GetCurrentRun());
+ body += Form("The contacted server was:\nDB: %s\nFXS:%s\n\n", fConfig->GetFXSdbHost(system), fConfig->GetFXSHost(system));
}
else {
subject = Form("%s %s Shuttle preprocessor FAILED in run %d (run type = %s)!",
body += Form("Find the %s log for the current run on \n\n"
- "\thttp://pcalishuttle01.cern.ch:8880/%s/%d/%s_%d.log \n\n",
- fCurrentDetector.Data(), logFolder.Data(), GetCurrentRun(),
- fCurrentDetector.Data(), GetCurrentRun());
- body += Form("The last 10 lines of %s log file are following:\n\n", fCurrentDetector.Data());
+ "\thttp://pcalishuttle02.cern.ch/%s/%d/%d/%s.log \n\n",
+ fCurrentDetector.Data(), logFolder.Data(), GetCurrentRun()/10000,
+ GetCurrentRun(), fCurrentDetector.Data());
+ body += Form("The last 15 lines of %s log file are following:\n\n", fCurrentDetector.Data());
AliDebug(2, Form("Body begin: %s", body.Data()));
mailBody.close();
mailBody.open(bodyFileName, ofstream::out | ofstream::app);
- TString logFileName = Form("%s/%d/%s_%d.log", GetShuttleLogDir(),
- GetCurrentRun(), fCurrentDetector.Data(), GetCurrentRun());
- TString tailCommand = Form("tail -n 10 %s >> %s", logFileName.Data(), bodyFileName.Data());
+ TString logFileName = Form("%s/%d/%d/%s.log", GetShuttleLogDir(),
+ GetCurrentRun()/10000, GetCurrentRun(), fCurrentDetector.Data());
+ TString tailCommand = Form("tail -n 15 %s >> %s", logFileName.Data(), bodyFileName.Data());
if (gSystem->Exec(tailCommand.Data()))
{
mailBody << Form("%s log file not found ...\n\n", fCurrentDetector.Data());
return result == 0;
}
-
//______________________________________________________________________________________________
const char* AliShuttle::GetRunType()
{
if (result->GetRowCount() == 0)
{
- Log("SHUTTLE", "ERROR: Trigger configuration not found in logbook_trigger_config");
+ Log("SHUTTLE", "WARNING: Trigger configuration not found in logbook_trigger_config");
delete result;
return 0;
}
return triggerConfig;
}
+//______________________________________________________________________________________________
+const char* AliShuttle::GetCTPTimeParams()
+{
+ // Receives the CTP time parameters from the DAQ logbook for the current run
+
+ // check connection, if needed reconnect
+ if (!Connect(3))
+ return 0;
+
+ TString sqlQuery;
+ sqlQuery.Form("SELECT alignmentFile 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", "WARNING: CTP time params 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 triggerTimeParams(row->GetField(0));
+
+ delete row;
+ row = 0;
+
+ delete result;
+ result = 0;
+
+ Log("SHUTTLE", Form("Found trigger time parameters: %s", triggerTimeParams.Data()));
+
+ return triggerTimeParams;
+}
+
+//______________________________________________________________________________________________
+const char* AliShuttle::GetTriggerDetectorMask()
+{
+ // Receives the trigger detector mask from DAQ logbook
+
+ // check connection, if needed reconnect
+ if (!Connect(3))
+ return 0;
+
+ TString sqlQuery;
+ sqlQuery.Form("SELECT BIN(BIT_OR(inputDetectorMask)) from logbook_trigger_clusters 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 Detector Mask not found in logbook_trigger_clusters");
+ delete result;
+ return 0;
+ }
+
+ TSQLRow* row = result->Next();
+ if (!row)
+ {
+ Log("SHUTTLE", "ERROR: Could not receive logbook_trigger_clusters data");
+ delete result;
+ return 0;
+ }
+
+ // static, so that pointer remains valid when it is returned to the calling class
+ static TString triggerDetectorMask(row->GetField(0));
+
+ delete row;
+ row = 0;
+
+ delete result;
+ result = 0;
+
+ Log("SHUTTLE", Form("Found Trigger Detector Mask: %s", triggerDetectorMask.Data()));
+
+ return triggerDetectorMask;
+}
+
//______________________________________________________________________________________________
void AliShuttle::SetShuttleTempDir(const char* tmpDir)
{
}
TString dir;
- dir.Form("%s%d/%s/SHUTTLE_DONE", fConfig->GetAlienPath(), GetCurrentYear(), GetLHCPeriod());
+ dir.Form("%s%d/SHUTTLE_DONE", fConfig->GetAlienPath(), GetCurrentYear());
// checking whether directory for touch command exists
TString commandLs;
commandLs.Form("ls %s",dir.Data());
return kFALSE;
}
TObjString *valueLsPath = dynamic_cast<TObjString*>(mapLs->GetValue("path"));
- if (!valueLsPath || (TString)(valueLsPath->GetString()).CompareTo(dir)!=1){
+ if (!valueLsPath || (valueLsPath->GetString()).CompareTo(dir)!=1){
Log("SHUTTLE",Form("No directory %s found, creating it",dir.Data()));
// creating the directory
Log("SHUTTLE", "Sucessfully touched the file");
return kTRUE;
}
+//______________________________________________________________________________________________
+UInt_t AliShuttle::GetStartTimeDCSQuery()
+{
+ // Return Start Time for the DCS query
+ //
+ // The call is delegated to AliShuttleInterface
+
+ return GetCurrentStartTime()-fConfig->GetDCSQueryOffset();
+}
+//______________________________________________________________________________________________
+UInt_t AliShuttle::GetEndTimeDCSQuery()
+{
+ // Return End Time for the DCS query
+ //
+ // The call is delegated to AliShuttleInterface
+ return GetCurrentEndTime()+fConfig->GetDCSQueryOffset();
+}