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 > 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;
}
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 + ")";
}
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());
}
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;
}
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.<DATAIN_NAME> B) .datain.<DATAIN_NAME>.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;
}
Aggregations