use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundleJobXCommand method testBundleJobInfo1.
/**
* Test: submit bundle job, then check job info
*
* @throws Exception
*/
public void testBundleJobInfo1() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetjpa = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetjpa);
assertEquals(job.getStatus(), Job.Status.PREP);
BundleJobBean bundleJob = (new BundleJobXCommand(job.getId())).call();
assertEquals(0, bundleJob.getCoordinators().size());
assertEquals(bundleJob.getStatus(), Job.Status.PREP);
assertEquals(bundleJob.getId(), job.getId());
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundleKillXCommand method testBundleKill2.
/**
* Test : Kill bundle job
*
* @throws Exception
*/
public void testBundleKill2() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
final JPAService jpaService = Services.get().get(JPAService.class);
Configuration jobConf = null;
try {
jobConf = new XConfiguration(new StringReader(job.getConf()));
} catch (IOException ioe) {
log.warn("Configuration parse error. read from DB :" + job.getConf(), ioe);
throw new CommandException(ErrorCode.E1005, ioe);
}
Path appPath = new Path(jobConf.get(OozieClient.BUNDLE_APP_PATH), "bundle.xml");
jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());
new BundleKillXCommand(job.getId()).call();
BundleSubmitXCommand submitCmd = new BundleSubmitXCommand(jobConf);
submitCmd.call();
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(submitCmd.getJob().getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.PREP, job.getStatus());
new BundleStartXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.RUNNING, job.getStatus());
sleep(2000);
List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertEquals(2, actions.size());
assertNotNull(actions.get(0).getCoordId());
assertNotNull(actions.get(1).getCoordId());
new BundleKillXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.KILLED, job.getStatus());
actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertEquals(true, actions.get(0).isPending());
assertEquals(true, actions.get(1).isPending());
final CoordJobGetJPAExecutor coordGetCmd1 = new CoordJobGetJPAExecutor(actions.get(0).getCoordId());
final CoordJobGetJPAExecutor coordGetCmd2 = new CoordJobGetJPAExecutor(actions.get(1).getCoordId());
waitFor(200000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean job1 = jpaService.execute(coordGetCmd1);
return job1.getStatus().equals(CoordinatorJobBean.Status.KILLED);
}
});
CoordinatorJobBean job1 = jpaService.execute(coordGetCmd1);
assertEquals(CoordinatorJobBean.Status.KILLED, job1.getStatus());
waitFor(200000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean job2 = jpaService.execute(coordGetCmd2);
return job2.getStatus().equals(CoordinatorJobBean.Status.KILLED);
}
});
CoordinatorJobBean job2 = jpaService.execute(coordGetCmd2);
assertEquals(CoordinatorJobBean.Status.KILLED, job2.getStatus());
final Runnable runnable = new StatusTransitRunnable();
runnable.run();
sleep(1000);
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.KILLED, job.getStatus());
actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
for (BundleActionBean action : actions) {
assertEquals(0, action.getPending());
assertEquals(CoordinatorJobBean.Status.KILLED, action.getStatus());
}
// If bundle kill + Status Transit service left the bundle action with Pending=1
// due to race condition, killing the bundle again should reset the pending.
job.setPending();
job.setStatus(Status.RUNNING);
actions.get(0).incrementAndGetPending();
BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PENDING, job);
BundleActionQueryExecutor.getInstance().executeUpdate(BundleActionQuery.UPDATE_BUNDLE_ACTION_PENDING_MODTIME, actions.get(0));
runnable.run();
sleep(1000);
new BundleKillXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.KILLED, job.getStatus());
runnable.run();
sleep(1000);
job = jpaService.execute(bundleJobGetCmd);
assertEquals(Job.Status.KILLED, job.getStatus());
actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
for (BundleActionBean action : actions) {
assertEquals(0, action.getPending());
assertEquals(CoordinatorJobBean.Status.KILLED, action.getStatus());
}
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundlePauseUnpauseXCommand method testBundlePauseUnpauseNeg1.
/**
* Test : Negative case - pause a suspended bundle
*
* @throws Exception
*/
public void testBundlePauseUnpauseNeg1() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.SUSPENDED, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(job.getStatus(), Job.Status.SUSPENDED);
try {
new BundlePauseXCommand(job).call();
fail("should not reach here.");
} catch (Exception ex) {
}
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundlePauseUnpauseXCommand method testBundlePauseUnpause1.
/**
* Test : Pause a PREP bundle
*
* @throws Exception
*/
public void testBundlePauseUnpause1() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(job.getStatus(), Job.Status.PREP);
new BundlePauseXCommand(job).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(job.getStatus(), Job.Status.PREPPAUSED);
new BundleUnpauseXCommand(job).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(job.getStatus(), Job.Status.PREP);
}
use of org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor in project oozie by apache.
the class TestBundlePauseUnpauseXCommand method testBundlePauseUnpause2.
/**
* Test : Pause a RUNNING bundle
*
* @throws Exception
*/
public void testBundlePauseUnpause2() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(job.getStatus(), Job.Status.RUNNING);
new BundlePauseXCommand(job).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(job.getStatus(), Job.Status.PAUSED);
new BundleUnpauseXCommand(job).call();
job = jpaService.execute(bundleJobGetCmd);
assertEquals(job.getStatus(), Job.Status.RUNNING);
}
Aggregations