use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class FsActionExecutor method getFileSystemFor.
/**
* @param path
* @param context
* @param fsConf
* @return FileSystem
* @throws HadoopAccessorException
*/
private FileSystem getFileSystemFor(Path path, Context context, XConfiguration fsConf) throws HadoopAccessorException {
String user = context.getWorkflow().getUser();
HadoopAccessorService has = Services.get().get(HadoopAccessorService.class);
Configuration conf = has.createConfiguration(path.toUri().getAuthority());
XConfiguration.copy(context.getProtoActionConf(), conf);
if (fsConf != null) {
XConfiguration.copy(fsConf, conf);
}
return has.createFileSystem(user, path.toUri(), conf);
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class BundleSubmitXCommand method submit.
/* (non-Javadoc)
* @see org.apache.oozie.command.SubmitTransitionXCommand#submit()
*/
@Override
protected String submit() throws CommandException {
LOG.info("STARTED Bundle Submit");
try {
InstrumentUtils.incrJobCounter(getName(), 1, getInstrumentation());
ParameterVerifier.verifyParameters(conf, XmlUtils.parseXml(bundleBean.getOrigJobXml()));
String jobXmlWithNoComment = XmlUtils.removeComments(this.bundleBean.getOrigJobXml().toString());
// Resolving all variables in the job properties.
// This ensures the Hadoop Configuration semantics is preserved.
XConfiguration resolvedVarsConf = new XConfiguration();
for (Map.Entry<String, String> entry : conf) {
resolvedVarsConf.set(entry.getKey(), conf.get(entry.getKey()));
}
conf = resolvedVarsConf;
String resolvedJobXml = resolvedVarsandFunctions(jobXmlWithNoComment, conf);
// verify the uniqueness of coord names
verifyCoordNameUnique(resolvedJobXml);
this.jobId = storeToDB(bundleBean, resolvedJobXml);
LogUtils.setLogInfo(bundleBean);
if (dryrun) {
Date startTime = bundleBean.getStartTime();
long startTimeMilli = startTime.getTime();
long endTimeMilli = startTimeMilli + (3600 * 1000);
Date jobEndTime = bundleBean.getEndTime();
Date endTime = new Date(endTimeMilli);
if (endTime.compareTo(jobEndTime) > 0) {
endTime = jobEndTime;
}
jobId = bundleBean.getId();
LOG.info("[" + jobId + "]: Update status to PREP");
bundleBean.setStatus(Job.Status.PREP);
try {
new XConfiguration(new StringReader(bundleBean.getConf()));
} catch (IOException e1) {
LOG.warn("Configuration parse error. read from DB :" + bundleBean.getConf(), e1);
}
String output = bundleBean.getJobXml() + System.getProperty("line.separator");
return output;
} else {
if (bundleBean.getKickoffTime() == null) {
// If there is no KickOffTime, default kickoff is NOW.
LOG.debug("Since kickoff time is not defined for job id " + jobId + ". Queuing and BundleStartXCommand immediately after submission");
queue(new BundleStartXCommand(jobId));
}
}
} catch (Exception ex) {
throw new CommandException(ErrorCode.E1310, ex.getMessage(), ex);
}
LOG.info("ENDED Bundle Submit");
return this.jobId;
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class DagELFunctions method configureEvaluator.
public static void configureEvaluator(ELEvaluator evaluator, WorkflowJobBean workflow, WorkflowActionBean action) {
evaluator.setVariable(WORKFLOW, workflow);
evaluator.setVariable(ACTION, action);
for (Map.Entry<String, String> entry : workflow.getWorkflowInstance().getConf()) {
if (ParamChecker.isValidIdentifier(entry.getKey())) {
String value = entry.getValue().trim();
try {
String valueElem = "<value>" + value + "</value>";
XmlUtils.parseXml(valueElem);
} catch (JDOMException ex) {
// If happens, try escaping the characters for XML. The escaping may or
// may not solve the problem since the JDOMException could be for a range of issues.
value = XmlUtils.escapeCharsForXML(value);
}
evaluator.setVariable(entry.getKey().trim(), value);
}
}
try {
evaluator.setVariable(ACTION_PROTO_CONF, new XConfiguration(new StringReader(workflow.getProtoActionConf())));
} catch (IOException ex) {
throw new RuntimeException("It should not happen", ex);
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class DagEngine method reRun.
/**
* Rerun a job.
*
* @param jobId job Id to rerun.
* @param conf configuration information for the rerun.
* @throws DagEngineException thrown if the job could not be rerun.
*/
@Override
public void reRun(String jobId, Configuration conf) throws DagEngineException {
try {
WorkflowJobBean wfBean = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW, jobId);
Configuration wfConf = new XConfiguration(new StringReader(wfBean.getConf()));
XConfiguration.copy(conf, wfConf);
validateReRunConfiguration(wfConf);
new ReRunXCommand(jobId, wfConf).call();
} catch (CommandException ex) {
throw new DagEngineException(ex);
} catch (JPAExecutorException ex) {
throw new DagEngineException(ex);
} catch (IOException ex) {
throw new DagEngineException(ErrorCode.E0803, ex.getMessage());
}
}
use of org.apache.oozie.util.XConfiguration in project oozie by apache.
the class MapReduceActionExecutor method evaluateConfigurationProperty.
// Return the value of the specified configuration property
private String evaluateConfigurationProperty(Element actionConf, String key, String defaultValue) throws ActionExecutorException {
try {
String ret = defaultValue;
if (actionConf != null) {
Namespace ns = actionConf.getNamespace();
Element e = actionConf.getChild("configuration", ns);
if (e != null) {
String strConf = XmlUtils.prettyPrint(e).toString();
XConfiguration inlineConf = new XConfiguration(new StringReader(strConf));
ret = inlineConf.get(key, defaultValue);
}
}
return ret;
} catch (IOException ex) {
throw convertException(ex);
}
}
Aggregations