use of org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable in project oozie by apache.
the class TestCoordMaterializeTriggerService method testCoordMaterializeTriggerService1.
/**
* Tests functionality of the CoordMaterializeTriggerService Runnable
* command. </p> Insert a coordinator job with PREP. Then, runs the
* CoordMaterializeTriggerService runnable and ensures the job status
* changes to RUNNING.
*
* @throws Exception
*/
public void testCoordMaterializeTriggerService1() throws Exception {
Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-02-20T23:59Z");
final CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, start, end, false, false, 0);
waitForStatus(30000, job, CoordinatorJob.Status.PREP);
Runnable runnable = new CoordMaterializeTriggerRunnable(3600, 300);
runnable.run();
waitForStatus(10000, job, CoordinatorJob.Status.RUNNING);
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
CoordinatorJobBean coordJob = jpaService.execute(coordGetCmd);
assertEquals(CoordinatorJob.Status.RUNNING, coordJob.getStatus());
int numWaitingActions = jpaService.execute(new CoordJobGetRunningActionsCountJPAExecutor(coordJob.getId()));
assert (numWaitingActions <= coordJob.getMatThrottling());
}
use of org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable in project oozie by apache.
the class TestCoordMaterializeTriggerService method testMaxMatThrottleNotPicked.
public void testMaxMatThrottleNotPicked() throws Exception {
Services.get().destroy();
setSystemProperty(CoordMaterializeTriggerService.CONF_MATERIALIZATION_SYSTEM_LIMIT, "10");
services = new Services();
services.init();
jpaService = services.get(JPAService.class);
Date start = new Date();
Date end = new Date(start.getTime() + 3600 * 5 * 1000);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
job.setMatThrottling(3);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job);
job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
Date lastModifiedDate = job.getLastModifiedTime();
Runnable runnable = new CoordMaterializeTriggerRunnable(3600, 300);
runnable.run();
waitForModification(job.getId(), lastModifiedDate);
job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
assertNotSame(lastModifiedDate, job.getLastModifiedTime());
job.setMatThrottling(2);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job);
job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
lastModifiedDate = job.getLastModifiedTime();
runnable.run();
job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
assertEquals(lastModifiedDate, job.getLastModifiedTime());
}
use of org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable in project oozie by apache.
the class TestCoordMaterializeTriggerService method testCoordMaterializeTriggerService3.
public void testCoordMaterializeTriggerService3() throws Exception {
Services.get().destroy();
setSystemProperty(CoordMaterializeTriggerService.CONF_MATERIALIZATION_SYSTEM_LIMIT, "1");
services = new Services();
services.init();
jpaService = services.get(JPAService.class);
Date start = new Date();
Date end = new Date(start.getTime() + 3600 * 5 * 1000);
CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
addRecordToCoordActionTable(job1.getId(), 2, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
job1.setMatThrottling(1);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job1);
CoordinatorJobBean job2 = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, start, end, false, false, 0);
CoordinatorJobBean job3 = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, start, end, false, false, 0);
Runnable runnable = new CoordMaterializeTriggerRunnable(3600, 300);
runnable.run();
waitForStatus(10000, job2, CoordinatorJob.Status.RUNNING);
// second job is beyond limit but still should be picked up
job2 = jpaService.execute(new CoordJobGetJPAExecutor(job2.getId()));
assertEquals(CoordinatorJob.Status.RUNNING, job2.getStatus());
// third job not picked up because limit iteration only twice
job3 = jpaService.execute(new CoordJobGetJPAExecutor(job3.getId()));
assertEquals(CoordinatorJob.Status.PREP, job3.getStatus());
}
use of org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable in project oozie by apache.
the class TestCoordMaterializeTriggerService method testCoordMaterializeTriggerService2.
/**
* Test current mode. The job should be picked up for materialization.
*
* @throws Exception
*/
public void testCoordMaterializeTriggerService2() throws Exception {
Date start = new Date();
Date end = new Date(start.getTime() + 3600 * 48 * 1000);
final CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, start, end, false, false, 0);
waitForStatus(30000, job, CoordinatorJob.Status.PREP);
Runnable runnable = new CoordMaterializeTriggerRunnable(3600, 300);
runnable.run();
waitForStatus(10000, job, CoordinatorJob.Status.RUNNING);
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
CoordinatorJobBean coordJob = jpaService.execute(coordGetCmd);
assertEquals(CoordinatorJob.Status.RUNNING, coordJob.getStatus());
}
use of org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable in project oozie by apache.
the class TestCoordMaterializeTriggerService method testMaxMatThrottleNotPickedMultipleJobs.
public void testMaxMatThrottleNotPickedMultipleJobs() throws Exception {
Services.get().destroy();
setSystemProperty(CoordMaterializeTriggerService.CONF_MATERIALIZATION_SYSTEM_LIMIT, "3");
services = new Services();
services.init();
jpaService = services.get(JPAService.class);
Date start = new Date();
Date end = new Date(start.getTime() + 3600 * 5 * 1000);
CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
addRecordToCoordActionTable(job1.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job1.getId(), 2, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
job1.setMatThrottling(3);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job1);
CoordinatorJobBean job2 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
addRecordToCoordActionTable(job2.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job2.getId(), 2, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
job2.setMatThrottling(3);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job2);
CoordinatorJobBean job3 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
addRecordToCoordActionTable(job3.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job3.getId(), 2, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
job3.setMatThrottling(2);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job3);
job1 = jpaService.execute(new CoordJobGetJPAExecutor(job1.getId()));
Date lastModifiedDate1 = job1.getLastModifiedTime();
job2 = jpaService.execute(new CoordJobGetJPAExecutor(job2.getId()));
Date lastModifiedDate2 = job2.getLastModifiedTime();
job3 = jpaService.execute(new CoordJobGetJPAExecutor(job3.getId()));
Date lastModifiedDate3 = job3.getLastModifiedTime();
Runnable runnable = new CoordMaterializeTriggerRunnable(3600, 300);
runnable.run();
waitForModification(job1.getId(), lastModifiedDate1);
waitForModification(job2.getId(), lastModifiedDate2);
waitForModification(job3.getId(), lastModifiedDate3);
job1 = jpaService.execute(new CoordJobGetJPAExecutor(job1.getId()));
assertNotSame(lastModifiedDate1, job1.getLastModifiedTime());
job2 = jpaService.execute(new CoordJobGetJPAExecutor(job2.getId()));
assertNotSame(lastModifiedDate2, job2.getLastModifiedTime());
job3 = jpaService.execute(new CoordJobGetJPAExecutor(job3.getId()));
assertEquals(lastModifiedDate3, job3.getLastModifiedTime());
}
Aggregations