Search in sources :

Example 36 with Services

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

the class TestBundleKillXCommand method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    services = new Services();
    services.init();
}
Also used : Services(org.apache.oozie.service.Services)

Example 37 with Services

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

the class TestBundlePauseUnpauseXCommand method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    services = new Services();
    services.init();
}
Also used : Services(org.apache.oozie.service.Services)

Example 38 with Services

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

the class TestBundleRerunXCommand method testBundleRerunWithError.

/**
 * Test : Rerun a DONEWITHERROR bundle job. Status should
 * change to RUNNINGWITHERROR
 *
 * @throws Exception
 */
public void testBundleRerunWithError() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
    services = new Services();
    services.init();
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.DONEWITHERROR, false);
    CoordinatorJobBean coord1 = addRecordToCoordJobTable("action1", CoordinatorJob.Status.SUCCEEDED, false, false);
    CoordinatorJobBean coord2 = addRecordToCoordJobTable("action2", CoordinatorJob.Status.FAILED, false, false);
    this.addRecordToBundleActionTable(job.getId(), coord1.getId(), "action1", 0, Job.Status.SUCCEEDED);
    this.addRecordToBundleActionTable(job.getId(), coord2.getId(), "action2", 0, Job.Status.FAILED);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(Job.Status.DONEWITHERROR, job.getStatus());
    new BundleRerunXCommand(job.getId(), null, "2009-02-01T00:00Z", false, true).call();
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(Job.Status.RUNNINGWITHERROR, job.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) Services(org.apache.oozie.service.Services) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService)

Example 39 with Services

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

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

the class SLADbOperations method getClientId.

public static String getClientId() {
    Services services = Services.get();
    if (services == null) {
        throw new RuntimeException("Services is not initialized");
    }
    String clientId = services.getConf().get(CLIENT_ID_TAG, // TODO" remove default
    "oozie-default-instance");
    if (clientId == null) {
        throw new RuntimeException("No SLA_CLIENT_ID defined in oozie-site.xml with property name " + CLIENT_ID_TAG);
    }
    return clientId;
}
Also used : Services(org.apache.oozie.service.Services)

Aggregations

Services (org.apache.oozie.service.Services)247 JPAService (org.apache.oozie.service.JPAService)32 Configuration (org.apache.hadoop.conf.Configuration)21 Date (java.util.Date)17 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)16 File (java.io.File)14 Before (org.junit.Before)14 XConfiguration (org.apache.oozie.util.XConfiguration)11 Path (org.apache.hadoop.fs.Path)10 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)10 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)8 EmbeddedServletContainer (org.apache.oozie.test.EmbeddedServletContainer)8 FileOutputStream (java.io.FileOutputStream)7 InputStream (java.io.InputStream)7 HashMap (java.util.HashMap)7 IOException (java.io.IOException)6 Properties (java.util.Properties)6 ActionService (org.apache.oozie.service.ActionService)6 StringWriter (java.io.StringWriter)5 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)5