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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations