Search in sources :

Example 1 with CoordJobGetActionsSubsetJPAExecutor

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

the class CoordJobXCommand method execute.

/* (non-Javadoc)
     * @see org.apache.oozie.command.XCommand#execute()
     */
@Override
protected CoordinatorJobBean execute() throws CommandException {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        CoordinatorJobBean coordJob = null;
        if (jpaService != null) {
            coordJob = jpaService.execute(new CoordJobGetJPAExecutor(id));
            if (getActionInfo) {
                int numAction = jpaService.execute(new CoordActionsCountForJobIdJPAExecutor(id, filterMap));
                List<CoordinatorActionBean> coordActions = null;
                if (len == 0) {
                    coordActions = new ArrayList<CoordinatorActionBean>();
                } else {
                    coordActions = jpaService.execute(new CoordJobGetActionsSubsetJPAExecutor(id, filterMap, offset, len, desc));
                }
                coordJob.setActions(coordActions);
                coordJob.setNumActions(numAction);
            }
        } else {
            LOG.error(ErrorCode.E0610);
        }
        return coordJob;
    } catch (XException ex) {
        throw new CommandException(ex);
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordActionsCountForJobIdJPAExecutor(org.apache.oozie.executor.jpa.CoordActionsCountForJobIdJPAExecutor) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) XException(org.apache.oozie.XException) CoordJobGetActionsSubsetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetActionsSubsetJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService)

Example 2 with CoordJobGetActionsSubsetJPAExecutor

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

the class TestCoordMaterializeTransitionXCommand method checkCoordActionsNominalTime.

private void checkCoordActionsNominalTime(String jobId, int number, Date[] nominalTimes) {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        List<CoordinatorActionBean> actions = jpaService.execute(new CoordJobGetActionsSubsetJPAExecutor(jobId, null, 1, 1000, false));
        if (actions.size() != number) {
            fail("Should have " + number + " actions created for job " + jobId + ", but has " + actions.size() + " actions.");
        }
        for (int i = 0; i < nominalTimes.length; i++) {
            assertEquals(nominalTimes[i], actions.get(i).getNominalTime());
        }
    } catch (JPAExecutorException se) {
        se.printStackTrace();
        fail("Job ID " + jobId + " was not stored properly in db");
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetActionsSubsetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetActionsSubsetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 3 with CoordJobGetActionsSubsetJPAExecutor

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

the class TestCoordMaterializeTransitionXCommand method checkCoordActionsStatus.

private void checkCoordActionsStatus(String jobId, CoordinatorActionBean.Status[] statuses) {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        List<CoordinatorActionBean> actions = jpaService.execute(new CoordJobGetActionsSubsetJPAExecutor(jobId, null, 1, 1000, false));
        if (actions.size() != statuses.length) {
            fail("Should have " + statuses.length + " actions created for job " + jobId + ", but has " + actions.size() + " actions.");
        }
        for (int i = 0; i < statuses.length; i++) {
            assertEquals(statuses[i], actions.get(i).getStatus());
        }
    } catch (JPAExecutorException se) {
        se.printStackTrace();
        fail("Job ID " + jobId + " was not stored properly in db");
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetActionsSubsetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetActionsSubsetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Aggregations

CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)3 CoordJobGetActionsSubsetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetActionsSubsetJPAExecutor)3 JPAService (org.apache.oozie.service.JPAService)3 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)2 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)1 XException (org.apache.oozie.XException)1 CommandException (org.apache.oozie.command.CommandException)1 CoordActionsCountForJobIdJPAExecutor (org.apache.oozie.executor.jpa.CoordActionsCountForJobIdJPAExecutor)1 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)1