Search in sources :

Example 1 with URIHandler

use of org.apache.oozie.dependency.URIHandler in project oozie by apache.

the class URIHandlerService method initLauncherClassesToShip.

/**
 * Initialize classes that need to be shipped for using LauncherURIHandler in the launcher job
 */
private void initLauncherClassesToShip() {
    launcherClassesToShip = new HashSet<Class<?>>();
    launcherClassesToShip.add(LauncherURIHandlerFactory.class);
    launcherClassesToShip.add(LauncherURIHandler.class);
    for (URIHandler handler : cache.values()) {
        launcherClassesToShip.add(handler.getLauncherURIHandlerClass());
        List<Class<?>> classes = handler.getClassesForLauncher();
        if (classes != null) {
            launcherClassesToShip.addAll(classes);
        }
    }
    launcherClassesToShip.add(defaultHandler.getLauncherURIHandlerClass());
}
Also used : LauncherURIHandler(org.apache.oozie.action.hadoop.LauncherURIHandler) URIHandler(org.apache.oozie.dependency.URIHandler) FSURIHandler(org.apache.oozie.dependency.FSURIHandler)

Example 2 with URIHandler

use of org.apache.oozie.dependency.URIHandler in project oozie by apache.

the class URIHandlerService method initLauncherURIHandlerConf.

/**
 * Initialize configuration required for using LauncherURIHandler in the launcher job
 */
private void initLauncherURIHandlerConf() {
    launcherConf = new Configuration(false);
    for (URIHandler handler : cache.values()) {
        for (String scheme : handler.getSupportedSchemes()) {
            String schemeConf = LauncherURIHandlerFactory.CONF_LAUNCHER_URIHANDLER_SCHEME_PREFIX + scheme;
            launcherConf.set(schemeConf, handler.getLauncherURIHandlerClass().getName());
        }
    }
    for (String scheme : defaultHandler.getSupportedSchemes()) {
        String schemeConf = LauncherURIHandlerFactory.CONF_LAUNCHER_URIHANDLER_SCHEME_PREFIX + scheme;
        launcherConf.set(schemeConf, defaultHandler.getLauncherURIHandlerClass().getName());
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LauncherURIHandler(org.apache.oozie.action.hadoop.LauncherURIHandler) URIHandler(org.apache.oozie.dependency.URIHandler) FSURIHandler(org.apache.oozie.dependency.FSURIHandler)

Example 3 with URIHandler

use of org.apache.oozie.dependency.URIHandler in project oozie by apache.

the class URIHandlerService method init.

private void init(Configuration conf) throws ClassNotFoundException {
    cache = new HashMap<String, URIHandler>();
    String[] classes = ConfigurationService.getStrings(conf, URI_HANDLERS);
    for (String classname : classes) {
        Class<?> clazz = Class.forName(classname.trim());
        URIHandler uriHandler = (URIHandler) ReflectionUtils.newInstance(clazz, null);
        uriHandler.init(conf);
        for (String scheme : uriHandler.getSupportedSchemes()) {
            cache.put(scheme, uriHandler);
        }
    }
    Class<?> defaultClass = conf.getClass(URI_HANDLER_DEFAULT, null);
    defaultHandler = (defaultClass == null) ? new FSURIHandler() : (URIHandler) ReflectionUtils.newInstance(defaultClass, null);
    defaultHandler.init(conf);
    for (String scheme : defaultHandler.getSupportedSchemes()) {
        cache.put(scheme, defaultHandler);
    }
    initLauncherClassesToShip();
    initLauncherURIHandlerConf();
    LOG.info("Loaded urihandlers {0}", Arrays.toString(classes));
    LOG.info("Loaded default urihandler {0}", defaultHandler.getClass().getName());
}
Also used : LauncherURIHandler(org.apache.oozie.action.hadoop.LauncherURIHandler) URIHandler(org.apache.oozie.dependency.URIHandler) FSURIHandler(org.apache.oozie.dependency.FSURIHandler) FSURIHandler(org.apache.oozie.dependency.FSURIHandler)

Example 4 with URIHandler

use of org.apache.oozie.dependency.URIHandler in project oozie by apache.

the class URIHandlerService method destroy.

@Override
public void destroy() {
    Set<URIHandler> handlers = new HashSet<URIHandler>();
    handlers.addAll(cache.values());
    for (URIHandler handler : handlers) {
        handler.destroy();
    }
    cache.clear();
}
Also used : LauncherURIHandler(org.apache.oozie.action.hadoop.LauncherURIHandler) URIHandler(org.apache.oozie.dependency.URIHandler) FSURIHandler(org.apache.oozie.dependency.FSURIHandler) HashSet(java.util.HashSet)

Example 5 with URIHandler

use of org.apache.oozie.dependency.URIHandler in project oozie by apache.

the class CoordPushDependencyCheckXCommand method unregisterMissingDependencies.

public static void unregisterMissingDependencies(List<String> missingDeps, String actionId) {
    final XLog LOG = XLog.getLog(CoordPushDependencyCheckXCommand.class);
    URIHandlerService uriService = Services.get().get(URIHandlerService.class);
    for (String missingDep : missingDeps) {
        try {
            URI missingURI = new URI(missingDep);
            URIHandler handler = uriService.getURIHandler(missingURI);
            if (handler.unregisterFromNotification(missingURI, actionId)) {
                LOG.debug("Successfully unregistered uri [{0}] from notifications", missingURI);
            } else {
                LOG.warn("Unable to unregister uri [{0}] from notifications", missingURI);
            }
        } catch (Exception e) {
            LOG.warn("Exception while unregistering uri [{0}] from notifications", missingDep, e);
        }
    }
}
Also used : XLog(org.apache.oozie.util.XLog) 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)

Aggregations

URIHandler (org.apache.oozie.dependency.URIHandler)22 URI (java.net.URI)15 URIHandlerService (org.apache.oozie.service.URIHandlerService)13 FSURIHandler (org.apache.oozie.dependency.FSURIHandler)9 IOException (java.io.IOException)5 CommandException (org.apache.oozie.command.CommandException)5 Configuration (org.apache.hadoop.conf.Configuration)4 Path (org.apache.hadoop.fs.Path)4 LauncherURIHandler (org.apache.oozie.action.hadoop.LauncherURIHandler)4 HCatURIHandler (org.apache.oozie.dependency.HCatURIHandler)4 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)4 ELEvaluator (org.apache.oozie.util.ELEvaluator)4 Element (org.jdom.Element)4 PreconditionException (org.apache.oozie.command.PreconditionException)3 ElException (org.apache.oozie.coord.ElException)3 Context (org.apache.oozie.dependency.URIHandler.Context)3 XConfiguration (org.apache.oozie.util.XConfiguration)3 XLog (org.apache.oozie.util.XLog)3 URISyntaxException (java.net.URISyntaxException)2 Calendar (java.util.Calendar)2