Search in sources :

Example 1 with ConsumerCollector

use of io.confluent.ksql.metrics.ConsumerCollector in project ksql by confluentinc.

the class KsqlEngineMetricsTest method consumeMessages.

private void consumeMessages(int numMessages, String groupId) {
    ConsumerCollector collector1 = new ConsumerCollector();
    collector1.configure(ImmutableMap.of(ConsumerConfig.GROUP_ID_CONFIG, groupId));
    Map<TopicPartition, List<ConsumerRecord<Object, Object>>> records = new HashMap<>();
    List<ConsumerRecord<Object, Object>> recordList = new ArrayList<>();
    for (int i = 0; i < numMessages; i++) {
        recordList.add(new ConsumerRecord<>("foo", 1, 1, 1l, TimestampType.CREATE_TIME, 1l, 10, 10, "key", "1234567890"));
    }
    records.put(new TopicPartition("foo", 1), recordList);
    ConsumerRecords<Object, Object> consumerRecords = new ConsumerRecords<>(records);
    collector1.onConsume(consumerRecords);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConsumerRecords(org.apache.kafka.clients.consumer.ConsumerRecords) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) ConsumerCollector(io.confluent.ksql.metrics.ConsumerCollector) TopicPartition(org.apache.kafka.common.TopicPartition) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ConsumerCollector (io.confluent.ksql.metrics.ConsumerCollector)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 ConsumerRecords (org.apache.kafka.clients.consumer.ConsumerRecords)1 TopicPartition (org.apache.kafka.common.TopicPartition)1