Search in sources :

Example 1 with SLASummaryGetRecordsOnRestartJPAExecutor

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);
    }
}
Also used : SLASummaryGetRecordsOnRestartJPAExecutor(org.apache.oozie.executor.jpa.sla.SLASummaryGetRecordsOnRestartJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) ServiceException(org.apache.oozie.service.ServiceException) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException)

Example 2 with SLASummaryGetRecordsOnRestartJPAExecutor

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());
}
Also used : JsonBean(org.apache.oozie.client.rest.JsonBean) SLASummaryGetRecordsOnRestartJPAExecutor(org.apache.oozie.executor.jpa.sla.SLASummaryGetRecordsOnRestartJPAExecutor) ArrayList(java.util.ArrayList) JPAService(org.apache.oozie.service.JPAService) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

SLASummaryGetRecordsOnRestartJPAExecutor (org.apache.oozie.executor.jpa.sla.SLASummaryGetRecordsOnRestartJPAExecutor)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 XException (org.apache.oozie.XException)1 JsonBean (org.apache.oozie.client.rest.JsonBean)1 CommandException (org.apache.oozie.command.CommandException)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1 JPAService (org.apache.oozie.service.JPAService)1 ServiceException (org.apache.oozie.service.ServiceException)1