Search in sources :

Example 11 with BasicExpression

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

the class AbstractDistribution method buildModuleGroups.

protected Map<ComponentType, Set<DistributionModuleGroup>> buildModuleGroups() {
    Map<ComponentType, Set<DistributionModuleGroup>> result = new HashMap<>();
    // HCatalog
    result.put(ComponentType.HCATALOG, ModuleGroupsUtils.getModuleGroups(null, ModuleGroupName.HDFS.get(this.getVersion()), false));
    // HDFS
    result.put(ComponentType.HDFS, ModuleGroupsUtils.getModuleGroups(null, ModuleGroupName.HDFS.get(this.getVersion()), false));
    // Hbase
    result.put(ComponentType.HBASE, ModuleGroupsUtils.getModuleGroups(null, ModuleGroupName.HBASE.get(this.getVersion()), true));
    // Hive
    ComponentCondition hiveOnHbaseCondition = new MultiComponentCondition(new SimpleComponentCondition(new BasicExpression(// 
    HiveConstant.HIVE_CONFIGURATION_COMPONENT_HBASEPARAMETER)), // 
    BooleanOperator.AND, new SimpleComponentCondition(new ShowExpression(HiveConstant.HIVE_CONFIGURATION_COMPONENT_HBASEPARAMETER)));
    Set<DistributionModuleGroup> hiveModuleGroups = new HashSet<>();
    hiveModuleGroups.addAll(ModuleGroupsUtils.getModuleGroups(null, ModuleGroupName.HIVE.get(this.getVersion()), false));
    hiveModuleGroups.addAll(ModuleGroupsUtils.getModuleGroups(hiveOnHbaseCondition, ModuleGroupName.HBASE.get(this.getVersion()), false));
    result.put(ComponentType.HIVE, hiveModuleGroups);
    // Hive on Spark
    result.put(ComponentType.HIVEONSPARK, ModuleGroupsUtils.getModuleGroups((ComponentCondition) null, ModuleGroupName.HIVE.get(this.getVersion()), true));
    // Sqoop
    result.put(ComponentType.SQOOP, SqoopModuleGroup.getModuleGroups(this.getVersion()));
    result.put(ComponentType.SPARKBATCH, ModuleGroupsUtils.getModuleGroups(null, ModuleGroupName.SPARK_BATCH.get(this.getVersion()), true));
    result.put(ComponentType.SPARKSTREAMING, ModuleGroupsUtils.getModuleGroups(null, ModuleGroupName.SPARK_STREAMING.get(this.getVersion()), true));
    return result;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ShowExpression(org.talend.hadoop.distribution.condition.ShowExpression) BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) HashMap(java.util.HashMap) SimpleComponentCondition(org.talend.hadoop.distribution.condition.SimpleComponentCondition) MultiComponentCondition(org.talend.hadoop.distribution.condition.MultiComponentCondition) SimpleComponentCondition(org.talend.hadoop.distribution.condition.SimpleComponentCondition) ComponentCondition(org.talend.hadoop.distribution.condition.ComponentCondition) MultiComponentCondition(org.talend.hadoop.distribution.condition.MultiComponentCondition) HashSet(java.util.HashSet)

Example 12 with BasicExpression

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

the class DistributionVersionModule method getModuleRequiredIf.

public ComponentCondition getModuleRequiredIf() {
    ComponentCondition condition;
    // The import is needed only if the good version and the good distribution are selected, and
    // if the Distribution is shown. The second condition to take the
    // USE_EXISTING_CONNECTIOn into account.
    final ComponentType componentType = distributionVersion.distribution.componentType;
    Expression distributionSelected = new BasicExpression(componentType.getDistributionParameter(), EqualityOperator.EQ, distributionVersion.distribution.name);
    Expression distributionVersionSelected = new BasicExpression(componentType.getVersionParameter(), EqualityOperator.EQ, distributionVersion.version);
    Expression distributionShown = new ShowExpression(componentType.getDistributionParameter());
    condition = new MultiComponentCondition(new SimpleComponentCondition(distributionSelected), BooleanOperator.AND, new MultiComponentCondition(new SimpleComponentCondition(distributionVersionSelected), BooleanOperator.AND, new SimpleComponentCondition(distributionShown)));
    if (moduleGroup.getRequiredIf() != null) {
        condition = new MultiComponentCondition(condition, BooleanOperator.AND, new NestedComponentCondition(moduleGroup.getRequiredIf()));
    }
    return condition;
}
Also used : ComponentType(org.talend.hadoop.distribution.ComponentType) ShowExpression(org.talend.hadoop.distribution.condition.ShowExpression) BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) ShowExpression(org.talend.hadoop.distribution.condition.ShowExpression) LinkedNodeExpression(org.talend.hadoop.distribution.condition.LinkedNodeExpression) Expression(org.talend.hadoop.distribution.condition.Expression) BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) RawExpression(org.talend.hadoop.distribution.condition.RawExpression) SimpleComponentCondition(org.talend.hadoop.distribution.condition.SimpleComponentCondition) 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) NestedComponentCondition(org.talend.hadoop.distribution.condition.NestedComponentCondition)

