Search in sources :

Example 51 with ELEvaluator

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

the class CoordELFunctions method ph1_coord_months.

/**
 * Used in defining the frequency in 'month' unit. <p> domain: <code> val &gt; 0</code> and should be integer.
 *
 * @param val frequency in number of months.
 * @return number of months and also set the frequency timeunit to "month"
 */
public static int ph1_coord_months(int val) {
    val = ParamChecker.checkGTZero(val, "n");
    ELEvaluator eval = ELEvaluator.getCurrent();
    eval.setVariable("timeunit", TimeUnit.MONTH);
    eval.setVariable("endOfDuration", TimeUnit.NONE);
    return val;
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 52 with ELEvaluator

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

the class CoordELFunctions 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 53 with ELEvaluator

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

the class CoordELFunctions method ph2_coord_actualTime.

/**
 * Return Action Start time. <p>
 *
 * @return coordinator action start time
 * @throws Exception if unable to format the Date object to String
 */
public static String ph2_coord_actualTime() throws Exception {
    ELEvaluator eval = ELEvaluator.getCurrent();
    SyncCoordAction coordAction = (SyncCoordAction) eval.getVariable(COORD_ACTION);
    if (coordAction == null) {
        throw new RuntimeException("Associated Application instance should be defined with key " + COORD_ACTION);
    }
    return DateUtils.formatDateOozieTZ(coordAction.getActualTime());
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 54 with ELEvaluator

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

the class CoordELFunctions method checkIfResolved.

/**
 * Check whether a function should be resolved.
 *
 * @param functionName
 * @param n
 * @return null if the functionName needs to be resolved otherwise return the calling function unresolved.
 */
private static String checkIfResolved(String functionName, String n) {
    ELEvaluator eval = ELEvaluator.getCurrent();
    String replace = (String) eval.getVariable("resolve_" + functionName);
    if (replace == null || (replace != null && replace.equalsIgnoreCase("false"))) {
        // Don't
        // resolve
        // return "${coord:" + functionName + "(" + n +")}"; //Unresolved
        eval.setVariable(".wrap", "true");
        // Unresolved
        return "coord:" + functionName + "(" + n + ")";
    }
    // Resolved it
    return null;
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 55 with ELEvaluator

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

the class CoordELFunctions method ph3_coord_dataIn.

/**
 * Used to specify a list of URI's that are used as input dir to the workflow job. <p> Look for two evaluator-level
 * variables <p> A) .datain.&lt;DATAIN_NAME&gt; B) .datain.&lt;DATAIN_NAME&gt;.unresolved <p> A defines the current list of
 * URI. <p> B defines whether there are any unresolved EL-function (i.e latest) <p> If there are something
 * unresolved, this function will echo back the original function <p> otherwise it sends the uris.
 *
 * @param dataInName : Datain name
 * @return the list of URI's separated by INSTANCE_SEPARATOR <p> if there are unresolved EL function (i.e. latest)
 *         , echo back <p> the function without resolving the function.
 */
public static String ph3_coord_dataIn(String dataInName) {
    String uris = "";
    ELEvaluator eval = ELEvaluator.getCurrent();
    if (eval.getVariable(".datain." + dataInName) == null && (eval.getVariable(".actionInputLogic") != null && !StringUtils.isEmpty(eval.getVariable(".actionInputLogic").toString()))) {
        try {
            return new CoordInputLogicEvaluatorUtil().getInputDependencies(dataInName, (SyncCoordAction) eval.getVariable(COORD_ACTION));
        } catch (JDOMException e) {
            XLog.getLog(CoordELFunctions.class).error(e);
            throw new RuntimeException(e.getMessage());
        }
    }
    uris = (String) eval.getVariable(".datain." + dataInName);
    Object unResolvedObj = eval.getVariable(".datain." + dataInName + ".unresolved");
    if (unResolvedObj == null) {
        return uris;
    }
    Boolean unresolved = Boolean.parseBoolean(unResolvedObj.toString());
    if (unresolved != null && unresolved.booleanValue() == true) {
        return "${coord:dataIn('" + dataInName + "')}";
    }
    return uris;
}
Also used : CoordInputLogicEvaluatorUtil(org.apache.oozie.coord.input.logic.CoordInputLogicEvaluatorUtil) ELEvaluator(org.apache.oozie.util.ELEvaluator) JDOMException(org.jdom.JDOMException)

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