use of org.apache.oozie.DagEngineException in project oozie by apache.
the class CallbackServlet method doPost.
/**
* POST callback
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String queryString = request.getQueryString();
CallbackService callbackService = Services.get().get(CallbackService.class);
if (!callbackService.isValid(queryString)) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0402, queryString);
}
String actionId = callbackService.getActionId(queryString);
if (actionId == null) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0402, queryString);
}
log = XLog.getLog(getClass());
setLogInfo(actionId);
log.debug("Received a CallbackServlet.doPost() with query string " + queryString);
validateContentType(request, RestConstants.TEXT_CONTENT_TYPE);
try {
log.info(XLog.STD, "callback for action [{0}]", actionId);
String data = IOUtils.getReaderAsString(request.getReader(), maxDataLen);
Properties props = PropertiesUtils.stringToProperties(data);
DagEngine dagEngine = Services.get().get(DagEngineService.class).getSystemDagEngine();
dagEngine.processCallback(actionId, callbackService.getExternalStatus(queryString), props);
} catch (IOException ex) {
if (ex.getMessage().startsWith("stream exceeds limit")) {
// TODO, WE MUST SET THE ACTION TO ERROR
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0403, "data too long");
} else {
throw ex;
}
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
}
use of org.apache.oozie.DagEngineException in project oozie by apache.
the class V1JobsServlet method submitHttpJob.
/**
* service implementation to submit a http job
*/
private JSONObject submitHttpJob(HttpServletRequest request, Configuration conf, String jobType) throws XServletException {
JSONObject json = new JSONObject();
try {
String user = conf.get(OozieClient.USER_NAME);
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(user);
String id = dagEngine.submitHttpJob(conf, jobType);
json.put(JsonTags.JOB_ID, id);
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return json;
}
use of org.apache.oozie.DagEngineException 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.DagEngineException 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.DagEngineException 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;
}
Aggregations