use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestPauseTransitService method testPauseCoordinatorForBackwardSupport.
/**
* Test : Pause a RUNNING coordinator, but set oozie.service.StatusTransitService.backward.support.for.coord.status=true
* and use uri:oozie:coordinator:0.1 namespace, the status should not be changed to PAUSED
*
* @throws Exception
*/
public void testPauseCoordinatorForBackwardSupport() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
services = new Services();
setClassesToBeExcluded(services.getConf(), excludedServices);
services.init();
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Date pauseTime = new Date(new Date().getTime() - 30 * 1000);
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean coordJob1 = addRecordToCoordJobTable("action1", CoordinatorJob.Status.RUNNING, start, end, false);
CoordinatorJobBean coordJob2 = addRecordToCoordJobTable("action2", CoordinatorJob.Status.RUNNING, start, end, false);
coordJob1.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
coordJob1.setPauseTime(pauseTime);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob1);
coordJob2.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
coordJob2.setPauseTime(pauseTime);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob2);
Runnable pauseStartRunnable = new PauseTransitRunnable();
pauseStartRunnable.run();
final String coordJobId1 = coordJob1.getId();
final String coordJobId2 = coordJob2.getId();
waitFor(10 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean cJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
return cJob1.getStatus() == Job.Status.RUNNING;
}
});
coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
assertEquals(Job.Status.RUNNING, coordJob1.getStatus());
coordJob2 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId2));
assertEquals(Job.Status.RUNNING, coordJob2.getStatus());
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class CoordChangeXCommand method loadState.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#loadState()
*/
@Override
protected void loadState() throws CommandException {
jpaService = Services.get().get(JPAService.class);
if (jpaService == null) {
throw new CommandException(ErrorCode.E0610);
}
try {
this.coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
oldPauseTime = coordJob.getPauseTime();
prevStatus = coordJob.getStatus();
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
LogUtils.setLogInfo(this.coordJob);
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordResumeXCommand method testCoordSuspendWithErrorAndResumeWithErrorForRunning.
/**
* Test : suspend a RUNNINGWITHERROR coordinator job and check the status to RUNNINGWITHERROR on resume
*
* @throws Exception
*/
public void testCoordSuspendWithErrorAndResumeWithErrorForRunning() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNINGWITHERROR, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
new CoordResumeXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordSuspendXCommand method testCoordSuspendWithErrorPostive2.
/**
* Test : suspend a PAUSEDWITHERROR coordinator job
*
* @throws Exception
*/
public void testCoordSuspendWithErrorPostive2() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PAUSEDWITHERROR, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.PAUSEDWITHERROR);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestCoordSuspendXCommand method testCoordSuspendNegative.
/**
* Negative Test : suspend a SUCCEEDED coordinator job
*
* @throws Exception
*/
public void testCoordSuspendNegative() throws Exception {
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
new CoordSuspendXCommand(job.getId()).call();
job = jpaService.execute(coordJobGetCmd);
assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
}
Aggregations