Search in sources :

Example 6 with BundleJobInsertJPAExecutor

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

the class TestBundleRerunXCommand method addRecordToBundleJobTableWithPausedTime.

protected BundleJobBean addRecordToBundleJobTableWithPausedTime(Job.Status jobStatus, boolean pending, Date pausedTime) throws Exception {
    BundleJobBean bundle = createBundleJob(jobStatus, pending);
    bundle.setPauseTime(pausedTime);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundle);
        jpaService.execute(bundleInsertjpa);
    } catch (JPAExecutorException ce) {
        ce.printStackTrace();
        fail("Unable to insert the test bundle job record to table");
        throw ce;
    }
    return bundle;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 7 with BundleJobInsertJPAExecutor

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

the class TestStatusTransitService method testBundleStatusTransitServicePausedWithError.

/**
 * Test : Check the transition of a PAUSED bundle job to PAUSEDWITHERROR
 * @throws Exception
 */
public void testBundleStatusTransitServicePausedWithError() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
    services = new Services();
    setClassesToBeExcluded(services.getConf(), excludedServices);
    services.init();
    BundleJobBean bundleJob = createBundleJob(Job.Status.PAUSED, true);
    bundleJob.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
    final JPAService jpaService = Services.get().get(JPAService.class);
    BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundleJob);
    jpaService.execute(bundleInsertjpa);
    final String bundleId = bundleJob.getId();
    addRecordToBundleActionTable(bundleId, "action1", 1, Job.Status.PAUSED);
    addRecordToBundleActionTable(bundleId, "action2", 1, Job.Status.PAUSED);
    BundleActionBean bundleAction = addRecordToBundleActionTable(bundleId, "action3", 0, Job.Status.FAILED);
    bundleAction.setCoordId("test");
    BundleActionQueryExecutor.getInstance().executeUpdate(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID, bundleAction);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
            return bundle.getStatus() == Job.Status.PAUSEDWITHERROR;
        }
    });
    bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
    assertEquals(Job.Status.PAUSEDWITHERROR, bundleJob.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) BundleActionBean(org.apache.oozie.BundleActionBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 8 with BundleJobInsertJPAExecutor

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

the class XDataTestCase method addRecordToBundleJobTable.

/**
 * Insert bundle job for testing.
 *
 * @param jobStatus job status
 * @param pending true if pending
 * @return bundle job bean
 * @throws Exception
 */
public BundleJobBean addRecordToBundleJobTable(Job.Status jobStatus, boolean pending) throws Exception {
    BundleJobBean bundle = createBundleJob(jobStatus, pending);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundle);
        jpaService.execute(bundleInsertjpa);
    } catch (JPAExecutorException ce) {
        ce.printStackTrace();
        fail("Unable to insert the test bundle job record to table");
        throw ce;
    }
    return bundle;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 9 with BundleJobInsertJPAExecutor

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

the class XDataTestCase method addRecordToBundleJobTableNegative.

/**
 * Insert a bad bundle job for testing negative cases.
 *
 * @param jobStatus job status
 * @return bundle job bean
 * @throws Exception
 */
protected BundleJobBean addRecordToBundleJobTableNegative(Job.Status jobStatus) throws Exception {
    BundleJobBean bundle = createBundleJobNegative(jobStatus);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundle);
        jpaService.execute(bundleInsertjpa);
    } catch (JPAExecutorException ce) {
        ce.printStackTrace();
        fail("Unable to insert the test bundle job record to table");
        throw ce;
    }
    return bundle;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 10 with BundleJobInsertJPAExecutor

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

the class XDataTestCase method addRecordToBundleJobTableDisabledCoord.

/**
 * Insert bundle job for testing.
 *
 * @param jobStatus job status
 * @param pending true if pending
 * @return bundle job bean
 * @throws Exception
 */
protected BundleJobBean addRecordToBundleJobTableDisabledCoord(Job.Status jobStatus) throws Exception {
    BundleJobBean bundle = createBundleJobCoordDisabled(jobStatus);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundle);
        jpaService.execute(bundleInsertjpa);
    } catch (JPAExecutorException ce) {
        ce.printStackTrace();
        fail("Unable to insert the test bundle job record to table");
        throw ce;
    }
    return bundle;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Aggregations

BundleJobBean (org.apache.oozie.BundleJobBean)10 BundleJobInsertJPAExecutor (org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor)10 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)9 JPAService (org.apache.oozie.service.JPAService)5 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)2 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)2 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BulkResponseInfo (org.apache.oozie.BulkResponseInfo)1 BundleActionBean (org.apache.oozie.BundleActionBean)1 BulkJPAExecutor (org.apache.oozie.executor.jpa.BulkJPAExecutor)1