Search in sources :

Example 1 with ByteBufferDeserializer

use of org.apache.kafka.common.serialization.ByteBufferDeserializer in project presto by prestodb.

the class KafkaConsumerManager method createConsumer.

KafkaConsumer<ByteBuffer, ByteBuffer> createConsumer(String threadName, HostAddress hostAddress) {
    final Properties properties = new Properties();
    properties.put(BOOTSTRAP_SERVERS_CONFIG, hostAddress.toString());
    properties.put(GROUP_ID_CONFIG, threadName);
    properties.put(MAX_POLL_RECORDS_CONFIG, Integer.toString(maxPollRecords));
    properties.put(MAX_PARTITION_FETCH_BYTES_CONFIG, maxPartitionFetchBytes);
    properties.put(CLIENT_ID_CONFIG, String.format("%s-%s", threadName, hostAddress.toString()));
    properties.put(ENABLE_AUTO_COMMIT_CONFIG, false);
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(KafkaPlugin.class.getClassLoader())) {
        log.debug("Creating KafkaConsumer for thread %s broker %s", threadName, hostAddress.toString());
        return new KafkaConsumer<>(properties, new ByteBufferDeserializer(), new ByteBufferDeserializer());
    }
}
Also used : ByteBufferDeserializer(org.apache.kafka.common.serialization.ByteBufferDeserializer) KafkaConsumer(org.apache.kafka.clients.consumer.KafkaConsumer) Properties(java.util.Properties) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader)

Aggregations

ThreadContextClassLoader (com.facebook.presto.spi.classloader.ThreadContextClassLoader)1 Properties (java.util.Properties)1 KafkaConsumer (org.apache.kafka.clients.consumer.KafkaConsumer)1 ByteBufferDeserializer (org.apache.kafka.common.serialization.ByteBufferDeserializer)1