Search in sources :

Example 6 with RelInfo

use of org.apache.apex.malhar.sql.planner.RelInfo in project apex-malhar by apache.

the class KafkaEndpoint method populateInputDAG.

@Override
public RelInfo populateInputDAG(DAG dag, JavaTypeFactory typeFactory) {
    KafkaSinglePortInputOperator kafkaInput = dag.addOperator(OperatorUtils.getUniqueOperatorName("KafkaInput"), KafkaSinglePortInputOperator.class);
    kafkaInput.setTopics((String) operands.get(KAFKA_TOPICS));
    kafkaInput.setInitialOffset("EARLIEST");
    Properties props = new Properties();
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, operands.get(KAFKA_SERVERS));
    props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, KEY_DESERIALIZER);
    props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, VALUE_DESERIALIZER);
    kafkaInput.setConsumerProps(props);
    kafkaInput.setClusters((String) operands.get(KAFKA_SERVERS));
    RelInfo spec = messageFormat.populateInputDAG(dag, typeFactory);
    dag.addStream(OperatorUtils.getUniqueStreamName("Kafka", "Parser"), kafkaInput.outputPort, spec.getInputPorts().get(0));
    return new RelInfo("Input", Lists.<Operator.InputPort>newArrayList(), spec.getOperator(), spec.getOutPort(), messageFormat.getRowType(typeFactory));
}
Also used : KafkaSinglePortOutputOperator(org.apache.apex.malhar.kafka.KafkaSinglePortOutputOperator) Operator(com.datatorrent.api.Operator) KafkaSinglePortInputOperator(org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator) KafkaSinglePortInputOperator(org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator) RelInfo(org.apache.apex.malhar.sql.planner.RelInfo) Properties(java.util.Properties)

Aggregations

RelInfo (org.apache.apex.malhar.sql.planner.RelInfo)6 Operator (com.datatorrent.api.Operator)4 Properties (java.util.Properties)2 KafkaSinglePortOutputOperator (org.apache.apex.malhar.kafka.KafkaSinglePortOutputOperator)2 GenericFileOutputOperator (org.apache.apex.malhar.lib.fs.GenericFileOutputOperator)2 CsvFormatter (org.apache.apex.malhar.contrib.formatter.CsvFormatter)1 CsvParser (org.apache.apex.malhar.contrib.parser.CsvParser)1 KafkaSinglePortInputOperator (org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator)1 LineReader (org.apache.apex.malhar.sql.operators.LineReader)1