use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class TestELService method testELForWorkflow.
public void testELForWorkflow() throws Exception {
assertNotNull(Services.get().get(ELService.class));
ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("workflow");
assertNotNull(eval.evaluate("${KB}", Long.class));
assertNotNull(eval.evaluate("${MB}", Long.class));
assertNotNull(eval.evaluate("${GB}", Long.class));
assertNotNull(eval.evaluate("${TB}", Long.class));
assertNotNull(eval.evaluate("${PB}", Long.class));
assertNotNull(eval.evaluate("${trim(' ')}", String.class));
assertNotNull(eval.evaluate("${concat('a', 'b')}", String.class));
assertNotNull(eval.evaluate("${firstNotNull(null, 'b')}", String.class));
assertNotNull(eval.evaluate("${timestamp()}", String.class));
assertNotNull(eval.evaluate("${urlEncode('abc')}", String.class));
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class JavaActionExecutor method getCredProperties.
@SuppressWarnings("unchecked")
protected CredentialsProperties getCredProperties(Context context, String credName) throws Exception {
CredentialsProperties credProp = null;
String workflowXml = ((WorkflowJobBean) context.getWorkflow()).getWorkflowInstance().getApp().getDefinition();
XConfiguration wfjobConf = getWorkflowConf(context);
Element elementJob = XmlUtils.parseXml(workflowXml);
Element credentials = elementJob.getChild("credentials", elementJob.getNamespace());
if (credentials != null) {
for (Element credential : (List<Element>) credentials.getChildren("credential", credentials.getNamespace())) {
String name = credential.getAttributeValue("name");
String type = credential.getAttributeValue("type");
LOG.debug("getCredProperties: Name: " + name + ", Type: " + type);
if (name.equalsIgnoreCase(credName)) {
credProp = new CredentialsProperties(name, type);
for (Element property : (List<Element>) credential.getChildren("property", credential.getNamespace())) {
String propertyName = property.getChildText("name", property.getNamespace());
String propertyValue = property.getChildText("value", property.getNamespace());
ELEvaluator eval = new ELEvaluator();
for (Map.Entry<String, String> entry : wfjobConf) {
eval.setVariable(entry.getKey(), entry.getValue().trim());
}
propertyName = eval.evaluate(propertyName, String.class);
propertyValue = eval.evaluate(propertyValue, String.class);
credProp.getProperties().put(propertyName, propertyValue);
LOG.debug("getCredProperties: Properties name :'" + propertyName + "', Value : '" + propertyValue + "'");
}
}
}
if (credProp == null && credName != null) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "JA021", "Could not load credentials with name [{0}]].", credName);
}
} else {
LOG.debug("credentials is null for the action");
}
return credProp;
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class DagELFunctions method wf_actionData.
/**
* Return the action data for an action.
*
* @param actionName action name.
* @return value of the property.
*/
@SuppressWarnings("unchecked")
public static Map<String, String> wf_actionData(String actionName) {
ELEvaluator eval = ELEvaluator.getCurrent();
Properties props = (Properties) eval.getVariable(actionName + ACTION_ERROR_MESSAGE);
if (props == null) {
String data = getWorkflow().getWorkflowInstance().getVar(actionName + WorkflowInstance.NODE_VAR_SEPARATOR + ACTION_DATA);
if (data != null) {
props = PropertiesUtils.stringToProperties(data);
} else {
props = new Properties();
}
eval.setVariable(actionName + ACTION_ERROR_MESSAGE, props);
}
return (Map<String, String>) (Map) props;
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordActionInputCheckXCommand method resolveCoordConfiguration.
static String resolveCoordConfiguration(StringBuilder actionXml, Configuration actionConf, String actionId, CoordInputDependency pullDependencies, CoordInputDependency pushDependencies) throws Exception {
Element eAction = XmlUtils.parseXml(actionXml.toString());
ELEvaluator eval = CoordELEvaluator.createDataEvaluator(eAction, actionConf, actionId, pullDependencies, pushDependencies);
materializeDataProperties(eAction, actionConf, eval);
return XmlUtils.prettyPrint(eAction).toString();
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordCommandUtils method materializeOutputDataEvents.
/**
* Materialize all <input-events>/<data-in> or <output-events>/<data-out>
* tags Create uris for resolved instances. Create unresolved instance for
* latest()/future().
*
* @param events
* @param appInst
* @param conf
* @throws Exception
*/
private static void materializeOutputDataEvents(List<Element> events, SyncCoordAction appInst, Configuration conf) throws Exception {
if (events == null) {
return;
}
for (Element event : events) {
StringBuilder instances = new StringBuilder();
ELEvaluator eval = CoordELEvaluator.createInstancesELEvaluator(event, appInst, conf);
// Handle list of instance tag
resolveInstances(event, instances, appInst, conf, eval);
// Handle start-instance and end-instance
resolveInstanceRange(event, instances, appInst, conf, eval);
// Separate out the unresolved instances
separateResolvedAndUnresolved(event, instances);
}
}
Aggregations