use of org.apache.oozie.executor.jpa.sla.SLASummaryGetRecordsOnRestartJPAExecutor in project oozie by apache.
the class SLACalculatorMemory method loadOnRestart.
private void loadOnRestart() {
try {
List<SLASummaryBean> summaryBeans = jpaService.execute(new SLASummaryGetRecordsOnRestartJPAExecutor(modifiedAfter));
for (SLASummaryBean summaryBean : summaryBeans) {
String jobId = summaryBean.getId();
putAndIncrement(jobId, new SLACalcStatus(summaryBean));
}
LOG.info("Loaded {0} SLASummary object after restart", slaMap.size());
} catch (Exception e) {
LOG.warn("Failed to retrieve SLASummary records on restart", e);
}
}
use of org.apache.oozie.executor.jpa.sla.SLASummaryGetRecordsOnRestartJPAExecutor in project oozie by apache.
the class TestSLASummaryGetOnRestartJPAExecutor method testSLARegistrationGet.
public void testSLARegistrationGet() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SLASummaryBean sla1 = new SLASummaryBean();
sla1.setId("jobId");
sla1.setAppName("appName");
sla1.setUser("user");
sla1.setParentId("parent");
sla1.setEventProcessed(7);
// set to 5 days back from now
sla1.setLastModifiedTime(new Date(System.currentTimeMillis() - 5 * 24 * 60 * 60 * 1000));
SLASummaryBean sla2 = new SLASummaryBean();
sla2.setId("jobId2");
sla2.setEventProcessed(6);
// set to long time back
sla2.setLastModifiedTime(sdf.parse("2009-06-03"));
List<JsonBean> insert = new ArrayList<JsonBean>();
insert.add(sla1);
insert.add(sla2);
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insert, null, null);
// get all records modified in last 7 days
SLASummaryGetRecordsOnRestartJPAExecutor slaGetOnRestart = new SLASummaryGetRecordsOnRestartJPAExecutor(7);
List<SLASummaryBean> beans = jpaService.execute(slaGetOnRestart);
assertEquals(1, beans.size());
assertEquals("jobId", beans.get(0).getId());
assertEquals("appName", beans.get(0).getAppName());
assertEquals("user", beans.get(0).getUser());
assertEquals("parent", beans.get(0).getParentId());
assertEquals(7, beans.get(0).getEventProcessed());
}
Aggregations