use of org.apache.oozie.DagEngineException 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;
}
use of org.apache.oozie.DagEngineException 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.DagEngineException 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.DagEngineException in project oozie by apache.
the class TestPurgeService method testPurgeServiceForWorkflow.
/**
* Tests the {@link org.apache.oozie.service.PurgeService}.
* </p>
* Creates and runs a new workflow job to completion.
* Attempts to purge jobs older than a day. Verifies the presence of the job in the system.
* </p>
* Sets the end date for the same job to make it qualify for the purge criteria.
* Calls the purge service, and ensure the job does not exist in the system.
*/
public void testPurgeServiceForWorkflow() throws Exception {
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, getTestCaseFileUri("workflow.xml"));
conf.setStrings(OozieClient.USER_NAME, getTestUser());
conf.setStrings(OozieClient.GROUP_NAME, getTestGroup());
conf.set(OozieClient.LOG_TOKEN, "t");
conf.set("external-status", "ok");
conf.set("signal-value", "based_on_action_status");
final String jobId = engine.submitJob(conf, true);
waitFor(5000, new Predicate() {
public boolean evaluate() throws Exception {
return (engine.getJob(jobId).getStatus() == WorkflowJob.Status.SUCCEEDED);
}
});
assertEquals(WorkflowJob.Status.SUCCEEDED, engine.getJob(jobId).getStatus());
new PurgeXCommand(1, 1, 1, 10000).call();
sleep(1000);
JPAService jpaService = Services.get().get(JPAService.class);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(jobId);
WorkflowJobBean wfBean = jpaService.execute(wfJobGetCmd);
Date endDate = new Date(System.currentTimeMillis() - 2 * 24 * 60 * 60 * 1000);
wfBean.setEndTime(endDate);
wfBean.setLastModifiedTime(new Date());
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_STATUS_INSTANCE_MOD_END, wfBean);
Runnable purgeRunnable = new PurgeRunnable(1, 1, 1, 100);
purgeRunnable.run();
waitFor(10000, new Predicate() {
public boolean evaluate() throws Exception {
try {
engine.getJob(jobId).getStatus();
} catch (Exception ex) {
return true;
}
return false;
}
});
try {
engine.getJob(jobId).getStatus();
fail("Job should be purged. Should fail.");
} catch (Exception ex) {
assertEquals(ex.getClass(), DagEngineException.class);
DagEngineException dex = (DagEngineException) ex;
assertEquals(ErrorCode.E0604, dex.getErrorCode());
}
}
Aggregations