Search in sources :

Example 1 with BulkJPAExecutor

use of org.apache.oozie.executor.jpa.BulkJPAExecutor 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 2 with BulkJPAExecutor

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

the class BulkJobsXCommand method execute.

/* (non-Javadoc)
     * @see org.apache.oozie.command.XCommand#execute()
     */
@Override
protected BulkResponseInfo execute() throws CommandException {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        BulkResponseInfo bulk = null;
        if (jpaService != null) {
            bulk = jpaService.execute(new BulkJPAExecutor(bulkParams, start, len));
        } else {
            LOG.error(ErrorCode.E0610);
        }
        return bulk;
    } catch (XException ex) {
        throw new CommandException(ex);
    }
}
Also used : BulkResponseInfo(org.apache.oozie.BulkResponseInfo) XException(org.apache.oozie.XException) BulkJPAExecutor(org.apache.oozie.executor.jpa.BulkJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService)

Aggregations

BulkResponseInfo (org.apache.oozie.BulkResponseInfo)2 BulkJPAExecutor (org.apache.oozie.executor.jpa.BulkJPAExecutor)2 BundleJobBean (org.apache.oozie.BundleJobBean)1 XException (org.apache.oozie.XException)1 CommandException (org.apache.oozie.command.CommandException)1 BundleJobInsertJPAExecutor (org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1 JPAService (org.apache.oozie.service.JPAService)1