use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestWorkflowJobsGetFromCoordParentIdJPAExecutor method testGetCoordinatorParent.
public void testGetCoordinatorParent() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordinatorJobBean coordJobA = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
CoordinatorJobBean coordJobB = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
WorkflowJobBean wfJobA1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowJobBean wfJobA2 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowJobBean wfJobB = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfActionA1 = addRecordToWfActionTable(wfJobA1.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfActionA2 = addRecordToWfActionTable(wfJobA2.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfActionB = addRecordToWfActionTable(wfJobB.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordActionA1 = addRecordToCoordActionTable(coordJobA.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobA1.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordActionA2 = addRecordToCoordActionTable(coordJobA.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobA2.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordActionB = addRecordToCoordActionTable(coordJobB.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobB.getId(), "SUCCEEDED", 0);
List<String> children = new ArrayList<String>();
children.addAll(jpaService.execute(new WorkflowJobsGetFromCoordParentIdJPAExecutor(coordJobA.getId(), 10)));
checkChildren(children, wfJobA1.getId(), wfJobA2.getId());
children = new ArrayList<String>();
children.addAll(jpaService.execute(new WorkflowJobsGetFromCoordParentIdJPAExecutor(coordJobB.getId(), 10)));
checkChildren(children, wfJobB.getId());
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestWorkflowJobsGetFromCoordParentIdJPAExecutor method testGetWorkflowParentTooMany.
public void testGetWorkflowParentTooMany() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
WorkflowJobBean wfJob1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, coordJob.getId());
WorkflowJobBean wfJob2 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, coordJob.getId());
WorkflowJobBean wfJob3 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, coordJob.getId());
WorkflowJobBean wfJob4 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, coordJob.getId());
WorkflowJobBean wfJob5 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, coordJob.getId());
WorkflowActionBean wfAction1 = addRecordToWfActionTable(wfJob1.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfAction2 = addRecordToWfActionTable(wfJob2.getId(), "2", WorkflowAction.Status.OK);
WorkflowActionBean wfAction3 = addRecordToWfActionTable(wfJob3.getId(), "2", WorkflowAction.Status.OK);
WorkflowActionBean wfAction4 = addRecordToWfActionTable(wfJob4.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfAction5 = addRecordToWfActionTable(wfJob5.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordAction1 = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob1.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordAction2 = addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob2.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordAction3 = addRecordToCoordActionTable(coordJob.getId(), 3, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob3.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordAction4 = addRecordToCoordActionTable(coordJob.getId(), 4, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob4.getId(), "SUCCEEDED", 0);
CoordinatorActionBean coordAction5 = addRecordToCoordActionTable(coordJob.getId(), 5, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob5.getId(), "SUCCEEDED", 0);
List<String> children = new ArrayList<String>();
// Get the first 3
children.addAll(jpaService.execute(new WorkflowJobsGetFromCoordParentIdJPAExecutor(coordJob.getId(), 3)));
assertEquals(3, children.size());
// Get the next 3 (though there's only 2 more)
children.addAll(jpaService.execute(new WorkflowJobsGetFromCoordParentIdJPAExecutor(coordJob.getId(), 3, 3)));
assertEquals(5, children.size());
checkChildren(children, wfJob1.getId(), wfJob2.getId(), wfJob3.getId(), wfJob4.getId(), wfJob5.getId());
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestWorkflowJobsGetFromWorkflowParentIdJPAExecutor method testGetCoordinatorParentTooMany.
public void testGetCoordinatorParentTooMany() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowJobBean subwfJob1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowJobBean subwfJob2 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowJobBean subwfJob3 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowJobBean subwfJob4 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowJobBean subwfJob5 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowActionBean wfAction1 = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfAction2 = addRecordToWfActionTable(wfJob.getId(), "2", WorkflowAction.Status.OK);
WorkflowActionBean wfAction3 = addRecordToWfActionTable(wfJob.getId(), "3", WorkflowAction.Status.OK);
WorkflowActionBean wfAction4 = addRecordToWfActionTable(wfJob.getId(), "4", WorkflowAction.Status.OK);
WorkflowActionBean wfAction5 = addRecordToWfActionTable(wfJob.getId(), "5", WorkflowAction.Status.OK);
WorkflowActionBean subwfAction1 = addRecordToWfActionTable(subwfJob1.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfAction2 = addRecordToWfActionTable(subwfJob2.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfAction3 = addRecordToWfActionTable(subwfJob3.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfAction4 = addRecordToWfActionTable(subwfJob4.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfAction5 = addRecordToWfActionTable(subwfJob5.getId(), "1", WorkflowAction.Status.OK);
List<String> children = new ArrayList<String>();
// Get the first 3
children.addAll(jpaService.execute(new WorkflowJobsGetFromWorkflowParentIdJPAExecutor(wfJob.getId(), 3)));
assertEquals(3, children.size());
// Get the next 3 (though there's only 2 more)
children.addAll(jpaService.execute(new WorkflowJobsGetFromWorkflowParentIdJPAExecutor(wfJob.getId(), 3, 3)));
assertEquals(5, children.size());
checkChildren(children, subwfJob1.getId(), subwfJob2.getId(), subwfJob3.getId(), subwfJob4.getId(), subwfJob5.getId());
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestRecoveryService method testWorkflowActionRecoveryService.
/**
* Tests functionality of the Recovery Service Runnable command. </p> Starts an action which behaves like an Async
* Action (Action and Job state set to Running). Changes the action configuration to run in sync mode and updates
* the store. Runs the recovery runnable, and ensures the state of the action and job have not changed. </p> Changes
* the state of the action from RUNNING to PREP and updates the store. Again, runs the recovery runnable and ensures
* the state changes to OK and the job completes successfully.
*
* @throws Exception
*/
public void testWorkflowActionRecoveryService() throws Exception {
Reader reader = IOUtils.getResourceAsReader("wf-ext-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
createTestCaseSubDir("lib");
IOUtils.copyCharStream(reader, writer);
final DagEngine engine = new DagEngine(getTestUser());
Configuration conf = new XConfiguration();
conf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set(OozieClient.LOG_TOKEN, "t");
conf.set("external-status", "ok");
conf.set("signal-value", "based_on_action_status");
conf.set("running-mode", "async");
// TODO CHECK, without this we get JPA concurrency exceptions, ODD
sleep(1000);
final String jobId = engine.submitJob(conf, true);
// TODO CHECK, without this we get JPA concurrency exceptions, ODD
sleep(1000);
waitFor(5000, new Predicate() {
public boolean evaluate() throws Exception {
return (engine.getJob(jobId).getStatus() == WorkflowJob.Status.RUNNING);
}
});
sleep(1000);
final WorkflowStore store = Services.get().get(WorkflowStoreService.class).create();
store.beginTrx();
List<WorkflowActionBean> actions = store.getActionsForWorkflow(jobId, false);
WorkflowActionBean action = null;
for (WorkflowActionBean bean : actions) {
if (bean.getType().equals("test")) {
action = bean;
break;
}
}
assertNotNull(action);
final String actionId = action.getId();
assertEquals(WorkflowActionBean.Status.RUNNING, action.getStatus());
String actionConf = action.getConf();
String fixedActionConf = actionConf.replaceAll("async", "sync");
action.setConf(fixedActionConf);
action.setPending();
store.updateAction(action);
store.commitTrx();
store.closeTrx();
Runnable recoveryRunnable = new RecoveryRunnable(0, 60, 60);
recoveryRunnable.run();
sleep(3000);
final WorkflowStore store2 = Services.get().get(WorkflowStoreService.class).create();
assertEquals(WorkflowJob.Status.RUNNING, engine.getJob(jobId).getStatus());
store2.beginTrx();
WorkflowActionBean action2 = store2.getAction(actionId, false);
assertEquals(WorkflowActionBean.Status.RUNNING, action2.getStatus());
action2.setStatus(WorkflowActionBean.Status.PREP);
action2.setPending();
store2.updateAction(action2);
store2.commitTrx();
store2.closeTrx();
sleep(1000);
recoveryRunnable.run();
sleep(3000);
waitFor(10000, new Predicate() {
public boolean evaluate() throws Exception {
return (engine.getWorkflowAction(actionId).getStatus() == WorkflowActionBean.Status.OK);
}
});
// getPendingActions works correctly only with MYSQL - following assertsfail with hsql - to be investigated
// assertEquals(WorkflowJob.Status.SUCCEEDED, engine.getJob(jobId).getStatus());
final WorkflowStore store3 = Services.get().get(WorkflowStoreService.class).create();
store3.beginTrx();
WorkflowActionBean action3 = store3.getAction(actionId, false);
assertEquals(WorkflowActionBean.Status.OK, action3.getStatus());
store3.commitTrx();
store3.closeTrx();
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestShareLibService method testAddShareLib_pig_withVersion.
@Test
public void testAddShareLib_pig_withVersion() throws Exception {
setShipLauncherInOozieConfig();
FileSystem fs = getFileSystem();
Date time = new Date(System.currentTimeMillis());
Path basePath = new Path(getOozieConfig().get(WorkflowAppService.SYSTEM_LIB_PATH));
Path libpath = new Path(basePath, ShareLibService.SHARE_LIB_PREFIX + ShareLibService.dateFormat.format(time));
fs.mkdirs(libpath);
Path pigPath = new Path(libpath.toString() + Path.SEPARATOR + "pig");
Path pigPath1 = new Path(libpath.toString() + Path.SEPARATOR + "pig_9");
Path pigPath2 = new Path(libpath.toString() + Path.SEPARATOR + "pig_10");
fs.mkdirs(pigPath);
fs.mkdirs(pigPath1);
fs.mkdirs(pigPath2);
createFiles(libpath.toString() + Path.SEPARATOR + "pig_10" + Path.SEPARATOR + "pig-10.jar");
services.init();
String actionXml = "<pig>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<property><name>oozie.action.sharelib.for.pig</name><value>pig_10</value></property>" + "</pig>";
Element eActionXml = XmlUtils.parseXml(actionXml);
XConfiguration protoConf = new XConfiguration();
protoConf.set(WorkflowAppService.HADOOP_USER, getTestUser());
WorkflowJobBean wfj = new WorkflowJobBean();
protoConf.setBoolean(OozieClient.USE_SYSTEM_LIBPATH, true);
wfj.setProtoActionConf(XmlUtils.prettyPrint(protoConf).toString());
wfj.setConf(XmlUtils.prettyPrint(protoConf).toString());
Context context = new TestJavaActionExecutor().new Context(wfj, new WorkflowActionBean());
PigActionExecutor ae = new PigActionExecutor();
Configuration jobConf = ae.createBaseHadoopConf(context, eActionXml);
jobConf.set("oozie.action.sharelib.for.pig", "pig_10");
ae.setLibFilesArchives(context, eActionXml, new Path("hdfs://dummyAppPath"), jobConf);
verifyFilesInDistributedCache(DistributedCache.getCacheFiles(jobConf), "MyPig.jar", "MyOozie.jar", "pig-10.jar");
}
Aggregations