use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class LiteWorkflowStoreService method getUserRetryInterval.
private static int getUserRetryInterval(NodeHandler.Context context) throws WorkflowException {
int ret = ConfigurationService.getInt(CONF_USER_RETRY_INTEVAL);
String userRetryInterval = context.getNodeDef().getUserRetryInterval();
if (!userRetryInterval.equals("null")) {
try {
ret = Integer.parseInt(userRetryInterval);
} catch (NumberFormatException nfe) {
throw new WorkflowException(ErrorCode.E0700, nfe.getMessage(), nfe);
}
}
return ret;
}
use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class TestLiteWorkflowAppService method testExtSchema.
public void testExtSchema() throws Exception {
setSystemProperty(SchemaService.WF_CONF_EXT_SCHEMAS, "wf-ext-schema.xsd");
setSystemProperty("oozie.service.ActionService.executor.ext.classes", TestActionExecutor.class.getName());
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-ext-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());
LiteWorkflowApp app = (LiteWorkflowApp) wps.parseDef(jobConf);
assertNotNull(app);
assertEquals("test-wf", app.getName());
reader = IOUtils.getResourceAsReader("wf-ext-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();
}
}
use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class WorkflowStore method getAction.
/**
* Load the action data and returns a bean.
*
* @param id Action Id
* @param locking true if the action is to be locked
* @return Action Bean
* @throws StoreException If action doesn't exist
*/
public WorkflowActionBean getAction(final String id, final boolean locking) throws StoreException {
ParamChecker.notEmpty(id, "ActionID");
WorkflowActionBean action = doOperation("getAction", new Callable<WorkflowActionBean>() {
public WorkflowActionBean call() throws SQLException, StoreException, WorkflowException, InterruptedException {
Query q = entityManager.createNamedQuery("GET_ACTION");
/*
* if (locking) { OpenJPAQuery oq = OpenJPAPersistence.cast(q);
* FetchPlan fetch = oq.getFetchPlan();
* fetch.setReadLockMode(LockModeType.WRITE);
* fetch.setLockTimeout(1000); // 1 seconds }
*/
WorkflowActionBean action = null;
q.setParameter("id", id);
List<WorkflowActionBean> actions = q.getResultList();
// action = (WorkflowActionBean) q.getSingleResult();
if (actions.size() > 0) {
action = actions.get(0);
} else {
throw new StoreException(ErrorCode.E0605, id);
}
// return action;
return getBeanForRunningAction(action);
}
});
return action;
}
use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class WorkflowStore method getWorkflow.
/**
* Load the Workflow into a Bean and return it. Also load the Workflow Instance into the bean. And lock the Workflow
* depending on the locking parameter.
*
* @param id Workflow ID
* @param locking true if Workflow is to be locked
* @return WorkflowJobBean
* @throws StoreException
*/
public WorkflowJobBean getWorkflow(final String id, final boolean locking) throws StoreException {
ParamChecker.notEmpty(id, "WorkflowID");
WorkflowJobBean wfBean = doOperation("getWorkflow", new Callable<WorkflowJobBean>() {
public WorkflowJobBean call() throws SQLException, StoreException, WorkflowException, InterruptedException {
WorkflowJobBean wfBean = null;
wfBean = getWorkflowOnly(id, locking);
if (wfBean == null) {
throw new StoreException(ErrorCode.E0604, id);
}
/*
* WorkflowInstance wfInstance; //krishna and next line
* wfInstance = workflowLib.get(id); wfInstance =
* wfBean.get(wfBean.getWfInstance());
* wfBean.setWorkflowInstance(wfInstance);
* wfBean.setWfInstance(wfInstance);
*/
return wfBean;
}
});
return wfBean;
}
use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.
the class ReRunXCommand method setupReRun.
private void setupReRun() throws CommandException {
InstrumentUtils.incrJobCounter(getName(), 1, getInstrumentation());
LogUtils.setLogInfo(wfBean);
WorkflowInstance oldWfInstance = this.wfBean.getWorkflowInstance();
WorkflowInstance newWfInstance;
String appPath = null;
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
try {
XLog.Info.get().setParameter(DagXLogInfoService.TOKEN, conf.get(OozieClient.LOG_TOKEN));
WorkflowApp app = wps.parseDef(conf, null);
XConfiguration protoActionConf = wps.createProtoActionConf(conf, true);
WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
appPath = conf.get(OozieClient.APP_PATH);
URI uri = new URI(appPath);
HadoopAccessorService has = Services.get().get(HadoopAccessorService.class);
Configuration fsConf = has.createConfiguration(uri.getAuthority());
FileSystem fs = has.createFileSystem(wfBean.getUser(), uri, fsConf);
Path configDefault = null;
// app path could be a directory
Path path = new Path(uri.getPath());
if (!fs.isFile(path)) {
configDefault = new Path(path, SubmitXCommand.CONFIG_DEFAULT);
} else {
configDefault = new Path(path.getParent(), SubmitXCommand.CONFIG_DEFAULT);
}
if (fs.exists(configDefault)) {
Configuration defaultConf = new XConfiguration(fs.open(configDefault));
PropertiesUtils.checkDisallowedProperties(defaultConf, DISALLOWED_DEFAULT_PROPERTIES);
XConfiguration.injectDefaults(defaultConf, conf);
}
PropertiesUtils.checkDisallowedProperties(conf, DISALLOWED_USER_PROPERTIES);
// Resolving all variables in the job properties. This ensures the Hadoop Configuration semantics are
// preserved. The Configuration.get function within XConfiguration.resolve() works recursively to get the
// final value corresponding to a key in the map Resetting the conf to contain all the resolved values is
// necessary to ensure propagation of Oozie properties to Hadoop calls downstream
conf = ((XConfiguration) conf).resolve();
try {
newWfInstance = workflowLib.createInstance(app, conf, jobId);
} catch (WorkflowException e) {
throw new CommandException(e);
}
String appName = ELUtils.resolveAppName(app.getName(), conf);
if (SLAService.isEnabled()) {
Element wfElem = XmlUtils.parseXml(app.getDefinition());
ELEvaluator evalSla = SubmitXCommand.createELEvaluatorForGroup(conf, "wf-sla-submit");
Element eSla = XmlUtils.getSLAElement(wfElem);
String jobSlaXml = null;
if (eSla != null) {
jobSlaXml = SubmitXCommand.resolveSla(eSla, evalSla);
}
writeSLARegistration(wfElem, jobSlaXml, newWfInstance.getId(), conf.get(SubWorkflowActionExecutor.PARENT_ID), conf.get(OozieClient.USER_NAME), appName, evalSla);
}
wfBean.setAppName(appName);
wfBean.setProtoActionConf(protoActionConf.toXmlString());
} catch (WorkflowException ex) {
throw new CommandException(ex);
} catch (IOException ex) {
throw new CommandException(ErrorCode.E0803, ex.getMessage(), ex);
} catch (HadoopAccessorException ex) {
throw new CommandException(ex);
} catch (URISyntaxException ex) {
throw new CommandException(ErrorCode.E0711, appPath, ex.getMessage(), ex);
} catch (Exception ex) {
throw new CommandException(ErrorCode.E1007, ex.getMessage(), ex);
}
for (int i = 0; i < actions.size(); i++) {
// action will be used to rerun the job.
if (!nodesToSkip.contains(actions.get(i).getName()) && !(conf.getBoolean(OozieClient.RERUN_FAIL_NODES, false) && SubWorkflowActionExecutor.ACTION_TYPE.equals(actions.get(i).getType()))) {
deleteList.add(actions.get(i));
LOG.info("Deleting Action[{0}] for re-run", actions.get(i).getId());
} else {
copyActionData(newWfInstance, oldWfInstance);
}
}
wfBean.setAppPath(conf.get(OozieClient.APP_PATH));
wfBean.setConf(XmlUtils.prettyPrint(conf).toString());
wfBean.setLogToken(conf.get(OozieClient.LOG_TOKEN, ""));
wfBean.setUser(conf.get(OozieClient.USER_NAME));
String group = ConfigUtils.getWithDeprecatedCheck(conf, OozieClient.JOB_ACL, OozieClient.GROUP_NAME, null);
wfBean.setGroup(group);
wfBean.setExternalId(conf.get(OozieClient.EXTERNAL_ID));
wfBean.setEndTime(null);
wfBean.setRun(wfBean.getRun() + 1);
wfBean.setStatus(WorkflowJob.Status.PREP);
wfBean.setWorkflowInstance(newWfInstance);
try {
wfBean.setLastModifiedTime(new Date());
updateList.add(new UpdateEntry<WorkflowJobQuery>(WorkflowJobQuery.UPDATE_WORKFLOW_RERUN, wfBean));
// call JPAExecutor to do the bulk writes
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(null, updateList, deleteList);
} catch (JPAExecutorException je) {
throw new CommandException(je);
} finally {
updateParentIfNecessary(wfBean);
}
}
Aggregations