Search in sources :

Example 6 with JsonBean

use of org.apache.oozie.client.rest.JsonBean in project oozie by apache.

the class TestSLACalculationJPAExecutor method testInsert.

/**
 * Test simple insert
 *
 * @throws Exception
 */
@Test
public void testInsert() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    String wfId = "workflow-1";
    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();
    cal.add(Calendar.DAY_OF_MONTH, 2);
    Date actEnd = cal.getTime();
    SLASummaryBean bean2 = _createSLASummaryBean(wfId, "RUNNING", EventStatus.START_MISS, expStart, expEnd, 1000, actStart, actEnd, 2000, (byte) 1, actEnd);
    List<JsonBean> insertList = new ArrayList<JsonBean>();
    insertList.add(bean2);
    BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
    SLASummaryBean sBean = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY, wfId);
    assertEquals(wfId, sBean.getId());
    assertEquals("RUNNING", sBean.getJobStatus());
    assertEquals(EventStatus.START_MISS, sBean.getEventStatus());
    assertEquals(expStart, sBean.getExpectedStart());
    assertEquals(expEnd, sBean.getExpectedEnd());
    assertEquals(1000, sBean.getExpectedDuration());
    assertEquals(actStart, sBean.getActualStart());
    assertEquals(actEnd, sBean.getActualEnd());
    assertEquals(2000, sBean.getActualDuration());
    assertEquals(actEnd, sBean.getLastModifiedTime());
}
Also used : JsonBean(org.apache.oozie.client.rest.JsonBean) ArrayList(java.util.ArrayList) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date) Test(org.junit.Test)

Example 7 with JsonBean

use of org.apache.oozie.client.rest.JsonBean in project oozie by apache.

the class TestSLACalculatorMemory method createWorkflow.

private void createWorkflow(List<String> idList) throws Exception {
    List<JsonBean> insertList = new ArrayList<JsonBean>();
    for (String id : idList) {
        WorkflowJobBean workflow = new WorkflowJobBean();
        workflow.setId(id);
        workflow.setStatusStr("PREP");
        workflow.setStartTime(new Date());
        insertList.add(workflow);
    }
    BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
}
Also used : JsonBean(org.apache.oozie.client.rest.JsonBean) ArrayList(java.util.ArrayList) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date)

Example 8 with JsonBean

use of org.apache.oozie.client.rest.JsonBean in project oozie by apache.

the class TestSLAJobEventListener method createWorkflowAction.

private WorkflowActionBean createWorkflowAction(String id, String parentId) throws Exception {
    List<JsonBean> insertList = new ArrayList<JsonBean>();
    WorkflowActionBean action = new WorkflowActionBean();
    action.setId(id);
    action.setJobId(parentId);
    insertList.add(action);
    BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
    return action;
}
Also used : JsonBean(org.apache.oozie.client.rest.JsonBean) ArrayList(java.util.ArrayList) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 9 with JsonBean

use of org.apache.oozie.client.rest.JsonBean in project oozie by apache.

the class TestSLAJobEventListener method createWorkflow.

private WorkflowJobBean createWorkflow(String id, Date actualStart) throws Exception {
    List<JsonBean> insertList = new ArrayList<JsonBean>();
    WorkflowJobBean workflow = new WorkflowJobBean();
    workflow.setId(id);
    workflow.setStatusStr("PREP");
    workflow.setStartTime(actualStart);
    workflow.setSlaXml("<sla></sla>");
    insertList.add(workflow);
    BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
    return workflow;
}
Also used : JsonBean(org.apache.oozie.client.rest.JsonBean) ArrayList(java.util.ArrayList) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Example 10 with JsonBean

use of org.apache.oozie.client.rest.JsonBean in project oozie by apache.

the class TestSLAJobEventListener method createCoordAction.

private CoordinatorActionBean createCoordAction(String id, String parentId) throws Exception {
    List<JsonBean> insertList = new ArrayList<JsonBean>();
    CoordinatorActionBean action = new CoordinatorActionBean();
    action.setId(id);
    action.setJobId(parentId);
    insertList.add(action);
    BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
    return action;
}
Also used : JsonBean(org.apache.oozie.client.rest.JsonBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) 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