Search in sources :

Example 16 with CoordinatorEngine

use of org.apache.oozie.CoordinatorEngine in project oozie by apache.

the class TestWorkflowJobQueryExecutor method testGetList.

public void testGetList() throws Exception {
    // GET_WORKFLOWS_PARENT_COORD_RERUN
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, null, null, false, false, 1);
    WorkflowJobBean wfJob1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, coordJob.getId() + "@2");
    CoordinatorActionBean coordAction1 = addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob1.getId(), "SUCCEEDED", 0);
    // second wf after rerunning coord action, having same parent id
    WorkflowJobBean wfJob2 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, coordJob.getId() + "@2");
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    List<WorkflowJobBean> wfsForRerun = ce.getReruns(coordAction1.getId());
    assertEquals(2, wfsForRerun.size());
    assertEquals(wfJob1.getId(), wfsForRerun.get(0).getId());
    assertEquals(wfJob2.getId(), wfsForRerun.get(1).getId());
    // GET_COMPLETED_COORD_WORKFLOWS_OLDER_THAN
    coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, null, null, false, false, 1);
    wfJob1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, coordJob.getId() + "@1");
    wfJob1.setEndTime(DateUtils.parseDateOozieTZ("2009-12-18T03:00Z"));
    WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, wfJob1);
    wfJob2 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, coordJob.getId() + "@2");
    wfJob2.setEndTime(DateUtils.parseDateOozieTZ("2009-12-18T03:00Z"));
    WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, wfJob2);
    long olderthan = 30;
    List<WorkflowJobBean> jobBeans = WorkflowJobQueryExecutor.getInstance().getList(WorkflowJobQuery.GET_COMPLETED_COORD_WORKFLOWS_OLDER_THAN, olderthan, 0, 10);
    HashSet<String> jobIds = new HashSet<String>(Arrays.asList(wfJob1.getId(), wfJob2.getId()));
    assertEquals(2, jobBeans.size());
    assertTrue(jobIds.contains(jobBeans.get(0).getId()));
    assertTrue(jobIds.contains(jobBeans.get(1).getId()));
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorEngine(org.apache.oozie.CoordinatorEngine) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) HashSet(java.util.HashSet)

Example 17 with CoordinatorEngine

use of org.apache.oozie.CoordinatorEngine in project oozie by apache.

the class TestActionCheckerService method testActionCheckerServiceCoord.

/**
 * Tests functionality of the Action Checker Service Runnable for
 * coordinator actions. </p> Inserts Coord Job, Coord Action, and Workflow
 * Job, and verifies the action status updated to SUCCEEDED. </p> Runs the
 * ActionCheck runnable, and checks for the action job.
 *
 * @throws Exception
 */
public void testActionCheckerServiceCoord() throws Exception {
    final int actionNum = 1;
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    final CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 0);
    final WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    final CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), actionNum, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob.getId(), "RUNNING", 0);
    sleep(3000);
    Runnable actionCheckRunnable = new ActionCheckRunnable(1);
    actionCheckRunnable.run();
    sleep(3000);
    waitFor(200000, new Predicate() {

        public boolean evaluate() throws Exception {
            return (ce.getCoordAction(action.getId()).getStatus() == CoordinatorAction.Status.SUCCEEDED);
        }
    });
    JPAService jpaService = Services.get().get(JPAService.class);
    CoordinatorActionBean recoveredAction = jpaService.execute(new CoordActionGetJPAExecutor(action.getId()));
    assertEquals(CoordinatorAction.Status.SUCCEEDED, recoveredAction.getStatus());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) ActionCheckRunnable(org.apache.oozie.service.ActionCheckerService.ActionCheckRunnable) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) CoordinatorEngine(org.apache.oozie.CoordinatorEngine) ActionCheckRunnable(org.apache.oozie.service.ActionCheckerService.ActionCheckRunnable)

Aggregations

CoordinatorEngine (org.apache.oozie.CoordinatorEngine)17 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)7 CoordinatorEngineException (org.apache.oozie.CoordinatorEngineException)6 CoordinatorEngineService (org.apache.oozie.service.CoordinatorEngineService)6 JSONObject (org.json.simple.JSONObject)6 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)4 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)4 IOException (java.io.IOException)3 Date (java.util.Date)3 XConfiguration (org.apache.oozie.util.XConfiguration)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Configuration (org.apache.hadoop.conf.Configuration)2 CoordinatorJobInfo (org.apache.oozie.CoordinatorJobInfo)2 DagEngineException (org.apache.oozie.DagEngineException)2 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)2 CoordinatorAction (org.apache.oozie.client.CoordinatorAction)2 CoordinatorJob (org.apache.oozie.client.CoordinatorJob)2 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)2 StoreException (org.apache.oozie.store.StoreException)2