Search in sources :

Example 36 with BundleJobBean

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

the class TestBundleChangeXCommand method testBundleChange1.

/**
 * Test : Change pause time of a bundle
 *
 * @throws Exception
 */
public void testBundleChange1() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
    String dateStr = "2099-01-01T01:00Z";
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(job.getPauseTime(), null);
    new BundleJobChangeXCommand(job.getId(), "pausetime=" + dateStr).call();
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(job.getPauseTime(), DateUtils.parseDateOozieTZ(dateStr));
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService)

Example 37 with BundleJobBean

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

the class TestBundleChangeXCommand method testBundleChange2.

/**
 * Test : Change pause time of a bundle that contains a SUCCEEDED coordinator job,
 * The coordinator should also change its pause time.
 *
 * @throws Exception
 */
public void testBundleChange2() throws Exception {
    BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    coordJob.setBundleId(bundleJob.getId());
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID, coordJob);
    coordJob.setAppName("COORD-TEST1");
    assertNotNull(jpaService);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, coordJob);
    BundleActionBean bundleAction = new BundleActionBean();
    bundleAction.setBundleActionId(bundleJob.getId() + "_COORD-TEST1");
    bundleAction.setCoordId(coordJob.getId());
    bundleAction.setBundleId(bundleJob.getId());
    bundleAction.setStatus(Job.Status.SUCCEEDED);
    jpaService.execute(new BundleActionInsertJPAExecutor(bundleAction));
    String dateStr = "2099-01-01T01:00Z";
    BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(bundleJob.getId());
    bundleJob = jpaService.execute(bundleJobGetCmd);
    assertEquals(bundleJob.getPauseTime(), null);
    new BundleJobChangeXCommand(bundleJob.getId(), "pausetime=" + dateStr).call();
    bundleJob = jpaService.execute(bundleJobGetCmd);
    assertEquals(DateUtils.parseDateOozieTZ(dateStr), bundleJob.getPauseTime());
    final String coordJobId = coordJob.getId();
    waitFor(60000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJobBean coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId));
            return (coordJob1.getPauseTime() != null);
        }
    });
    coordJob = jpaService.execute(new CoordJobGetJPAExecutor(coordJob.getId()));
    assertEquals(DateUtils.parseDateOozieTZ(dateStr), coordJob.getPauseTime());
}
Also used : BundleActionInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleActionInsertJPAExecutor) BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) BundleJobBean(org.apache.oozie.BundleJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean) XException(org.apache.oozie.XException)

Example 38 with BundleJobBean

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

the class TestBundleChangeXCommand method testBundleChangeNegative2.

/**
 * Negative Test : pause time is a past time
 *
 * @throws Exception
 */
public void testBundleChangeNegative2() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
    String dateStr = "2009-01-01T01:00Z";
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(job.getPauseTime(), null);
    try {
        new BundleJobChangeXCommand(job.getId(), "pausetime=" + dateStr).call();
        fail("Should not reach here");
    } catch (XException e) {
        assertEquals(ErrorCode.E1317, e.getErrorCode());
    }
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) XException(org.apache.oozie.XException) JPAService(org.apache.oozie.service.JPAService)

Example 39 with BundleJobBean

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

the class TestBundleJobSuspendXCommand method testBundleSuspendWithError.

/**
 * Test : Suspend bundle job in RUNNINGWITHERROR state
 *
 * @throws Exception
 */
public void testBundleSuspendWithError() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNINGWITHERROR, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(Job.Status.RUNNINGWITHERROR, job.getStatus());
    new BundleJobSuspendXCommand(job.getId()).call();
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(Job.Status.SUSPENDEDWITHERROR, job.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService)

Example 40 with BundleJobBean

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

the class TestBundleJobSuspendXCommand method testBundleSuspendWithError2.

/**
 * Test : Suspend bundle job in PAUSEDWITHERROR state
 *
 * @throws Exception
 */
public void testBundleSuspendWithError2() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PAUSEDWITHERROR, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(Job.Status.PAUSEDWITHERROR, job.getStatus());
    new BundleJobSuspendXCommand(job.getId()).call();
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(Job.Status.SUSPENDEDWITHERROR, job.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService)

Aggregations

BundleJobBean (org.apache.oozie.BundleJobBean)159 JPAService (org.apache.oozie.service.JPAService)78 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)69 BundleActionBean (org.apache.oozie.BundleActionBean)58 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)46 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)44 Date (java.util.Date)35 ArrayList (java.util.ArrayList)24 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)24 List (java.util.List)21 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)21 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)21 HashMap (java.util.HashMap)20 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)20 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)18 IOException (java.io.IOException)16 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)16 XConfiguration (org.apache.oozie.util.XConfiguration)16 Query (javax.persistence.Query)14 CommandException (org.apache.oozie.command.CommandException)14