use of org.apache.oozie.BundleJobInfo in project oozie by apache.
the class TestBundleJobsXCommand method _testGetJobInfoForUser.
private void _testGetJobInfoForUser() throws Exception {
Map<String, List<String>> filter = new HashMap<String, List<String>>();
List<String> list = new ArrayList<String>();
list.add(getTestUser());
filter.put(OozieClient.FILTER_USER, list);
BundleJobsXCommand bundlesGetCmd = new BundleJobsXCommand(filter, 1, 20);
BundleJobInfo ret = bundlesGetCmd.call();
assertNotNull(ret);
assertEquals(6, ret.getBundleJobs().size());
}
use of org.apache.oozie.BundleJobInfo in project oozie by apache.
the class TestBundleJobsXCommand method _testGetJobsForUserAndStatus.
private void _testGetJobsForUserAndStatus() throws Exception {
Map<String, List<String>> filter = new HashMap<String, List<String>>();
List<String> list1 = new ArrayList<String>();
list1.add(getTestUser());
filter.put(OozieClient.FILTER_USER, list1);
List<String> list2 = new ArrayList<String>();
list2.add("KILLED");
filter.put(OozieClient.FILTER_STATUS, list2);
BundleJobsXCommand bundlesGetCmd = new BundleJobsXCommand(filter, 1, 20);
BundleJobInfo ret = bundlesGetCmd.call();
assertNotNull(ret);
assertEquals(1, ret.getBundleJobs().size());
}
use of org.apache.oozie.BundleJobInfo in project oozie by apache.
the class V1JobsServlet method getBundleJobs.
@SuppressWarnings("unchecked")
private JSONObject getBundleJobs(HttpServletRequest request) throws XServletException {
JSONObject json;
try {
String filter = request.getParameter(RestConstants.JOBS_FILTER_PARAM);
String startStr = request.getParameter(RestConstants.OFFSET_PARAM);
String lenStr = request.getParameter(RestConstants.LEN_PARAM);
String timeZoneId = request.getParameter(RestConstants.TIME_ZONE_PARAM) == null ? "GMT" : request.getParameter(RestConstants.TIME_ZONE_PARAM);
int start = (startStr != null) ? Integer.parseInt(startStr) : 1;
start = (start < 1) ? 1 : start;
int len = (lenStr != null) ? Integer.parseInt(lenStr) : 50;
len = (len < 1) ? 50 : len;
BundleEngine bundleEngine = Services.get().get(BundleEngineService.class).getBundleEngine(getUser(request));
BundleJobInfo jobs = bundleEngine.getBundleJobs(filter, start, len);
json = OozieJsonFactory.getBundleJSONObject(jobs, timeZoneId);
} catch (BundleEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return json;
}
use of org.apache.oozie.BundleJobInfo in project oozie by apache.
the class V1JobsServlet method bulkModifyJobs.
private JSONObject bulkModifyJobs(HttpServletRequest request, HttpServletResponse response) throws XServletException, IOException {
String action = request.getParameter(RestConstants.ACTION_PARAM);
String jobType = request.getParameter(RestConstants.JOBTYPE_PARAM);
String filter = request.getParameter(RestConstants.JOBS_FILTER_PARAM);
String startStr = request.getParameter(RestConstants.OFFSET_PARAM);
String lenStr = request.getParameter(RestConstants.LEN_PARAM);
String timeZoneId = request.getParameter(RestConstants.TIME_ZONE_PARAM) == null ? "GMT" : request.getParameter(RestConstants.TIME_ZONE_PARAM);
int start = (startStr != null) ? Integer.parseInt(startStr) : 1;
start = (start < 1) ? 1 : start;
int len = (lenStr != null) ? Integer.parseInt(lenStr) : 50;
len = (len < 1) ? 50 : len;
JSONObject json;
List<String> ids = new ArrayList<String>();
if (jobType.equals("wf")) {
WorkflowsInfo jobs;
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(getUser(request));
try {
switch(action) {
case RestConstants.JOB_ACTION_KILL:
jobs = dagEngine.killJobs(filter, start, len);
break;
case RestConstants.JOB_ACTION_SUSPEND:
jobs = dagEngine.suspendJobs(filter, start, len);
break;
case RestConstants.JOB_ACTION_RESUME:
jobs = dagEngine.resumeJobs(filter, start, len);
break;
default:
throw new DagEngineException(ErrorCode.E0301, action);
}
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
json = OozieJsonFactory.getWFJSONObject(jobs, timeZoneId);
} else if (jobType.equals("bundle")) {
BundleJobInfo jobs;
BundleEngine bundleEngine = Services.get().get(BundleEngineService.class).getBundleEngine(getUser(request));
try {
switch(action) {
case RestConstants.JOB_ACTION_KILL:
jobs = bundleEngine.killJobs(filter, start, len);
break;
case RestConstants.JOB_ACTION_SUSPEND:
jobs = bundleEngine.suspendJobs(filter, start, len);
break;
case RestConstants.JOB_ACTION_RESUME:
jobs = bundleEngine.resumeJobs(filter, start, len);
break;
default:
throw new BundleEngineException(ErrorCode.E0301, action);
}
} catch (BundleEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
json = OozieJsonFactory.getBundleJSONObject(jobs, timeZoneId);
} else {
CoordinatorJobInfo jobs;
CoordinatorEngine coordEngine = Services.get().get(CoordinatorEngineService.class).getCoordinatorEngine(getUser(request));
try {
switch(action) {
case RestConstants.JOB_ACTION_KILL:
jobs = coordEngine.killJobs(filter, start, len);
break;
case RestConstants.JOB_ACTION_SUSPEND:
jobs = coordEngine.suspendJobs(filter, start, len);
break;
case RestConstants.JOB_ACTION_RESUME:
jobs = coordEngine.resumeJobs(filter, start, len);
break;
default:
throw new CoordinatorEngineException(ErrorCode.E0301, action);
}
} catch (CoordinatorEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
json = OozieJsonFactory.getCoordJSONObject(jobs, timeZoneId);
}
json.put(JsonTags.JOB_IDS, toJSONArray(ids));
return json;
}
use of org.apache.oozie.BundleJobInfo in project oozie by apache.
the class BundleJobsXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected BundleJobInfo execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
BundleJobInfo bundleInfo = null;
if (jpaService != null) {
bundleInfo = jpaService.execute(new BundleJobInfoGetJPAExecutor(filter, start, len));
} else {
LOG.error(ErrorCode.E0610);
}
return bundleInfo;
} catch (XException ex) {
throw new CommandException(ex);
}
}
Aggregations