Example 13 with BasicExpression

use of org.talend.hadoop.distribution.condition.BasicExpression 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 BasicExpression

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

the class DynamicSparkStreamingModuleGroup method init.

protected void init() {
    // $NON-NLS-1$
    spark1Condition = new SimpleComponentCondition(new BasicExpression("SUPPORTED_SPARK_VERSION", EqualityOperator.EQ, ESparkVersion.SPARK_1_6.getSparkVersion()));
    spark2Condition = new MultiComponentCondition(// $NON-NLS-1$
    new BasicExpression("SUPPORTED_SPARK_VERSION", EqualityOperator.EQ, ESparkVersion.SPARK_2_0.getSparkVersion()), BooleanOperator.OR, new MultiComponentCondition(// $NON-NLS-1$
    new BasicExpression("SUPPORTED_SPARK_VERSION", EqualityOperator.EQ, ESparkVersion.SPARK_2_1.getSparkVersion()), BooleanOperator.OR, new MultiComponentCondition(// $NON-NLS-1$
    new BasicExpression("SUPPORTED_SPARK_VERSION", EqualityOperator.EQ, ESparkVersion.SPARK_2_2.getSparkVersion()), BooleanOperator.OR, new MultiComponentCondition(// $NON-NLS-1$
    new BasicExpression("SUPPORTED_SPARK_VERSION", EqualityOperator.EQ, ESparkVersion.SPARK_2_3_X.getSparkVersion()), BooleanOperator.OR, // $NON-NLS-1$
    new BasicExpression("SUPPORTED_SPARK_VERSION", EqualityOperator.EQ, ESparkVersion.SPARK_2_4_X.getSparkVersion())))));
}
Also used : BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) SimpleComponentCondition(org.talend.hadoop.distribution.condition.SimpleComponentCondition) MultiComponentCondition(org.talend.hadoop.distribution.condition.MultiComponentCondition)

Example 15 with BasicExpression

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

the class DynamicHDPSparkBatchModuleGroup method initConditions.

@Override
protected void initConditions() {
    super.initConditions();
    conditionNotSpark16 = new SimpleComponentCondition(// $NON-NLS-1$
    new BasicExpression("SUPPORTED_SPARK_VERSION", EqualityOperator.NOT_EQ, ESparkVersion.SPARK_1_6.getSparkVersion()));
}
Also used : BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) SimpleComponentCondition(org.talend.hadoop.distribution.condition.SimpleComponentCondition)

Aggregations

BasicExpression (org.talend.hadoop.distribution.condition.BasicExpression)23 SimpleComponentCondition (org.talend.hadoop.distribution.condition.SimpleComponentCondition)20 MultiComponentCondition (org.talend.hadoop.distribution.condition.MultiComponentCondition)16 ComponentCondition (org.talend.hadoop.distribution.condition.ComponentCondition)15 HashSet (java.util.HashSet)13 DistributionModuleGroup (org.talend.hadoop.distribution.DistributionModuleGroup)11 DynamicPluginAdapter (org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter)5 Expression (org.talend.hadoop.distribution.condition.Expression)4 NestedComponentCondition (org.talend.hadoop.distribution.condition.NestedComponentCondition)4 ShowExpression (org.talend.hadoop.distribution.condition.ShowExpression)4 Set (java.util.Set)3 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 LinkedNodeExpression (org.talend.hadoop.distribution.condition.LinkedNodeExpression)2 RawExpression (org.talend.hadoop.distribution.condition.RawExpression)2 SparkBatchLinkedNodeCondition (org.talend.hadoop.distribution.condition.common.SparkBatchLinkedNodeCondition)2 SparkStreamingLinkedNodeCondition (org.talend.hadoop.distribution.condition.common.SparkStreamingLinkedNodeCondition)2 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 ComponentType (org.talend.hadoop.distribution.ComponentType)1