use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class TestV2SLAServlet method insertEntriesIntoSLASummaryTable.
private void insertEntriesIntoSLASummaryTable(String jobID, String parentId, String appName, AppType appType, EventStatus eventStatus, SLAStatus slaStatus, Date expectedStartTime, Date actualStartTime, long expectedDuration, long actualDuration, Date expectedEndTime, Date actualEndTime, Date nominalTime) throws JPAExecutorException {
SLASummaryBean bean = new SLASummaryBean();
bean.setId(jobID);
bean.setParentId(parentId);
bean.setAppName(appName);
bean.setAppType(appType);
bean.setJobStatus("RUNNING");
bean.setEventStatus(eventStatus);
bean.setSLAStatus(slaStatus);
bean.setNominalTime(nominalTime);
bean.setExpectedStart(expectedStartTime);
bean.setActualStart(actualStartTime);
bean.setExpectedDuration(expectedDuration);
bean.setActualDuration(actualDuration);
bean.setExpectedEnd(expectedEndTime);
bean.setActualEnd(actualEndTime);
bean.setUser("testuser");
bean.setLastModifiedTime(Calendar.getInstance().getTime());
SLASummaryQueryExecutor.getInstance().insert(bean);
}
use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class SLAJobHistoryXCommand method updateSLASummary.
/**
* Update sla summary.
*
* @param id the id
* @param startTime the start time
* @param endTime the end time
* @param status the status
* @throws JPAExecutorException the JPA executor exception
*/
protected void updateSLASummary(String id, Date startTime, Date endTime, String status) throws JPAExecutorException {
SLASummaryBean sla = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY, id);
if (sla.getJobStatus().equals(status) && sla.getEventProcessed() == 8) {
LOG.debug("SLA job is already updated", sla.getId(), sla.getEventProcessed(), sla.getJobStatus());
return;
}
if (sla != null) {
sla.setActualStart(startTime);
sla.setActualEnd(endTime);
if (startTime != null && endTime != null) {
sla.setActualDuration(endTime.getTime() - startTime.getTime());
}
sla.setLastModifiedTime(new Date());
sla.setEventProcessed(8);
sla.setJobStatus(status);
SLASummaryQueryExecutor.getInstance().executeUpdate(SLASummaryQuery.UPDATE_SLA_SUMMARY_FOR_STATUS_ACTUAL_TIMES, sla);
LOG.debug(" Stored SLA SummaryBean Job [{0}] eventProc = [{1}], status = [{2}]", sla.getId(), sla.getEventProcessed(), sla.getJobStatus());
}
}
use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class TestSLASummaryQueryExecutor method testGetQuery.
public void testGetQuery() throws Exception {
EntityManager em = jpaService.getEntityManager();
SLASummaryBean bean = addRecordToSLASummaryTable("test-sla-summary", SLAStatus.IN_PROCESS);
// GET_SLA_SUMMARY
Query query = SLASummaryQueryExecutor.getInstance().getSelectQuery(SLASummaryQuery.GET_SLA_SUMMARY, em, bean.getId());
assertEquals(query.getParameterValue("id"), bean.getId());
// GET_SLA_SUMMARY_EVENTPROCESSED
query = SLASummaryQueryExecutor.getInstance().getSelectQuery(SLASummaryQuery.GET_SLA_SUMMARY_EVENTPROCESSED, em, bean.getId());
assertEquals(query.getParameterValue("id"), bean.getId());
}
use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class TestSLASummaryQueryExecutor method testGetValue.
public void testGetValue() throws Exception {
SLASummaryBean bean = addRecordToSLASummaryTable("test-sla-summary", SLAStatus.IN_PROCESS);
// GET_SLA_REG_ON_RESTART
Object ret = ((SLASummaryQueryExecutor) SLASummaryQueryExecutor.getInstance()).getSingleValue(SLASummaryQuery.GET_SLA_SUMMARY_EVENTPROCESSED, bean.getId());
assertEquals(bean.getEventProcessed(), ((Byte) ret).byteValue());
}
use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class CoordChangeXCommand method deleteAction.
/**
* Delete coordinator action
*
* @param actionNum coordinator action number
*/
private Date deleteAction(int actionNum, Date afterDate) throws CommandException {
try {
if (actionNum <= 0) {
return null;
}
String actionId = jobId + "@" + actionNum;
CoordinatorActionBean bean = CoordActionQueryExecutor.getInstance().getIfExist(CoordActionQueryExecutor.CoordActionQuery.GET_COORD_ACTION, actionId);
if (bean == null) {
return null;
}
if (afterDate.compareTo(bean.getNominalTime()) <= 0) {
if (bean.getStatus() == CoordinatorAction.Status.WAITING || bean.getStatus() == CoordinatorAction.Status.READY) {
// delete SLA registration entry (if any) for action
if (SLAService.isEnabled()) {
Services.get().get(SLAService.class).removeRegistration(actionId);
}
SLARegistrationBean slaReg = SLARegistrationQueryExecutor.getInstance().get(SLARegQuery.GET_SLA_REG_ALL, actionId);
if (slaReg != null) {
LOG.debug("Deleting registration bean corresponding to action " + slaReg.getId());
deleteList.add(slaReg);
}
SLASummaryBean slaSummaryBean = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY, actionId);
if (slaSummaryBean != null) {
LOG.debug("Deleting summary bean corresponding to action " + slaSummaryBean.getId());
deleteList.add(slaSummaryBean);
}
deleteList.add(bean);
} else {
throw new CommandException(ErrorCode.E1022, bean.getId());
}
return bean.getNominalTime();
} else {
return null;
}
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
}
Aggregations