Search in sources :

Example 11 with HadoopComponent

use of org.talend.hadoop.distribution.component.HadoopComponent 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 HadoopComponent

use of org.talend.hadoop.distribution.component.HadoopComponent 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 HadoopComponent

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

the class HadoopDistributionsHelper method buildDistribution.

/**
 * Builds a {@link HadoopComponent} distribution.
 *
 * @param pDistribution The name of the distribution
 * @param pVersion The name of the version
 * @return an implementation of {@link HadoopComponent}.
 * @throws Exception
 */
public static HadoopComponent buildDistribution(String pDistribution, String pVersion) throws Exception {
    final BundleContext bc = FrameworkUtil.getBundle(DistributionFactory.class).getBundleContext();
    // find hadoop components
    if (hadoopDistributions == null) {
        synchronized (HadoopDistributionsHelper.class) {
            if (hadoopDistributions == null) {
                try {
                    hadoopDistributions = bc.getServiceReferences(HadoopComponent.class, null);
                } catch (InvalidSyntaxException e) {
                    CommonExceptionHandler.process(e);
                }
            }
        }
    }
    for (ServiceReference<HadoopComponent> sr : hadoopDistributions) {
        HadoopComponent np = bc.getService(sr);
        String thatDistribution = np.getDistribution();
        if (Constant.DISTRIBUTION_CUSTOM.equals(thatDistribution) && thatDistribution.equals(pDistribution)) {
            return np;
        }
        if (thatDistribution != null && thatDistribution.equals(pDistribution)) {
            String thatVersion = np.getVersion();
            if (thatVersion != null && thatVersion.equals(pVersion)) {
                return np;
            }
        }
    }
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    throw new Exception("The distribution " + pDistribution + " with the version " + pVersion + " doesn't exist.");
}
Also used : DistributionFactory(org.talend.hadoop.distribution.DistributionFactory) HadoopComponent(org.talend.hadoop.distribution.component.HadoopComponent) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) BundleContext(org.osgi.framework.BundleContext)

Example 14 with HadoopComponent

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

the class DBR550DistributionTest method testDatabricksDistribution.

@Test
public void testDatabricksDistribution() throws Exception {
    HadoopComponent distribution = new DBR550Distribution();
    assertNotNull(distribution.getDistributionName());
    assertNotNull(distribution.getVersionName(null));
    assertTrue(distribution.doSupportS3());
    assertEquals(DBR550Distribution.DISTRIBUTION_NAME, distribution.getDistribution());
    assertEquals(DBR550Distribution.VERSION, distribution.getVersion());
    assertEquals(EHadoopVersion.HADOOP_2, distribution.getHadoopVersion());
    assertFalse(distribution.doSupportKerberos());
    assertTrue(distribution.doSupportUseDatanodeHostname());
    assertFalse(distribution.doSupportGroup());
    assertTrue(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_2_4_X));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_2_3));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_2_2));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_2_0));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_1_6));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_1_5));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_1_4));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_1_3));
    assertTrue(((SparkBatchComponent) distribution).doSupportDynamicMemoryAllocation());
    assertFalse(((SparkBatchComponent) distribution).isExecutedThroughSparkJobServer());
    assertTrue(((SparkBatchComponent) distribution).doSupportSparkStandaloneMode());
    assertFalse(((SparkBatchComponent) distribution).doSupportSparkYarnClientMode());
    assertFalse(((SparkBatchComponent) distribution).doSupportSparkYarnClusterMode());
    assertTrue(((SparkStreamingComponent) distribution).doSupportBackpressure());
    assertTrue(((SparkStreamingComponent) distribution).doSupportCheckpointing());
    assertTrue(distribution.doSupportCreateServiceConnection());
    assertTrue((distribution.getNecessaryServiceName() == null ? 0 : distribution.getNecessaryServiceName().size()) == 0);
    assertTrue(distribution.doSupportAzureDataLakeStorage());
}
Also used : DBR550Distribution(org.talend.hadoop.distribution.dbr550.DBR550Distribution) SparkBatchComponent(org.talend.hadoop.distribution.component.SparkBatchComponent) HadoopComponent(org.talend.hadoop.distribution.component.HadoopComponent) Test(org.junit.Test)

