Search in sources :

Example 56 with CoordActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor 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)

Example 57 with CoordActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.

the class XDataTestCase method setMissingDependencies.

protected void setMissingDependencies(String actionId, String missingDependencies) throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
    action.setMissingDependencies(missingDependencies);
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action);
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 58 with CoordActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.

the class XDataTestCase method checkCoordActionStatus.

protected CoordinatorActionBean checkCoordActionStatus(final String actionId, final CoordinatorAction.Status stat) throws Exception {
    final JPAService jpaService = Services.get().get(JPAService.class);
    waitFor(5 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            try {
                CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
                return stat.equals(action.getStatus());
            } catch (JPAExecutorException se) {
                throw new Exception("Action ID " + actionId + " was not stored properly in db");
            }
        }
    });
    CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
    assertEquals(stat, action.getStatus());
    return action;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException)

Example 59 with CoordActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.

the class XDataTestCase method setCoordActionCreationTime.

protected void setCoordActionCreationTime(String actionId, long actionCreationTime) throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
    action.setCreatedTime(new Date(actionCreationTime));
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action);
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Example 60 with CoordActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.

the class XDataTestCase method setCoordActionNominalTime.

protected void setCoordActionNominalTime(String actionId, long actionNominalTime) throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
    action.setNominalTime(new Date(actionNominalTime));
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action);
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Aggregations

CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)60 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)60 JPAService (org.apache.oozie.service.JPAService)54 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)43 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)41 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)32 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)25 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)23 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)21 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)21 Date (java.util.Date)19 BundleActionBean (org.apache.oozie.BundleActionBean)9 BundleJobBean (org.apache.oozie.BundleJobBean)9 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)9 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)9 IOException (java.io.IOException)8 CommandException (org.apache.oozie.command.CommandException)7 CoordActionStartXCommand (org.apache.oozie.command.coord.CoordActionStartXCommand)3 Properties (java.util.Properties)2 CoordinatorEngine (org.apache.oozie.CoordinatorEngine)2