use of org.apache.oozie.client.rest.JsonBean 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);
}
use of org.apache.oozie.client.rest.JsonBean in project oozie by apache.
the class TestSLACalculationJPAExecutor method testInsertUpdate.
/**
* Test insert + update
*
* @throws Exception
*/
@Test
public void testInsertUpdate() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
String wfId = "workflow-1";
// initial insert
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_MONTH, -2);
Date expStart = cal.getTime();
cal.add(Calendar.DAY_OF_MONTH, -1);
Date expEnd = cal.getTime();
Date actStart = new Date();
SLASummaryBean bean2 = _createSLASummaryBean(wfId, "RUNNING", EventStatus.START_MISS, expStart, expEnd, 1000, actStart, null, 2000, (byte) 0, actStart);
List<JsonBean> insertList = new ArrayList<JsonBean>();
insertList.add(bean2);
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
// update existing record
Date newDate = new Date();
bean2 = _createSLASummaryBean(wfId, "RUNNING", EventStatus.DURATION_MISS, expStart, expEnd, 1000, actStart, newDate, 2000, (byte) 1, newDate);
bean2.setAppType(AppType.WORKFLOW_ACTION);
List<UpdateEntry> updateList = new ArrayList<UpdateEntry>();
SLASummaryQueryExecutor.getInstance().executeUpdate(SLASummaryQuery.UPDATE_SLA_SUMMARY_ALL, bean2);
SLASummaryBean sBean = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY, wfId);
// check updated + original fields
assertEquals(wfId, sBean.getId());
assertEquals(EventStatus.DURATION_MISS, sBean.getEventStatus());
assertEquals(expStart, sBean.getExpectedStart());
assertEquals(expEnd, sBean.getExpectedEnd());
assertEquals(1000, sBean.getExpectedDuration());
assertEquals(actStart, sBean.getActualStart());
assertEquals(newDate, sBean.getActualEnd());
assertEquals(2000, sBean.getActualDuration());
assertEquals(newDate, sBean.getLastModifiedTime());
}
use of org.apache.oozie.client.rest.JsonBean in project oozie by apache.
the class TestSLAJobEventListener method createCoord.
private CoordinatorJobBean createCoord(String id) throws Exception {
List<JsonBean> insertList = new ArrayList<JsonBean>();
CoordinatorJobBean job = new CoordinatorJobBean();
job.setId(id);
insertList.add(job);
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
return job;
}
Aggregations