use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class LiteWorkflowAppParser method getGlobalString.
/**
* Write the GlobalSectionData to a Base64 string.
* @param globalSectionData
* @return String
* @throws WorkflowException
*/
private String getGlobalString(GlobalSectionData globalSectionData) throws WorkflowException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream oos = null;
try {
Deflater def = new Deflater();
oos = new DataOutputStream(new DeflaterOutputStream(baos, def));
globalSectionData.write(oos);
oos.close();
} catch (IOException e) {
throw new WorkflowException(ErrorCode.E0700, "Error while processing global section conf");
}
return Base64.encodeBase64String(baos.toByteArray());
}
use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class DBLiteWorkflowLib method get.
/**
* Loads the Workflow instance with the given ID.
*
* @param id
* @return pInstance returns a workflow instance with the given ID
* @throws WorkflowException
*/
@Override
public WorkflowInstance get(String id) throws WorkflowException {
ParamChecker.notNull(id, "id");
try {
ResultSetReader rs = SqlStatement.parse(SqlStatement.selectColumns(OozieColumn.PI_state).where(SqlStatement.isEqual(OozieColumn.PI_wfId, ParamChecker.notNull(id, "id"))).prepareAndSetValues(connection).executeQuery());
rs.next();
LiteWorkflowInstance pInstance = WritableUtils.fromByteArray(rs.getByteArray(OozieColumn.PI_state), LiteWorkflowInstance.class);
return pInstance;
} catch (SQLException e) {
throw new WorkflowException(ErrorCode.E0713, e.getMessage(), e);
}
}
use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class TestLiteWorkflowAppService method testActionNameLength.
public void testActionNameLength() throws Exception {
setSystemProperty("oozie.service.ActionService.executor.ext.classes", TestActionExecutor.class.getName());
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-action-name-too-long.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
WorkflowAppService wps = services.get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
try {
LiteWorkflowApp app = (LiteWorkflowApp) wps.parseDef(jobConf);
fail();
} catch (WorkflowException ex) {
assertEquals(ErrorCode.E0724, ex.getErrorCode());
// nop
}
} finally {
services.destroy();
}
}
use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class TestLiteWorkflowAppService method testMaxWfDefinition.
/**
* Making sure an exception is thrown when a WF exceeds the maximum length
*
* @throws Exception
*/
public void testMaxWfDefinition() throws Exception {
setSystemProperty(WorkflowAppService.CONFG_MAX_WF_LENGTH, "100");
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
Configuration conf = new XConfiguration();
WorkflowAppService wps = services.get(WorkflowAppService.class);
wps.readDefinition(getTestCaseFileUri("workflow.xml"), getTestUser(), conf);
fail("an exception should be thrown as the definition exceeds the given maximum");
} catch (WorkflowException wfe) {
assertEquals(wfe.getErrorCode(), ErrorCode.E0736);
} finally {
services.destroy();
}
}
use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class TestLiteWorkflowAppService method testSchema.
public void testSchema() throws Exception {
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
WorkflowAppService wps = services.get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
WorkflowApp app = wps.parseDef(jobConf);
assertNotNull(app);
assertEquals("test-wf", app.getName());
reader = IOUtils.getResourceAsReader("wf-schema-invalid.xml", -1);
writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
try {
wps.parseDef(jobConf);
fail();
} catch (WorkflowException ex) {
// nop
}
} finally {
services.destroy();
}
}
Aggregations