Search in sources :

Example 6 with KafkaSinglePortInputOperator

use of org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator in project apex-malhar by apache.

the class StreamFactory method fromKafka09.

/**
 * Create stream of byte array messages from kafka 0.9
 * @param brokers
 * @param topic
 * @param opts
 * @return
 */
public static ApexStream<byte[]> fromKafka09(String brokers, String topic, Option... opts) {
    KafkaSinglePortInputOperator kafkaInput = new KafkaSinglePortInputOperator();
    kafkaInput.setClusters(brokers);
    kafkaInput.setTopics(topic);
    ApexStreamImpl<String> newStream = new ApexStreamImpl<>();
    return newStream.addOperator(kafkaInput, null, kafkaInput.outputPort, opts);
}
Also used : KafkaSinglePortInputOperator(org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator)

Example 7 with KafkaSinglePortInputOperator

use of org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator in project apex-malhar by apache.

the class StreamFactory method fromKafka09.

/**
 * Create stream of byte array messages from kafka 0.9 with more partition options
 */
public static ApexStream<byte[]> fromKafka09(String brokers, String topic, PartitionStrategy strategy, int partitionNumber, Option... opts) {
    KafkaSinglePortInputOperator kafkaInput = new KafkaSinglePortInputOperator();
    kafkaInput.setClusters(brokers);
    kafkaInput.setTopics(topic);
    kafkaInput.setStrategy(strategy.name());
    kafkaInput.setInitialPartitionCount(partitionNumber);
    ApexStreamImpl<String> newStream = new ApexStreamImpl<>();
    return newStream.addOperator(kafkaInput, null, kafkaInput.outputPort, opts);
}
Also used : KafkaSinglePortInputOperator(org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator)

Aggregations

KafkaSinglePortInputOperator (org.apache.apex.malhar.kafka.KafkaSinglePortInputOperator)7 KafkaSinglePortOutputOperator (org.apache.apex.malhar.kafka.KafkaSinglePortOutputOperator)3 Properties (java.util.Properties)2 CsvParser (org.apache.apex.malhar.contrib.parser.CsvParser)2 StreamEndpoint (org.apache.apex.malhar.sql.table.StreamEndpoint)2 Operator (com.datatorrent.api.Operator)1 LogicalPlan (com.datatorrent.stram.plan.logical.LogicalPlan)1 CsvFormatter (org.apache.apex.malhar.contrib.formatter.CsvFormatter)1 SQLExecEnvironment (org.apache.apex.malhar.sql.SQLExecEnvironment)1 RelInfo (org.apache.apex.malhar.sql.planner.RelInfo)1 CSVMessageFormat (org.apache.apex.malhar.sql.table.CSVMessageFormat)1 FileEndpoint (org.apache.apex.malhar.sql.table.FileEndpoint)1 Test (org.junit.Test)1