use of org.apache.oozie.service.URIHandlerService in project oozie by apache.
the class CoordOldInputDependency method getDependency.
@SuppressWarnings("unchecked")
private Map<String, ActionDependency> getDependency(CoordinatorActionBean coordAction) throws JDOMException, URIHandlerException {
Map<String, ActionDependency> dependenciesMap = new HashMap<String, ActionDependency>();
URIHandlerService uriService = Services.get().get(URIHandlerService.class);
Element eAction = XmlUtils.parseXml(coordAction.getActionXml());
Element inputList = eAction.getChild("input-events", eAction.getNamespace());
List<Element> eDataEvents = inputList.getChildren("data-in", eAction.getNamespace());
for (Element event : eDataEvents) {
Element uri = event.getChild("uris", event.getNamespace());
ActionDependency dependency = new ActionDependency();
if (uri != null) {
Element doneFlagElement = event.getChild("dataset", event.getNamespace()).getChild("done-flag", event.getNamespace());
String[] dataSets = uri.getText().split(CoordELFunctions.INSTANCE_SEPARATOR);
String doneFlag = CoordUtils.getDoneFlag(doneFlagElement);
for (String dataSet : dataSets) {
URIHandler uriHandler;
uriHandler = uriService.getURIHandler(dataSet);
dependency.getMissingDependencies().add(uriHandler.getURIWithDoneFlag(dataSet, doneFlag));
}
}
if (event.getChildTextTrim(CoordCommandUtils.UNRESOLVED_INSTANCES_TAG, event.getNamespace()) != null) {
ActionDependency unResolvedDependency = getUnResolvedDependency(coordAction, event);
dependency.getMissingDependencies().addAll(unResolvedDependency.getMissingDependencies());
dependency.setUriTemplate(unResolvedDependency.getUriTemplate());
}
dependenciesMap.put(event.getAttributeValue("name"), dependency);
}
return dependenciesMap;
}
use of org.apache.oozie.service.URIHandlerService in project oozie by apache.
the class CoordInputLogicEvaluatorPhaseThree method getPathWithoutDoneFlag.
private String getPathWithoutDoneFlag(String sPath, String dataSet) throws URIHandlerException {
if (dataSet == null) {
return sPath;
}
URIHandlerService service = Services.get().get(URIHandlerService.class);
URIHandler handler = service.getURIHandler(sPath);
return handler.getURIWithoutDoneFlag(sPath, eval.getVariable(".datain." + dataSet + ".doneFlag").toString());
}
use of org.apache.oozie.service.URIHandlerService in project oozie by apache.
the class CoordPushDependencyCheckXCommand method registerForNotification.
private void registerForNotification(List<String> missingDeps, Configuration actionConf) {
URIHandlerService uriService = Services.get().get(URIHandlerService.class);
String user = actionConf.get(OozieClient.USER_NAME, OozieClient.USER_NAME);
for (String missingDep : missingDeps) {
try {
URI missingURI = new URI(missingDep);
URIHandler handler = uriService.getURIHandler(missingURI);
handler.registerForNotification(missingURI, actionConf, user, actionId);
LOG.debug("Registered uri [{0}] for notifications", missingURI);
} catch (Exception e) {
LOG.warn("Exception while registering uri [{0}] for notifications", missingDep, e);
}
}
}
use of org.apache.oozie.service.URIHandlerService in project oozie by apache.
the class CoordPushDependencyCheckXCommand method unregisterAvailableDependencies.
private void unregisterAvailableDependencies(List<String> availableDeps) {
URIHandlerService uriService = Services.get().get(URIHandlerService.class);
for (String availableDep : availableDeps) {
try {
URI availableURI = new URI(availableDep);
URIHandler handler = uriService.getURIHandler(availableURI);
if (handler.unregisterFromNotification(availableURI, actionId)) {
LOG.debug("Successfully unregistered uri [{0}] from notifications", availableURI);
} else {
LOG.warn("Unable to unregister uri [{0}] from notifications", availableURI);
}
} catch (Exception e) {
LOG.warn("Exception while unregistering uri [{0}] from notifications", availableDep, e);
}
}
}
use of org.apache.oozie.service.URIHandlerService in project oozie by apache.
the class CoordCommandUtils method createEarlyURIs.
/**
* The function create a list of URIs separated by "," using the instances
* time stamp and URI-template
*
* @param event : <data-in> event
* @param instances : List of time stamp separated by ","
* @param unresolvedInstances : list of instance with latest function
* @param urisWithDoneFlag : list of URIs with the done flag appended
* @return : list of URIs separated by ";" as a string.
* @throws Exception
*/
public static String createEarlyURIs(Element event, String instances, StringBuilder unresolvedInstances, StringBuilder urisWithDoneFlag) throws Exception {
if (instances == null || instances.length() == 0) {
return "";
}
String[] instanceList = instances.split(CoordELFunctions.INSTANCE_SEPARATOR);
StringBuilder uris = new StringBuilder();
Element doneFlagElement = event.getChild("dataset", event.getNamespace()).getChild("done-flag", event.getNamespace());
URIHandlerService uriService = Services.get().get(URIHandlerService.class);
for (int i = 0; i < instanceList.length; i++) {
if (instanceList[i].trim().length() == 0) {
continue;
}
int funcType = getFuncType(instanceList[i]);
if (funcType == LATEST || funcType == FUTURE) {
if (unresolvedInstances.length() > 0) {
unresolvedInstances.append(CoordELFunctions.INSTANCE_SEPARATOR);
}
unresolvedInstances.append(instanceList[i]);
continue;
}
ELEvaluator eval = CoordELEvaluator.createURIELEvaluator(instanceList[i]);
if (uris.length() > 0) {
uris.append(CoordELFunctions.INSTANCE_SEPARATOR);
urisWithDoneFlag.append(CoordELFunctions.INSTANCE_SEPARATOR);
}
String uriPath = CoordELFunctions.evalAndWrap(eval, event.getChild("dataset", event.getNamespace()).getChild("uri-template", event.getNamespace()).getTextTrim());
URIHandler uriHandler = uriService.getURIHandler(uriPath);
uriHandler.validate(uriPath);
uris.append(uriPath);
urisWithDoneFlag.append(uriHandler.getURIWithDoneFlag(uriPath, CoordUtils.getDoneFlag(doneFlagElement)));
}
return uris.toString();
}
Aggregations