Search in sources :

Example 6 with BaseEngineException

use of org.apache.oozie.BaseEngineException 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;
}
Also used : DagEngine(org.apache.oozie.DagEngine) JSONObject(org.json.simple.JSONObject) BaseEngineException(org.apache.oozie.BaseEngineException) DagEngineService(org.apache.oozie.service.DagEngineService)

Example 7 with BaseEngineException

use of org.apache.oozie.BaseEngineException in project oozie by apache.

the class V0JobServlet method streamJobLog.

/*
     * v0 service method to stream a job log into response object
     */
@Override
protected void streamJobLog(HttpServletRequest request, HttpServletResponse response) throws XServletException, IOException {
    DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(getUser(request));
    String jobId = getResourceName(request);
    try {
        dagEngine.streamLog(jobId, response.getWriter(), request.getParameterMap());
    } catch (BaseEngineException ex) {
        throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
    }
}
Also used : DagEngine(org.apache.oozie.DagEngine) BaseEngineException(org.apache.oozie.BaseEngineException) DagEngineService(org.apache.oozie.service.DagEngineService)

Aggregations

BaseEngineException (org.apache.oozie.BaseEngineException)7 DagEngineService (org.apache.oozie.service.DagEngineService)3 JSONObject (org.json.simple.JSONObject)3 DagEngine (org.apache.oozie.DagEngine)2 JSONArray (org.json.simple.JSONArray)2 StringReader (java.io.StringReader)1 BulkResponseInfo (org.apache.oozie.BulkResponseInfo)1 BundleEngine (org.apache.oozie.BundleEngine)1 CoordinatorEngine (org.apache.oozie.CoordinatorEngine)1 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)1 BulkResponseImpl (org.apache.oozie.client.rest.BulkResponseImpl)1 JsonBean (org.apache.oozie.client.rest.JsonBean)1 AuthorizationException (org.apache.oozie.service.AuthorizationException)1 AuthorizationService (org.apache.oozie.service.AuthorizationService)1 BundleEngineService (org.apache.oozie.service.BundleEngineService)1 XConfiguration (org.apache.oozie.util.XConfiguration)1