Search in sources :

Example 6 with StatusTransitRunnable

use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.

the class TestStatusTransitService method testCoordStatusTransitServiceSuspendedByUser.

/**
 * Test : coord job suspended by user and all coord actions are succeeded - pending update to false
 *
 * @throws Exception
 */
public void testCoordStatusTransitServiceSuspendedByUser() throws Exception {
    String currentDateplusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDateplusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDateplusMonth);
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUSPENDED, start, end, true, true, 3);
    addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 3, 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();
    waitFor(10 * 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());
    assertEquals(Job.Status.SUCCEEDED, job.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) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 7 with StatusTransitRunnable

use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.

the class TestStatusTransitService method testCoordStatusTransitServiceSuspendedWithError.

/**
 * Test : all coord actions suspended except one which is killed - check status change to SUSPENDEDWITHERROR
 *
 * @throws Exception
 */
public void testCoordStatusTransitServiceSuspendedWithError() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
    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 job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, true, 4);
    addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.KILLED, "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.SUSPENDED, "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.SUSPENDEDWITHERROR;
        }
    });
    CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorJob.Status.SUSPENDEDWITHERROR, 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 8 with StatusTransitRunnable

use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable 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 9 with StatusTransitRunnable

use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.

the class TestStatusTransitService method testBundleStatusTransitServiceSucceeded1.

/**
 * Test : all bundle actions are succeeded - bundle job's status will be updated to succeeded.
 *
 * @throws Exception
 */
public void testBundleStatusTransitServiceSucceeded1() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    final String jobId = job.getId();
    BundleActionBean ba1 = addRecordToBundleActionTable(jobId, "action1", 0, Job.Status.SUCCEEDED);
    addRecordToBundleActionTable(jobId, "action2", 0, Job.Status.SUCCEEDED);
    addRecordToBundleActionTable(jobId, "action3", 0, Job.Status.SUCCEEDED);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
            return bundle.getStatus().equals(Job.Status.SUCCEEDED);
        }
    });
    job = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
    assertEquals(Job.Status.SUCCEEDED, job.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) BundleActionBean(org.apache.oozie.BundleActionBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 10 with StatusTransitRunnable

use of org.apache.oozie.service.StatusTransitService.StatusTransitRunnable in project oozie by apache.

the class TestStatusTransitService method testBundleStatusTransitServicePaused.

/**
 * Test : Check the transition of a PAUSEDWITHERROR bundle job to PAUSED
 * @throws Exception
 */
public void testBundleStatusTransitServicePaused() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
    services = new Services();
    setClassesToBeExcluded(services.getConf(), excludedServices);
    services.init();
    BundleJobBean bundleJob = createBundleJob(Job.Status.PAUSEDWITHERROR, true);
    bundleJob.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
    final JPAService jpaService = Services.get().get(JPAService.class);
    BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundleJob);
    jpaService.execute(bundleInsertjpa);
    final String bundleId = bundleJob.getId();
    addRecordToBundleActionTable(bundleId, "action1", 1, Job.Status.PAUSED);
    addRecordToBundleActionTable(bundleId, "action2", 1, Job.Status.PAUSED);
    addRecordToBundleActionTable(bundleId, "action3", 0, Job.Status.SUCCEEDED);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
            return bundle.getStatus() == Job.Status.PAUSED;
        }
    });
    bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
    assertEquals(Job.Status.PAUSED, bundleJob.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Aggregations

StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)42 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)34 Date (java.util.Date)30 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)29 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)25 BundleJobBean (org.apache.oozie.BundleJobBean)18 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)14 BundleActionBean (org.apache.oozie.BundleActionBean)10 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)8 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)6 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)5 CoordKillXCommand (org.apache.oozie.command.coord.CoordKillXCommand)4 CoordSuspendXCommand (org.apache.oozie.command.coord.CoordSuspendXCommand)4 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)4 JPAService (org.apache.oozie.service.JPAService)4 CoordResumeXCommand (org.apache.oozie.command.coord.CoordResumeXCommand)3 CoordJobInsertJPAExecutor (org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor)3 Configuration (org.apache.hadoop.conf.Configuration)2 BundleJobInsertJPAExecutor (org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor)2 CoordActionGetForCheckJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetForCheckJPAExecutor)2