Search in sources :

Example 91 with JPAService

use of org.apache.oozie.service.JPAService 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 92 with JPAService

use of org.apache.oozie.service.JPAService 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 93 with JPAService

use of org.apache.oozie.service.JPAService 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)

Example 94 with JPAService

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

the class TestBundleKillXCommand method testBundleKill3.

/**
 * Test : Kill bundle job
 *
 * @throws Exception
 */
public void testBundleKill3() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    Configuration jobConf = null;
    try {
        jobConf = new XConfiguration(new StringReader(job.getConf()));
    } catch (IOException ioe) {
        log.warn("Configuration parse error. read from DB :" + job.getConf(), ioe);
        throw new CommandException(ErrorCode.E1005, ioe);
    }
    Path appPath = new Path(jobConf.get(OozieClient.BUNDLE_APP_PATH), "bundle.xml");
    jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());
    BundleSubmitXCommand submitCmd = new BundleSubmitXCommand(jobConf);
    submitCmd.call();
    BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(submitCmd.getJob().getId());
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(Job.Status.PREP, job.getStatus());
    new BundleKillXCommand(job.getId()).call();
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(Job.Status.KILLED, job.getStatus());
}
Also used : Path(org.apache.hadoop.fs.Path) BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) BundleJobBean(org.apache.oozie.BundleJobBean) StringReader(java.io.StringReader) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService)

Example 95 with JPAService

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

the class TestBundleKillXCommand method testBundleKill1.

/**
 * Test : Kill bundle job
 *
 * @throws Exception
 */
public void testBundleKill1() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(Job.Status.PREP, job.getStatus());
    new BundleKillXCommand(job.getId()).call();
    job = jpaService.execute(bundleJobGetCmd);
    assertEquals(Job.Status.KILLED, job.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService)

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