Search in sources :

Example 1 with HadoopConfJarBean

use of org.talend.core.hadoop.HadoopConfJarBean in project tbd-studio-se by Talend.

the class HadoopClusterService method getCustomConfsJar.

@Override
public Optional<HadoopConfJarBean> getCustomConfsJar(ConnectionItem connectionItem, boolean createJarIfNotExist, boolean addExtraIds) {
    if (connectionItem instanceof HadoopClusterConnectionItem) {
        HadoopClusterConnectionItem item = (HadoopClusterConnectionItem) connectionItem;
        HadoopClusterConnection connection = (HadoopClusterConnection) item.getConnection();
        if (connection != null && connection.isUseCustomConfs()) {
            String extraIds = null;
            boolean isContextMode = connection.isContextMode();
            if (addExtraIds && isContextMode) {
                ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connection, true);
                extraIds = contextType.getName();
            }
            String defaultName = null;
            if (extraIds == null) {
                defaultName = HadoopConfsUtils.getConfsJarDefaultName(item, createJarIfNotExist);
            } else {
                defaultName = HadoopConfsUtils.getConfsJarDefaultName(item, createJarIfNotExist, extraIds);
            }
            return Optional.of(new HadoopConfJarBean(isContextMode, connection.isUseCustomConfs() && HCParameterUtil.isOverrideHadoopConfs(connection), HCParameterUtil.getHadoopConfSpecificJar(connection, false), HCParameterUtil.getHadoopConfSpecificJar(connection, true), defaultName));
        }
    }
    return Optional.ofNullable(null);
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) HadoopConfJarBean(org.talend.core.hadoop.HadoopConfJarBean)

Example 2 with HadoopConfJarBean

use of org.talend.core.hadoop.HadoopConfJarBean in project tbd-studio-se by Talend.

the class HadoopClassLoaderFactory method loadCustomConfJar.

private static ClassLoader loadCustomConfJar(HDFSConnectionBean connectionBean, ClassLoader loader) {
    if ((connectionBean.getRelativeHadoopClusterId() != null || connectionBean.isUseCustomConfs()) && loader instanceof DynamicClassLoader) {
        try {
            HadoopConfJarBean confJarBean = getCustomConfsJarName(connectionBean.getRelativeHadoopClusterId());
            if (confJarBean != null) {
                Consumer<DynamicClassLoader> afterLoad = null;
                String[] addingJars = null;
                if (confJarBean.isOverrideCustomConf()) {
                    String overrideCustomConfPath = confJarBean.getOriginalOverrideCustomConfPath();
                    if (StringUtils.isBlank(overrideCustomConfPath) || !new File(overrideCustomConfPath).exists()) {
                        ExceptionHandler.process(new Exception("Set Hadoop configuration JAR path is invalid: " + overrideCustomConfPath));
                    } else {
                        afterLoad = (t) -> t.addLibrary(overrideCustomConfPath);
                    }
                } else {
                    String customConfsJarName = confJarBean.getCustomConfJarName();
                    if (customConfsJarName != null) {
                        addingJars = new String[] { customConfsJarName };
                    }
                }
                if (afterLoad != null || addingJars != null) {
                    loader = DynamicClassLoader.createNewOneBaseLoader((DynamicClassLoader) loader, addingJars, EHadoopConfigurationJars.HDFS.getEnableSecurityJars());
                    if (afterLoad != null) {
                        afterLoad.accept((DynamicClassLoader) loader);
                    }
                }
            }
            // Add webhdfs extra jars
            loader = HadoopClassLoaderUtil.addExtraJars(loader, EHadoopCategory.HDFS, connectionBean.getNameNodeURI());
        } catch (MalformedURLException e) {
            ExceptionHandler.process(e);
        }
    }
    return loader;
}
Also used : DynamicClassLoader(org.talend.core.classloader.DynamicClassLoader) MalformedURLException(java.net.MalformedURLException) HadoopConfJarBean(org.talend.core.hadoop.HadoopConfJarBean) File(java.io.File) MalformedURLException(java.net.MalformedURLException)

Aggregations

HadoopConfJarBean (org.talend.core.hadoop.HadoopConfJarBean)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 DynamicClassLoader (org.talend.core.classloader.DynamicClassLoader)1 ContextType (org.talend.designer.core.model.utils.emf.talendfile.ContextType)1 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)1 HadoopClusterConnectionItem (org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)1