use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class CoordInputLogicEvaluatorPhaseTwo method evalInput.
@Override
public CoordInputLogicEvaluatorResult evalInput(String dataSet, int min, int wait) {
try {
CoordPullInputDependency coordPullInputDependency = (CoordPullInputDependency) coordInputDependency;
ELEvaluator eval = CoordELEvaluator.createLazyEvaluator(actualTime, coordAction.getNominalTime(), getInputSetEvent(dataSet), getConf());
if (coordPullInputDependency.getUnResolvedDependency(dataSet) == null) {
return super.evalInput(dataSet, min, wait);
} else {
cleanPreviousCheckData(coordPullInputDependency, dataSet);
List<String> unresolvedList = coordPullInputDependency.getUnResolvedDependency(dataSet).getDependencies();
for (String unresolved : unresolvedList) {
String resolvedPath = "";
CoordELFunctions.evalAndWrap(eval, unresolved);
boolean isResolved = (Boolean) eval.getVariable(CoordELConstants.IS_RESOLVED);
coordPullInputDependency.setDependencyMap(dependencyMap);
if (eval.getVariable(CoordELConstants.RESOLVED_PATH) != null) {
resolvedPath = eval.getVariable(CoordELConstants.RESOLVED_PATH).toString();
}
if (resolvedPath != null) {
resolvedPath = getEvalResult(isResolved, min, wait, Arrays.asList(DependencyChecker.dependenciesAsArray(resolvedPath.toString()))).getDataSets();
}
log.trace(MessageFormat.format("Return data is {0}", resolvedPath));
log.debug(MessageFormat.format("Resolved status of Data set {0} with min {1} and wait {2} = {3}", dataSet, min, wait, !StringUtils.isEmpty(resolvedPath)));
if ((isInputWaitElapsed(wait) || isResolved) && !StringUtils.isEmpty(resolvedPath)) {
coordPullInputDependency.addResolvedList(dataSet, resolvedPath.toString());
} else {
cleanPreviousCheckData(coordPullInputDependency, dataSet);
if (!isInputWaitElapsed(wait)) {
return new CoordInputLogicEvaluatorResult(CoordInputLogicEvaluatorResult.STATUS.TIMED_WAITING);
} else {
return new CoordInputLogicEvaluatorResult(CoordInputLogicEvaluatorResult.STATUS.FALSE);
}
}
}
coordPullInputDependency.getUnResolvedDependency(dataSet).setResolved(true);
return new CoordInputLogicEvaluatorResult(STATUS.TRUE, getListAsString(coordPullInputDependency.getUnResolvedDependency(dataSet).getResolvedList(), dataSet));
}
} catch (Exception e) {
throw new RuntimeException(" event not found" + e, e);
}
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class HCatELFunctions method ph3_coord_dataInPartitionMax.
/**
* Used to specify the MINIMUM value of an HCat partition which is input dependency for 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
* HCat URIs. <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 min partition value.
*
* @param dataInName : Datain name
* @param partitionName : Specific partition name whose MIN value is wanted
*/
public static String ph3_coord_dataInPartitionMax(String dataInName, String partitionName) {
ELEvaluator eval = ELEvaluator.getCurrent();
String uris = (String) eval.getVariable(".datain." + dataInName);
Boolean unresolved = (Boolean) eval.getVariable(".datain." + dataInName + ".unresolved");
if (unresolved != null && unresolved.booleanValue() == true) {
return "${coord:dataInPartitionMin('" + dataInName + "', '" + partitionName + "')}";
}
String maxPartition = null;
if (uris != null) {
String[] uriList = HCatURIParser.splitHCatUris(uris, HCAT_URI_PATTERN);
// get the partition values list and find minimum
try {
// initialize minValue with first partition value
maxPartition = new HCatURI(uriList[0]).getPartitionValue(partitionName);
if (maxPartition == null || maxPartition.isEmpty()) {
throw new RuntimeException("No value in data-in uri for partition key: " + partitionName);
}
for (int i = 1; i < uriList.length; i++) {
String value = new HCatURI(uriList[i]).getPartitionValue(partitionName);
if (value.compareTo(maxPartition) > 0) {
maxPartition = value;
}
}
} catch (URISyntaxException urie) {
throw new RuntimeException("HCat URI can't be parsed " + urie);
}
} else {
XLog.getLog(HCatELFunctions.class).warn("URI is null");
return null;
}
return maxPartition;
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class HCatELFunctions method ph3_coord_dataInPartitionMin.
/**
* Used to specify the MAXIMUM value of an HCat partition which is input dependency for 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
* HCat URIs. <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 max partition value.
*
* @param dataInName : Datain name
* @param partitionName : Specific partition name whose MAX value is wanted
*/
public static String ph3_coord_dataInPartitionMin(String dataInName, String partitionName) {
ELEvaluator eval = ELEvaluator.getCurrent();
String uris = (String) eval.getVariable(".datain." + dataInName);
Boolean unresolved = (Boolean) eval.getVariable(".datain." + dataInName + ".unresolved");
if (unresolved != null && unresolved.booleanValue() == true) {
return "${coord:dataInPartitionMin('" + dataInName + "', '" + partitionName + "')}";
}
String minPartition = null;
if (uris != null) {
String[] uriList = HCatURIParser.splitHCatUris(uris, HCAT_URI_PATTERN);
// get the partition values list and find minimum
try {
// initialize minValue with first partition value
minPartition = new HCatURI(uriList[0]).getPartitionValue(partitionName);
if (minPartition == null || minPartition.isEmpty()) {
throw new RuntimeException("No value in data-in uri for partition key: " + partitionName);
}
for (int i = 1; i < uriList.length; i++) {
String value = new HCatURI(uriList[i]).getPartitionValue(partitionName);
if (value.compareTo(minPartition) < 0) {
// sticking to string comparison since some numerical date
// values can also contain letters e.g. 20120101T0300Z (UTC)
minPartition = value;
}
}
} catch (URISyntaxException urie) {
throw new RuntimeException("HCat URI can't be parsed " + urie);
}
} else {
XLog.getLog(HCatELFunctions.class).warn("URI is null");
return null;
}
return minPartition;
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class HCatELFunctions method ph3_coord_dataOutPartitionValue.
/**
* Used to specify the HCat partition's value defining output for workflow job.<p> Look for two evaluator-level
* variables <p> A) .dataout.<DATAOUT_NAME> B) .dataout.<DATAOUT_NAME>.unresolved <p> A defines the current list of
* HCat URIs. <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 partition value.
*
* @param dataOutName : Dataout name
* @param partitionName : Specific partition name whose value is wanted
*/
public static String ph3_coord_dataOutPartitionValue(String dataOutName, String partitionName) {
ELEvaluator eval = ELEvaluator.getCurrent();
String uri = (String) eval.getVariable(".dataout." + dataOutName);
Boolean unresolved = (Boolean) eval.getVariable(".dataout." + dataOutName + ".unresolved");
if (unresolved != null && unresolved.booleanValue() == true) {
return "${coord:dataOutPartitionValue('" + dataOutName + "', '" + partitionName + "')}";
}
try {
HCatURI hcatUri = new HCatURI(uri);
return hcatUri.getPartitionValue(partitionName);
} catch (URISyntaxException urie) {
XLog.getLog(HCatELFunctions.class).warn("Exception with uriTemplate [{0}]. Reason [{1}]: ", uri, urie);
throw new RuntimeException("HCat URI can't be parsed " + urie);
}
}
use of org.apache.oozie.util.ELEvaluator in project oozie by apache.
the class HCatELFunctions method ph3_coord_dataInPartitionFilter.
/**
* Used to specify the HCat partition filter which is input dependency for 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
* HCat URIs. <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 partition filter.
*
* @param dataInName : Datain name
* @param type : for action type - pig, MR or hive
*/
public static String ph3_coord_dataInPartitionFilter(String dataInName, String type) {
ELEvaluator eval = ELEvaluator.getCurrent();
String uris = (String) eval.getVariable(".datain." + dataInName);
Boolean unresolved = (Boolean) eval.getVariable(".datain." + dataInName + ".unresolved");
if (unresolved != null && unresolved.booleanValue() == true) {
return "${coord:dataInPartitionFilter('" + dataInName + "', '" + type + "')}";
}
return createPartitionFilter(uris, type);
}
Aggregations