use of org.apache.oozie.BundleJobBean in project oozie by apache.
the class BundleJobQueryExecutor method getIfExist.
@Override
public BundleJobBean getIfExist(BundleJobQuery namedQuery, Object... parameters) throws JPAExecutorException {
JPAService jpaService = Services.get().get(JPAService.class);
EntityManager em = jpaService.getEntityManager();
Query query = getSelectQuery(namedQuery, em, parameters);
Object ret = jpaService.executeGet(namedQuery.name(), query, em);
if (ret == null) {
return null;
}
BundleJobBean bean = constructBean(namedQuery, ret, parameters);
return bean;
}
use of org.apache.oozie.BundleJobBean in project oozie by apache.
the class BundleJobQueryExecutor method getList.
@Override
public List<BundleJobBean> getList(BundleJobQuery namedQuery, Object... parameters) throws JPAExecutorException {
JPAService jpaService = Services.get().get(JPAService.class);
EntityManager em = jpaService.getEntityManager();
Query query = getSelectQuery(namedQuery, em, parameters);
List<?> retList = (List<?>) jpaService.executeGetList(namedQuery.name(), query, em);
List<BundleJobBean> beanList = new ArrayList<BundleJobBean>();
if (retList != null) {
for (Object ret : retList) {
beanList.add(constructBean(namedQuery, ret));
}
}
return beanList;
}
use of org.apache.oozie.BundleJobBean in project oozie by apache.
the class BundleJobsGetPausedJPAExecutor method execute.
@Override
@SuppressWarnings("unchecked")
public List<BundleJobBean> execute(EntityManager em) throws JPAExecutorException {
List<BundleJobBean> bjBeans;
try {
Query q = em.createNamedQuery("GET_BUNDLE_JOBS_PAUSED");
if (limit > 0) {
q.setMaxResults(limit);
}
bjBeans = q.getResultList();
} catch (Exception e) {
throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
}
return bjBeans;
}
use of org.apache.oozie.BundleJobBean in project oozie by apache.
the class TestV1JobsServletBundleEngine method testGetBundleJobs.
/**
* Tests method {@link BundleEngine#getBundleJobs(String, int, int)}. Also
* tests positive cases of the filter parsing by
* {@link BundleEngine#parseFilter(String)}.
*/
public void testGetBundleJobs() throws Exception {
final BundleJobBean bundleJobBean = xDataTestCase.addRecordToBundleJobTable(Job.Status.PREP, false);
runTest("/v1/jobs", V1JobsServlet.class, IS_SECURITY_ENABLED, new Callable<Void>() {
@Override
public Void call() throws Exception {
MockDagEngineService.reset();
Map<String, String> params = new HashMap<String, String>();
params.put(RestConstants.JOBTYPE_PARAM, "bundle");
params.put(RestConstants.JOBS_FILTER_PARAM, OozieClient.FILTER_STATUS + "=PREP;" + OozieClient.FILTER_NAME + "=BUNDLE-TEST;" + OozieClient.FILTER_USER + "=" + getTestUser());
URL url = createURL("", params);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode());
assertTrue(conn.getHeaderField("content-type").startsWith(RestConstants.JSON_CONTENT_TYPE));
JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream()));
assertEquals(Long.valueOf(1L), json.get("total"));
JSONArray array = (JSONArray) json.get("bundlejobs");
JSONObject jo = (JSONObject) array.get(0);
assertEquals(bundleJobBean.getId(), jo.get("bundleJobId"));
return null;
}
});
}
use of org.apache.oozie.BundleJobBean in project oozie by apache.
the class TestOozieJobInfo method createBundleJob.
protected BundleJobBean createBundleJob(Job.Status jobStatus, boolean pending) throws Exception {
Path coordPath1 = new Path(getFsTestCaseDir(), "coord1");
String coord = "<coordinator-app name='COORD-TEST' frequency='${coord:days(1)}' " + "start=\"${START_TIME}\" end=\"${END_TIME}\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\">" + "<controls>" + "<concurrency>2</concurrency>" + "<execution>LIFO</execution>" + "</controls>" + "<action>" + "<workflow>" + "<app-path>${wfAppPath}</app-path>" + "<configuration>" + "<property>" + "<name>inputA</name>" + "<value>aaaa</value>" + "</property>" + "</configuration>" + "</workflow> " + "</action>" + "</coordinator-app>";
writeToFile(coord, coordPath1, "coordinator.xml");
Path bundleAppPath = new Path(getFsTestCaseDir(), "bundle");
String bundleAppXml = "<bundle-app name='test_bundle' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + "xmlns='uri:oozie:bundle:0.1'> " + "<controls> <kick-off-time>2009-02-02T00:00Z</kick-off-time> </controls> " + "<coordinator name='c12'> " + "<app-path>#app_path1</app-path>" + "<configuration> " + "<property> <name>START_TIME</name> <value>2009-02-01T00:00Z</value> </property> </configuration> " + "</coordinator></bundle-app>";
bundleAppXml = bundleAppXml.replaceAll("#app_path1", Matcher.quoteReplacement(new Path(coordPath1.toString(), "coordinator.xml").toString()));
writeToFile(bundleAppXml, bundleAppPath, "bundle.xml");
Configuration conf = new XConfiguration();
conf.set(OozieClient.BUNDLE_APP_PATH, bundleAppPath.toString());
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set("jobTracker", getJobTrackerUri());
conf.set("nameNode", getNameNodeUri());
conf.set("appName", "bundle-app-name");
conf.set("start", "2009-02-01T00:00Z");
conf.set("end", "2009-02-01T00:00Z");
conf.set("START_TIME", "2009-02-01T00:00Z");
conf.set("END_TIME", "2009-03-01T00:00Z");
setCoordConf(conf);
BundleJobBean bundle = new BundleJobBean();
bundle.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.BUNDLE));
bundle.setAppName("BUNDLE-TEST");
bundle.setAppPath(bundleAppPath.toString());
bundle.setConf(XmlUtils.prettyPrint(conf).toString());
bundle.setConsoleUrl("consoleUrl");
bundle.setCreatedTime(new Date());
bundle.setJobXml(bundleAppXml);
bundle.setLastModifiedTime(new Date());
bundle.setOrigJobXml(bundleAppXml);
if (pending) {
bundle.setPending();
} else {
bundle.resetPending();
}
bundle.setStatus(jobStatus);
bundle.setUser(conf.get(OozieClient.USER_NAME));
return bundle;
}
Aggregations