use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestCoordChangeXCommand method checkCoordJobs.
private void checkCoordJobs(String jobId, Date endTime, Integer concurrency, Date pauseTime, boolean checkPauseTime) throws StoreException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(jobId);
CoordinatorJobBean job = null;
job = jpaService.execute(coordGetCmd);
if (endTime != null) {
Date d = job.getEndTime();
if (d.compareTo(endTime) != 0) {
fail("Endtime is not updated properly job_end_time=" + d + ", expected_end_time=" + endTime);
}
CoordinatorJob.Status status = job.getStatus();
if (status != CoordinatorJob.Status.RUNNING) {
fail("Coordinator job's status is not updated properly");
}
}
if (concurrency != null) {
int c = job.getConcurrency();
if (c != concurrency) {
fail("Concurrency is not updated properly");
}
}
if (checkPauseTime) {
Date d = job.getPauseTime();
if (pauseTime == null) {
if (d != null) {
fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time=" + pauseTime);
}
} else {
if (d.compareTo(pauseTime) != 0) {
fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time=" + pauseTime);
}
}
}
} catch (JPAExecutorException e) {
e.printStackTrace();
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestCoordChangeXCommand method addRecordToCoordJobTableForPauseTimeTest.
protected CoordinatorJobBean addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status status, Date start, Date end, Date lastActionTime, boolean pending, boolean doneMatd, int lastActionNum) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, start, end, pending, doneMatd, lastActionNum);
coordJob.setFrequency("1");
coordJob.setTimeUnit(Timeunit.HOUR);
coordJob.setLastActionNumber(lastActionNum);
coordJob.setLastActionTime(lastActionTime);
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.JPAExecutorException 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.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testActionMaterWithCronFrequency3.
public void testActionMaterWithCronFrequency3() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2013-07-18T00:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2013-07-18T01:00Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, null, "0/15 2 * 5-7 4,5");
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
final int expectedNominalTimeCount = 0;
checkCoordActionsNominalTime(job.getId(), expectedNominalTimeCount, new Date[] {});
try {
JPAService jpaService = Services.get().get(JPAService.class);
job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
assertTrue(job.isDoneMaterialization());
assertEquals(job.getLastActionNumber(), expectedNominalTimeCount);
assertEquals(job.getNextMaterializedTime(), DateUtils.parseDateOozieTZ("2013-07-18T02:00Z"));
} catch (JPAExecutorException se) {
se.printStackTrace();
fail("Job ID " + job.getId() + " was not stored properly in db");
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method checkTwoActionsAfterCatchup.
private void checkTwoActionsAfterCatchup(CoordinatorJobBean job) throws ParseException {
try {
final JPAService jpaService = Services.get().get(JPAService.class);
job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
assertTrue("coordinator job should have already been materialized", job.isDoneMaterialization());
assertEquals("coordinator action count mismatch", 2, job.getLastActionNumber());
final String startPlusThreeHours = "2013-03-10T10:00Z";
assertEquals("coordinator next materialization time mismatch", DateUtils.parseDateOozieTZ(startPlusThreeHours), job.getNextMaterializedTime());
} catch (final JPAExecutorException se) {
se.printStackTrace();
fail("Job ID " + job.getId() + " was not stored properly in db");
}
}
Aggregations