use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class TestJMSTopicService method testMixedTopic1.
@Test
public void testMixedTopic1() throws Exception {
services = setupServicesForTopic();
services.getConf().set(JMSTopicService.TOPIC_NAME, JMSTopicService.JobType.WORKFLOW.getValue() + " = workflow," + JMSTopicService.JobType.COORDINATOR.getValue() + "=coord, default = " + JMSTopicService.TopicType.JOBID.getValue());
services.init();
JMSTopicService jmsTopicService = Services.get().get(JMSTopicService.class);
WorkflowJobBean wfj = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
assertEquals("workflow", jmsTopicService.getTopic(wfj.getId()));
assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_JOB, wfj.getUser(), wfj.getId(), null));
WorkflowActionBean wab = addRecordToWfActionTable(wfj.getId(), "1", WorkflowAction.Status.RUNNING);
assertEquals("workflow", jmsTopicService.getTopic(wab.getId()));
assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_ACTION, wfj.getUser(), wab.getId(), wab.getWfId()));
CoordinatorJobBean cjb = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, true, true);
assertEquals("coord", jmsTopicService.getTopic(cjb.getId()));
assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_JOB, cjb.getUser(), cjb.getId(), null));
CoordinatorActionBean cab = addRecordToCoordActionTable(cjb.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-for-action-input-check.xml", 0);
assertEquals("coord", jmsTopicService.getTopic(cab.getId()));
assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_ACTION, cjb.getUser(), cab.getId(), cab.getJobId()));
BundleJobBean bjb = addRecordToBundleJobTable(Job.Status.RUNNING, true);
assertEquals(bjb.getId(), jmsTopicService.getTopic(bjb.getId()));
assertEquals(bjb.getId(), jmsTopicService.getTopic(AppType.BUNDLE_JOB, bjb.getUser(), bjb.getId(), null));
BundleActionBean bab = addRecordToBundleActionTable(bjb.getId(), "1", 1, Job.Status.RUNNING);
assertEquals(bjb.getId(), jmsTopicService.getTopic(bab.getBundleActionId()));
assertEquals(bjb.getId(), jmsTopicService.getTopic(AppType.BUNDLE_ACTION, bjb.getUser(), bab.getBundleActionId(), bab.getBundleId()));
}
use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class TestJMSTopicService method testMixedTopic2.
@Test
public void testMixedTopic2() throws Exception {
services = setupServicesForTopic();
services.getConf().set(JMSTopicService.TOPIC_NAME, JMSTopicService.JobType.WORKFLOW.getValue() + " = workflow," + JMSTopicService.JobType.COORDINATOR.getValue() + "=coord");
services.init();
JMSTopicService jmsTopicService = Services.get().get(JMSTopicService.class);
WorkflowJobBean wfj = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
assertEquals("workflow", jmsTopicService.getTopic(wfj.getId()));
assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_JOB, wfj.getUser(), wfj.getId(), null));
WorkflowActionBean wab = addRecordToWfActionTable(wfj.getId(), "1", WorkflowAction.Status.RUNNING);
assertEquals("workflow", jmsTopicService.getTopic(wab.getId()));
assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_ACTION, wfj.getUser(), wab.getId(), wab.getWfId()));
CoordinatorJobBean cjb = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, true, true);
assertEquals("coord", jmsTopicService.getTopic(cjb.getId()));
CoordinatorActionBean cab = addRecordToCoordActionTable(cjb.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-for-action-input-check.xml", 0);
assertEquals("coord", jmsTopicService.getTopic(cab.getId()));
assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_ACTION, cjb.getUser(), cab.getId(), cab.getJobId()));
BundleJobBean bjb = addRecordToBundleJobTable(Job.Status.RUNNING, true);
// As no default is specified, user will be considered as topic
assertEquals(bjb.getUser(), jmsTopicService.getTopic(bjb.getId()));
assertEquals(bjb.getUser(), jmsTopicService.getTopic(AppType.BUNDLE_JOB, bjb.getUser(), bjb.getId(), null));
BundleActionBean bab = addRecordToBundleActionTable(bjb.getId(), "1", 1, Job.Status.RUNNING);
assertEquals(bjb.getUser(), jmsTopicService.getTopic(bab.getBundleActionId()));
assertEquals(bjb.getUser(), jmsTopicService.getTopic(AppType.BUNDLE_ACTION, bjb.getUser(), bab.getBundleActionId(), bab.getBundleId()));
}
use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class TestPauseTransitService method testUnpauseBundleAndCoordinator.
/**
* Test : Unpause a PAUSED bundle, then check bundle action has been updated to RUNNING by BundleStatusUpdateXCommand
*
* @throws Exception
*/
public void testUnpauseBundleAndCoordinator() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PAUSED, false);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
job.setPauseTime(null);
BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQuery.UPDATE_BUNDLE_JOB_PAUSE_KICKOFF, job);
BundleActionBean bundleAction1 = this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.PAUSED);
BundleActionBean bundleAction2 = this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.PAUSED);
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean coordJob1 = addRecordToCoordJobTable("action1", CoordinatorJob.Status.PAUSED, start, end, false);
CoordinatorJobBean coordJob2 = addRecordToCoordJobTable("action2", CoordinatorJob.Status.PAUSED, start, end, false);
coordJob1.setPauseTime(null);
coordJob1.setBundleId(job.getId());
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob1);
coordJob2.setPauseTime(null);
coordJob2.setBundleId(job.getId());
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob2);
BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(Job.Status.PAUSED, job.getStatus());
Runnable pauseStartRunnable = new PauseTransitRunnable();
pauseStartRunnable.run();
final String jobId = job.getId();
waitFor(10 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
BundleJobBean bJob1 = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
return bJob1.getStatus() == Job.Status.RUNNING;
}
});
final String coordJobId1 = coordJob1.getId();
final String coordJobId2 = coordJob2.getId();
waitFor(10 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean cJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
CoordinatorJobBean cJob2 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId2));
return cJob1.getStatus() == Job.Status.RUNNING && cJob2.getStatus() == Job.Status.RUNNING;
}
});
job = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
assertEquals(Job.Status.RUNNING, job.getStatus());
coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
assertEquals(Job.Status.RUNNING, coordJob1.getStatus());
coordJob2 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId2));
assertEquals(Job.Status.RUNNING, coordJob2.getStatus());
bundleAction1 = jpaService.execute(new BundleActionGetJPAExecutor(job.getId(), "action1"));
assertEquals(Job.Status.RUNNING, bundleAction1.getStatus());
bundleAction2 = jpaService.execute(new BundleActionGetJPAExecutor(job.getId(), "action2"));
assertEquals(Job.Status.RUNNING, bundleAction2.getStatus());
}
use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class BundleJobChangeXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected Void execute() throws CommandException {
StringBuffer changeReport = new StringBuffer();
try {
if (isChangePauseTime || isChangeEndTime) {
if (isChangePauseTime) {
bundleJob.setPauseTime(newPauseTime);
} else if (isChangeEndTime) {
bundleJob.setEndTime(newEndTime);
if (bundleJob.getStatus() == Job.Status.SUCCEEDED) {
bundleJob.setStatus(Job.Status.RUNNING);
}
if (bundleJob.getStatus() == Job.Status.DONEWITHERROR || bundleJob.getStatus() == Job.Status.FAILED) {
bundleJob.setStatus(StatusUtils.getStatusIfBackwardSupportTrue(Job.Status.RUNNINGWITHERROR));
}
}
for (BundleActionBean action : this.bundleActions) {
// queue coord change commands;
if (action.getStatus() != Job.Status.KILLED && action.getCoordId() != null) {
try {
new CoordChangeXCommand(action.getCoordId(), changeValue).call();
} catch (Exception e) {
String errorMsg = action.getCoordId() + " : " + e.getMessage();
LOG.info("Change command failed " + errorMsg);
changeReport.append("[ ").append(errorMsg).append(" ]");
}
} else {
String errorMsg = action.getCoordId() + " : Coord is in killed state";
LOG.info("Change command failed " + errorMsg);
changeReport.append("[ ").append(errorMsg).append(" ]");
}
}
updateList.add(new UpdateEntry<BundleJobQuery>(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PAUSE_ENDTIME, bundleJob));
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(null, updateList, null);
}
if (!changeReport.toString().isEmpty()) {
throw new CommandException(ErrorCode.E1320, changeReport.toString());
}
return null;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class BundleKillXCommand method killChildren.
@Override
public void killChildren() throws CommandException {
if (bundleActions != null) {
for (BundleActionBean action : bundleActions) {
if (action.getCoordId() != null) {
queue(new CoordKillXCommand(action.getCoordId()));
updateBundleAction(action);
LOG.debug("Killed bundle action = [{0}], new status = [{1}], " + "pending = [{2}] and queue CoordKillXCommand for [{3}]", action.getBundleActionId(), action.getStatus(), action.getPending(), action.getCoordId());
} else {
updateBundleAction(action);
LOG.debug("Killed bundle action = [{0}], current status = [{1}]," + "pending = [{2}]", action.getBundleActionId(), action.getStatus(), action.getPending());
}
}
}
LOG.debug("Killed coord jobs for the bundle=[{0}]", jobId);
}
Aggregations