Search in sources :

Example 1 with CoordInputLogicEvaluatorUtil

use of org.apache.oozie.coord.input.logic.CoordInputLogicEvaluatorUtil in project oozie by apache.

the class CoordCommandUtils method dryRunCoord.

/**
 * @param eAction the actionXml related element
 * @param actionBean the coordinator action bean
 * @return actionXml returns actionXml as String
 * @throws Exception
 */
static String dryRunCoord(Element eAction, CoordinatorActionBean actionBean) throws Exception {
    String action = XmlUtils.prettyPrint(eAction).toString();
    StringBuilder actionXml = new StringBuilder(action);
    Configuration actionConf = new XConfiguration(new StringReader(actionBean.getRunConf()));
    actionBean.setActionXml(action);
    if (CoordUtils.isInputLogicSpecified(eAction)) {
        new CoordInputLogicEvaluatorUtil(actionBean).validateInputLogic();
    }
    boolean isPushDepAvailable = true;
    String pushMissingDependencies = actionBean.getPushInputDependencies().getMissingDependencies();
    if (pushMissingDependencies != null) {
        ActionDependency actionDependencies = DependencyChecker.checkForAvailability(pushMissingDependencies, actionConf, true);
        if (actionDependencies.getMissingDependencies().size() != 0) {
            isPushDepAvailable = false;
        }
    }
    boolean isPullDepAvailable = true;
    CoordActionInputCheckXCommand coordActionInput = new CoordActionInputCheckXCommand(actionBean.getId(), actionBean.getJobId());
    if (actionBean.getMissingDependencies() != null) {
        StringBuilder existList = new StringBuilder();
        StringBuilder nonExistList = new StringBuilder();
        StringBuilder nonResolvedList = new StringBuilder();
        getResolvedList(actionBean.getPullInputDependencies().getMissingDependencies(), nonExistList, nonResolvedList);
        isPullDepAvailable = actionBean.getPullInputDependencies().checkPullMissingDependencies(actionBean, existList, nonExistList);
    }
    if (isPullDepAvailable && isPushDepAvailable) {
        // Check for latest/future
        boolean isLatestFutureDepAvailable = coordActionInput.checkUnResolvedInput(actionBean, actionXml, actionConf);
        if (isLatestFutureDepAvailable) {
            String newActionXml = CoordActionInputCheckXCommand.resolveCoordConfiguration(actionXml, actionConf, actionBean.getId());
            actionXml.replace(0, actionXml.length(), newActionXml);
        }
    }
    return actionXml.toString();
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) CoordInputLogicEvaluatorUtil(org.apache.oozie.coord.input.logic.CoordInputLogicEvaluatorUtil) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) StringReader(java.io.StringReader) ActionDependency(org.apache.oozie.dependency.ActionDependency)

Example 2 with CoordInputLogicEvaluatorUtil

use of org.apache.oozie.coord.input.logic.CoordInputLogicEvaluatorUtil in project oozie by apache.

the class AbstractCoordInputDependency method checkUnresolved.

@SuppressWarnings("unchecked")
public boolean checkUnresolved(CoordinatorActionBean coordAction, Element eAction) throws Exception {
    String actualTimeStr = eAction.getAttributeValue("action-actual-time");
    Element inputList = eAction.getChild("input-events", eAction.getNamespace());
    Date actualTime = null;
    if (actualTimeStr == null) {
        actualTime = new Date();
    } else {
        actualTime = DateUtils.parseDateOozieTZ(actualTimeStr);
    }
    if (inputList == null) {
        return true;
    }
    List<Element> eDataEvents = inputList.getChildren("data-in", eAction.getNamespace());
    for (Element dEvent : eDataEvents) {
        if (dEvent.getChild(CoordCommandUtils.UNRESOLVED_INSTANCES_TAG, dEvent.getNamespace()) == null) {
            continue;
        }
        String unResolvedInstance = dEvent.getChild(CoordCommandUtils.UNRESOLVED_INSTANCES_TAG, dEvent.getNamespace()).getTextTrim();
        String name = dEvent.getAttribute("name").getValue();
        addUnResolvedList(name, unResolvedInstance);
    }
    return new CoordInputLogicEvaluatorUtil(coordAction).checkUnResolved(actualTime);
}
Also used : CoordInputLogicEvaluatorUtil(org.apache.oozie.coord.input.logic.CoordInputLogicEvaluatorUtil) Element(org.jdom.Element) Date(java.util.Date)

Example 3 with CoordInputLogicEvaluatorUtil

use of org.apache.oozie.coord.input.logic.CoordInputLogicEvaluatorUtil 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

CoordInputLogicEvaluatorUtil (org.apache.oozie.coord.input.logic.CoordInputLogicEvaluatorUtil)3 StringReader (java.io.StringReader)1 Date (java.util.Date)1 Configuration (org.apache.hadoop.conf.Configuration)1 ActionDependency (org.apache.oozie.dependency.ActionDependency)1 ELEvaluator (org.apache.oozie.util.ELEvaluator)1 XConfiguration (org.apache.oozie.util.XConfiguration)1 Element (org.jdom.Element)1 JDOMException (org.jdom.JDOMException)1