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());
}
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;
}
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);
}
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;
}
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);
}
Aggregations