use of org.apache.oozie.DagEngine in project oozie by apache.
the class V0JobServlet method getJobDefinition.
/*
* v0 service method to get a job definition in String format
*/
@Override
protected String getJobDefinition(HttpServletRequest request, HttpServletResponse response) throws XServletException, IOException {
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(getUser(request));
String wfDefinition = null;
String jobId = getResourceName(request);
try {
wfDefinition = dagEngine.getDefinition(jobId);
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return wfDefinition;
}
use of org.apache.oozie.DagEngine 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);
}
}
use of org.apache.oozie.DagEngine in project oozie by apache.
the class V0JobsServlet method getJobIdForExternalId.
/**
* v0 service implementation to get a JSONObject representation of a job from its external ID
*/
@Override
protected JSONObject getJobIdForExternalId(HttpServletRequest request, String externalId) throws XServletException, IOException {
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 LocalOozie method getClient.
/**
* Return a {@link org.apache.oozie.client.OozieClient} for LocalOozie configured for a given user.
* <p>
* The following methods of the client are NOP in the returned instance:
* {@link org.apache.oozie.client.OozieClient#validateWSVersion},
* {@link org.apache.oozie.client.OozieClient#setHeader},
* {@link org.apache.oozie.client.OozieClient#getHeader},
* {@link org.apache.oozie.client.OozieClient#removeHeader},
* {@link org.apache.oozie.client.OozieClient#getHeaderNames},
* {@link org.apache.oozie.client.OozieClient#setSystemMode(OozieClient.SYSTEM_MODE)},
* {@link org.apache.oozie.client.OozieClient#getHeaders},
* {@link org.apache.oozie.client.OozieClient#getClientBuildVersion}.
*
* @param user user name to use in LocalOozie for running workflows.
* @return a {@link org.apache.oozie.client.OozieClient} for LocalOozie configured for the given user.
*/
public static OozieClient getClient(String user) {
if (!localOozieActive) {
throw new IllegalStateException("LocalOozie is not initialized");
}
ParamChecker.notEmpty(user, "user");
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(user);
return new LocalOozieClient(dagEngine);
}
use of org.apache.oozie.DagEngine in project oozie by apache.
the class TestActionErrors method _testDataNotSet.
/**
* Provides functionality to test for set*Data calls not being made by the Action Handler.
*
* @param avoidParam set*Data function call to avoid.
* @param expActionErrorCode the expected action error code.
* @throws Exception
*/
private void _testDataNotSet(String avoidParam, String expActionErrorCode) throws Exception {
String workflowPath = getTestCaseFileUri("workflow.xml");
Reader reader = IOUtils.getResourceAsReader("wf-ext-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
final DagEngine engine = new DagEngine("u");
Configuration conf = new XConfiguration();
conf.set(OozieClient.APP_PATH, workflowPath);
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set(OozieClient.LOG_TOKEN, "t");
conf.set("external-status", "ok");
conf.set("signal-value", "based_on_action_status");
conf.set(avoidParam, "true");
final String jobId = engine.submitJob(conf, true);
final WorkflowStore store = Services.get().get(WorkflowStoreService.class).create();
store.beginTrx();
Thread.sleep(2000);
waitFor(5000, new Predicate() {
public boolean evaluate() throws Exception {
WorkflowJobBean bean = store.getWorkflow(jobId, false);
return (bean.getWorkflowInstance().getStatus() == WorkflowInstance.Status.FAILED);
}
});
store.commitTrx();
store.closeTrx();
final WorkflowStore store2 = Services.get().get(WorkflowStoreService.class).create();
store2.beginTrx();
assertEquals(WorkflowInstance.Status.FAILED, store2.getWorkflow(jobId, false).getWorkflowInstance().getStatus());
assertEquals(WorkflowJob.Status.FAILED, engine.getJob(jobId).getStatus());
List<WorkflowActionBean> actions = store2.getActionsForWorkflow(jobId, false);
WorkflowActionBean action = null;
for (WorkflowActionBean bean : actions) {
if (bean.getType().equals("test")) {
action = bean;
break;
}
}
assertNotNull(action);
assertEquals(expActionErrorCode, action.getErrorCode());
store2.commitTrx();
store2.closeTrx();
}
Aggregations