use of org.apache.oozie.command.bundle.BundleStartXCommand in project oozie by apache.
the class TestCoordUpdateXCommand method setUpBundleAndGetCoordID.
private String setUpBundleAndGetCoordID(XConfiguration jobConf) throws UnsupportedEncodingException, IOException, CommandException, JPAExecutorException {
final Path coordPath1 = new Path(getFsTestCaseDir(), "coord1");
final Path coordPath2 = new Path(getFsTestCaseDir(), "coord2");
writeCoordXml(coordPath1, "coord-multiple-input-instance3.xml");
writeCoordXml(coordPath2, "coord-multiple-input-instance3.xml");
Path bundleAppPath = new Path(getFsTestCaseDir(), "bundle");
String bundleAppXml = getBundleXml("bundle-submit-job.xml");
assertNotNull(bundleAppXml);
assertTrue(bundleAppXml.length() > 0);
bundleAppXml = bundleAppXml.replaceAll("#app_path1", Matcher.quoteReplacement(new Path(coordPath1.toString(), "coordinator.xml").toString()));
bundleAppXml = bundleAppXml.replaceAll("#app_path2", Matcher.quoteReplacement(new Path(coordPath2.toString(), "coordinator.xml").toString()));
writeToFile(bundleAppXml, bundleAppPath, "bundle.xml");
final Path appPath = new Path(bundleAppPath, "bundle.xml");
jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());
jobConf.set("appName", "test");
jobConf.set(OozieClient.USER_NAME, getTestUser());
jobConf.set("coordName1", "NAME");
jobConf.set("coordName2", "coord2");
jobConf.set("isEnabled", "true");
BundleSubmitXCommand command = new BundleSubmitXCommand(jobConf);
final BundleJobBean bundleBean = (BundleJobBean) command.getJob();
bundleBean.setStartTime(new Date());
bundleBean.setEndTime(new Date());
final String jobId = command.call();
sleep(2000);
new BundleStartXCommand(jobId).call();
waitFor(200000, new Predicate() {
public boolean evaluate() throws Exception {
List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, jobId);
return actions.get(0).getStatus().equals(Job.Status.RUNNING);
}
});
final List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, jobId);
return actions.get(0).getCoordId();
}
use of org.apache.oozie.command.bundle.BundleStartXCommand in project oozie by apache.
the class TestOozieJobInfo method testInfoWithBundle.
public void testInfoWithBundle() throws Exception {
Services.get().getConf().setBoolean(OozieJobInfo.CONF_JOB_INFO, true);
OozieJobInfo.setJobInfo(true);
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);
}
setCoordConf(jobConf);
Path appPath = new Path(jobConf.get(OozieClient.BUNDLE_APP_PATH), "bundle.xml");
jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());
BundleSubmitXCommand submitCmd = new BundleSubmitXCommand(jobConf);
submitCmd.call();
BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(submitCmd.getJob().getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(job.getStatus(), Job.Status.PREP);
new BundleStartXCommand(job.getId()).call();
sleep(2000);
List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertEquals(1, actions.size());
final String bundleID = job.getId();
waitFor(200000, new Predicate() {
public boolean evaluate() throws Exception {
List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, bundleID);
return actions.get(0).getStatus().equals(Job.Status.RUNNING);
}
});
actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
final String cordID = actions.get(0).getCoordId();
waitFor(200000, new Predicate() {
public boolean evaluate() throws Exception {
CoordJobGetJPAExecutor coordGetCmd2 = new CoordJobGetJPAExecutor(cordID);
CoordinatorJobBean cc = jpaService.execute(coordGetCmd2);
return cc.getStatus().equals(Job.Status.RUNNING);
}
});
final String jobID = jpaService.execute(new WorkflowJobsGetFromCoordParentIdJPAExecutor(cordID, 1)).get(0);
final WorkflowActionsGetForJobJPAExecutor actionsGetExecutor = new WorkflowActionsGetForJobJPAExecutor(jobID);
waitFor(200000, new Predicate() {
public boolean evaluate() throws Exception {
List<WorkflowActionBean> actions = jpaService.execute(actionsGetExecutor);
WorkflowActionBean action = null;
for (WorkflowActionBean bean : actions) {
if (bean.getName().contains("hadoop")) {
action = bean;
break;
}
}
return action.getStatus().toString().equalsIgnoreCase(Job.Status.RUNNING.toString());
}
});
final WorkflowJobGetJPAExecutor wfeExc = new WorkflowJobGetJPAExecutor(jobID);
WorkflowJobBean wfbean = jpaService.execute(wfeExc);
List<WorkflowActionBean> actionList = jpaService.execute(actionsGetExecutor);
ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(wfbean, actionList.get(1), false, false);
MapReduceActionExecutor actionExecutor = new MapReduceActionExecutor();
Configuration conf = actionExecutor.createBaseHadoopConf(context, XmlUtils.parseXml(actionList.get(1).getConf()));
String user = conf.get("user.name");
FileSystem fs = getFileSystem();
Configuration jobXmlConf = new XConfiguration(fs.open(getPathToWorkflowResource(user, wfbean, services, context, LauncherAM.LAUNCHER_JOB_CONF_XML)));
String jobInfo = jobXmlConf.get(OozieJobInfo.JOB_INFO_KEY);
// BUNDLE_ID;BUNDLE_NAME;COORDINATOR_NAME;COORDINATOR_NOMINAL_TIME;
// WORKFLOW_ID;WORKFLOW_NAME;WORKFLOW_DEPTH;WORKFLOW_SUPERPARENT;
// ACTION_TYPE;ACTION_NAME,JOB_INFO,custom_info;
assertEquals(jobInfo.split(OozieJobInfo.SEPARATOR).length, 13);
assertTrue(jobInfo.contains(bundleID));
assertTrue(jobInfo.contains("bundle.name=test_bundle,"));
assertTrue(jobInfo.contains(cordID));
assertTrue(jobInfo.contains("action.type=map-reduce"));
assertTrue(jobInfo.contains("wf.depth=0"));
assertTrue(jobInfo.contains("wf.superparent.id=" + cordID));
assertTrue(jobInfo.contains(",testing=test,"));
assertTrue(jobInfo.contains(",coord.nominal.time="));
assertTrue(jobInfo.contains("launcher=true"));
}
Aggregations