use of org.apache.heron.spouts.kafka.DefaultKafkaConsumerFactory in project heron by twitter.
the class HeronKafkaSpoutSampleTopology method main.
public static void main(String[] args) {
Map<String, Object> kafkaConsumerConfig = new HashMap<>();
kafkaConsumerConfig.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
kafkaConsumerConfig.put(ConsumerConfig.GROUP_ID_CONFIG, "sample-kafka-spout");
kafkaConsumerConfig.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
kafkaConsumerConfig.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
LOG.info("Kafka Consumer Config: {}", kafkaConsumerConfig);
KafkaConsumerFactory<String, String> kafkaConsumerFactory = new DefaultKafkaConsumerFactory<>(kafkaConsumerConfig);
TopologyBuilder topologyBuilder = new TopologyBuilder();
topologyBuilder.setSpout(KAFKA_SPOUT_NAME, new KafkaSpout<>(kafkaConsumerFactory, Collections.singletonList("test-topic")));
topologyBuilder.setBolt(LOGGING_BOLT_NAME, new LoggingBolt()).shuffleGrouping(KAFKA_SPOUT_NAME);
Config config = new Config();
config.setNumStmgrs(1);
config.setContainerCpuRequested(1);
config.setContainerRamRequested(ByteAmount.fromGigabytes(1));
config.setContainerDiskRequested(ByteAmount.fromGigabytes(1));
config.setComponentCpu(KAFKA_SPOUT_NAME, 0.25);
config.setComponentRam(KAFKA_SPOUT_NAME, ByteAmount.fromMegabytes(256));
config.setComponentDisk(KAFKA_SPOUT_NAME, ByteAmount.fromMegabytes(512));
config.setComponentCpu(LOGGING_BOLT_NAME, 0.25);
config.setComponentRam(LOGGING_BOLT_NAME, ByteAmount.fromMegabytes(256));
config.setComponentDisk(LOGGING_BOLT_NAME, ByteAmount.fromMegabytes(256));
Simulator simulator = new Simulator();
simulator.submitTopology("heron-kafka-spout-sample-topology", config, topologyBuilder.createTopology());
}
Aggregations