Search in sources :

Example 6 with MultiComponentCondition

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

the class DynamicSparkStreamingKafkaClientModuleGroup method getModuleGroups.

@Override
public Set<DistributionModuleGroup> getModuleGroups(String distribution, String version) throws Exception {
    Set<DistributionModuleGroup> hs = new HashSet<>();
    DynamicPluginAdapter pluginAdapter = getPluginAdapter();
    String sparkKafkaClientMrRequiredRuntimeId = pluginAdapter.getRuntimeModuleGroupIdByTemplateId(DynamicModuleGroupConstant.SPARK_KAFKA_CLIENT_MRREQUIRED_MODULE_GROUP.getModuleName());
    String spark2KafkaClientMrRequiredRuntimeId = pluginAdapter.getRuntimeModuleGroupIdByTemplateId(DynamicModuleGroupConstant.SPARK2_KAFKA_CLIENT_MRREQUIRED_MODULE_GROUP.getModuleName());
    checkRuntimeId(sparkKafkaClientMrRequiredRuntimeId);
    checkRuntimeId(spark2KafkaClientMrRequiredRuntimeId);
    if (StringUtils.isNotBlank(sparkKafkaClientMrRequiredRuntimeId)) {
        // Spark 1
        DistributionModuleGroup dmgSpark1 = new DistributionModuleGroup(sparkKafkaClientMrRequiredRuntimeId, true, new NestedComponentCondition(new MultiComponentCondition(new SparkStreamingLinkedNodeCondition(distribution, version, SparkStreamingConstant.KAFKA_SPARKCONFIGURATION_LINKEDPARAMETER).getCondition(), BooleanOperator.AND, spark1Condition)));
        hs.add(dmgSpark1);
    }
    if (StringUtils.isNotBlank(spark2KafkaClientMrRequiredRuntimeId)) {
        // Spark 2
        DistributionModuleGroup dmgSpark2 = new DistributionModuleGroup(spark2KafkaClientMrRequiredRuntimeId, true, new NestedComponentCondition(new MultiComponentCondition(new SparkStreamingLinkedNodeCondition(distribution, version, SparkStreamingConstant.KAFKA_SPARKCONFIGURATION_LINKEDPARAMETER).getCondition(), BooleanOperator.AND, spark2Condition)));
        hs.add(dmgSpark2);
    }
    return hs;
}
Also used : DynamicPluginAdapter(org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter) SparkStreamingLinkedNodeCondition(org.talend.hadoop.distribution.condition.common.SparkStreamingLinkedNodeCondition) MultiComponentCondition(org.talend.hadoop.distribution.condition.MultiComponentCondition) NestedComponentCondition(org.talend.hadoop.distribution.condition.NestedComponentCondition) DistributionModuleGroup(org.talend.hadoop.distribution.DistributionModuleGroup) HashSet(java.util.HashSet)

Example 7 with MultiComponentCondition

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

the class ComponentConditionUtil method buildDistributionShowIf.

/**
 * This method creates a condition made of other conditions, contained in the given Set of conditions.
 *
 * @param conditions - the Set of conditions to merge in a single condition.
 * @return a new ComponentCondition made of the other conditions. Returns null in case of at least one condition is
 * null.
 */
public static ComponentCondition buildDistributionShowIf(Set<ComponentCondition> conditions) {
    if (conditions != null) {
        Iterator<ComponentCondition> iter = conditions.iterator();
        ComponentCondition previous = null;
        while (iter.hasNext()) {
            ComponentCondition cc = iter.next();
            if (cc == null) {
                return null;
            }
            ComponentCondition wrappedCondition = new NestedComponentCondition(cc);
            if (previous != null) {
                wrappedCondition = new MultiComponentCondition(previous, BooleanOperator.OR, wrappedCondition);
            }
            previous = wrappedCondition;
        }
        if (previous != null) {
            return new NestedComponentCondition(previous);
        }
    }
    return null;
}
Also used : 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 8 with MultiComponentCondition

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

the class DynamicHiveModuleGroup method getModuleGroups.

