Search in sources :

Example 16 with ELEvaluator

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

the class CoordELFunctions method getUriEvaluator.

/**
 * @param tm
 * @return a new Evaluator to be used for URI-template evaluation
 */
private static ELEvaluator getUriEvaluator(Calendar tm) {
    tm.setTimeZone(DateUtils.getOozieProcessingTimeZone());
    ELEvaluator retEval = new ELEvaluator();
    retEval.setVariable("YEAR", tm.get(Calendar.YEAR));
    retEval.setVariable("MONTH", (tm.get(Calendar.MONTH) + 1) < 10 ? "0" + (tm.get(Calendar.MONTH) + 1) : (tm.get(Calendar.MONTH) + 1));
    retEval.setVariable("DAY", tm.get(Calendar.DAY_OF_MONTH) < 10 ? "0" + tm.get(Calendar.DAY_OF_MONTH) : tm.get(Calendar.DAY_OF_MONTH));
    retEval.setVariable("HOUR", tm.get(Calendar.HOUR_OF_DAY) < 10 ? "0" + tm.get(Calendar.HOUR_OF_DAY) : tm.get(Calendar.HOUR_OF_DAY));
    retEval.setVariable("MINUTE", tm.get(Calendar.MINUTE) < 10 ? "0" + tm.get(Calendar.MINUTE) : tm.get(Calendar.MINUTE));
    return retEval;
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 17 with ELEvaluator

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

the class CoordELFunctions method ph1_coord_endOfDays.

/**
 * Used in defining the frequency in 'day' unit and specify the "end of day" property. <p> Every instance will
 * start at 00:00 hour of each day. <p> domain: <code> val &gt; 0</code> and should be integer.
 *
 * @param val frequency in number of days.
 * @return number of days and also set the frequency timeunit to "day" and end_of_duration flag to "day"
 */
public static int ph1_coord_endOfDays(int val) {
    val = ParamChecker.checkGTZero(val, "n");
    ELEvaluator eval = ELEvaluator.getCurrent();
    eval.setVariable("timeunit", TimeUnit.DAY);
    eval.setVariable("endOfDuration", TimeUnit.END_OF_DAY);
    return val;
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 18 with ELEvaluator

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

the class CoordELFunctions method ph1_coord_endOfWeeks.

/**
 * Used in defining the frequency in 'week' unit and specify the "end of
 * week" property.
 * <p>
 * Every instance will start at 00:00 hour of start of week
 * <p>
 * domain: <code> val &gt; 0</code> and should be integer.
 *
 * @param val frequency in number of weeks.
 * @return number of weeks and also set the frequency timeunit to week of
 *         the year and end_of_duration flag to week of the year
 */
public static int ph1_coord_endOfWeeks(int val) {
    val = ParamChecker.checkGTZero(val, "n");
    ELEvaluator eval = ELEvaluator.getCurrent();
    eval.setVariable("timeunit", TimeUnit.WEEK);
    eval.setVariable("endOfDuration", TimeUnit.END_OF_WEEK);
    return val;
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 19 with ELEvaluator

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

the class CoordELFunctions method ph3_coord_dataOut.

/**
 * Used to specify a list of URI's that are output dir of the workflow job. <p> Look for one evaluator-level
 * variable <p> dataout.&lt;DATAOUT_NAME&gt; <p> It defines the current list of URI. <p> otherwise it sends the uris.
 *
 * @param dataOutName : Dataout name
 * @return the list of URI's separated by INSTANCE_SEPARATOR
 */
public static String ph3_coord_dataOut(String dataOutName) {
    String uris = "";
    ELEvaluator eval = ELEvaluator.getCurrent();
    uris = (String) eval.getVariable(".dataout." + dataOutName);
    return uris;
}
Also used : ELEvaluator(org.apache.oozie.util.ELEvaluator)

Example 20 with ELEvaluator

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

the class CoordELFunctions method ph2_coord_name.

/**
 * Return Job Name. <p>
 *
 * @return coordinator name
 */
public static String ph2_coord_name() throws Exception {
    ELEvaluator eval = ELEvaluator.getCurrent();
    SyncCoordAction action = ParamChecker.notNull((SyncCoordAction) eval.getVariable(COORD_ACTION), "Coordinator Action");
    return action.getName();
}
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