use of org.apache.oozie.dependency.URIHandlerException in project oozie by apache.
the class CoordRerunXCommand method cleanupOutputEvents.
/**
* Cleanup output-events directories
*
* @param eAction coordinator action xml
*/
@SuppressWarnings("unchecked")
private void cleanupOutputEvents(Element eAction, Configuration coordJobConf, Map<String, Context> uriHandlerContextMap) throws CommandException {
Element outputList = eAction.getChild("output-events", eAction.getNamespace());
if (outputList != null) {
for (Element data : (List<Element>) outputList.getChildren("data-out", eAction.getNamespace())) {
String nocleanup = data.getAttributeValue("nocleanup");
if (data.getChild("uris", data.getNamespace()) != null && (nocleanup == null || !nocleanup.equals("true"))) {
String uris = data.getChild("uris", data.getNamespace()).getTextTrim();
if (uris != null) {
String[] uriArr = uris.split(CoordELFunctions.INSTANCE_SEPARATOR);
try {
for (String uriStr : uriArr) {
URI uri = new URI(uriStr);
URIHandler handler = Services.get().get(URIHandlerService.class).getURIHandler(uri);
String schemeWithAuthority = uri.getScheme() + "://" + uri.getAuthority();
if (!uriHandlerContextMap.containsKey(schemeWithAuthority)) {
Context context = handler.getContext(uri, coordJobConf, coordJob.getUser(), false);
uriHandlerContextMap.put(schemeWithAuthority, context);
}
handler.delete(uri, uriHandlerContextMap.get(schemeWithAuthority));
LOG.info("Cleanup the output data " + uri.toString());
}
} catch (URISyntaxException e) {
throw new CommandException(ErrorCode.E0907, e.getMessage());
} catch (URIHandlerException e) {
throw new CommandException(ErrorCode.E0907, e.getMessage());
}
}
}
}
} else {
LOG.info("No output-events defined in coordinator xml. Therefore nothing to cleanup");
}
}
use of org.apache.oozie.dependency.URIHandlerException in project oozie by apache.
the class CoordOldInputDependency method getMissingDependencies.
public Map<String, ActionDependency> getMissingDependencies(CoordinatorActionBean coordAction) throws CommandException, IOException, JDOMException {
Map<String, ActionDependency> dependenciesMap = null;
try {
dependenciesMap = getDependency(coordAction);
} catch (URIHandlerException e) {
throw new IOException(e);
}
StringBuilder nonExistList = new StringBuilder();
StringBuilder nonResolvedList = new StringBuilder();
CoordCommandUtils.getResolvedList(getMissingDependencies(), nonExistList, nonResolvedList);
Set<String> missingSets = new HashSet<String>(Arrays.asList(nonExistList.toString().split(CoordELFunctions.INSTANCE_SEPARATOR)));
missingSets.addAll(Arrays.asList(nonResolvedList.toString().split(CoordCommandUtils.RESOLVED_UNRESOLVED_SEPARATOR)));
for (Iterator<Map.Entry<String, ActionDependency>> it = dependenciesMap.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, ActionDependency> entry = it.next();
ActionDependency dependency = entry.getValue();
dependency.getMissingDependencies().retainAll(missingSets);
if (dependency.getUriTemplate() != null) {
for (int i = 0; i < dependency.getMissingDependencies().size(); i++) {
if (dependency.getMissingDependencies().get(i).trim().startsWith("${coord:")) {
dependency.getMissingDependencies().set(i, dependency.getMissingDependencies().get(i) + " -> " + dependency.getUriTemplate());
}
}
}
if (dependenciesMap.get(entry.getKey()).getMissingDependencies().isEmpty()) {
it.remove();
}
}
return dependenciesMap;
}
Aggregations