Search in sources :

Example 31 with CoordJobGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor 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");
    }
}
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 32 with CoordJobGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.

the class TestCoordMaterializeTransitionXCommand method testFailedJobNotMaterializeActions.

/**
 * Test a coordinator does not materialize actions upon CommandException
 * leading to FAILED state
 *
 * @throws Exception
 */
public void testFailedJobNotMaterializeActions() throws Exception {
    String coordXml = "<coordinator-app xmlns=\"uri:oozie:coordinator:0.4\"" + " name=\"NAME\" frequency=\"5\"" + " start=\"#start\" end=\"#end\" timezone=\"America/Los_Angeles\"" + " freq_timeunit=\"DAY\" end_of_duration=\"NONE\">" + "<input-events>" + "<data-in name=\"a\" dataset=\"a\">" + "<dataset name=\"a\" frequency=\"7\" initial-instance=\"2010-01-01T00:00Z\" timezone=\"UTC\" " + "freq_timeunit=\"MINUTE\" end_of_duration=\"NONE\">" + "<uri-template>${hcatNode}/${db}/${table}/ds=${YEAR}-${MONTH}-${DAY};region=${region}</uri-template>" + "</dataset>" + "<start-instance>${coord:current(0)}</start-instance>" + "<end-instance>${coord:latest(0)}</end-instance>" + "</data-in>" + "</input-events>" + "<action>" + "<workflow>" + "<app-path>hdfs:///tmp/workflows/</app-path>" + "</workflow>" + "</action>" + "</coordinator-app>";
    CoordinatorJobBean job = addRecordToCoordJobTable(coordXml);
    new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
    JPAService jpaService = Services.get().get(JPAService.class);
    job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
    assertEquals(CoordinatorJob.Status.FAILED, job.getStatus());
    // GetActions for coord job, should be none
    int actions = jpaService.execute(new CoordJobGetActionsJPAExecutor(job.getId()));
    assertEquals(0, actions);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetActionsJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetActionsJPAExecutor) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 33 with CoordJobGetJPAExecutor

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

Example 34 with CoordJobGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.

the class TestCoordMaterializeTransitionXCommand method testActionMaterWithCronFrequency2.

public void testActionMaterWithCronFrequency2() 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, "10-20 * * * *");
    new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
    Date[] nominalTimes = new Date[] { DateUtils.parseDateOozieTZ("2013-07-18T00:10Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:11Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:12Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:13Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:14Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:15Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:16Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:17Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:18Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:19Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:20Z") };
    final int expectedNominalTimeCount = 11;
    checkCoordActionsNominalTime(job.getId(), expectedNominalTimeCount, nominalTimes);
    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-18T01:10Z"));
    } catch (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 35 with CoordJobGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.

the class TestCoordMaterializeTransitionXCommand method testActionMaterWithDST2.

public void testActionMaterWithDST2() throws Exception {
    Date startTime = DateUtils.parseDateOozieTZ("2012-11-04T07:00Z");
    Date endTime = DateUtils.parseDateOozieTZ("2012-11-04T11:00Z");
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, null, "0 * * * *");
    new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(4)).call();
    Date[] nominalTimes = new Date[] { DateUtils.parseDateOozieTZ("2012-11-04T07:00Z"), DateUtils.parseDateOozieTZ("2012-11-04T08:00Z"), DateUtils.parseDateOozieTZ("2012-11-04T09:00Z"), DateUtils.parseDateOozieTZ("2012-11-04T10:00Z"), DateUtils.parseDateOozieTZ("2012-11-04T11:00Z") };
    final int expectedNominalTimeCount = 5;
    checkCoordActionsNominalTime(job.getId(), expectedNominalTimeCount, nominalTimes);
    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("2012-11-04T12:00Z"));
    } catch (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)

Aggregations

CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)121 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)114 JPAService (org.apache.oozie.service.JPAService)85 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)79 Date (java.util.Date)66 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)42 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)32 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)30 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)29 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)25 BundleJobBean (org.apache.oozie.BundleJobBean)21 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)21 BundleActionBean (org.apache.oozie.BundleActionBean)20 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)20 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)20 CommandException (org.apache.oozie.command.CommandException)18 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)16 IOException (java.io.IOException)5 CoordMaterializeTriggerRunnable (org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable)5 Services (org.apache.oozie.service.Services)5