Search in sources :

Example 21 with ELEvaluator

use of org.apache.oozie.util.ELEvaluator in project oozie by apache.

the class CoordELFunctions method ph2_coord_nominalTime.

/**
 * Return nominal time or Action Creation Time.
 *
 * @return coordinator action creation or materialization date time
 * @throws Exception if unable to format the Date object to String
 */
public static String ph2_coord_nominalTime() throws Exception {
    ELEvaluator eval = ELEvaluator.getCurrent();
    SyncCoordAction action = ParamChecker.notNull((SyncCoordAction) eval.getVariable(COORD_ACTION), "Coordinator Action");
    return DateUtils.formatDateOozieTZ(action.getNominalTime());
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 22 with ELEvaluator

use of org.apache.oozie.util.ELEvaluator in project oozie by apache.

the class CoordELFunctions method isSyncDataSet.

/**
 * @return whether a data set is SYNCH or ASYNC
 */
private static boolean isSyncDataSet() {
    ELEvaluator eval = ELEvaluator.getCurrent();
    SyncCoordDataset ds = (SyncCoordDataset) eval.getVariable(DATASET);
    if (ds == null) {
        throw new RuntimeException("Associated Dataset should be defined with key " + DATASET);
    }
    return ds.getType().equalsIgnoreCase("SYNC");
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 23 with ELEvaluator

use of org.apache.oozie.util.ELEvaluator in project oozie by apache.

the class CoordInputLogicEvaluatorUtil method getInputDependencies.

/**
 * Get input dependencies.
 *
 * @param name the name
 * @param syncCoordAction the sync coord action
 * @return the string
 * @throws JDOMException the JDOM exception
 */
public String getInputDependencies(String name, SyncCoordAction syncCoordAction) throws JDOMException {
    JexlEngine jexl = new OozieJexlEngine();
    CoordinatorActionBean coordAction = new CoordinatorActionBean();
    ELEvaluator eval = ELEvaluator.getCurrent();
    coordAction.setId(syncCoordAction.getActionId());
    Element eJob = XmlUtils.parseXml(eval.getVariable(".actionInputLogic").toString());
    String expression = new InputLogicParser().parseWithName(eJob, name);
    Expression e = jexl.createExpression(expression);
    CoordPullInputDependency pull = (CoordPullInputDependency) syncCoordAction.getPullDependencies();
    CoordPushInputDependency push = (CoordPushInputDependency) syncCoordAction.getPushDependencies();
    coordAction.setPushInputDependencies(push);
    coordAction.setPullInputDependencies(pull);
    JexlContext jc = new OozieJexlParser(jexl, new CoordInputLogicBuilder(new CoordInputLogicEvaluatorPhaseThree(coordAction, eval)));
    CoordInputLogicEvaluatorResult result = (CoordInputLogicEvaluatorResult) e.evaluate(jc);
    if (result == null || !result.isTrue()) {
        log.debug("Input logic expression for [{0}] is [{1}] and it is not resolved", name, expression);
        return "${coord:dataIn('" + name + "')}";
    } else {
        log.debug("Input logic expression for [{0}] is [{1}] and evaluate result is [{2}]", name, expression, result.getStatus());
        return result.getDataSets();
    }
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) Element(org.jdom.Element) CoordPullInputDependency(org.apache.oozie.coord.input.dependency.CoordPullInputDependency) JexlEngine(org.apache.commons.jexl2.JexlEngine) Expression(org.apache.commons.jexl2.Expression) JexlContext(org.apache.commons.jexl2.JexlContext) ELEvaluator(org.apache.oozie.util.ELEvaluator) CoordPushInputDependency(org.apache.oozie.coord.input.dependency.CoordPushInputDependency)

Example 24 with ELEvaluator

use of org.apache.oozie.util.ELEvaluator in project oozie by apache.

the class HCatELFunctions method echoUnResolvedPre.

private static String echoUnResolvedPre(String functionName, String n, String prefix) {
    ELEvaluator eval = ELEvaluator.getCurrent();
    eval.setVariable(".wrap", "true");
    // Unresolved
    return prefix + functionName + "(" + n + ")";
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 25 with ELEvaluator

use of org.apache.oozie.util.ELEvaluator in project oozie by apache.

the class HCatELFunctions method isValidDataEvent.

private static boolean isValidDataEvent(String dataInName) {
    ELEvaluator eval = ELEvaluator.getCurrent();
    String val = (String) eval.getVariable("oozie.dataname." + dataInName);
    if (val == null || (val.equals("data-in") == false && val.equals("data-out") == false)) {
        XLog.getLog(HCatELFunctions.class).error("dataset name " + dataInName + " is not valid. val :" + val);
        throw new RuntimeException("data set name " + dataInName + " is not valid");
    }
    return true;
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Aggregations

ELEvaluator (org.apache.oozie.util.ELEvaluator)72 Element (org.jdom.Element)16 ELService (org.apache.oozie.service.ELService)15 XConfiguration (org.apache.oozie.util.XConfiguration)15 Configuration (org.apache.hadoop.conf.Configuration)13 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)11 URISyntaxException (java.net.URISyntaxException)9 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)9 CoordELEvaluator (org.apache.oozie.coord.CoordELEvaluator)8 EndNodeDef (org.apache.oozie.workflow.lite.EndNodeDef)7 LiteWorkflowApp (org.apache.oozie.workflow.lite.LiteWorkflowApp)7 LiteWorkflowInstance (org.apache.oozie.workflow.lite.LiteWorkflowInstance)7 StartNodeDef (org.apache.oozie.workflow.lite.StartNodeDef)7 CommandException (org.apache.oozie.command.CommandException)6 IOException (java.io.IOException)5 StringReader (java.io.StringReader)5 URI (java.net.URI)5 Date (java.util.Date)5 Map (java.util.Map)5 HCatURI (org.apache.oozie.util.HCatURI)5