use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordCommandUtils method materializeInputDataEvents.
public static void materializeInputDataEvents(List<Element> events, SyncCoordAction appInst, Configuration conf, CoordinatorActionBean actionBean, boolean isInputLogicSpecified) throws Exception {
if (events == null) {
return;
}
CoordInputDependency coordPullInputDependency = CoordInputDependencyFactory.createPullInputDependencies(isInputLogicSpecified);
CoordInputDependency coordPushInputDependency = CoordInputDependencyFactory.createPushInputDependencies(isInputLogicSpecified);
List<Pair<String, String>> unresolvedList = new ArrayList<Pair<String, String>>();
URIHandlerService uriService = Services.get().get(URIHandlerService.class);
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
String resolvedList = separateResolvedAndUnresolved(event, instances);
String name = event.getAttribute("name").getValue();
if (!resolvedList.isEmpty()) {
Element uri = event.getChild("dataset", event.getNamespace()).getChild("uri-template", event.getNamespace());
String uriTemplate = uri.getText();
URI baseURI = uriService.getAuthorityWithScheme(uriTemplate);
URIHandler handler = uriService.getURIHandler(baseURI);
List<CoordInputInstance> inputInstanceList = new ArrayList<CoordInputInstance>();
for (String inputInstance : resolvedList.split("#")) {
inputInstanceList.add(new CoordInputInstance(inputInstance, false));
}
if (handler.getDependencyType(baseURI).equals(DependencyType.PULL)) {
coordPullInputDependency.addInputInstanceList(name, inputInstanceList);
} else {
coordPushInputDependency.addInputInstanceList(name, inputInstanceList);
}
}
String tmpUnresolved = event.getChildTextTrim(UNRESOLVED_INSTANCES_TAG, event.getNamespace());
if (tmpUnresolved != null) {
unresolvedList.add(new Pair<String, String>(name, tmpUnresolved));
}
}
for (Pair<String, String> unresolvedDataset : unresolvedList) {
coordPullInputDependency.addUnResolvedList(unresolvedDataset.getFirst(), unresolvedDataset.getSecond());
}
actionBean.setPullInputDependencies(coordPullInputDependency);
actionBean.setPushInputDependencies(coordPushInputDependency);
actionBean.setMissingDependencies(coordPullInputDependency.serialize());
actionBean.setPushMissingDependencies(coordPushInputDependency.serialize());
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordELEvaluator method createELEvaluatorForDataEcho.
public static ELEvaluator createELEvaluatorForDataEcho(Configuration conf, String group, HashMap<String, String> dataNameList) throws Exception {
ELEvaluator eval = createELEvaluatorForGroup(conf, group);
for (Iterator<String> it = dataNameList.keySet().iterator(); it.hasNext(); ) {
String key = it.next();
String value = dataNameList.get(key);
eval.setVariable("oozie.dataname." + key, value);
}
return eval;
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordELEvaluator method createLazyEvaluator.
/**
* Create a new evaluator for Lazy resolve (phase 3). For example, coord_latest(n) and coord_actualTime()function
* should be resolved when all other data dependencies are met.
*
* @param actualTime : Action start time
* @param nominalTime : Action creation time
* @param dEvent :XML element for data-in element usually enclosed by <data-in(out)> tag
* @param conf :Configuration to substitute any variables
* @return configured ELEvaluator
* @throws Exception : If there is any date-time string in wrong format, the exception is thrown
*/
public static ELEvaluator createLazyEvaluator(Date actualTime, Date nominalTime, Element dEvent, Configuration conf) throws Exception {
ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("coord-action-start");
setConfigToEval(eval, conf);
SyncCoordDataset ds = getDSObject(dEvent);
SyncCoordAction appInst = new SyncCoordAction();
appInst.setNominalTime(nominalTime);
appInst.setActualTime(actualTime);
CoordELFunctions.configureEvaluator(eval, ds, appInst);
eval.setVariable(CoordELFunctions.CONFIGURATION, conf);
return eval;
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordELEvaluator method createDataEvaluator.
public static ELEvaluator createDataEvaluator(Element eJob, Configuration conf, String actionId, CoordInputDependency pullDependencies, CoordInputDependency pushDependencies) throws Exception {
ELEvaluator e = Services.get().get(ELService.class).createEvaluator("coord-action-start");
setConfigToEval(e, conf);
SyncCoordAction appInst = new SyncCoordAction();
String strNominalTime = eJob.getAttributeValue("action-nominal-time");
if (strNominalTime != null) {
appInst.setNominalTime(DateUtils.parseDateOozieTZ(strNominalTime));
appInst.setTimeZone(DateUtils.getTimeZone(eJob.getAttributeValue("timezone")));
appInst.setFrequency(eJob.getAttributeValue("frequency"));
appInst.setTimeUnit(TimeUnit.valueOf(eJob.getAttributeValue("freq_timeunit")));
appInst.setActionId(actionId);
appInst.setName(eJob.getAttributeValue("name"));
appInst.setPullDependencies(pullDependencies);
appInst.setPushDependencies(pushDependencies);
if (CoordUtils.isInputLogicSpecified(eJob)) {
e.setVariable(".actionInputLogic", XmlUtils.prettyPrint(eJob.getChild(CoordInputLogicEvaluator.INPUT_LOGIC, eJob.getNamespace())).toString());
}
}
String strActualTime = eJob.getAttributeValue("action-actual-time");
if (strActualTime != null) {
appInst.setActualTime(DateUtils.parseDateOozieTZ(strActualTime));
}
CoordELFunctions.configureEvaluator(e, null, appInst);
Element events = eJob.getChild("input-events", eJob.getNamespace());
if (events != null) {
for (Element data : (List<Element>) events.getChildren("data-in", eJob.getNamespace())) {
if (data.getChild("uris", data.getNamespace()) != null) {
String uris = data.getChild("uris", data.getNamespace()).getTextTrim();
uris = uris.replaceAll(CoordELFunctions.INSTANCE_SEPARATOR, CoordELFunctions.DIR_SEPARATOR);
e.setVariable(".datain." + data.getAttributeValue("name"), uris);
} else {
}
if (data.getChild(CoordCommandUtils.UNRESOLVED_INSTANCES_TAG, data.getNamespace()) != null) {
// TODO:
e.setVariable(".datain." + data.getAttributeValue("name") + ".unresolved", "true");
// check
// null
}
Element doneFlagElement = data.getChild("dataset", data.getNamespace()).getChild("done-flag", data.getNamespace());
String doneFlag = CoordUtils.getDoneFlag(doneFlagElement);
e.setVariable(".datain." + data.getAttributeValue("name") + ".doneFlag", doneFlag);
}
}
events = eJob.getChild("output-events", eJob.getNamespace());
if (events != null) {
for (Element data : (List<Element>) events.getChildren("data-out", eJob.getNamespace())) {
if (data.getChild("uris", data.getNamespace()) != null) {
String uris = data.getChild("uris", data.getNamespace()).getTextTrim();
uris = uris.replaceAll(CoordELFunctions.INSTANCE_SEPARATOR, CoordELFunctions.DIR_SEPARATOR);
e.setVariable(".dataout." + data.getAttributeValue("name"), uris);
} else {
}
// TODO
if (data.getChild(CoordCommandUtils.UNRESOLVED_INSTANCES_TAG, data.getNamespace()) != null) {
// TODO:
e.setVariable(".dataout." + data.getAttributeValue("name") + ".unresolved", "true");
// check
// null
}
}
}
return e;
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordELEvaluator method createInstancesELEvaluator.
public static ELEvaluator createInstancesELEvaluator(String tag, Element event, SyncCoordAction appInst, Configuration conf) throws Exception {
ELEvaluator eval = Services.get().get(ELService.class).createEvaluator(tag);
setConfigToEval(eval, conf);
SyncCoordDataset ds = getDSObject(event);
CoordELFunctions.configureEvaluator(eval, ds, appInst);
return eval;
}
Aggregations