Search in sources :

Example 1 with KafkaConsumerConfig

use of org.apache.samza.config.KafkaConsumerConfig in project samza by apache.

the class TestKafkaSystemConsumer method createConsumer.

private KafkaSystemConsumer createConsumer(String fetchMsg, String fetchBytes) {
    final Map<String, String> map = new HashMap<>();
    map.put(JobConfig.JOB_NAME, TEST_JOB);
    map.put(String.format(KafkaConfig.CONSUMER_FETCH_THRESHOLD(), TEST_SYSTEM), fetchMsg);
    map.put(String.format(KafkaConfig.CONSUMER_FETCH_THRESHOLD_BYTES(), TEST_SYSTEM), fetchBytes);
    map.put(String.format("systems.%s.consumer.%s", TEST_SYSTEM, ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG), BOOTSTRAP_SERVERS);
    map.put(JobConfig.JOB_NAME, "jobName");
    Config config = new MapConfig(map);
    String clientId = KafkaConsumerConfig.createClientId(TEST_CLIENT_ID, config);
    KafkaConsumerConfig consumerConfig = KafkaConsumerConfig.getKafkaSystemConsumerConfig(config, TEST_SYSTEM, clientId);
    final KafkaConsumer<byte[], byte[]> kafkaConsumer = new MockKafkaConsumer(consumerConfig);
    MockKafkaSystemConsumer newKafkaSystemConsumer = new MockKafkaSystemConsumer(kafkaConsumer, TEST_SYSTEM, config, TEST_CLIENT_ID, new KafkaSystemConsumerMetrics(TEST_SYSTEM, new NoOpMetricsRegistry()), System::currentTimeMillis);
    return newKafkaSystemConsumer;
}
Also used : KafkaConsumerConfig(org.apache.samza.config.KafkaConsumerConfig) NoOpMetricsRegistry(org.apache.samza.util.NoOpMetricsRegistry) HashMap(java.util.HashMap) JobConfig(org.apache.samza.config.JobConfig) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) KafkaConfig(org.apache.samza.config.KafkaConfig) KafkaConsumerConfig(org.apache.samza.config.KafkaConsumerConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig)

Aggregations

HashMap (java.util.HashMap)1 ConsumerConfig (org.apache.kafka.clients.consumer.ConsumerConfig)1 Config (org.apache.samza.config.Config)1 JobConfig (org.apache.samza.config.JobConfig)1 KafkaConfig (org.apache.samza.config.KafkaConfig)1 KafkaConsumerConfig (org.apache.samza.config.KafkaConsumerConfig)1 MapConfig (org.apache.samza.config.MapConfig)1 NoOpMetricsRegistry (org.apache.samza.util.NoOpMetricsRegistry)1