use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.
the class TestStatusTransitService method testCoordStatusTransitServicePausedWithError.
/**
* Test : all coord actions are running, job pending is reset
*
* @throws Exception
*/
public void testCoordStatusTransitServicePausedWithError() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
services = new Services();
setClassesToBeExcluded(services.getConf(), excludedServices);
services.init();
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean job = createCoordJob(CoordinatorJob.Status.PAUSEDWITHERROR, start, end, true, false, 3);
// set the pause time explicity to make sure the job is not unpaused
job.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
final JPAService jpaService = Services.get().get(JPAService.class);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(job);
jpaService.execute(coordInsertCmd);
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
final String jobId = job.getId();
assertNotNull(jpaService);
Runnable runnable = new StatusTransitRunnable();
runnable.run();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
return coordJob.isPending() == false;
}
});
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordGetCmd);
assertFalse(job.isPending());
assertEquals(CoordinatorJob.Status.PAUSED, job.getStatus());
}
use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.
the class TestPauseTransitService method addRecordToCoordJobTable.
protected CoordinatorJobBean addRecordToCoordJobTable(String coordId, CoordinatorJob.Status status, Date start, Date end, boolean pending) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, start, end, pending, false, 0);
coordJob.setId(coordId);
coordJob.setAppName(coordId);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
jpaService.execute(coordInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test coord job record to table");
throw je;
}
return coordJob;
}
use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.
the class XDataTestCase method addRecordToCoordJobTable.
protected CoordinatorJobBean addRecordToCoordJobTable(String appXml) throws Exception {
Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-02-03T23:59Z");
appXml = appXml.replaceAll("#start", DateUtils.formatDateOozieTZ(start));
appXml = appXml.replaceAll("#end", DateUtils.formatDateOozieTZ(end));
Path appPath = new Path(getFsTestCaseDir(), "coord");
writeToFile(appXml, appPath, "coordinator.xml");
CoordinatorJobBean coordJob = createCoordBean(appPath, appXml, CoordinatorJob.Status.PREP, start, end, false, false, 0);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
jpaService.execute(coordInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test coord job record to table");
throw je;
}
return coordJob;
}
use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.
the class XDataTestCase method addRecordToCoordJobTable.
/**
* Inserts the passed coord job
* @param coord job bean
* @throws Exception
*/
protected void addRecordToCoordJobTable(CoordinatorJobBean coordJob) throws Exception {
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
jpaService.execute(coordInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test coord job record to table");
throw je;
}
}
use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.
the class XDataTestCase method addRecordToCoordJobTable.
/**
* Insert coord job for testing.
*
* @param status coord job status
* @param start start time
* @param end end time
* @param created Time
* @param pending true if pending is true
* @param doneMatd true if doneMaterialization is true
* @param lastActionNum last action number
* @return coord job bean
* @throws Exception
*/
protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date start, Date end, Date createdTime, boolean pending, boolean doneMatd, int lastActionNum) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, start, end, createdTime, pending, doneMatd, lastActionNum);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
jpaService.execute(coordInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test coord job record to table");
throw je;
}
return coordJob;
}
Aggregations