Search in sources :

Example 26 with CoordinatorJobBean

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

the class TestPauseTransitService method testPauseCoordinatorForBackwardSupport.

/**
 * Test : Pause a RUNNING coordinator, but set oozie.service.StatusTransitService.backward.support.for.coord.status=true
 * and use uri:oozie:coordinator:0.1 namespace, the status should not be changed to PAUSED
 *
 * @throws Exception
 */
public void testPauseCoordinatorForBackwardSupport() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
    services = new Services();
    setClassesToBeExcluded(services.getConf(), excludedServices);
    services.init();
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    Date pauseTime = new Date(new Date().getTime() - 30 * 1000);
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean coordJob1 = addRecordToCoordJobTable("action1", CoordinatorJob.Status.RUNNING, start, end, false);
    CoordinatorJobBean coordJob2 = addRecordToCoordJobTable("action2", CoordinatorJob.Status.RUNNING, start, end, false);
    coordJob1.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
    coordJob1.setPauseTime(pauseTime);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob1);
    coordJob2.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
    coordJob2.setPauseTime(pauseTime);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob2);
    Runnable pauseStartRunnable = new PauseTransitRunnable();
    pauseStartRunnable.run();
    final String coordJobId1 = coordJob1.getId();
    final String coordJobId2 = coordJob2.getId();
    waitFor(10 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJobBean cJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
            return cJob1.getStatus() == Job.Status.RUNNING;
        }
    });
    coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
    assertEquals(Job.Status.RUNNING, coordJob1.getStatus());
    coordJob2 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId2));
    assertEquals(Job.Status.RUNNING, coordJob2.getStatus());
}
Also used : Services(org.apache.oozie.service.Services) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) PauseTransitRunnable(org.apache.oozie.service.PauseTransitService.PauseTransitRunnable) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) PauseTransitRunnable(org.apache.oozie.service.PauseTransitService.PauseTransitRunnable) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 27 with CoordinatorJobBean

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

the class TestCoordRerunXCommand method testCoordRerunInFailed.

/**
 * Test : Rerun FAILED coordinator job
 *
 * @throws Exception
 */
public void testCoordRerunInFailed() throws Exception {
    CoordinatorJobBean job = this.addRecordToCoordJobTable(Job.Status.FAILED, false, false);
    job = getCoordinatorJob(job.getId());
    assertEquals(Job.Status.FAILED, job.getStatus());
    try {
        new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true, false, null).call();
        fail("Coordinator job is FAILED, rerun should throw exception");
    } catch (CommandException ce) {
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CommandException(org.apache.oozie.command.CommandException)

Example 28 with CoordinatorJobBean

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

the class TestCoordRerunXCommand method addRecordToCoordJobTableWithPausedTime.

protected CoordinatorJobBean addRecordToCoordJobTableWithPausedTime(CoordinatorJob.Status status, boolean pending, boolean doneMatd, Date pausedTime) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, pending, doneMatd);
    coordJob.setPauseTime(pausedTime);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
        jpaService.execute(coordInsertCmd);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test coord job record to table");
        throw je;
    }
    return coordJob;
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 29 with CoordinatorJobBean

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

the class TestCoordRerunXCommand method testCoordRerunInDoneWithError.

/**
 * Test : Rerun DONEWITHERROR coordinator job
 *
 * @throws Exception
 */
public void testCoordRerunInDoneWithError() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
    services = new Services();
    services.init();
    CoordinatorJobBean job = this.addRecordToCoordJobTable(Job.Status.DONEWITHERROR, false, false);
    addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.FAILED, "coord-rerun-action1.xml", 0);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    job = getCoordinatorJob(job.getId());
    assertEquals(Job.Status.DONEWITHERROR, job.getStatus());
    new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true, false, null).call();
    job = getCoordinatorJob(job.getId());
    assertEquals(Job.Status.RUNNINGWITHERROR, job.getStatus());
}
Also used : Services(org.apache.oozie.service.Services) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAService(org.apache.oozie.service.JPAService)

Example 30 with CoordinatorJobBean

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

the class TestCoordRerunXCommand method testCoordRerunForBackwardSupport3.

/**
 * Tests functionality of the coord rerun for backward support is true. </p> Insert a coordinator job with SUCCEEDED
 * and coordinator actions with pending false. However, job's doneMaterialization is false to imitate update from
 * 2.x to 3.0.1.
 * Set oozie.service.StatusTransitService.backward.support.for.coord.status=true
 * and use uri:oozie:coordinator:0.1 namespace, then, rerun the coord job for action 1 and action 2.
 *
 * @throws Exception
 */
public void testCoordRerunForBackwardSupport3() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
    services = new Services();
    services.init();
    Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
    Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, start, end, false, false, 3);
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    coordJob.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_APPNAMESPACE, coordJob);
    CoordinatorActionBean action1 = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
    CoordinatorActionBean action2 = addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
    CoordinatorActionBean action3 = addRecordToCoordActionTable(coordJob.getId(), 3, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
    String rerunScope = Integer.toString(1) + "-" + Integer.toString(2);
    final OozieClient coordClient = LocalOozie.getCoordClient();
    coordClient.reRunCoord(coordJob.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, rerunScope, false, true);
    coordJob = getCoordinatorJob(coordJob.getId());
    assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
    action1 = getCoordinatorAction(action1.getId());
    assertNotSame(action1.getStatus(), CoordinatorAction.Status.SUCCEEDED);
    action2 = getCoordinatorAction(action2.getId());
    assertNotSame(action2.getStatus(), CoordinatorAction.Status.SUCCEEDED);
}
Also used : Services(org.apache.oozie.service.Services) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Aggregations

CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)373 Date (java.util.Date)177 JPAService (org.apache.oozie.service.JPAService)153 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)149 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)121 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)114 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)53 CommandException (org.apache.oozie.command.CommandException)49 BundleJobBean (org.apache.oozie.BundleJobBean)46 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)43 IOException (java.io.IOException)39 XConfiguration (org.apache.oozie.util.XConfiguration)38 ArrayList (java.util.ArrayList)36 BundleActionBean (org.apache.oozie.BundleActionBean)36 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)34 Configuration (org.apache.hadoop.conf.Configuration)33 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)32 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)30 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)30 Path (org.apache.hadoop.fs.Path)24