use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestCoordActionInputCheckXCommand method checkCoordAction.
private CoordinatorActionBean checkCoordAction(String actionId, String expDeps, CoordinatorAction.Status stat) throws Exception {
try {
JPAService jpaService = Services.get().get(JPAService.class);
CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
String missDeps = action.getMissingDependencies();
assertEquals(expDeps, missDeps);
assertEquals(stat, action.getStatus());
return action;
} catch (JPAExecutorException se) {
throw new Exception("Action ID " + actionId + " was not stored properly in db");
}
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestCoordActionInputCheckXCommand method testActionInputCheckLatestCurrentTime.
public void testActionInputCheckLatestCurrentTime() throws Exception {
Services.get().getConf().setBoolean(CoordELFunctions.LATEST_EL_USE_CURRENT_TIME, true);
String jobId = "0000000-" + new Date().getTime() + "-TestCoordActionInputCheckXCommand-C";
Date startTime = DateUtils.parseDateOozieTZ("2009-02-15T23:59" + TZ);
Date endTime = DateUtils.parseDateOozieTZ("2009-02-16T23:59" + TZ);
CoordinatorJobBean job = addRecordToCoordJobTable(jobId, startTime, endTime, "latest");
new CoordMaterializeTransitionXCommand(job.getId(), 3600).call();
JPAService jpaService = Services.get().get(JPAService.class);
CoordinatorActionBean action = jpaService.execute(new CoordActionGetForInputCheckJPAExecutor(job.getId() + "@1"));
assertEquals(CoordCommandUtils.RESOLVED_UNRESOLVED_SEPARATOR + "${coord:latestRange(-3,0)}", action.getMissingDependencies());
// Update action creation time
String actionXML = action.getActionXml();
String actionCreationTime = "2009-02-15T01:00" + TZ;
actionXML = actionXML.replaceAll("action-actual-time=\".*\">", "action-actual-time=\"" + actionCreationTime + "\">");
action.setActionXml(actionXML);
action.setCreatedTime(DateUtils.parseDateOozieTZ(actionCreationTime));
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQueryExecutor.CoordActionQuery.UPDATE_COORD_ACTION_FOR_INPUTCHECK, action);
action = jpaService.execute(new CoordActionGetForInputCheckJPAExecutor(job.getId() + "@1"));
assertTrue(action.getActionXml().contains("action-actual-time=\"2009-02-15T01:00"));
// providing some of the dataset dirs required as per coordinator
// specification with holes
// before and after action creation time
createTestCaseSubDir("2009/03/05/_SUCCESS".split("/"));
createTestCaseSubDir("2009/02/19/_SUCCESS".split("/"));
createTestCaseSubDir("2009/02/12/_SUCCESS".split("/"));
createTestCaseSubDir("2009/02/05/_SUCCESS".split("/"));
createTestCaseSubDir("2009/01/22/_SUCCESS".split("/"));
createTestCaseSubDir("2009/01/08/_SUCCESS".split("/"));
new CoordActionInputCheckXCommand(job.getId() + "@1", job.getId()).call();
// Sleep for sometime as it gets requeued with 10ms delay on failure to acquire write lock
Thread.sleep(1000);
action = jpaService.execute(new CoordActionGetJPAExecutor(job.getId() + "@1"));
actionXML = action.getActionXml();
assertEquals("", action.getMissingDependencies());
// Datasets should be picked up based on current time and not action creation/actual time.
String resolvedList = getTestCaseFileUri("2009/03/05") + CoordELFunctions.INSTANCE_SEPARATOR + getTestCaseFileUri("2009/02/19") + CoordELFunctions.INSTANCE_SEPARATOR + getTestCaseFileUri("2009/02/12") + CoordELFunctions.INSTANCE_SEPARATOR + getTestCaseFileUri("2009/02/05");
assertEquals(resolvedList, actionXML.substring(actionXML.indexOf("<uris>") + 6, actionXML.indexOf("</uris>")));
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestReRunXCommand method testRerunWithExistingCoodConf.
// rerun should use existing coord conf
public void testRerunWithExistingCoodConf() throws Exception {
final OozieClient wfClient = LocalOozie.getClient();
Date start = DateUtils.parseDateOozieTZ("2009-12-15T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-12-16T01:00Z");
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
CoordinatorActionBean action = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUBMITTED, "coord-action-start-escape-strings.xml", 0);
String actionId = action.getId();
new CoordActionStartXCommand(actionId, getTestUser(), "myapp", "myjob").call();
final JPAService jpaService = Services.get().get(JPAService.class);
action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) {
fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)");
}
final String wfId = action.getExternalId();
wfClient.kill(wfId);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.KILLED;
}
});
Properties newConf = wfClient.createConfiguration();
newConf.setProperty(OozieClient.RERUN_FAIL_NODES, "true");
wfClient.reRun(wfId, newConf);
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(wfId).getStatus() == WorkflowJob.Status.SUCCEEDED;
}
});
assertEquals(WorkflowJob.Status.SUCCEEDED, wfClient.getJobInfo(wfId).getStatus());
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestCoordActionGetJPAExecutor method _testGetAction.
private void _testGetAction(String actionId) throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordActionGetJPAExecutor actionGetCmd = new CoordActionGetJPAExecutor(actionId);
CoordinatorActionBean ret = jpaService.execute(actionGetCmd);
assertNotNull(ret);
assertEquals(ret.getId(), actionId);
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestStatusTransitService method testCoordStatusTransitServiceKilledByUser1.
/**
* Tests functionality of the StatusTransitService Runnable command. </p> Insert a coordinator job with RUNNING and
* pending false and coordinator actions with pending false. Then, runs the CoordKillXCommand and
* StatusTransitService runnable and ensures the job pending changes to false.
*
* @throws Exception
*/
public void testCoordStatusTransitServiceKilledByUser1() throws Exception {
final JPAService jpaService = Services.get().get(JPAService.class);
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
final String wfJobId = wfJob.getId();
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJobId, "RUNNING", 0);
new CoordKillXCommand(coordJob.getId()).call();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
WorkflowJobGetJPAExecutor wfGetCmd = new WorkflowJobGetJPAExecutor(wfJobId);
WorkflowJobBean wfBean = jpaService.execute(wfGetCmd);
return wfBean.getStatusStr().equals("KILLED");
}
});
assertNotNull(jpaService);
final CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
WorkflowJobGetJPAExecutor wfGetCmd = new WorkflowJobGetJPAExecutor(wfJobId);
coordJob = jpaService.execute(coordJobGetCmd);
coordAction = jpaService.execute(coordActionGetCmd);
wfJob = jpaService.execute(wfGetCmd);
assertEquals(CoordinatorJob.Status.KILLED, coordJob.getStatus());
assertEquals(CoordinatorAction.Status.KILLED, coordAction.getStatus());
assertEquals(WorkflowJob.Status.KILLED, wfJob.getStatus());
assertEquals(false, coordAction.isPending());
Runnable runnable = new StatusTransitRunnable();
runnable.run();
// Status of coordJobBean is being updated asynchronously.
// Increasing wait time to atmost 10s to make sure there is
// sufficient time for the status to get updated. Thus, resulting
// in following assertion not failing.
waitFor(10 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean coordJobBean = jpaService.execute(coordJobGetCmd);
return !coordJobBean.isPending();
}
});
coordJob = jpaService.execute(coordJobGetCmd);
assertEquals(false, coordJob.isPending());
}
Aggregations