Search in sources :

Example 16 with CoordinatorJobBean

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

the class TestStatusTransitService method testCoordStatusTransitServiceKilledByUser2.

/**
 * Test : coord job killed by user - pending update to false
 *
 * @throws Exception
 */
public void testCoordStatusTransitServiceKilledByUser2() throws Exception {
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.KILLED, start, end, true, false, 3);
    addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
    final String jobId = job.getId();
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
            return coordJob.isPending() == false;
        }
    });
    CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordGetCmd);
    assertFalse(job.isPending());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 17 with CoordinatorJobBean

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

the class TestStatusTransitService method testCoordStatusTransitServiceNoDoneWithErrorForBackwardSupport.

/**
 * Tests functionality of the StatusTransitService Runnable command. </p> Insert a coordinator job with RUNNING and
 * pending true and coordinator actions with pending false, but one of action is KILLED.
 * Set oozie.service.StatusTransitService.backward.support.for.coord.status=true
 * and use uri:oozie:coordinator:0.1 namespace, then, runs the StatusTransitService runnable and
 * ensures the job status stay in RUNNING.
 *
 * @throws Exception
 */
public void testCoordStatusTransitServiceNoDoneWithErrorForBackwardSupport() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
    services = new Services();
    setClassesToBeExcluded(services.getConf(), excludedServices);
    services.init();
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, true, 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);
    addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(coordJob.getId(), 3, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    sleep(1000);
    CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
    coordJob = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorJob.Status.RUNNING, coordJob.getStatus());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) Date(java.util.Date)

Example 18 with CoordinatorJobBean

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

the class TestStatusTransitService method testCoordStatusTransitServiceSuspendedBottomUp.

/**
 * Test : coord actions suspended and 1 succeeded - check status change to SUSPENDED and pending update to false
 *
 * @throws Exception
 */
public void testCoordStatusTransitServiceSuspendedBottomUp() throws Exception {
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, true, 4);
    addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    final String jobId = job.getId();
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    // Keeping wait time to 20s to ensure status is updated
    waitFor(20 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
            return coordJob.getStatus() == CoordinatorJob.Status.SUSPENDED;
        }
    });
    CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorJob.Status.SUSPENDED, job.getStatus());
    assertFalse(job.isPending());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 19 with CoordinatorJobBean

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

the class TestStatusTransitService method testCoordStatusTransitRunningFromKilled.

// Test coord transition from killed to running when one action is rerun.
public void testCoordStatusTransitRunningFromKilled() throws Exception {
    final JPAService jpaService = Services.get().get(JPAService.class);
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
    final CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", null, "RUNNING", 0);
    new CoordKillXCommand(coordJob.getId()).call();
    final CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJobBean coordJob = jpaService.execute(coordJobGetCmd);
            return coordJob.getStatusStr().equals("KILLED");
        }
    });
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    sleep(1000);
    coordJob = jpaService.execute(coordJobGetCmd);
    assertEquals(CoordinatorJob.Status.KILLED, coordJob.getStatus());
    coordAction.setStatus(CoordinatorAction.Status.RUNNING);
    coordJob.setPending();
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_STATUS_PENDING, coordJob);
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, coordAction);
    runnable.run();
    sleep(1000);
    coordJob = jpaService.execute(coordJobGetCmd);
    assertEquals(CoordinatorJob.Status.RUNNING, coordJob.getStatus());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordKillXCommand(org.apache.oozie.command.coord.CoordKillXCommand) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 20 with CoordinatorJobBean

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

the class TestCoordMaterializeTriggerService method testCoordMaterializeTriggerService1.

/**
 * Tests functionality of the CoordMaterializeTriggerService Runnable
 * command. </p> Insert a coordinator job with PREP. Then, runs the
 * CoordMaterializeTriggerService runnable and ensures the job status
 * changes to RUNNING.
 *
 * @throws Exception
 */
public void testCoordMaterializeTriggerService1() throws Exception {
    Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
    Date end = DateUtils.parseDateOozieTZ("2009-02-20T23:59Z");
    final CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, start, end, false, false, 0);
    waitForStatus(30000, job, CoordinatorJob.Status.PREP);
    Runnable runnable = new CoordMaterializeTriggerRunnable(3600, 300);
    runnable.run();
    waitForStatus(10000, job, CoordinatorJob.Status.RUNNING);
    CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
    CoordinatorJobBean coordJob = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorJob.Status.RUNNING, coordJob.getStatus());
    int numWaitingActions = jpaService.execute(new CoordJobGetRunningActionsCountJPAExecutor(coordJob.getId()));
    assert (numWaitingActions <= coordJob.getMatThrottling());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordMaterializeTriggerRunnable(org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordMaterializeTriggerRunnable(org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable) CoordJobGetRunningActionsCountJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetRunningActionsCountJPAExecutor) 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