use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class BundleSubmitXCommand method createEvaluator.
/**
* Create ELEvaluator
*
* @param conf job configuration
* @return ELEvaluator the evaluator for el function
* @throws BundleJobException thrown if failed to create evaluator
*/
public ELEvaluator createEvaluator(Configuration conf) throws BundleJobException {
ELEvaluator eval;
ELEvaluator.Context context;
try {
context = new ELEvaluator.Context();
eval = new ELEvaluator(context);
for (Map.Entry<String, String> entry : conf) {
eval.setVariable(entry.getKey(), entry.getValue());
}
} catch (Exception e) {
throw new BundleJobException(ErrorCode.E1004, e.getMessage(), e);
}
return eval;
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class BundleSubmitXCommand method createELEvaluatorForGroup.
public static ELEvaluator createELEvaluatorForGroup(Configuration conf, String group) {
ELEvaluator eval = Services.get().get(ELService.class).createEvaluator(group);
setConfigToEval(eval, conf);
return eval;
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordSLAChangeXCommand method executeSlaCommand.
@Override
protected boolean executeSlaCommand() throws ServiceException, CommandException {
try {
List<Pair<String, Map<String, String>>> idSlaDefinitionList = new ArrayList<Pair<String, Map<String, String>>>();
List<CoordinatorActionBean> coordinatorActionBeanList = getNotTerminatedActions();
Configuration conf = getJobConf();
for (CoordinatorActionBean coordAction : coordinatorActionBeanList) {
Map<String, String> slaDefinitionMap = new HashMap<String, String>(newParams);
for (String key : slaDefinitionMap.keySet()) {
Element eAction = XmlUtils.parseXml(coordAction.getActionXml().toString());
ELEvaluator evalSla = CoordELEvaluator.createSLAEvaluator(eAction, coordAction, conf);
String updateValue = CoordELFunctions.evalAndWrap(evalSla, slaDefinitionMap.get(key));
slaDefinitionMap.put(key, updateValue);
}
idSlaDefinitionList.add(new Pair<String, Map<String, String>>(coordAction.getId(), slaDefinitionMap));
}
return Services.get().get(SLAService.class).changeDefinition(idSlaDefinitionList);
} catch (Exception e) {
throw new CommandException(ErrorCode.E1027, e.getMessage(), e);
}
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordCommandUtils method createEarlyURIs.
/**
* The function create a list of URIs separated by "," using the instances
* time stamp and URI-template
*
* @param event : <data-in> event
* @param instances : List of time stamp separated by ","
* @param unresolvedInstances : list of instance with latest function
* @param urisWithDoneFlag : list of URIs with the done flag appended
* @return : list of URIs separated by ";" as a string.
* @throws Exception
*/
public static String createEarlyURIs(Element event, String instances, StringBuilder unresolvedInstances, StringBuilder urisWithDoneFlag) throws Exception {
if (instances == null || instances.length() == 0) {
return "";
}
String[] instanceList = instances.split(CoordELFunctions.INSTANCE_SEPARATOR);
StringBuilder uris = new StringBuilder();
Element doneFlagElement = event.getChild("dataset", event.getNamespace()).getChild("done-flag", event.getNamespace());
URIHandlerService uriService = Services.get().get(URIHandlerService.class);
for (int i = 0; i < instanceList.length; i++) {
if (instanceList[i].trim().length() == 0) {
continue;
}
int funcType = getFuncType(instanceList[i]);
if (funcType == LATEST || funcType == FUTURE) {
if (unresolvedInstances.length() > 0) {
unresolvedInstances.append(CoordELFunctions.INSTANCE_SEPARATOR);
}
unresolvedInstances.append(instanceList[i]);
continue;
}
ELEvaluator eval = CoordELEvaluator.createURIELEvaluator(instanceList[i]);
if (uris.length() > 0) {
uris.append(CoordELFunctions.INSTANCE_SEPARATOR);
urisWithDoneFlag.append(CoordELFunctions.INSTANCE_SEPARATOR);
}
String uriPath = CoordELFunctions.evalAndWrap(eval, event.getChild("dataset", event.getNamespace()).getChild("uri-template", event.getNamespace()).getTextTrim());
URIHandler uriHandler = uriService.getURIHandler(uriPath);
uriHandler.validate(uriPath);
uris.append(uriPath);
urisWithDoneFlag.append(uriHandler.getURIWithDoneFlag(uriPath, CoordUtils.getDoneFlag(doneFlagElement)));
}
return uris.toString();
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordCommandUtils method materializeSLA.
/**
* @param eAction
* @param coordAction
* @param conf
* @return boolean to determine whether the SLA element is present or not
* @throws CoordinatorJobException
*/
public static boolean materializeSLA(Element eAction, CoordinatorActionBean coordAction, Configuration conf) throws CoordinatorJobException {
Element eSla = eAction.getChild("action", eAction.getNamespace()).getChild("info", eAction.getNamespace("sla"));
if (eSla == null) {
// eAppXml.getNamespace("sla"));
return false;
}
try {
ELEvaluator evalSla = CoordELEvaluator.createSLAEvaluator(eAction, coordAction, conf);
List<Element> elemList = eSla.getChildren();
for (Element elem : elemList) {
String updated;
try {
updated = CoordELFunctions.evalAndWrap(evalSla, elem.getText().trim());
} catch (Exception e) {
throw new CoordinatorJobException(ErrorCode.E1004, e.getMessage(), e);
}
elem.removeContent();
elem.addContent(updated);
}
} catch (Exception e) {
throw new CoordinatorJobException(ErrorCode.E1004, e.getMessage(), e);
}
return true;
}
Aggregations