@Override
public Set<DistributionModuleGroup> getModuleGroups() throws Exception {
    Set<DistributionModuleGroup> hs = new HashSet<>();
    DynamicPluginAdapter pluginAdapter = getPluginAdapter();
    String hiveRuntimeId = pluginAdapter.getRuntimeModuleGroupIdByTemplateId(DynamicModuleGroupConstant.HIVE_MODULE_GROUP.getModuleName());
    String hdfsRuntimeId = pluginAdapter.getRuntimeModuleGroupIdByTemplateId(DynamicModuleGroupConstant.HDFS_MODULE_GROUP.getModuleName());
    String mrRuntimeId = pluginAdapter.getRuntimeModuleGroupIdByTemplateId(DynamicModuleGroupConstant.MAPREDUCE_MODULE_GROUP.getModuleName());
    String hiveHBaseRuntimeId = pluginAdapter.getRuntimeModuleGroupIdByTemplateId(DynamicModuleGroupConstant.HIVE_HBASE_MODULE_GROUP.getModuleName());
    checkRuntimeId(hiveRuntimeId);
    checkRuntimeId(hdfsRuntimeId);
    checkRuntimeId(mrRuntimeId);
    checkRuntimeId(hiveHBaseRuntimeId);
    if (StringUtils.isNotBlank(hiveRuntimeId)) {
        hs.add(new DistributionModuleGroup(hiveRuntimeId));
    }
    if (StringUtils.isNotBlank(hdfsRuntimeId)) {
        hs.add(new DistributionModuleGroup(hdfsRuntimeId));
    }
    if (StringUtils.isNotBlank(mrRuntimeId)) {
        hs.add(new DistributionModuleGroup(mrRuntimeId));
    }
    if (StringUtils.isNotBlank(hiveHBaseRuntimeId)) {
        // The following condition instance stands for:
        // (isShow[STORE_BY_HBASE] AND STORE_BY_HBASE=='true')
        ComponentCondition hbaseLoaderCondition = new MultiComponentCondition(// 
        new SimpleComponentCondition(new BasicExpression(HiveConstant.HIVE_CONFIGURATION_COMPONENT_HBASEPARAMETER)), // 
        BooleanOperator.AND, new SimpleComponentCondition(new ShowExpression(HiveConstant.HIVE_CONFIGURATION_COMPONENT_HBASEPARAMETER)));
        // The Hive components need to import some hbase libraries if the "Use HBase storage" is checked.
        hs.add(new DistributionModuleGroup(hiveHBaseRuntimeId, false, hbaseLoaderCondition));
    }
    return hs;
}
Also used : DynamicPluginAdapter(org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter) ShowExpression(org.talend.hadoop.distribution.condition.ShowExpression) BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) 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) DistributionModuleGroup(org.talend.hadoop.distribution.DistributionModuleGroup) HashSet(java.util.HashSet)

Example 9 with MultiComponentCondition

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

the class ComponentConditionTest method testGetConditionString.

@Test
public void testGetConditionString() throws Exception {
    ComponentCondition dc1 = new SimpleComponentCondition(new BasicExpression(PARAM_1, VALUE_1, EqualityOperator.EQ));
    assertEquals(dc1.getConditionString(), LEFT_PAR + PARAM_1 + EQ + SINGLE_QUOTE + VALUE_1 + SINGLE_QUOTE + RIGHT_PAR);
    // $NON-NLS-1$ //$NON-NLS-2$
    Expression e1 = new BasicExpression("A", "aaa", EqualityOperator.EQ);
    // $NON-NLS-1$ //$NON-NLS-2$
    Expression e2 = new BasicExpression("Z", "ccc", EqualityOperator.EQ);
    // $NON-NLS-1$ //$NON-NLS-2$
    Expression e3 = new BasicExpression("A", "bbb", EqualityOperator.EQ);
    // $NON-NLS-1$ //$NON-NLS-2$
    Expression e4 = new BasicExpression("B", "ccc", EqualityOperator.NOT_EQ);
    dc1 = new NestedComponentCondition(new MultiComponentCondition(new SimpleComponentCondition(e1), new NestedComponentCondition(new MultiComponentCondition(new SimpleComponentCondition(e4), new NestedComponentCondition(new MultiComponentCondition(new SimpleComponentCondition(e2), new SimpleComponentCondition(e3), BooleanOperator.AND)), BooleanOperator.OR)), BooleanOperator.AND));
    assertEquals(dc1.getConditionString(), result1);
    dc1 = new MultiComponentCondition(new SimpleComponentCondition(e1), new MultiComponentCondition(new SimpleComponentCondition(e2), new NestedComponentCondition(new MultiComponentCondition(new SimpleComponentCondition(e4), new SimpleComponentCondition(e3), BooleanOperator.OR)), BooleanOperator.AND), BooleanOperator.AND);
    assertEquals(dc1.getConditionString(), result2);
}
Also used : BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) Expression(org.talend.hadoop.distribution.condition.Expression) BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) 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) Test(org.junit.Test)

