Search in sources :

Example 11 with TemplateBean

use of org.talend.hadoop.distribution.dynamic.bean.TemplateBean in project tbd-studio-se by Talend.

the class AbstractDynamicDistribution method buildDynamicPlugin.

@Override
public IDynamicPlugin buildDynamicPlugin(IDynamicMonitor monitor, DynamicConfiguration configuration) throws Exception {
    String distribution = configuration.getDistribution();
    if (!StringUtils.equals(getDistributionName(), distribution)) {
        throw new Exception("only support to build dynamic plugin of " + getDistributionName() + " instead of " + distribution);
    }
    String version = configuration.getVersion();
    TemplateBean bestTemplateBean = getCompatibleTemplate(monitor, version);
    // normally bestTemplateBean can't be null here
    DynamicTemplateAdapter templateAdapter = new DynamicTemplateAdapter(bestTemplateBean, configuration);
    templateAdapter.adapt(monitor);
    IDynamicPlugin dynamicPlugin = templateAdapter.getDynamicPlugin();
    return dynamicPlugin;
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) TemplateBean(org.talend.hadoop.distribution.dynamic.bean.TemplateBean) DynamicTemplateAdapter(org.talend.hadoop.distribution.dynamic.adapter.DynamicTemplateAdapter)

Example 12 with TemplateBean

use of org.talend.hadoop.distribution.dynamic.bean.TemplateBean in project tbd-studio-se by Talend.

the class AbstractDynamicDistribution method getCompatibleVersions.

@Override
public List<String> getCompatibleVersions(IDynamicMonitor monitor) throws Exception {
    Set<String> allCompatibleVersion = new HashSet<>();
    List<TemplateBean> templates = getTemplates(monitor);
    if (templates != null) {
        DynamicDistributionUtils.checkCancelOrNot(monitor);
        templateBeanCompatibleVersionMap = new HashMap<>();
        DynamicDistributionManager dynamicDistributionManager = DynamicDistributionManager.getInstance();
        DynamicConfiguration dynamicConfiguration = new DynamicConfiguration();
        dynamicConfiguration.setDistribution(getDistributionName());
        IDependencyResolver dependencyResolver = dynamicDistributionManager.getDependencyResolver(dynamicConfiguration);
        List<String> allHadoopVersions = dependencyResolver.listHadoopVersions(null, null, monitor);
        if (allHadoopVersions != null) {
            for (TemplateBean templateBean : templates) {
                DynamicDistributionUtils.checkCancelOrNot(monitor);
                String baseVersion = templateBean.getBaseVersion();
                String topVersion = templateBean.getTopVersion();
                // $NON-NLS-1$
                String versionRange = "[";
                if (StringUtils.isEmpty(baseVersion)) {
                    // $NON-NLS-1$
                    versionRange = versionRange + "0";
                } else {
                    versionRange = versionRange + baseVersion;
                }
                // $NON-NLS-1$
                versionRange = versionRange + ",";
                if (StringUtils.isNotEmpty(topVersion)) {
                    versionRange = versionRange + topVersion;
                }
                // $NON-NLS-1$
                versionRange = versionRange + ")";
                List<String> filteredVersions = DynamicDistributionAetherUtils.filterVersions(allHadoopVersions, versionRange);
                if (filteredVersions != null && !filteredVersions.isEmpty()) {
                    allCompatibleVersion.addAll(filteredVersions);
                    templateBeanCompatibleVersionMap.put(templateBean, filteredVersions);
                }
            }
        }
    }
    List<String> compatibleVersionList = new LinkedList<>(allCompatibleVersion);
    Collections.sort(compatibleVersionList, Collections.reverseOrder(new VersionStringComparator()));
    return compatibleVersionList;
}
Also used : VersionStringComparator(org.talend.designer.maven.aether.comparator.VersionStringComparator) TemplateBean(org.talend.hadoop.distribution.dynamic.bean.TemplateBean) IDependencyResolver(org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 13 with TemplateBean

use of org.talend.hadoop.distribution.dynamic.bean.TemplateBean in project tbd-studio-se by Talend.

the class DynamicExclusionAdapter method resolve.

@Override
protected void resolve() throws Exception {
    if (isResolved()) {
        return;
    }
    TemplateBean templateBean = getTemplateBean();
    String artifactId = (String) DynamicDistributionUtils.calculate(templateBean, exclusionBean.getArtifactId());
    String classifier = (String) DynamicDistributionUtils.calculate(templateBean, exclusionBean.getClassifier());
    String extension = (String) DynamicDistributionUtils.calculate(templateBean, exclusionBean.getExtension());
    String groupId = (String) DynamicDistributionUtils.calculate(templateBean, exclusionBean.getGroupId());
    exclusionBean.setArtifactId(artifactId);
    exclusionBean.setClassifier(classifier);
    exclusionBean.setExtension(extension);
    exclusionBean.setGroupId(groupId);
    setResolved(true);
}
Also used : TemplateBean(org.talend.hadoop.distribution.dynamic.bean.TemplateBean)

Example 14 with TemplateBean

use of org.talend.hadoop.distribution.dynamic.bean.TemplateBean in project tbd-studio-se by Talend.

the class DynamicTemplateAdapter method adapt.

public void adapt(IDynamicMonitor monitor) throws Exception {
    DynamicDistributionUtils.checkCancelOrNot(monitor);
    resolve();
    TemplateBean templateBean = getTemplateBean();
    DynamicConfiguration configuration = getConfiguration();
    // use id instead of version
    templateBean.setDynamicVersion(configuration.getId());
    DynamicDistributionManager dynamicDistributionManager = DynamicDistributionManager.getInstance();
    IDependencyResolver dependencyResolver = dynamicDistributionManager.getDependencyResolver(configuration);
    dynamicPlugin = DynamicFactory.getInstance().createDynamicPlugin();
    distriConfigAdapter = new DynamicDistribConfigAdapter(templateBean, configuration);
    IDynamicPluginConfiguration pluginConfiguration = distriConfigAdapter.adapt(monitor);
    dynamicPlugin.setPluginConfiguration(pluginConfiguration);
    moduleBeanAdapterMap = new HashMap<>();
    moduleGroupBeanAdapterMap = new HashMap<>();
    DynamicLibraryNeededExtensionAdaper libNeededExtAdapter = new DynamicLibraryNeededExtensionAdaper(templateBean, configuration, dependencyResolver, moduleBeanAdapterMap, moduleGroupBeanAdapterMap);
    libNeededExtAdapter.enableMultiThread(!Boolean.getBoolean(PROPERTY_DISABLE_MULTI_THTREAD));
    IDynamicExtension dynamicLibNeededExtension = libNeededExtAdapter.adapt(monitor);
    dynamicPlugin.addExtension(dynamicLibNeededExtension);
    DynamicClassLoaderExtensionAdaper clsLoaderAdapter = new DynamicClassLoaderExtensionAdaper(templateBean, configuration, moduleGroupBeanAdapterMap);
    IDynamicExtension dynamicClsLoaderExtension = clsLoaderAdapter.adapt(monitor);
    dynamicPlugin.addExtension(dynamicClsLoaderExtension);
}
Also used : DynamicConfiguration(org.talend.hadoop.distribution.dynamic.DynamicConfiguration) IDynamicExtension(org.talend.core.runtime.dynamic.IDynamicExtension) DynamicDistributionManager(org.talend.hadoop.distribution.dynamic.DynamicDistributionManager) TemplateBean(org.talend.hadoop.distribution.dynamic.bean.TemplateBean) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) IDependencyResolver(org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver)

