Search in sources :

Example 11 with DistributionVersion

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

the class DistributionsManager method removeDistribution.

private void removeDistribution(BundleContext bc, Map<String, DistributionBean> distributionsMap, ComponentType type, ServiceReference<? extends HadoopComponent> sr) {
    HadoopComponent hc = bc.getService(sr);
    final String distribution = hc.getDistribution();
    final String distributionName = hc.getDistributionName();
    String key = getKey(hc);
    DistributionBean distributionBean = distributionsMap.get(key);
    if (distributionBean == null) {
        // not exsit, no need to remove
        return;
    } else {
        // check the name and displayName
        if (!distribution.equals(distributionBean.name) || !distributionName.equals(distributionBean.displayName)) {
            // $NON-NLS-1$
            CommonExceptionHandler.warn(" There are different distribution name for " + distributionBean);
        // return;
        }
    }
    clearCache();
    final String version = hc.getVersion();
    DistributionVersion versionBean = null;
    if (hc instanceof AbstractDynamicDistributionTemplate) {
        AbstractDynamicDistributionTemplate dynamicDistribution = (AbstractDynamicDistributionTemplate) hc;
        versionBean = new DynamicDistributionVersion(dynamicDistribution, distributionBean, type, version, hc.getVersionName(type));
    } else {
        versionBean = new DistributionVersion(hc, distributionBean, version, hc.getVersionName(type));
    }
    // special condition for current version
    versionBean.displayCondition = hc.getDisplayCondition(type);
    distributionBean.removeVersion(versionBean);
    distributionBean.setDefaultVersion(null);
    DistributionVersion[] versions = distributionBean.getVersions();
    if (versions == null || versions.length <= 0) {
        distributionsMap.remove(key);
    }
}
Also used : DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) DynamicDistributionVersion(org.talend.hadoop.distribution.model.DynamicDistributionVersion) HadoopComponent(org.talend.hadoop.distribution.component.HadoopComponent) AbstractDynamicDistributionTemplate(org.talend.hadoop.distribution.dynamic.template.AbstractDynamicDistributionTemplate) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean) DynamicDistributionVersion(org.talend.hadoop.distribution.model.DynamicDistributionVersion)

Example 12 with DistributionVersion

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

the class DistributionsManager method addDistribution.

private void addDistribution(BundleContext bc, Map<String, DistributionBean> disctributionsMap, ComponentType type, ServiceReference<? extends HadoopComponent> sr) {
    HadoopComponent hc = bc.getService(sr);
    if (hc != null && hc.isActivated()) {
        final String distribution = hc.getDistribution();
        final String distributionName = hc.getDistributionName();
        String key = getKey(hc);
        DistributionBean distributionBean = disctributionsMap.get(key);
        if (distributionBean == null) {
            distributionBean = new DistributionBean(type, distribution, distributionName, ((AbstractDistribution) hc).isSparkLocal());
            if (ISparkDistribution.DISTRIBUTION_NAME.equals(distribution)) {
                distributionBean.setHadoopFSVersions(((AbstractDistribution) hc).getSupportedHadoopFSVersion());
                distributionBean.setHiveVersions(((AbstractDistribution) hc).getSupportedHiveVersion());
                distributionBean.sethBaseVersions(((AbstractDistribution) hc).getSupportedHBaseVersion());
                distributionBean.sethCatalogVersions(((AbstractDistribution) hc).getSupportedHCatalogVersion());
            }
            disctributionsMap.put(key, distributionBean);
        } else {
            // check the name and displayName
            if (!distribution.equals(distributionBean.name) || !distributionName.equals(distributionBean.displayName)) {
                // $NON-NLS-1$
                CommonExceptionHandler.warn(" There are different distribution name for " + distributionBean);
                return;
            }
        }
        clearCache();
        DistributionVersion versionBean = null;
        final String version = hc.getVersion();
        if (hc instanceof AbstractDynamicDistributionTemplate) {
            AbstractDynamicDistributionTemplate dynamicDistribution = (AbstractDynamicDistributionTemplate) hc;
            versionBean = new DynamicDistributionVersion(dynamicDistribution, distributionBean, type, version, hc.getVersionName(type));
        } else {
            versionBean = new DistributionVersion(hc, distributionBean, version, hc.getVersionName(type));
        }
        versionBean.addModuleGroups(hc.getModuleGroups(type));
        // special condition for current version
        versionBean.displayCondition = hc.getDisplayCondition(type);
        distributionBean.addVersion(versionBean);
        // add all version conditions ?
        distributionBean.addCondition(hc.getDisplayCondition(type));
    }
}
Also used : DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) DynamicDistributionVersion(org.talend.hadoop.distribution.model.DynamicDistributionVersion) AbstractDistribution(org.talend.hadoop.distribution.AbstractDistribution) HadoopComponent(org.talend.hadoop.distribution.component.HadoopComponent) AbstractDynamicDistributionTemplate(org.talend.hadoop.distribution.dynamic.template.AbstractDynamicDistributionTemplate) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean) DynamicDistributionVersion(org.talend.hadoop.distribution.model.DynamicDistributionVersion)

