use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordCommandUtils method addRecordToCoordJobTable.
protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date startTime, Date endTime, String freq) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, startTime, endTime, false, false, 0);
coordJob.setStartTime(startTime);
coordJob.setEndTime(endTime);
coordJob.setFrequency(freq);
coordJob.setTimeUnit(CoordinatorJob.Timeunit.MINUTE);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
jpaService.execute(coordInsertCmd);
} catch (JPAExecutorException ex) {
ex.printStackTrace();
fail("Unable to insert the test coord job record to table");
throw ex;
}
return coordJob;
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordELExtensions method testCoordELActionMater.
public void testCoordELActionMater() throws Exception {
Date startTime = DateUtils.parseDateUTC("2009-03-06T010:00Z");
Date endTime = DateUtils.parseDateUTC("2009-03-07T12:00Z");
CoordinatorJobBean job = createCoordJob("coord-job-for-elext.xml", CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
addRecordToCoordJobTable(job);
new CoordMaterializeTransitionXCommand(job.getId(), 3600).call();
checkCoordAction(job.getId() + "@1");
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordKillXCommand method testCoordKillSuccess1.
/**
* Test : kill job and action (READY) successfully
*
* @throws Exception
*/
public void testCoordKillSuccess1() throws Exception {
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 0);
CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.READY, "coord-action-get.xml", 0);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(action.getId());
job = jpaService.execute(coordJobGetCmd);
action = jpaService.execute(coordActionGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNING);
assertEquals(action.getStatus(), CoordinatorAction.Status.READY);
assertFalse(job.isDoneMaterialization());
new CoordKillXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
action = jpaService.execute(coordActionGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.KILLED);
assertTrue(job.isDoneMaterialization());
assertNotNull(job.getLastModifiedTime());
assertEquals(action.getStatus(), CoordinatorAction.Status.KILLED);
// Change job status to RUNNINGWITHERROR to simulate StatusTransitService changing it to
// RUNNINGWITHERROR if it had loaded status and had it as RUNNING in memory when CoordKill
// executes and updates status to KILLED in database.
job.setStatus(CoordinatorJob.Status.RUNNINGWITHERROR);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_STATUS, job);
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
final CoordMaterializeTransitionXCommand transitionCmd = new CoordMaterializeTransitionXCommand(job.getId(), 3600);
try {
transitionCmd.loadState();
transitionCmd.verifyPrecondition();
fail();
} catch (PreconditionException e) {
// Materialization should not happen as done materialization is set to true by coord kill
}
StatusTransitService.StatusTransitRunnable statusTransit = new StatusTransitService.StatusTransitRunnable();
statusTransit.run();
// StatusTransitService should change the job back to KILLED
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.KILLED);
assertTrue(job.isDoneMaterialization());
assertNotNull(job.getLastModifiedTime());
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordKillXCommand method testCoordKillSuccess2.
/**
* Test : kill job and action (RUNNING) successfully
*
* @throws Exception
*/
public void testCoordKillSuccess2() throws Exception {
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, true, 0);
CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(action.getId());
job = jpaService.execute(coordJobGetCmd);
action = jpaService.execute(coordActionGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNING);
assertEquals(action.getStatus(), CoordinatorAction.Status.RUNNING);
new CoordKillXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
action = jpaService.execute(coordActionGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.KILLED);
assertNotNull(job.getLastModifiedTime());
assertEquals(action.getStatus(), CoordinatorAction.Status.KILLED);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordKillXCommand method testCoordKillRemovePushMissingDeps.
public void testCoordKillRemovePushMissingDeps() throws Exception {
try {
services.destroy();
services = super.setupServicesForHCatalog();
services.init();
String db = "default";
String table = "tablename";
String server = "hcatserver";
String newHCatDependency1 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=brazil";
String newHCatDependency2 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=usa";
String pushMissingDeps = newHCatDependency1 + CoordELFunctions.INSTANCE_SEPARATOR + newHCatDependency2;
PartitionDependencyManagerService pdms = Services.get().get(PartitionDependencyManagerService.class);
CoordinatorJobBean job = addRecordToCoordJobTableForWaiting("coord-job-for-action-input-check.xml", CoordinatorJob.Status.RUNNING, false, true);
CoordinatorActionBean action1 = addRecordToCoordActionTableForWaiting(job.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-for-action-input-check.xml", null, pushMissingDeps, "Z");
String newHCatDependency3 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=russia";
CoordinatorActionBean action2 = addRecordToCoordActionTableForWaiting(job.getId(), 2, CoordinatorAction.Status.WAITING, "coord-action-for-action-input-check.xml", null, newHCatDependency3, "Z");
HCatURI hcatURI1, hcatURI2, hcatURI3;
hcatURI1 = new HCatURI(newHCatDependency1);
hcatURI2 = new HCatURI(newHCatDependency2);
hcatURI3 = new HCatURI(newHCatDependency3);
pdms.addMissingDependency(hcatURI1, action1.getId());
pdms.addMissingDependency(hcatURI2, action1.getId());
pdms.addMissingDependency(hcatURI3, action2.getId());
assertTrue(pdms.getWaitingActions(new HCatURI(newHCatDependency1)).contains(action1.getId()));
assertTrue(pdms.getWaitingActions(new HCatURI(newHCatDependency2)).contains(action1.getId()));
assertTrue(pdms.getWaitingActions(new HCatURI(newHCatDependency3)).contains(action2.getId()));
new CoordKillXCommand(job.getId()).call();
assertNull(pdms.getWaitingActions(new HCatURI(newHCatDependency1)));
assertNull(pdms.getWaitingActions(new HCatURI(newHCatDependency2)));
assertNull(pdms.getWaitingActions(new HCatURI(newHCatDependency3)));
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations