Search in sources :

Example 31 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestCoordRerunXCommand method testCoordRerunForBackwardSupport3.

/**
 * Tests functionality of the coord rerun for backward support is true. </p> Insert a coordinator job with SUCCEEDED
 * and coordinator actions with pending false. However, job's doneMaterialization is false to imitate update from
 * 2.x to 3.0.1.
 * Set oozie.service.StatusTransitService.backward.support.for.coord.status=true
 * and use uri:oozie:coordinator:0.1 namespace, then, rerun the coord job for action 1 and action 2.
 *
 * @throws Exception
 */
public void testCoordRerunForBackwardSupport3() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
    services = new Services();
    services.init();
    Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
    Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, start, end, false, false, 3);
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    coordJob.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_APPNAMESPACE, coordJob);
    CoordinatorActionBean action1 = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
    CoordinatorActionBean action2 = addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
    CoordinatorActionBean action3 = addRecordToCoordActionTable(coordJob.getId(), 3, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
    String rerunScope = Integer.toString(1) + "-" + Integer.toString(2);
    final OozieClient coordClient = LocalOozie.getCoordClient();
    coordClient.reRunCoord(coordJob.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, rerunScope, false, true);
    coordJob = getCoordinatorJob(coordJob.getId());
    assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
    action1 = getCoordinatorAction(action1.getId());
    assertNotSame(action1.getStatus(), CoordinatorAction.Status.SUCCEEDED);
    action2 = getCoordinatorAction(action2.getId());
    assertNotSame(action2.getStatus(), CoordinatorAction.Status.SUCCEEDED);
}
Also used : Services(org.apache.oozie.service.Services) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Example 32 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestCoordResumeXCommand method testCoordSuspendWithErrorAndResumeWithErrorForRunning.

/**
 * Test : suspend a RUNNINGWITHERROR coordinator job and check the status to RUNNINGWITHERROR on resume
 *
 * @throws Exception
 */
public void testCoordSuspendWithErrorAndResumeWithErrorForRunning() throws Exception {
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNINGWITHERROR, false, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
    new CoordSuspendXCommand(job.getId()).call();
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
    new CoordResumeXCommand(job.getId()).call();
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 33 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestCoordSuspendXCommand method testCoordSuspendWithErrorPostive2.

/**
 * Test : suspend a PAUSEDWITHERROR coordinator job
 *
 * @throws Exception
 */
public void testCoordSuspendWithErrorPostive2() throws Exception {
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PAUSEDWITHERROR, false, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.PAUSEDWITHERROR);
    new CoordSuspendXCommand(job.getId()).call();
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 34 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestCoordSuspendXCommand method testCoordSuspendNegative.

/**
 * Negative Test : suspend a SUCCEEDED coordinator job
 *
 * @throws Exception
 */
public void testCoordSuspendNegative() throws Exception {
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
    new CoordSuspendXCommand(job.getId()).call();
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 35 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestCoordWfActionInfoXCommand method createTestData.

/**
 * init the test case.
 * 1 coordJob
 * 5 coordAction created by the coordJob, while the 5th coordAction's workflow instance is null
 * 4 wfJob match the 1st ~ 4th coordAction
 * the 1st - 3rd wfAction has a wfAction named 'aa' each, but the 4th desn't.
 */
private void createTestData() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull("Missing jpa service", jpaService);
    coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    wfJobs = new ArrayList<WorkflowJobBean>();
    coordActions = new ArrayList<CoordinatorActionBean>();
    for (int i = 0; i < 4; i++) {
        WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
        wfJobs.add(wfJob);
    }
    for (int i = 0; i < 4; i++) {
        CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), (i + 1), CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobs.get(i).getId(), "SUCCEEDED", 0);
        coordActions.add(coordAction);
    }
    // add a coordAction that doesnt create workflow instance yet
    CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 5, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", null, null, 0);
    coordActions.add(coordAction);
    // set the NominalTime,in order to keep the order of the coordAction.
    for (int i = 0; i < 5; i++) {
        setCoordActionNominalTime(coordActions.get(i).getId(), (i + 1) * 1000);
    }
    // create the case that the 4th wfJob doesnt have a action named "aa"
    for (int i = 0; i < 4; i++) {
        String name = (i == 3) ? "bb" : "aa";
        addRecordToWfActionTable(wfJobs.get(i).getId(), name, WorkflowAction.Status.DONE);
    }
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Aggregations

JPAService (org.apache.oozie.service.JPAService)449 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)156 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)152 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)113 Date (java.util.Date)95 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)94 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)84 BundleJobBean (org.apache.oozie.BundleJobBean)78 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)78 ArrayList (java.util.ArrayList)76 CommandException (org.apache.oozie.command.CommandException)66 List (java.util.List)59 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)54 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)54 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)49 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)47 HashMap (java.util.HashMap)41 BundleActionBean (org.apache.oozie.BundleActionBean)35 Configuration (org.apache.hadoop.conf.Configuration)32 EntityManager (javax.persistence.EntityManager)31