use of org.apache.oozie.executor.jpa.SLASummaryQueryExecutor in project oozie by apache.
the class SLACalculatorMemory method addJobStatus.
/**
* Triggered after receiving Job status change event, update SLA status
* accordingly
*/
@Override
public boolean addJobStatus(String jobId, String jobStatus, JobEvent.EventStatus jobEventStatus, Date startTime, Date endTime) throws JPAExecutorException, ServiceException {
LOG.debug("Received addJobStatus request for job [{0}] jobStatus = [{1}], jobEventStatus = [{2}], startTime = [{3}], " + "endTime = [{4}] ", jobId, jobStatus, jobEventStatus, startTime, endTime);
SLACalcStatus slaCalc = slaMap.get(jobId);
boolean firstCheckAfterRetstart = checkAndUpdateSLACalcAfterRestart(slaCalc);
if (slaCalc == null) {
SLARegistrationBean slaRegBean = SLARegistrationQueryExecutor.getInstance().get(SLARegQuery.GET_SLA_REG_ALL, jobId);
if (slaRegBean != null) {
// filter out jobs picked by SLA job event listener
// but not actually configured for SLA
SLASummaryBean slaSummaryBean = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY, jobId);
slaCalc = new SLACalcStatus(slaSummaryBean, slaRegBean);
putAndIncrement(jobId, slaCalc);
}
} else {
SLASummaryBean summaryBean = ((SLASummaryQueryExecutor) SLASummaryQueryExecutor.getInstance()).get(SLASummaryQuery.GET_SLA_SUMMARY_EVENTPROCESSED_LAST_MODIFIED, jobId);
byte eventProc = summaryBean.getEventProcessed();
if (!slaCalc.getLastModifiedTime().equals(summaryBean.getLastModifiedTime())) {
// Update last modified time.
slaCalc.setLastModifiedTime(summaryBean.getLastModifiedTime());
reloadExpectedTimeAndConfig(slaCalc);
LOG.debug("Last modified time has changed for job " + jobId + " reloading config from DB");
}
slaCalc.setEventProcessed(eventProc);
}
if (slaCalc != null) {
try {
SLAXCommandFactory.getSLAEventXCommand(slaCalc, ConfigurationService.getLong(SLAService.CONF_SLA_CALC_LOCK_TIMEOUT, 20 * 1000)).call();
checkEventProc(slaCalc);
} catch (XException e) {
if (firstCheckAfterRetstart) {
slaCalc.setSLARegistrationBean(null);
}
LOG.error(e);
throw new ServiceException(e);
}
return true;
} else {
return false;
}
}
Aggregations