use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class TestCoordActionsIgnoreXCommand method createDBRecords.
private void createDBRecords() throws Exception {
JPAService jpaService = services.get(JPAService.class);
coordJobs = new ArrayList<CoordinatorJobBean>();
coordActions = new ArrayList<CoordinatorActionBean>();
Date startTime = DateUtils.parseDateOozieTZ("2013-08-01T23:59Z");
Date endTime = DateUtils.parseDateOozieTZ("2013-08-02T23:59Z");
CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.KILLED, startTime, endTime, false, true, 0);
CoordinatorJobBean job2 = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, startTime, endTime, false, true, 0);
coordJobs.add(job1);
coordJobs.add(job2);
CoordinatorActionBean action1_1 = addRecordToCoordActionTable(job1.getId(), 1, CoordinatorAction.Status.FAILED, "coord-action-get.xml", 0);
CoordinatorActionBean action1_2 = addRecordToCoordActionTable(job1.getId(), 2, CoordinatorAction.Status.FAILED, "coord-action-get.xml", 0);
CoordinatorActionBean action1_3 = addRecordToCoordActionTable(job1.getId(), 3, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
CoordinatorActionBean action1_4 = addRecordToCoordActionTable(job1.getId(), 4, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
CoordinatorActionBean action1_5 = addRecordToCoordActionTable(job1.getId(), 5, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
coordActions.add(action1_1);
coordActions.add(action1_2);
coordActions.add(action1_3);
coordActions.add(action1_4);
coordActions.add(action1_5);
action1_1.setNominalTime(DateUtils.parseDateOozieTZ("2009-12-15T02:00Z"));
action1_1.setExternalId(null);
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action1_1);
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class TestCoordActionsKillXCommand method createDBRecords.
private String[] createDBRecords() throws Exception {
JPAService jpaService = services.get(JPAService.class);
Date startTime = DateUtils.parseDateOozieTZ("2013-08-01T23:59Z");
Date endTime = DateUtils.parseDateOozieTZ("2013-08-02T23:59Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, true, 0);
CoordinatorActionBean action1 = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
CoordinatorActionBean action2 = addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
action2.setNominalTime(DateUtils.parseDateOozieTZ("2009-12-15T02:00Z"));
action2.setExternalId(null);
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action2);
WorkflowJobBean wf = new WorkflowJobBean();
WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
wf.setId(action1.getExternalId());
wf.setStatus(WorkflowJob.Status.RUNNING);
WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
WorkflowInstance wfInstance = workflowLib.createInstance(app, new XConfiguration());
((LiteWorkflowInstance) wfInstance).setStatus(WorkflowInstance.Status.RUNNING);
wf.setWorkflowInstance(wfInstance);
jpaService.execute(new WorkflowJobInsertJPAExecutor(wf));
return new String[] { job.getId(), action1.getId(), action2.getId(), wf.getId() };
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class TestCoordActionsKillXCommand method testActionKillCommandActionNumbers.
/**
* Test the working of CoordActionKillXCommand by passing range
* as action ids
*
* @throws Exception
*/
public void testActionKillCommandActionNumbers() throws Exception {
JPAService jpaService = services.get(JPAService.class);
String[] ids = createDBRecords();
new CoordActionsKillXCommand(ids[0], "action", "1,3").call();
CoordinatorActionBean action = jpaService.execute(new CoordActionGetForCheckJPAExecutor(ids[1]));
assertEquals(CoordinatorAction.Status.KILLED, action.getStatus());
sleep(100);
WorkflowJobBean wf = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_FOR_SLA, ids[3]);
assertEquals(WorkflowJob.Status.KILLED, wf.getStatus());
CoordinatorJobBean job = jpaService.execute(new CoordJobGetJPAExecutor(ids[0]));
assertEquals(CoordinatorJob.Status.RUNNING, job.getStatus());
Runnable runnable = new StatusTransitRunnable();
runnable.run();
job = jpaService.execute(new CoordJobGetJPAExecutor(ids[0]));
assertEquals(CoordinatorJob.Status.RUNNINGWITHERROR, job.getStatus());
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class TestCoordChangeXCommand method testCoordChangeConcurrency.
public void testCoordChangeConcurrency() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2013-08-01T00:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2013-08-01T04:59Z");
final CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.RUNNING, startTime, endTime, endTime, true, false, 4);
CoordinatorActionBean ca1 = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
CoordinatorActionBean ca2 = addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
CoordinatorActionBean ca3 = addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.READY, "coord-action-get.xml", 0);
CoordinatorActionBean ca4 = addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.READY, "coord-action-get.xml", 0);
new CoordChangeXCommand(job.getId(), "concurrency=4").call();
Thread.sleep(100);
ca1 = CoordActionQueryExecutor.getInstance().get(CoordActionQueryExecutor.CoordActionQuery.GET_COORD_ACTION, job.getId() + "@1");
ca2 = CoordActionQueryExecutor.getInstance().get(CoordActionQueryExecutor.CoordActionQuery.GET_COORD_ACTION, job.getId() + "@2");
ca3 = CoordActionQueryExecutor.getInstance().get(CoordActionQueryExecutor.CoordActionQuery.GET_COORD_ACTION, job.getId() + "@3");
ca4 = CoordActionQueryExecutor.getInstance().get(CoordActionQueryExecutor.CoordActionQuery.GET_COORD_ACTION, job.getId() + "@4");
assertEquals(CoordinatorAction.Status.RUNNING.toString(), ca1.getStatusStr());
assertEquals(CoordinatorAction.Status.RUNNING.toString(), ca2.getStatusStr());
assertEquals(CoordinatorAction.Status.READY.toString(), ca3.getStatusStr());
assertEquals(CoordinatorAction.Status.READY.toString(), ca4.getStatusStr());
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class TestCoordCommandUtils method createCoordinatorActionBean.
private CoordinatorActionBean createCoordinatorActionBean(CoordinatorJob job) throws IOException {
CoordinatorActionBean actionBean = new CoordinatorActionBean();
String actionId = Services.get().get(UUIDService.class).generateChildId(job.getId(), "1");
actionBean.setJobId(job.getId());
actionBean.setId(actionId);
Configuration jobConf = new XConfiguration(new StringReader(job.getConf()));
actionBean.setRunConf(XmlUtils.prettyPrint(jobConf).toString());
return actionBean;
}
Aggregations