Search in sources :

Example 46 with BundleJobBean

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

the class TestBundleRerunXCommand method testBundleRerunInPaused.

/**
 * Test : Rerun paused bundle job
 *
 * @throws Exception
 */
public void testBundleRerunInPaused() throws Exception {
    Date curr = new Date();
    Date pauseTime = new Date(curr.getTime() - 1000);
    BundleJobBean job = this.addRecordToBundleJobTableWithPausedTime(Job.Status.PAUSED, false, pauseTime);
    this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.SUCCEEDED);
    this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.PAUSED);
    addRecordToCoordJobTable("action1", CoordinatorJob.Status.SUCCEEDED, false, false);
    addRecordToCoordJobTable("action2", CoordinatorJob.Status.PAUSED, false, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(Job.Status.PAUSED, job.getStatus());
    new BundleRerunXCommand(job.getId(), "action2", null, false, true).call();
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(Job.Status.PAUSED, job.getStatus());
    assertNotNull(job.getPauseTime());
    assertFalse(job.isPending());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Example 47 with BundleJobBean

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

the class TestBundleRerunXCommand method testBundleRerun1.

/**
 * Test : Rerun bundle job for dateScope
 *
 * @throws Exception
 */
public void testBundleRerun1() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    CoordinatorJobBean coord1 = addRecordToCoordJobTable("action1", CoordinatorJob.Status.SUCCEEDED, false, false);
    CoordinatorJobBean coord2 = addRecordToCoordJobTable("action2", CoordinatorJob.Status.SUCCEEDED, false, false);
    this.addRecordToBundleActionTable(job.getId(), coord1.getId(), "action1", 0, Job.Status.SUCCEEDED);
    this.addRecordToBundleActionTable(job.getId(), coord2.getId(), "action2", 0, Job.Status.SUCCEEDED);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(Job.Status.SUCCEEDED, job.getStatus());
    new BundleRerunXCommand(job.getId(), null, "2009-02-01T00:00Z", false, true).call();
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(Job.Status.RUNNING, job.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService)

Example 48 with BundleJobBean

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

the class TestBundleStartXCommand method testBundleStartWithFailedCoordinator.

public void testBundleStartWithFailedCoordinator() throws Exception {
    services.destroy();
    services = new Services();
    String[] excludeServices = { "org.apache.oozie.service.UUIDService", "org.apache.oozie.service.StatusTransitService" };
    Configuration conf = services.getConf();
    setClassesToBeExcluded(conf, excludeServices);
    conf.set(Services.CONF_SERVICE_CLASSES, conf.get(Services.CONF_SERVICE_CLASSES) + "," + DummyUUIDService.class.getName());
    services.init();
    CoordinatorJobBean coordJob = new CoordinatorJobBean();
    coordJob.setId("dummy-coord-id");
    JPAService jpaService = Services.get().get(JPAService.class);
    CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
    jpaService.execute(coordInsertCmd);
    BundleJobBean job = addRecordToBundleJobTable(Job.Status.PREP, false);
    BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.PREP);
    new BundleStartXCommand(job.getId()).call();
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.RUNNING);
    sleep(2000);
    List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
    assertNull(actions.get(0).getCoordId());
    assertEquals(Job.Status.FAILED, actions.get(0).getStatus());
    Runnable runnable = new StatusTransitRunnable();
    // 1st run of StatusTransitionService changes bundle to running
    runnable.run();
    sleep(2000);
    // 2nd run changes bundle to DoneWithError
    runnable.run();
    sleep(2000);
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.DONEWITHERROR);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) Services(org.apache.oozie.service.Services) BundleJobBean(org.apache.oozie.BundleJobBean) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 49 with BundleJobBean

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

the class TestBundleStartXCommand method testBundleStartDryrun.

/**
 * Test : Start bundle job with dryrun
 *
 * @throws Exception
 */
public void testBundleStartDryrun() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.PREP);
    new BundleStartXCommand(job.getId(), true).call();
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.RUNNING);
    sleep(2000);
    List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
    assertEquals(2, actions.size());
    assertEquals(true, actions.get(0).isCritical());
    assertEquals(job.getId(), actions.get(0).getBundleId());
    assertEquals(false, actions.get(1).isCritical());
    assertEquals(job.getId(), actions.get(1).getBundleId());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 50 with BundleJobBean

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

the class TestBundleSubmitXCommand method testJobXmlCommentRemoved.

/**
 * https://issues.apache.org/jira/browse/OOZIE-945
 *
 * @throws Exception
 */
public void testJobXmlCommentRemoved() throws Exception {
    // this retrieves bundle-submit-job.xml
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
    final 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 command = new BundleSubmitXCommand(true, jobConf);
    BundleJobBean bundleBean = (BundleJobBean) command.getJob();
    bundleBean.setStartTime(new Date());
    bundleBean.setEndTime(new Date());
    command.call();
    // result includes bundle-submit-job.xml file instead of jobId since this is a dryRun mode
    String result = command.submit();
    // bundle-submit-job.xml contains the Apache license but this result should not contain the comment block
    assertTrue("submit result should not contain <!-- ", !result.contains("<!--"));
    assertTrue("submit result should not contain --> ", !result.contains("-->"));
}
Also used : Path(org.apache.hadoop.fs.Path) 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) Date(java.util.Date)

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