Example 15 with TemplateBean

use of org.talend.hadoop.distribution.dynamic.bean.TemplateBean in project tbd-studio-se by Talend.

the class DynamicTemplateAdapter method resolve.

@Override
protected void resolve() throws Exception {
    if (isResolved()) {
        return;
    }
    TemplateBean templateBean = getTemplateBean();
    String id = (String) DynamicDistributionUtils.calculate(templateBean, templateBean.getId());
    String name = (String) DynamicDistributionUtils.calculate(templateBean, templateBean.getName());
    String description = (String) DynamicDistributionUtils.calculate(templateBean, templateBean.getDescription());
    String distribution = (String) DynamicDistributionUtils.calculate(templateBean, templateBean.getDistribution());
    String templateId = (String) DynamicDistributionUtils.calculate(templateBean, templateBean.getTemplateId());
    String baseVersion = (String) DynamicDistributionUtils.calculate(templateBean, templateBean.getBaseVersion());
    String topVersion = (String) DynamicDistributionUtils.calculate(templateBean, templateBean.getTopVersion());
    templateBean.setId(id);
    templateBean.setName(name);
    templateBean.setDescription(description);
    templateBean.setDistribution(distribution);
    templateBean.setTemplateId(templateId);
    templateBean.setBaseVersion(baseVersion);
    templateBean.setTopVersion(topVersion);
    setResolved(true);
}
Also used : TemplateBean(org.talend.hadoop.distribution.dynamic.bean.TemplateBean)

Aggregations

TemplateBean (org.talend.hadoop.distribution.dynamic.bean.TemplateBean)17 DynamicConfiguration (org.talend.hadoop.distribution.dynamic.DynamicConfiguration)7 ArrayList (java.util.ArrayList)5 IDynamicConfiguration (org.talend.core.runtime.dynamic.IDynamicConfiguration)5 IDynamicExtension (org.talend.core.runtime.dynamic.IDynamicExtension)3 IDependencyResolver (org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)2 VersionStringComparator (org.talend.designer.maven.aether.comparator.VersionStringComparator)2 ExclusionNode (org.talend.designer.maven.aether.node.ExclusionNode)2 ESparkVersion (org.talend.hadoop.distribution.ESparkVersion)2 DynamicDistributionManager (org.talend.hadoop.distribution.dynamic.DynamicDistributionManager)2 ExclusionBean (org.talend.hadoop.distribution.dynamic.bean.ExclusionBean)2 ModuleBean (org.talend.hadoop.distribution.dynamic.bean.ModuleBean)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 URL (java.net.URL)1