Search in sources :

Example 6 with URIHandlerService

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;
}
Also used : HashMap(java.util.HashMap) URIHandlerService(org.apache.oozie.service.URIHandlerService) Element(org.jdom.Element) URIHandler(org.apache.oozie.dependency.URIHandler) ActionDependency(org.apache.oozie.dependency.ActionDependency)

Example 7 with URIHandlerService

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());
}
Also used : URIHandlerService(org.apache.oozie.service.URIHandlerService) URIHandler(org.apache.oozie.dependency.URIHandler)

Example 8 with URIHandlerService

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);
        }
    }
}
Also used : URIHandlerService(org.apache.oozie.service.URIHandlerService) URIHandler(org.apache.oozie.dependency.URIHandler) URI(java.net.URI) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) ElException(org.apache.oozie.coord.ElException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException) PreconditionException(org.apache.oozie.command.PreconditionException)

Example 9 with URIHandlerService

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);
        }
    }
}
Also used : URIHandlerService(org.apache.oozie.service.URIHandlerService) URIHandler(org.apache.oozie.dependency.URIHandler) URI(java.net.URI) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) ElException(org.apache.oozie.coord.ElException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException) PreconditionException(org.apache.oozie.command.PreconditionException)

Example 10 with URIHandlerService

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 : &lt;data-in&gt; 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();
}
Also used : Element(org.jdom.Element) URIHandlerService(org.apache.oozie.service.URIHandlerService) URIHandler(org.apache.oozie.dependency.URIHandler) CoordELEvaluator(org.apache.oozie.coord.CoordELEvaluator) ELEvaluator(org.apache.oozie.util.ELEvaluator)

Aggregations

URIHandlerService (org.apache.oozie.service.URIHandlerService)15 URI (java.net.URI)11 URIHandler (org.apache.oozie.dependency.URIHandler)11 CommandException (org.apache.oozie.command.CommandException)4 ELEvaluator (org.apache.oozie.util.ELEvaluator)4 XLog (org.apache.oozie.util.XLog)4 IOException (java.io.IOException)3 PreconditionException (org.apache.oozie.command.PreconditionException)3 ElException (org.apache.oozie.coord.ElException)3 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)3 Element (org.jdom.Element)3 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 Configuration (org.apache.hadoop.conf.Configuration)2 CoordELEvaluator (org.apache.oozie.coord.CoordELEvaluator)2 Context (org.apache.oozie.dependency.URIHandler.Context)2 Test (org.junit.Test)2 URISyntaxException (java.net.URISyntaxException)1 Date (java.util.Date)1