Search in sources :

Example 1 with DynamicDistributionVersion

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

use of org.talend.hadoop.distribution.model.DynamicDistributionVersion 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)

Aggregations

HadoopComponent (org.talend.hadoop.distribution.component.HadoopComponent)2 AbstractDynamicDistributionTemplate (org.talend.hadoop.distribution.dynamic.template.AbstractDynamicDistributionTemplate)2 DistributionBean (org.talend.hadoop.distribution.model.DistributionBean)2 DistributionVersion (org.talend.hadoop.distribution.model.DistributionVersion)2 DynamicDistributionVersion (org.talend.hadoop.distribution.model.DynamicDistributionVersion)2 AbstractDistribution (org.talend.hadoop.distribution.AbstractDistribution)1