Example 10 with MultiComponentCondition

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

the class EMR5290HiveModuleGroup method getModuleGroups.

public static Set<DistributionModuleGroup> getModuleGroups() {
    ComponentCondition hbaseLoaderCondition = new MultiComponentCondition(new SimpleComponentCondition(new BasicExpression(// 
    HiveConstant.HIVE_CONFIGURATION_COMPONENT_HBASEPARAMETER)), // 
    BooleanOperator.AND, new SimpleComponentCondition(new ShowExpression(HiveConstant.HIVE_CONFIGURATION_COMPONENT_HBASEPARAMETER)));
    Set<DistributionModuleGroup> hs = new HashSet<>();
    hs.add(new DistributionModuleGroup(EMR5290Constant.HIVE_MODULE_GROUP.getModuleName()));
    hs.add(new DistributionModuleGroup(EMR5290Constant.HDFS_MODULE_GROUP.getModuleName()));
    hs.add(new DistributionModuleGroup(EMR5290Constant.MAPREDUCE_MODULE_GROUP.getModuleName()));
    // The Hive components need to import some hbase libraries if the "Use HBase storage" is checked.
    hs.add(new DistributionModuleGroup(EMR5290Constant.HIVE_HBASE_MODULE_GROUP.getModuleName(), false, hbaseLoaderCondition));
    return hs;
}
Also used : ShowExpression(org.talend.hadoop.distribution.condition.ShowExpression) BasicExpression(org.talend.hadoop.distribution.condition.BasicExpression) 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) DistributionModuleGroup(org.talend.hadoop.distribution.DistributionModuleGroup) HashSet(java.util.HashSet)

Aggregations

MultiComponentCondition (org.talend.hadoop.distribution.condition.MultiComponentCondition)24 SimpleComponentCondition (org.talend.hadoop.distribution.condition.SimpleComponentCondition)18 BasicExpression (org.talend.hadoop.distribution.condition.BasicExpression)14 HashSet (java.util.HashSet)13 DistributionModuleGroup (org.talend.hadoop.distribution.DistributionModuleGroup)12 ComponentCondition (org.talend.hadoop.distribution.condition.ComponentCondition)12 NestedComponentCondition (org.talend.hadoop.distribution.condition.NestedComponentCondition)9 DynamicPluginAdapter (org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter)7 SparkStreamingLinkedNodeCondition (org.talend.hadoop.distribution.condition.common.SparkStreamingLinkedNodeCondition)6 ShowExpression (org.talend.hadoop.distribution.condition.ShowExpression)4 Expression (org.talend.hadoop.distribution.condition.Expression)3 LinkedNodeExpression (org.talend.hadoop.distribution.condition.LinkedNodeExpression)3 Set (java.util.Set)2 RawExpression (org.talend.hadoop.distribution.condition.RawExpression)2 SparkBatchLinkedNodeCondition (org.talend.hadoop.distribution.condition.common.SparkBatchLinkedNodeCondition)2 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Test (org.junit.Test)1 ComponentType (org.talend.hadoop.distribution.ComponentType)1