Search in sources :

Example 1 with SparkComponent

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

the class HadoopSubMultiRepTypeProcessor method isValidAttributes.

private boolean isValidAttributes(RepositoryNode node) {
    if (node == null) {
        return true;
    }
    if (attributesMap != null && !attributesMap.isEmpty()) {
        HadoopClusterConnection hcConnection = HCRepositoryUtil.getRelativeHadoopClusterConnection(node.getId());
        if (hcConnection != null) {
            IElement elem = (IElement) attributesMap.get(ELEMENT);
            DistributionBean hadoopDistribution = HadoopDistributionsHelper.HADOOP.getDistribution(hcConnection.getDistribution(), false);
            if (hadoopDistribution != null) {
                DistributionVersion distributionVersion = hadoopDistribution.getVersion(hcConnection.getDfVersion(), false);
                if (distributionVersion != null && distributionVersion.hadoopComponent != null) {
                    boolean validated = true;
                    Object isSpark = attributesMap.get(ISSPARK);
                    if (isSpark != null && Boolean.valueOf(isSpark.toString())) {
                        validated = (validated && distributionVersion.hadoopComponent instanceof SparkComponent);
                        if (!validated) {
                            return false;
                        }
                    }
                    Object useYarn = attributesMap.get(USEYARN);
                    if (useYarn != null && Boolean.valueOf(useYarn.toString())) {
                        // CustomDistribution.doSupportSparkYarnClusterMode = true
                        if (ICustomDistribution.DISTRIBUTION_NAME.equals(distributionVersion.hadoopComponent.getDistribution())) {
                            validated = true;
                        } else {
                            validated = (validated && (distributionVersion.hadoopComponent.isHadoop2() || distributionVersion.hadoopComponent.isHadoop3()));
                        }
                        if (!validated) {
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}
Also used : IElement(org.talend.core.model.process.IElement) DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) SparkComponent(org.talend.hadoop.distribution.component.SparkComponent) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean)

Example 2 with SparkComponent

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

the class DistributionHelperTest method test_doSupportService_SparkStreamingComponent.

@Test
public void test_doSupportService_SparkStreamingComponent() {
    HadoopComponent hadoopComponent = Mockito.mock(HadoopComponent.class);
    DistributionBean distribution = Mockito.mock(DistributionBean.class);
    Assert.assertFalse(DistributionHelper.doSupportService(new DistributionVersion(hadoopComponent, distribution, "ABC_10", "Abc 1.0"), IHDConstants.SERVICE_SPARK_STREAMING));
    SparkComponent sparkComponent = Mockito.mock(SparkComponent.class);
    Assert.assertFalse(DistributionHelper.doSupportService(new DistributionVersion(sparkComponent, distribution, "ABC_10", "Abc 1.0"), IHDConstants.SERVICE_SPARK_STREAMING));
    SparkStreamingComponent sparkStreamingComponent = Mockito.mock(SparkStreamingComponent.class);
    Assert.assertTrue(DistributionHelper.doSupportService(new DistributionVersion(sparkStreamingComponent, distribution, "ABC_10", "Abc 1.0"), IHDConstants.SERVICE_SPARK_STREAMING));
}
Also used : IHDistributionVersion(org.talend.core.runtime.hd.IHDistributionVersion) DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) SparkComponent(org.talend.hadoop.distribution.component.SparkComponent) HadoopComponent(org.talend.hadoop.distribution.component.HadoopComponent) SparkStreamingComponent(org.talend.hadoop.distribution.component.SparkStreamingComponent) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean) Test(org.junit.Test)

Example 3 with SparkComponent

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

the class DistributionHelperTest method test_doSupportService_HadoopComponent.

@Test
public void test_doSupportService_HadoopComponent() {
    HadoopComponent hadoopComponent = Mockito.mock(HadoopComponent.class);
    DistributionBean distribution = Mockito.mock(DistributionBean.class);
    Assert.assertTrue(DistributionHelper.doSupportService(new DistributionVersion(hadoopComponent, distribution, "ABC_10", "Abc 1.0"), IHDConstants.SERVICE_HADOOP));
    // because the SparkComponent is sub class of HadoopComponent
    SparkComponent sparkComponent = Mockito.mock(SparkComponent.class);
    Assert.assertTrue(DistributionHelper.doSupportService(new DistributionVersion(sparkComponent, distribution, "ABC_10", "Abc 1.0"), IHDConstants.SERVICE_HADOOP));
}
Also used : IHDistributionVersion(org.talend.core.runtime.hd.IHDistributionVersion) DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) SparkComponent(org.talend.hadoop.distribution.component.SparkComponent) HadoopComponent(org.talend.hadoop.distribution.component.HadoopComponent) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean) Test(org.junit.Test)

Example 4 with SparkComponent

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

the class DistributionHelperTest method test_doSupportService_SparkComponent.

@Test
public void test_doSupportService_SparkComponent() {
    HadoopComponent hadoopComponent = Mockito.mock(HadoopComponent.class);
    DistributionBean distribution = Mockito.mock(DistributionBean.class);
    Assert.assertFalse(DistributionHelper.doSupportService(new DistributionVersion(hadoopComponent, distribution, "ABC_10", "Abc 1.0"), IHDConstants.SERVICE_SPARK));
    SparkComponent sparkComponent = Mockito.mock(SparkComponent.class);
    Assert.assertTrue(DistributionHelper.doSupportService(new DistributionVersion(sparkComponent, distribution, "ABC_10", "Abc 1.0"), IHDConstants.SERVICE_SPARK));
    // because the SparkStreamingComponent is sub class of SparkComponent
    SparkStreamingComponent sparkStreamingComponent = Mockito.mock(SparkStreamingComponent.class);
    Assert.assertTrue(DistributionHelper.doSupportService(new DistributionVersion(sparkStreamingComponent, distribution, "ABC_10", "Abc 1.0"), IHDConstants.SERVICE_SPARK));
}
Also used : IHDistributionVersion(org.talend.core.runtime.hd.IHDistributionVersion) DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) SparkComponent(org.talend.hadoop.distribution.component.SparkComponent) HadoopComponent(org.talend.hadoop.distribution.component.HadoopComponent) SparkStreamingComponent(org.talend.hadoop.distribution.component.SparkStreamingComponent) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean) Test(org.junit.Test)

Aggregations

SparkComponent (org.talend.hadoop.distribution.component.SparkComponent)4 DistributionBean (org.talend.hadoop.distribution.model.DistributionBean)4 DistributionVersion (org.talend.hadoop.distribution.model.DistributionVersion)4 Test (org.junit.Test)3 IHDistributionVersion (org.talend.core.runtime.hd.IHDistributionVersion)3 HadoopComponent (org.talend.hadoop.distribution.component.HadoopComponent)3 SparkStreamingComponent (org.talend.hadoop.distribution.component.SparkStreamingComponent)2 IElement (org.talend.core.model.process.IElement)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)1