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();
}
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);
}
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.<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