Example 13 with DistributionVersion

use of org.talend.hadoop.distribution.model.DistributionVersion 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 14 with DistributionVersion

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

the class HadoopClusterForm method addFieldsListeners.

@Override
protected void addFieldsListeners() {
    distributionCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            String newDistributionDisplayName = distributionCombo.getText();
            DistributionBean newDistribution = HadoopDistributionsHelper.HADOOP.getDistribution(newDistributionDisplayName, true);
            String newDistributionName = newDistribution.name;
            String originalDistributionName = getConnection().getDistribution();
            getConnection().setDistribution(newDistributionName);
            getConnection().setUseCustomVersion(newDistribution.useCustom());
            boolean distrChanged = !StringUtils.equals(newDistributionName, originalDistributionName);
            if (distrChanged) {
                getConnection().setDfVersion(null);
            }
            updateVersionPart();
            updateKnoxPart();
            updateYarnContent();
            updateKnoxContent();
            switchToInfoForm();
            checkFieldsValue();
        }
    });
    versionCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            String newVersionDisplayName = versionCombo.getText();
            if (StringUtils.isEmpty(newVersionDisplayName)) {
                return;
            }
            DistributionBean hadoopDistribution = HadoopDistributionsHelper.HADOOP.getDistribution(distributionCombo.getText(), true);
            DistributionVersion hadoopVersion = hadoopDistribution.getVersion(newVersionDisplayName, true);
            getConnection().setDfVersion(hadoopVersion.version);
            if (hadoopVersion.hadoopComponent.isHadoop2() || hadoopVersion.hadoopComponent.isHadoop3()) {
                getConnection().setUseYarn(true);
            } else {
                getConnection().setUseYarn(false);
            }
            updateKnoxPart();
            updateYarnContent();
            updateKnoxContent();
            switchToInfoForm();
            checkFieldsValue();
        }
    });
    customButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            HadoopCustomVersionDefineDialog customVersionDialog = new HadoopCustomVersionDefineDialog(getShell(), HCVersionUtil.getCustomVersionMap(getConnection()));
            if (customVersionDialog.open() == Window.OK) {
                HCVersionUtil.injectCustomVersionMap(getConnection(), customVersionDialog.getLibMap());
            }
        }
    });
    useYarnButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            getConnection().setUseYarn(useYarnButton.getSelection());
            switchToInfoForm();
        }
    });
    useKnoxButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String selection = String.valueOf(useKnoxButton.getSelection());
            getConnection().getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USE_KNOX, selection);
            switchToInfoForm();
            checkFieldsValue();
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) HadoopCustomVersionDefineDialog(org.talend.core.hadoop.version.custom.HadoopCustomVersionDefineDialog) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean)

Example 15 with DistributionVersion

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

the class HadoopClusterForm method updateVersionPart.

private void updateVersionPart() {
    DistributionBean distribution = HadoopDistributionsHelper.HADOOP.getDistribution(distributionCombo.getText(), true);
    versionCombo.getCombo().setItems(distribution.getVersionsDisplay());
    final DistributionVersion defaultVersion = distribution.getDefaultVersion();
    DistributionVersion hadoopVersion = distribution.getVersion(getConnection().getDfVersion(), false);
    if (hadoopVersion != null && hadoopVersion.displayVersion != null) {
        versionCombo.setText(hadoopVersion.displayVersion);
    } else if (defaultVersion != null) {
        versionCombo.setText(defaultVersion.displayVersion);
    } else {
        versionCombo.getCombo().select(0);
    }
    if (distribution.useCustom()) {
        versionCombo.setHideWidgets(true);
        hideControl(useYarnButton, false);
        hideControl(customButton, false);
    } else {
        versionCombo.setHideWidgets(false);
        hideControl(useYarnButton, true);
        hideControl(customButton, true);
    }
}
Also used : DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean)

Aggregations

DistributionVersion (org.talend.hadoop.distribution.model.DistributionVersion)23 DistributionBean (org.talend.hadoop.distribution.model.DistributionBean)15 HadoopComponent (org.talend.hadoop.distribution.component.HadoopComponent)5 SparkComponent (org.talend.hadoop.distribution.component.SparkComponent)4 Test (org.junit.Test)3 IHDistributionVersion (org.talend.core.runtime.hd.IHDistributionVersion)3 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)3 ESparkVersion (org.talend.hadoop.distribution.ESparkVersion)2 SparkStreamingComponent (org.talend.hadoop.distribution.component.SparkStreamingComponent)2 AbstractDynamicDistributionTemplate (org.talend.hadoop.distribution.dynamic.template.AbstractDynamicDistributionTemplate)2 DynamicDistributionVersion (org.talend.hadoop.distribution.model.DynamicDistributionVersion)2 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Ignore (org.junit.Ignore)1 PersistenceException (org.talend.commons.exception.PersistenceException)1