Search in sources :

Example 26 with JsonBean

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);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) SLARegistrationBean(org.apache.oozie.sla.SLARegistrationBean) JsonBean(org.apache.oozie.client.rest.JsonBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) ArrayList(java.util.ArrayList) Date(java.util.Date) SLASummaryBean(org.apache.oozie.sla.SLASummaryBean)

Example 27 with JsonBean

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());
}
Also used : JsonBean(org.apache.oozie.client.rest.JsonBean) UpdateEntry(org.apache.oozie.executor.jpa.BatchQueryExecutor.UpdateEntry) ArrayList(java.util.ArrayList) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date) Test(org.junit.Test)

Example 28 with JsonBean

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;
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JsonBean(org.apache.oozie.client.rest.JsonBean) ArrayList(java.util.ArrayList)

Aggregations

JsonBean (org.apache.oozie.client.rest.JsonBean)28 ArrayList (java.util.ArrayList)20 Date (java.util.Date)15 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)10 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)9 JPAService (org.apache.oozie.service.JPAService)9 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)7 UpdateEntry (org.apache.oozie.executor.jpa.BatchQueryExecutor.UpdateEntry)7 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)6 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)6 SLARegistrationBean (org.apache.oozie.sla.SLARegistrationBean)6 WorkflowJobQuery (org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor.WorkflowJobQuery)5 SLASummaryBean (org.apache.oozie.sla.SLASummaryBean)5 BundleActionBean (org.apache.oozie.BundleActionBean)3 CommandException (org.apache.oozie.command.CommandException)3 IOException (java.io.IOException)2 BundleJobBean (org.apache.oozie.BundleJobBean)2 DagEngine (org.apache.oozie.DagEngine)2 DagEngineException (org.apache.oozie.DagEngineException)2 PreconditionException (org.apache.oozie.command.PreconditionException)2