Search in sources :

Example 1 with CoordJobGetActionsJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetActionsJPAExecutor 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 2 with CoordJobGetActionsJPAExecutor

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

the class TestCoordMaterializeTransitionXCommand method checkCoordActions.

private void checkCoordActions(String jobId, int number, CoordinatorJob.Status status) {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        Integer actionsSize = jpaService.execute(new CoordJobGetActionsJPAExecutor(jobId));
        if (actionsSize != number) {
            fail("Should have " + number + " actions created for job " + jobId + ", but has " + actionsSize + " actions.");
        }
        if (status != null) {
            CoordinatorJob job = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
            if (job.getStatus() != status) {
                fail("Job status " + job.getStatus() + " should be " + status);
            }
        }
    } catch (JPAExecutorException se) {
        se.printStackTrace();
        fail("Job ID " + jobId + " was not stored properly in db");
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobGetActionsJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetActionsJPAExecutor) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Aggregations

CoordJobGetActionsJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetActionsJPAExecutor)2 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)2 JPAService (org.apache.oozie.service.JPAService)2 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)1 CoordinatorJob (org.apache.oozie.client.CoordinatorJob)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1