Search in sources :

Example 16 with CoordJobInsertJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.

the class TestStatusTransitService method testCoordStatusTransitServicePausedWithError.

/**
 * Test : all coord actions are running, job pending is reset
 *
 * @throws Exception
 */
public void testCoordStatusTransitServicePausedWithError() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
    services = new Services();
    setClassesToBeExcluded(services.getConf(), excludedServices);
    services.init();
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean job = createCoordJob(CoordinatorJob.Status.PAUSEDWITHERROR, start, end, true, false, 3);
    // set the pause time explicity to make sure the job is not unpaused
    job.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
    final JPAService jpaService = Services.get().get(JPAService.class);
    CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(job);
    jpaService.execute(coordInsertCmd);
    addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
    final String jobId = job.getId();
    assertNotNull(jpaService);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
            return coordJob.isPending() == false;
        }
    });
    CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordGetCmd);
    assertFalse(job.isPending());
    assertEquals(CoordinatorJob.Status.PAUSED, job.getStatus());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 17 with CoordJobInsertJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.

the class TestPauseTransitService method addRecordToCoordJobTable.

protected CoordinatorJobBean addRecordToCoordJobTable(String coordId, CoordinatorJob.Status status, Date start, Date end, boolean pending) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, start, end, pending, false, 0);
    coordJob.setId(coordId);
    coordJob.setAppName(coordId);
    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 18 with CoordJobInsertJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.

the class XDataTestCase method addRecordToCoordJobTable.

protected CoordinatorJobBean addRecordToCoordJobTable(String appXml) throws Exception {
    Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
    Date end = DateUtils.parseDateOozieTZ("2009-02-03T23:59Z");
    appXml = appXml.replaceAll("#start", DateUtils.formatDateOozieTZ(start));
    appXml = appXml.replaceAll("#end", DateUtils.formatDateOozieTZ(end));
    Path appPath = new Path(getFsTestCaseDir(), "coord");
    writeToFile(appXml, appPath, "coordinator.xml");
    CoordinatorJobBean coordJob = createCoordBean(appPath, appXml, CoordinatorJob.Status.PREP, start, end, false, false, 0);
    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 : Path(org.apache.hadoop.fs.Path) 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) Date(java.util.Date)

Example 19 with CoordJobInsertJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.

the class XDataTestCase method addRecordToCoordJobTable.

/**
 * Inserts the passed coord job
 * @param coord job bean
 * @throws Exception
 */
protected void addRecordToCoordJobTable(CoordinatorJobBean coordJob) throws Exception {
    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;
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 20 with CoordJobInsertJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.

the class XDataTestCase method addRecordToCoordJobTable.

/**
 * Insert coord job for testing.
 *
 * @param status coord job status
 * @param start start time
 * @param end end time
 * @param created Time
 * @param pending true if pending is true
 * @param doneMatd true if doneMaterialization is true
 * @param lastActionNum last action number
 * @return coord job bean
 * @throws Exception
 */
protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date start, Date end, Date createdTime, boolean pending, boolean doneMatd, int lastActionNum) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, start, end, createdTime, pending, doneMatd, lastActionNum);
    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)

Aggregations

CoordJobInsertJPAExecutor (org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor)22 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)21 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)20 JPAService (org.apache.oozie.service.JPAService)19 Date (java.util.Date)6 CommandException (org.apache.oozie.command.CommandException)3 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)3 XConfiguration (org.apache.oozie.util.XConfiguration)3 IOException (java.io.IOException)2 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)2 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 BundleActionBean (org.apache.oozie.BundleActionBean)1 BundleJobBean (org.apache.oozie.BundleJobBean)1 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)1 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)1 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)1 Services (org.apache.oozie.service.Services)1 StoreException (org.apache.oozie.store.StoreException)1