use of org.apache.oozie.DagEngine in project oozie by apache.
the class V1JobsServlet method getWorkflowJobIdForExternalId.
/**
* v1 service implementation to get a JSONObject representation of a job from its external ID
*/
@SuppressWarnings("unchecked")
private JSONObject getWorkflowJobIdForExternalId(HttpServletRequest request, String externalId) throws XServletException {
JSONObject json = new JSONObject();
try {
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(getUser(request));
String jobId = dagEngine.getJobIdForExternalId(externalId);
json.put(JsonTags.JOB_ID, jobId);
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return json;
}
use of org.apache.oozie.DagEngine in project oozie by apache.
the class V1JobsServlet method getWorkflowJobs.
/**
* v1 service implementation to get a list of workflows, with filtering or interested windows embedded in the
* request object
*/
private JSONObject getWorkflowJobs(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;
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(getUser(request));
WorkflowsInfo jobs = dagEngine.getJobs(filter, start, len);
json = OozieJsonFactory.getWFJSONObject(jobs, timeZoneId);
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return json;
}
use of org.apache.oozie.DagEngine in project oozie by apache.
the class V1JobsServlet method submitWorkflowJob.
/**
* v1 service implementation to submit a workflow job
*/
@SuppressWarnings("unchecked")
private JSONObject submitWorkflowJob(HttpServletRequest request, Configuration conf) throws XServletException {
JSONObject json = new JSONObject();
try {
String action = request.getParameter(RestConstants.ACTION_PARAM);
if (action != null && !action.equals(RestConstants.JOB_ACTION_START) && !action.equals(RestConstants.JOB_ACTION_DRYRUN)) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0303, RestConstants.ACTION_PARAM, action);
}
boolean startJob = (action != null);
String user = conf.get(OozieClient.USER_NAME);
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(user);
String id;
boolean dryrun = false;
if (action != null) {
dryrun = (action.equals(RestConstants.JOB_ACTION_DRYRUN));
}
if (dryrun) {
id = dagEngine.dryRunSubmit(conf);
} else {
id = dagEngine.submitJob(conf, startJob);
}
json.put(JsonTags.JOB_ID, id);
} catch (BaseEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return json;
}
use of org.apache.oozie.DagEngine in project oozie by apache.
the class V0JobServlet method getJob.
/*
* v0 service method to get a job in JsonBean representation
*/
@Override
protected JsonBean getJob(HttpServletRequest request, HttpServletResponse response) throws XServletException, IOException {
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(getUser(request));
JsonBean jobBean = null;
String jobId = getResourceName(request);
try {
jobBean = (JsonBean) dagEngine.getJob(jobId);
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return jobBean;
}
use of org.apache.oozie.DagEngine in project oozie by apache.
the class V0JobServlet method reRunJob.
/*
* v0 service method to reRun a job
*/
@Override
protected JSONObject reRunJob(HttpServletRequest request, HttpServletResponse response, Configuration conf) throws XServletException, IOException {
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(getUser(request));
String jobId = getResourceName(request);
try {
dagEngine.reRun(jobId, conf);
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return null;
}
Aggregations