Search in sources :

Example 1 with BundleJobInsertJPAExecutor

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

the class TestPurgeService method addRecordToBundleJobTable.

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

Example 2 with BundleJobInsertJPAExecutor

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

the class ZKUUIDServiceWithException method testBulkJobForZKUUIDService.

public void testBulkJobForZKUUIDService() throws Exception {
    Services service = Services.get();
    ZKUUIDService uuid = new ZKUUIDService();
    try {
        setSystemProperty(UUIDService.CONF_GENERATOR, "counter");
        uuid.init(service);
        String bundleId = uuid.generateId(ApplicationType.BUNDLE);
        BundleJobBean bundle = createBundleJob(bundleId, Job.Status.SUCCEEDED, false);
        JPAService jpaService = Services.get().get(JPAService.class);
        BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundle);
        jpaService.execute(bundleInsertjpa);
        addCoordForBulkMonitor(bundleId);
        String request = "bundle=" + bundleId;
        BulkJPAExecutor bulkjpa = new BulkJPAExecutor(BundleEngine.parseBulkFilter(request), 1, 1);
        try {
            BulkResponseInfo response = jpaService.execute(bulkjpa);
            assertEquals(response.getResponses().get(0).getBundle().getId(), bundleId);
        } catch (JPAExecutorException jex) {
            // should not throw exception as this case is now supported
            fail();
        }
    } finally {
        uuid.destroy();
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) BulkResponseInfo(org.apache.oozie.BulkResponseInfo) BulkJPAExecutor(org.apache.oozie.executor.jpa.BulkJPAExecutor) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor)

Example 3 with BundleJobInsertJPAExecutor

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

the class TestBulkMonitorWebServiceAPI method testMultipleBundleIdsForName.

public void testMultipleBundleIdsForName() throws Exception {
    // Adding another bundle having same name
    BundleJobBean bundle = new BundleJobBean();
    bundle.setId("00002-12345-B");
    bundle.setAppName(bundleName);
    bundle.setStatus(BundleJob.Status.RUNNING);
    bundle.setStartTime(new Date());
    BundleJobInsertJPAExecutor bundleInsert = new BundleJobInsertJPAExecutor(bundle);
    jpaService.execute(bundleInsert);
    runTest("/v1/jobs", V1JobsServlet.class, false, new Callable<Void>() {

        public Void call() throws Exception {
            String bulkRequest = "bundle=" + bundleName;
            Map<String, String> params = new HashMap<String, String>();
            params.put(RestConstants.JOBS_BULK_PARAM, bulkRequest);
            params.put(RestConstants.OFFSET_PARAM, "1");
            params.put(RestConstants.LEN_PARAM, "5");
            URL url = createURL("", params);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            // WS call will throw BAD_REQUEST code 400 error because no
            // records found for this bundle
            assertFalse(HttpServletResponse.SC_BAD_REQUEST == conn.getResponseCode());
            return null;
        }
    });
}
Also used : HttpURLConnection(java.net.HttpURLConnection) BundleJobBean(org.apache.oozie.BundleJobBean) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date) URL(java.net.URL)

Example 4 with BundleJobInsertJPAExecutor

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

the class TestStatusTransitService method testBundleStatusTransitServicePaused.

/**
 * Test : Check the transition of a PAUSEDWITHERROR bundle job to PAUSED
 * @throws Exception
 */
public void testBundleStatusTransitServicePaused() 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.PAUSEDWITHERROR, 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);
    addRecordToBundleActionTable(bundleId, "action3", 0, Job.Status.SUCCEEDED);
    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.PAUSED;
        }
    });
    bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
    assertEquals(Job.Status.PAUSED, 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) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 5 with BundleJobInsertJPAExecutor

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

the class TestPurgeXCommand method addRecordToBundleJobTable.

protected BundleJobBean addRecordToBundleJobTable(Job.Status jobStatus, Date lastModifiedTime) throws Exception {
    BundleJobBean bundle = createBundleJob(jobStatus, false);
    bundle.setLastModifiedTime(lastModifiedTime);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundle);
        jpaService.execute(bundleInsertjpa);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test bundle job record to table");
        throw je;
    }
    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