Search in sources :

Example 61 with CoordinatorJobBean

use of org.apache.oozie.CoordinatorJobBean 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 62 with CoordinatorJobBean

use of org.apache.oozie.CoordinatorJobBean 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 63 with CoordinatorJobBean

use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.

the class TestCoordMaterializeTransitionXCommand method testMatThrottle.

public void testMatThrottle() 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();
    checkCoordWaiting(job.getId(), job.getMatThrottling());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) Date(java.util.Date)

Example 64 with CoordinatorJobBean

use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.

the class TestCoordMaterializeTransitionXCommand method testCurrentTimeCheck.

public void testCurrentTimeCheck() throws Exception {
    long now = System.currentTimeMillis();
    // now
    Date startTime = DateUtils.toDate(new Timestamp(now));
    // 3 secondsFromHours from now
    Date endTime = DateUtils.toDate(new Timestamp(now + 3 * 60 * 60 * 1000));
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, null, "5", 20);
    new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
    checkCoordJobs(job.getId(), CoordinatorJob.Status.RUNNING);
    job = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job.getId());
    assertEquals(job.getLastActionNumber(), 12);
    new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
    // unfortunatily XCommand doesn't throw exception on precondition
    // assertEquals(e.getErrorCode(), ErrorCode.E1100);
    // assertTrue(e.getMessage().contains("Request is for future time. Lookup time is"));
    job = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job.getId());
    // getLastActionNumber should 12, last CoordMaterializeTransitionXCommand have failed
    assertEquals(job.getLastActionNumber(), 12);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 65 with CoordinatorJobBean

use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.

the class TestCoordMaterializeTransitionXCommand method testMatLookupCommand2.

/**
 * Test a coordinator job that will run in far future,
 * materialization should not happen.
 * @throws Exception
 */
public void testMatLookupCommand2() throws Exception {
    Date startTime = DateUtils.parseDateOozieTZ("2099-02-01T01:00Z");
    Date endTime = DateUtils.parseDateOozieTZ("2099-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.PREP);
}
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