Search in sources :

Example 1 with PartitionedGroupDeterminer

use of io.siddhi.core.stream.output.sink.PartitionedGroupDeterminer in project siddhi by wso2.

the class DefinitionParserHelper method constructOutputGroupDeterminer.

private static OutputGroupDeterminer constructOutputGroupDeterminer(OptionHolder transportOptHolder, OptionHolder distributedOptHolder, StreamDefinition streamDef, int destinationCount) {
    OutputGroupDeterminer groupDeterminer = null;
    if (distributedOptHolder != null) {
        String strategy = distributedOptHolder.validateAndGetStaticValue(SiddhiConstants.DISTRIBUTION_STRATEGY_KEY);
        if (strategy.equalsIgnoreCase(SiddhiConstants.DISTRIBUTION_STRATEGY_PARTITIONED)) {
            String partitionKeyField = distributedOptHolder.validateAndGetStaticValue(SiddhiConstants.PARTITION_KEY_FIELD_KEY);
            int partitioningFieldIndex = streamDef.getAttributePosition(partitionKeyField);
            groupDeterminer = new PartitionedGroupDeterminer(partitioningFieldIndex, destinationCount);
        }
    }
    if (groupDeterminer == null) {
        List<Option> dynamicTransportOptions = new ArrayList<Option>(transportOptHolder.getDynamicOptionsKeys().size());
        for (String option : transportOptHolder.getDynamicOptionsKeys()) {
            dynamicTransportOptions.add(transportOptHolder.validateAndGetOption(option));
        }
        if (dynamicTransportOptions.size() > 0) {
            groupDeterminer = new DynamicOptionGroupDeterminer(dynamicTransportOptions);
        }
    }
    return groupDeterminer;
}
Also used : PartitionedGroupDeterminer(io.siddhi.core.stream.output.sink.PartitionedGroupDeterminer) ArrayList(java.util.ArrayList) Option(io.siddhi.core.util.transport.Option) OutputGroupDeterminer(io.siddhi.core.stream.output.sink.OutputGroupDeterminer) DynamicOptionGroupDeterminer(io.siddhi.core.stream.output.sink.DynamicOptionGroupDeterminer)

Aggregations

DynamicOptionGroupDeterminer (io.siddhi.core.stream.output.sink.DynamicOptionGroupDeterminer)1 OutputGroupDeterminer (io.siddhi.core.stream.output.sink.OutputGroupDeterminer)1 PartitionedGroupDeterminer (io.siddhi.core.stream.output.sink.PartitionedGroupDeterminer)1 Option (io.siddhi.core.util.transport.Option)1 ArrayList (java.util.ArrayList)1