Search in sources :

Example 21 with BundleActionBean

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

the class TestBundleStartXCommand method testBundleStartDryrun.

/**
 * Test : Start bundle job with dryrun
 *
 * @throws Exception
 */
public void testBundleStartDryrun() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.PREP);
    new BundleStartXCommand(job.getId(), true).call();
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.RUNNING);
    sleep(2000);
    List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
    assertEquals(2, actions.size());
    assertEquals(true, actions.get(0).isCritical());
    assertEquals(job.getId(), actions.get(0).getBundleId());
    assertEquals(false, actions.get(1).isCritical());
    assertEquals(job.getId(), actions.get(1).getBundleId());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 22 with BundleActionBean

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

the class XDataTestCase method addRecordToBundleActionTable.

/**
 * Create bundle action bean and save to db
 *
 * @param jobId bundle job id
 * @param coordName coordinator name
 * @param pending true if action is pending
 * @param status job status
 * @return bundle action bean
 * @throws Exception
 */
protected BundleActionBean addRecordToBundleActionTable(String jobId, String coordName, int pending, Job.Status status) throws Exception {
    BundleActionBean action = createBundleAction(jobId, null, coordName, pending, status);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        BundleActionInsertJPAExecutor bundleActionJPAExecutor = new BundleActionInsertJPAExecutor(action);
        jpaService.execute(bundleActionJPAExecutor);
    } catch (JPAExecutorException ex) {
        ex.printStackTrace();
        fail("Unable to insert the test bundle action record to table");
        throw ex;
    }
    return action;
}
Also used : BundleActionInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleActionInsertJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 23 with BundleActionBean

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

the class BundleJobSuspendXCommand method suspendChildren.

@Override
public void suspendChildren() throws CommandException {
    for (BundleActionBean action : this.bundleActions) {
        if (action.getStatus() == Job.Status.RUNNING || action.getStatus() == Job.Status.RUNNINGWITHERROR || action.getStatus() == Job.Status.PREP || action.getStatus() == Job.Status.PAUSED || action.getStatus() == Job.Status.PAUSEDWITHERROR) {
            // queue a CoordSuspendXCommand
            if (action.getCoordId() != null) {
                queue(new CoordSuspendXCommand(action.getCoordId()));
                updateBundleAction(action);
                LOG.debug("Suspend bundle action = [{0}], new status = [{1}], pending = [{2}] and queue CoordSuspendXCommand" + " for [{3}]", action.getBundleActionId(), action.getStatus(), action.getPending(), action.getCoordId());
            } else {
                updateBundleAction(action);
                LOG.debug("Suspend bundle action = [{0}], new status = [{1}], pending = [{2}] and coord id is null", action.getBundleActionId(), action.getStatus(), action.getPending());
            }
        }
    }
    LOG.debug("Suspended bundle actions for the bundle=[{0}]", jobId);
}
Also used : CoordSuspendXCommand(org.apache.oozie.command.coord.CoordSuspendXCommand) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 24 with BundleActionBean

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

the class BundleStartXCommand method createBundleAction.

private BundleActionBean createBundleAction(String jobId, String coordName, boolean isCritical) {
    BundleActionBean action = new BundleActionBean();
    action.setBundleActionId(jobId + "_" + coordName);
    action.setBundleId(jobId);
    action.setCoordName(coordName);
    action.setStatus(Job.Status.PREP);
    action.setLastModifiedTime(new Date());
    if (isCritical) {
        action.setCritical();
    } else {
        action.resetCritical();
    }
    return action;
}
Also used : BundleActionBean(org.apache.oozie.BundleActionBean) Date(java.util.Date)

Example 25 with BundleActionBean

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

the class TestBundleActionQueryExecutor method testExecuteUpdate.

public void testExecuteUpdate() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    BundleActionBean bean = this.addRecordToBundleActionTable(job.getId(), "action1", 1, Job.Status.PREP);
    bean.setStatus(Job.Status.RUNNING);
    BundleActionQueryExecutor.getInstance().executeUpdate(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME, bean);
    BundleActionBean retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_ACTION, bean.getBundleActionId());
    assertEquals(retBean.getStatus(), Job.Status.RUNNING);
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionBean(org.apache.oozie.BundleActionBean)

Aggregations

BundleActionBean (org.apache.oozie.BundleActionBean)76 BundleJobBean (org.apache.oozie.BundleJobBean)58 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)36 JPAService (org.apache.oozie.service.JPAService)35 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)33 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)30 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)24 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)20 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)20 Date (java.util.Date)19 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)19 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)16 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)13 IOException (java.io.IOException)10 CommandException (org.apache.oozie.command.CommandException)10 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)10 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)9 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)9 XConfiguration (org.apache.oozie.util.XConfiguration)8 ArrayList (java.util.ArrayList)6