Search in sources :

Example 71 with CoordinatorJobBean

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);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) Date(java.util.Date)

Example 72 with CoordinatorJobBean

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);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) Date(java.util.Date)

Example 73 with CoordinatorJobBean

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());
    }
}
Also used : Services(org.apache.oozie.service.Services) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) ParseException(java.text.ParseException) CommandException(org.apache.oozie.command.CommandException)

Example 74 with CoordinatorJobBean

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");
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Example 75 with CoordinatorJobBean

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"));
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) Date(java.util.Date)

Aggregations

CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)373 Date (java.util.Date)177 JPAService (org.apache.oozie.service.JPAService)153 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)149 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)121 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)114 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)53 CommandException (org.apache.oozie.command.CommandException)49 BundleJobBean (org.apache.oozie.BundleJobBean)46 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)43 IOException (java.io.IOException)39 XConfiguration (org.apache.oozie.util.XConfiguration)38 ArrayList (java.util.ArrayList)36 BundleActionBean (org.apache.oozie.BundleActionBean)36 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)34 Configuration (org.apache.hadoop.conf.Configuration)33 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)32 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)30 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)30 Path (org.apache.hadoop.fs.Path)24