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;
}
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();
}
}
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;
}
});
}
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());
}
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;
}
Aggregations