Search in sources :

Example 11 with ESparkVersion

use of org.talend.hadoop.distribution.ESparkVersion in project tbd-studio-se by Talend.

the class ComponentConditionUtil method generateSparkVersionShowIfConditions.

/**
 * Generates the "SHOW_IF" condition for the "SUPPORTED_SPARK_VERSION" drop down list. Given a map of Spark versions
 * and corresponding supported hadoop versions, it builds a {@link ComponentCondition} for each entry in the map.
 *
 * @param supportedSparkVersions the map of Spark versions
 * @return an array of a String reprensation of a {@link ComponentCondition}
 */
public static String[] generateSparkVersionShowIfConditions(Map<ESparkVersion, Set<DistributionVersion>> supportedSparkVersions) {
    String[] results = null;
    if (supportedSparkVersions != null) {
        results = new String[supportedSparkVersions.size()];
        int conditionIndex = 0;
        for (Map.Entry<ESparkVersion, Set<DistributionVersion>> entry : supportedSparkVersions.entrySet()) {
            Set<ComponentCondition> multiComponentConditions = new LinkedHashSet<>();
            for (DistributionVersion distributionVersion : entry.getValue()) {
                SimpleComponentCondition distribution = new SimpleComponentCondition(new BasicExpression("DISTRIBUTION", EqualityOperator.EQ, // $NON-NLS-1$
                distributionVersion.distribution.getName()));
                SimpleComponentCondition version = new SimpleComponentCondition(new BasicExpression("SPARK_VERSION", EqualityOperator.EQ, // $NON-NLS-1$
                distributionVersion.getVersion()));
                multiComponentConditions.add(new MultiComponentCondition(distribution, BooleanOperator.AND, version));
            }
            ComponentCondition componentCondition = buildDistributionShowIf(multiComponentConditions);
            results[conditionIndex++] = componentCondition != null ? componentCondition.getConditionString() : null;
        }
    }
    return results;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) SimpleComponentCondition(org.talend.hadoop.distribution.condition.SimpleComponentCondition) ESparkVersion(org.talend.hadoop.distribution.ESparkVersion) DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) MultiComponentCondition(org.talend.hadoop.distribution.condition.MultiComponentCondition) SimpleComponentCondition(org.talend.hadoop.distribution.condition.SimpleComponentCondition) NestedComponentCondition(org.talend.hadoop.distribution.condition.NestedComponentCondition) ComponentCondition(org.talend.hadoop.distribution.condition.ComponentCondition) MultiComponentCondition(org.talend.hadoop.distribution.condition.MultiComponentCondition) Map(java.util.Map)

Example 12 with ESparkVersion

use of org.talend.hadoop.distribution.ESparkVersion in project tbd-studio-se by Talend.

the class AbstractDynamicDistributionTemplate method getSparkVersions.

@Override
public Set<ESparkVersion> getSparkVersions() {
    Set<ESparkVersion> version = new HashSet<>();
    IDynamicPluginConfiguration pluginConfiguration = pluginAdapter.getPluginConfiguration();
    List<String> selectedSparkVersions = (List<String>) pluginConfiguration.getAttribute(DynamicConstants.ATTR_SELECTED_SPARK_VERSIONS);
    if (selectedSparkVersions != null) {
        List<ESparkVersion> sparkVersions = DynamicDistributionUtils.convert2ESparkVersions(selectedSparkVersions);
        version.addAll(sparkVersions);
    }
    return version;
}
Also used : ESparkVersion(org.talend.hadoop.distribution.ESparkVersion) ArrayList(java.util.ArrayList) List(java.util.List) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) HashSet(java.util.HashSet)

Example 13 with ESparkVersion

use of org.talend.hadoop.distribution.ESparkVersion in project tbd-studio-se by Talend.

the class DynamicDistributionOptionForm method refreshSparkVersionCombo.

private void refreshSparkVersionCombo(String version) throws Exception {
    selectedSparkVersions.clear();
    TemplateBean compatibleTemplate = getDynamicDistributionSetupData().getDynamicDistributionsGroup().getCompatibleDistribution(null, version).getCompatibleTemplate(null, version);
    List<String> supportedSparkVersions = compatibleTemplate.getSupportedSparkVersions();
    if (supportedSparkVersions != null && !supportedSparkVersions.isEmpty()) {
        List<ESparkVersion> versions = DynamicDistributionUtils.convert2ESparkVersions(supportedSparkVersions);
        sparkVersionsComboViewer.getSelection();
        sparkVersionsComboViewer.setInput(versions);
        if (!versions.isEmpty()) {
            ESparkVersion defaultSparkVersion = versions.get(0);
            sparkVersionsComboViewer.setSelection(new StructuredSelection(defaultSparkVersion));
        }
    }
}
Also used : ESparkVersion(org.talend.hadoop.distribution.ESparkVersion) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) TemplateBean(org.talend.hadoop.distribution.dynamic.bean.TemplateBean)

Aggregations

ESparkVersion (org.talend.hadoop.distribution.ESparkVersion)13 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)2 List (java.util.List)2 IDynamicConfiguration (org.talend.core.runtime.dynamic.IDynamicConfiguration)2 DynamicConfiguration (org.talend.hadoop.distribution.dynamic.DynamicConfiguration)2 TemplateBean (org.talend.hadoop.distribution.dynamic.bean.TemplateBean)2 DistributionVersion (org.talend.hadoop.distribution.model.DistributionVersion)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1