Example 15 with HadoopComponent

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

the class DBR640DistributionTest method testDatabricksDistribution.

@Test
public void testDatabricksDistribution() throws Exception {
    HadoopComponent distribution = new DBR640Distribution();
    assertNotNull(distribution.getDistributionName());
    assertNotNull(distribution.getVersionName(null));
    assertTrue(distribution.doSupportS3());
    assertEquals(DBR640Distribution.DISTRIBUTION_NAME, distribution.getDistribution());
    assertEquals(DBR640Distribution.VERSION, distribution.getVersion());
    assertEquals(EHadoopVersion.HADOOP_2, distribution.getHadoopVersion());
    assertFalse(distribution.doSupportKerberos());
    assertTrue(distribution.doSupportUseDatanodeHostname());
    assertFalse(distribution.doSupportGroup());
    assertTrue(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_2_4_X));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_2_3));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_2_2));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_2_0));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_1_6));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_1_5));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_1_4));
    assertFalse(((SparkBatchComponent) distribution).getSparkVersions().contains(ESparkVersion.SPARK_1_3));
    assertTrue(((SparkBatchComponent) distribution).doSupportDynamicMemoryAllocation());
    assertFalse(((SparkBatchComponent) distribution).isExecutedThroughSparkJobServer());
    assertTrue(((SparkBatchComponent) distribution).doSupportSparkStandaloneMode());
    assertFalse(((SparkBatchComponent) distribution).doSupportSparkYarnClientMode());
    assertTrue(((SparkStreamingComponent) distribution).doSupportBackpressure());
    assertTrue(((SparkStreamingComponent) distribution).doSupportCheckpointing());
    assertTrue(distribution.doSupportCreateServiceConnection());
    assertTrue((distribution.getNecessaryServiceName() == null ? 0 : distribution.getNecessaryServiceName().size()) == 0);
    assertTrue(distribution.doSupportAzureDataLakeStorage());
}
Also used : SparkBatchComponent(org.talend.hadoop.distribution.component.SparkBatchComponent) HadoopComponent(org.talend.hadoop.distribution.component.HadoopComponent) DBR640Distribution(org.talend.hadoop.distribution.dbr640.DBR640Distribution) Test(org.junit.Test)

Aggregations

HadoopComponent (org.talend.hadoop.distribution.component.HadoopComponent)20 Test (org.junit.Test)10 DistributionBean (org.talend.hadoop.distribution.model.DistributionBean)6 DistributionVersion (org.talend.hadoop.distribution.model.DistributionVersion)5 HCatalogComponent (org.talend.hadoop.distribution.component.HCatalogComponent)4 ImpalaComponent (org.talend.hadoop.distribution.component.ImpalaComponent)4 SparkBatchComponent (org.talend.hadoop.distribution.component.SparkBatchComponent)4 SparkStreamingComponent (org.talend.hadoop.distribution.component.SparkStreamingComponent)4 IHDistributionVersion (org.talend.core.runtime.hd.IHDistributionVersion)3 HBaseComponent (org.talend.hadoop.distribution.component.HBaseComponent)3 SparkComponent (org.talend.hadoop.distribution.component.SparkComponent)3 SqoopComponent (org.talend.hadoop.distribution.component.SqoopComponent)3 Before (org.junit.Before)2 BundleContext (org.osgi.framework.BundleContext)2 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)2 AbstractDynamicDistributionTemplate (org.talend.hadoop.distribution.dynamic.template.AbstractDynamicDistributionTemplate)2 DynamicDistributionVersion (org.talend.hadoop.distribution.model.DynamicDistributionVersion)2 AbstractDistributionTest (org.talend.hadoop.distribution.test.AbstractDistributionTest)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1