Search in sources :

Example 1 with IHDistributionVersion

use of org.talend.core.runtime.hd.IHDistributionVersion in project tdq-studio-se by Talend.

the class AliasAndManaDriverHelper method getImpalaClassLoader.

public ClassLoader getImpalaClassLoader(IMetadataConnection metadataConn) {
    IHadoopDistributionService hadoopService = getHadoopDistributionService();
    if (hadoopService != null) {
        String distribution = (String) metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_IMPALA_DISTRIBUTION);
        String version = (String) metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_IMPALA_VERSION);
        IHDistribution impalaDistribution = hadoopService.getImpalaDistributionManager().getDistribution(distribution, false);
        if (impalaDistribution != null) {
            String impalaIndex = EDatabaseTypeName.IMPALA.getProduct() + ClassLoaderFactory.KEY_SEPARATOR + impalaDistribution.getName();
            if (impalaDistribution.useCustom()) {
                String jarsStr = (String) metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CUSTOM_JARS);
                // $NON-NLS-1$
                String index = "CustomImpala" + ClassLoaderFactory.KEY_SEPARATOR + impalaIndex + ClassLoaderFactory.KEY_SEPARATOR + metadataConn.getId();
                DynamicClassLoader classLoader = ClassLoaderFactory.getCustomClassLoader(index, jarsStr);
                if (classLoader != null) {
                    return classLoader;
                }
            } else {
                IHDistributionVersion impalaVersion = impalaDistribution.getHDVersion(version, false);
                if (impalaVersion != null) {
                    boolean isKeb = Boolean.valueOf((String) metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_USE_KRB));
                    DynamicClassLoader classLoader = ClassLoaderFactory.getClassLoader(impalaIndex + ClassLoaderFactory.KEY_SEPARATOR + impalaVersion.getVersion() + // $NON-NLS-1$//$NON-NLS-2$
                    (isKeb ? "?USE_KRB" : ""));
                    // if not work for extension point, try modules from hadoop distribution
                    if (classLoader == null) {
                        classLoader = ClassLoaderFactory.getClassLoader(impalaVersion);
                    }
                    if (classLoader != null) {
                        return classLoader;
                    }
                }
            }
        }
    }
    return this.getClass().getClassLoader();
}
Also used : DynamicClassLoader(org.talend.core.classloader.DynamicClassLoader) IHadoopDistributionService(org.talend.core.hadoop.IHadoopDistributionService) IHDistributionVersion(org.talend.core.runtime.hd.IHDistributionVersion) IHDistribution(org.talend.core.runtime.hd.IHDistribution)

Example 2 with IHDistributionVersion

use of org.talend.core.runtime.hd.IHDistributionVersion in project tdq-studio-se by Talend.

the class AliasAndManaDriverHelper method getImpalaDriverJarNameList.

private List<String> getImpalaDriverJarNameList(DatabaseConnection dbConnnection) {
    List<String> driverJarNameList = new ArrayList<String>();
    IHadoopDistributionService hadoopService = getHadoopDistributionService();
    if (hadoopService != null) {
        String distribution = dbConnnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_IMPALA_DISTRIBUTION);
        String version = dbConnnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_IMPALA_VERSION);
        IHDistribution impalaDistribution = hadoopService.getImpalaDistributionManager().getDistribution(distribution, false);
        if (impalaDistribution != null) {
            String impalaIndex = EDatabaseTypeName.IMPALA.getProduct() + ClassLoaderFactory.KEY_SEPARATOR + impalaDistribution.getName();
            if (impalaDistribution.useCustom()) {
            // TODO handle custom impala here
            } else {
                IHDistributionVersion impalaVersion = impalaDistribution.getHDVersion(version, false);
                if (impalaVersion != null) {
                    List<ModuleNeeded> modulesNeeded = impalaVersion.getModulesNeeded();
                    Set<String> libraries = new HashSet<String>();
                    for (ModuleNeeded m : modulesNeeded) {
                        libraries.add(m.getModuleName());
                    }
                    driverJarNameList.addAll(libraries);
                }
            }
        }
    }
    return driverJarNameList;
}
Also used : IHadoopDistributionService(org.talend.core.hadoop.IHadoopDistributionService) IHDistributionVersion(org.talend.core.runtime.hd.IHDistributionVersion) ArrayList(java.util.ArrayList) IHDistribution(org.talend.core.runtime.hd.IHDistribution) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) HashSet(java.util.HashSet)

Aggregations

IHadoopDistributionService (org.talend.core.hadoop.IHadoopDistributionService)2 IHDistribution (org.talend.core.runtime.hd.IHDistribution)2 IHDistributionVersion (org.talend.core.runtime.hd.IHDistributionVersion)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 DynamicClassLoader (org.talend.core.classloader.DynamicClassLoader)1 ModuleNeeded (org.talend.core.model.general.ModuleNeeded)1