use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class TestSLASummaryQueryExecutor method testGet.
public void testGet() throws Exception {
SLASummaryBean bean = addRecordToSLASummaryTable("test-sla-summary", SLAStatus.IN_PROCESS);
// GET_SLA_REG_ON_RESTART
SLASummaryBean sBean = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY_EVENTPROCESSED, bean.getId());
assertEquals(bean.getEventProcessed(), sBean.getEventProcessed());
}
use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class TestSLASummaryQueryExecutor method testExecuteUpdate.
public void testExecuteUpdate() throws Exception {
SLASummaryBean bean = addRecordToSLASummaryTable("test-sla-summary", SLAStatus.IN_PROCESS);
SLASummaryBean retBean = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY, bean.getId());
Date createdTime = retBean.getCreatedTime();
assertNotNull(createdTime);
Date startTime = new Date(System.currentTimeMillis() - 1000 * 3600 * 2);
Date endTime = new Date(System.currentTimeMillis() - 1000 * 3600 * 1);
bean.setActualStart(startTime);
bean.setActualEnd(endTime);
bean.setSLAStatus(SLAStatus.MET);
// Should not be updated
bean.setCreatedTime(startTime);
SLASummaryQueryExecutor.getInstance().executeUpdate(SLASummaryQuery.UPDATE_SLA_SUMMARY_ALL, bean);
retBean = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY, bean.getId());
assertEquals(bean.getActualStartTimestamp(), retBean.getActualStartTimestamp());
assertEquals(bean.getActualEndTimestamp(), retBean.getActualEndTimestamp());
assertEquals(SLAStatus.MET, retBean.getSLAStatus());
// Created time should not be updated
assertEquals(createdTime, retBean.getCreatedTime());
// test UPDATE_SLA_SUMMARY_FOR_ACTUAL_TIMES
bean = addRecordToSLASummaryTable("test-sla-summary", SLAStatus.IN_PROCESS);
bean.setActualStart(startTime);
bean.setActualStart(endTime);
bean.setActualDuration(endTime.getTime() - startTime.getTime());
bean.setLastModifiedTime(new Date());
bean.setEventProcessed(8);
SLASummaryQueryExecutor.getInstance().executeUpdate(SLASummaryQuery.UPDATE_SLA_SUMMARY_FOR_STATUS_ACTUAL_TIMES, bean);
retBean = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY, bean.getId());
assertEquals(bean.getActualStartTimestamp(), retBean.getActualStartTimestamp());
assertEquals(bean.getActualEndTimestamp(), retBean.getActualEndTimestamp());
assertEquals(bean.getActualDuration(), retBean.getActualDuration());
assertEquals(bean.getLastModifiedTimestamp(), retBean.getLastModifiedTimestamp());
assertEquals(bean.getEventProcessed(), retBean.getEventProcessed());
}
use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class TestSLASummaryQueryExecutor method testUpdateQuery.
public void testUpdateQuery() throws Exception {
EntityManager em = jpaService.getEntityManager();
SLASummaryBean bean = addRecordToSLASummaryTable("test-sla-summary", SLAStatus.IN_PROCESS);
// UPDATE_SLA_SUMMARY_FOR_STATUS_ACTUAL_TIMES
Query query = SLASummaryQueryExecutor.getInstance().getUpdateQuery(SLASummaryQuery.UPDATE_SLA_SUMMARY_FOR_STATUS_ACTUAL_TIMES, bean, em);
assertEquals(query.getParameterValue("jobId"), bean.getId());
assertEquals(query.getParameterValue("slaStatus"), bean.getSLAStatus().toString());
assertEquals(query.getParameterValue("lastModifiedTS"), bean.getLastModifiedTimestamp());
assertEquals(query.getParameterValue("eventStatus"), bean.getEventStatus().toString());
assertEquals(query.getParameterValue("jobStatus"), bean.getJobStatus());
assertEquals(query.getParameterValue("eventProcessed"), bean.getEventProcessed());
assertEquals(query.getParameterValue("actualStartTS"), bean.getActualStartTimestamp());
assertEquals(query.getParameterValue("actualEndTS"), bean.getActualEndTimestamp());
assertEquals(query.getParameterValue("actualDuration"), bean.getActualDuration());
// UPDATE_SLA_SUMMARY_REGISTRATION
query = SLASummaryQueryExecutor.getInstance().getUpdateQuery(SLASummaryQuery.UPDATE_SLA_SUMMARY_ALL, bean, em);
assertEquals(query.getParameterValue("appName"), bean.getAppName());
assertEquals(query.getParameterValue("appType"), bean.getAppType().toString());
assertEquals(query.getParameterValue("nominalTime"), bean.getNominalTimestamp());
assertEquals(query.getParameterValue("expectedStartTime"), bean.getExpectedStartTimestamp());
assertEquals(query.getParameterValue("expectedEndTime"), bean.getExpectedEndTimestamp());
assertEquals(query.getParameterValue("expectedDuration"), bean.getExpectedDuration());
assertEquals(query.getParameterValue("jobStatus"), bean.getJobStatus());
assertEquals(query.getParameterValue("slaStatus"), bean.getSLAStatus().toString());
assertEquals(query.getParameterValue("eventStatus"), bean.getEventStatus().toString());
assertEquals(query.getParameterValue("lastModTime"), bean.getLastModifiedTimestamp());
assertEquals(query.getParameterValue("user"), bean.getUser());
assertEquals(query.getParameterValue("parentId"), bean.getParentId());
assertEquals(query.getParameterValue("eventProcessed"), bean.getEventProcessed());
assertEquals(query.getParameterValue("actualDuration"), bean.getActualDuration());
assertEquals(query.getParameterValue("actualEndTS"), bean.getActualEndTimestamp());
assertEquals(query.getParameterValue("actualStartTS"), bean.getActualStartTimestamp());
assertEquals(query.getParameterValue("jobId"), bean.getId());
em.close();
}
use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class DummySLACalculatorMemory method createDBEntryForStarted.
private SLASummaryBean createDBEntryForStarted(String actionId, Date expectedStartTS, Date expectedEndTS, int eventProcessed) throws Exception {
ArrayList<JsonBean> insertList = new ArrayList<JsonBean>();
Date modTime = new Date();
WorkflowJobBean wf = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING, actionId);
wf.setStatus(wf.getStatus());
wf.setStartTime(expectedStartTS);
wf.setLastModifiedTime(modTime);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_STATUS_INSTANCE_MOD_START_END, wf);
CoordinatorActionBean coordAction = new CoordinatorActionBean();
coordAction.setId(actionId);
coordAction.setJobId(actionId.split("@", -1)[0]);
coordAction.setStatusStr("RUNNING");
coordAction.setLastModifiedTime(modTime);
coordAction.setExternalId(wf.getId());
CoordinatorJobBean coordJob = new CoordinatorJobBean();
coordJob.setId(actionId.split("@", -1)[0]);
coordJob.setUser("dummy");
coordJob.setAppName("dummy");
coordJob.setStatusStr("RUNNING");
coordJob.setAppNamespace("dummy");
SLASummaryBean sla = new SLASummaryBean();
sla.setId(actionId);
sla.setAppType(AppType.COORDINATOR_ACTION);
sla.setJobStatus("RUNNING");
sla.setSLAStatus(SLAStatus.IN_PROCESS);
sla.setEventProcessed(eventProcessed);
sla.setLastModifiedTime(modTime);
sla.setExpectedStart(expectedStartTS);
sla.setActualStart(expectedStartTS);
sla.setExpectedEnd(expectedEndTS);
sla.setExpectedDuration(10 * 60 * 1000);
SLARegistrationBean reg = new SLARegistrationBean();
reg.setId(actionId);
insertList.add(coordAction);
insertList.add(coordJob);
insertList.add(sla);
insertList.add(reg);
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
return sla;
}
use of org.apache.oozie.sla.SLASummaryBean in project oozie by apache.
the class DummySLACalculatorMemory method createDBEntry.
private void createDBEntry(String actionId, Date expectedStartTS, Date expectedEndTS) throws Exception {
ArrayList<JsonBean> insertList = new ArrayList<JsonBean>();
CoordinatorActionBean coordAction = new CoordinatorActionBean();
Date modTime = new Date(System.currentTimeMillis() - 1000 * 3600 * 2);
coordAction.setId(actionId);
coordAction.setJobId(actionId.split("@", -1)[0]);
coordAction.setStatusStr("WAITING");
coordAction.setLastModifiedTime(modTime);
CoordinatorJobBean coordJob = new CoordinatorJobBean();
coordJob.setId(actionId.split("@", -1)[0]);
coordJob.setUser("dummy");
coordJob.setAppName("dummy");
coordJob.setStatusStr("RUNNING");
coordJob.setAppNamespace("dummy");
SLASummaryBean sla = new SLASummaryBean();
sla.setId(actionId);
sla.setAppType(AppType.COORDINATOR_ACTION);
sla.setJobStatus("WAITING");
sla.setSLAStatus(SLAStatus.NOT_STARTED);
sla.setEventProcessed(0);
sla.setLastModifiedTime(modTime);
sla.setExpectedStart(expectedStartTS);
sla.setExpectedEnd(expectedEndTS);
sla.setExpectedDuration(10 * 60 * 1000);
SLARegistrationBean reg = new SLARegistrationBean();
reg.setId(actionId);
insertList.add(coordAction);
insertList.add(coordJob);
insertList.add(sla);
insertList.add(reg);
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
}
Aggregations