use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testCronFrequencyCatchupThrottleEqualsDurationDSTChange.
public void testCronFrequencyCatchupThrottleEqualsDurationDSTChange() throws Exception {
final String startInThePast = "2013-03-10T08:00Z";
final Date startTimeBeforeDSTChange = DateUtils.parseDateOozieTZ(startInThePast);
final String startPlusTwoHoursAndSome = "2013-03-10T10:01Z";
final Date endTimeAfterDSTChange = DateUtils.parseDateOozieTZ(startPlusTwoHoursAndSome);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, startTimeBeforeDSTChange, endTimeAfterDSTChange, false, false, 0);
job.setNextMaterializedTime(startTimeBeforeDSTChange);
job.setMatThrottling(3);
final String everyHour = "0 * * * *";
job.setFrequency(everyHour);
job.setTimeUnit(Timeunit.CRON);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job);
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
final String startPlusOneHour = "2013-03-10T09:00Z";
final Date[] nominalTimesWithDSTChange = new Date[] { DateUtils.parseDateOozieTZ(startInThePast), DateUtils.parseDateOozieTZ(startPlusOneHour) };
checkCoordActionsNominalTime(job.getId(), 2, nominalTimesWithDSTChange);
checkTwoActionsAfterCatchup(job);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testMatLookupCommand1.
public void testMatLookupCommand1() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2009-02-03T23:59Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, startTime, endTime, false, false, 0);
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
checkCoordJobs(job.getId(), CoordinatorJob.Status.RUNNING);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testActionMaterForHcatalogIncorrectURI.
public void testActionMaterForHcatalogIncorrectURI() throws Exception {
Services.get().destroy();
Services services = super.setupServicesForHCatalog();
services.init();
Date startTime = DateUtils.parseDateOozieTZ("2009-03-06T010:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2009-03-11T10:00Z");
CoordinatorJobBean job = addRecordToCoordJobTableForWaiting("coord-job-for-matd-neg-hcat.xml", CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
try {
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
fail("Expected Command exception but didn't catch any");
} catch (CommandException e) {
e.printStackTrace();
job = services.get(JPAService.class).execute(new CoordJobGetJPAExecutor(job.getId()));
assertEquals(CoordinatorJob.Status.FAILED, job.getStatus());
assertEquals(ErrorCode.E1012, e.getErrorCode());
} catch (Exception e) {
fail("Unexpected exception " + e.getMessage());
}
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testCronFrequencyCatchupThrottleLessThanDuration.
public void testCronFrequencyCatchupThrottleLessThanDuration() throws Exception {
final String startInThePast = "2013-03-10T08:00Z";
final String startPlusOneDay = "2013-03-11T08:00Z";
final Date startTime = DateUtils.parseDateOozieTZ(startInThePast);
final Date endTime = DateUtils.parseDateOozieTZ(startPlusOneDay);
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, startTime, endTime, false, false, 0);
job.setNextMaterializedTime(startTime);
job.setMatThrottling(3);
final String everyHour = "0 * * * *";
job.setFrequency(everyHour);
job.setTimeUnit(Timeunit.CRON);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job);
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
final String startPlusOneHour = "2013-03-10T09:00Z";
final String startPlusTwoHours = "2013-03-10T10:00Z";
final Date[] nominalTimes = new Date[] { DateUtils.parseDateOozieTZ(startInThePast), DateUtils.parseDateOozieTZ(startPlusOneHour), DateUtils.parseDateOozieTZ(startPlusTwoHours) };
final int expectedNominalTimeCount = 3;
checkCoordActionsNominalTime(job.getId(), expectedNominalTimeCount, nominalTimes);
try {
final JPAService jpaService = Services.get().get(JPAService.class);
job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
assertFalse("coordinator job shouldn't have yet been materialized", job.isDoneMaterialization());
assertEquals("coordinator action count mismatch", expectedNominalTimeCount, job.getLastActionNumber());
final String startPlusThreeHours = "2013-03-10T11: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");
}
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testGetDryrun.
public void testGetDryrun() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2009-03-06T10:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2009-03-06T10:14Z");
CoordinatorJobBean job = createCoordJob(CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
job.setFrequency("5");
job.setTimeUnit(Timeunit.MINUTE);
job.setMatThrottling(20);
String dryRunOutput = new CoordMaterializeTransitionXCommand(job, hoursToSeconds(1), startTime, endTime).materializeActions(true);
String[] actions = dryRunOutput.split("action for new instance");
assertEquals(3, actions.length - 1);
for (int i = 1; i < actions.length; i++) {
assertTrue(actions[i].contains("action-nominal-time"));
}
}
Aggregations