mmiklavc commented on a change in pull request #1453: METRON-2169: Upgrade 
Kafka/Storm
URL: https://github.com/apache/metron/pull/1453#discussion_r315425859
 
 

 ##########
 File path: 
metron-platform/metron-integration-test/src/main/java/org/apache/metron/integration/components/KafkaComponent.java
 ##########
 @@ -237,43 +256,18 @@ public void reset() {
   }
 
   public List<byte[]> readMessages(String topic) {
-    SimpleConsumer consumer = new SimpleConsumer("localhost", 6667, 100000, 64 
* 1024, "consumer");
-    FetchRequest req = new FetchRequestBuilder()
-            .clientId("consumer")
-            .addFetch(topic, 0, 0, 100000)
-            .build();
-    FetchResponse fetchResponse = consumer.fetch(req);
-    Iterator<MessageAndOffset> results = fetchResponse.messageSet(topic, 
0).iterator();
+    if (consumer == null) {
+      consumer = createConsumer(new HashMap<>());
+    }
+    consumer.assign(Arrays.asList(new TopicPartition(topic, 0)));
+    consumer.seek(new TopicPartition(topic, 0), 0);
     List<byte[]> messages = new ArrayList<>();
-    while(results.hasNext()) {
-      ByteBuffer payload = results.next().message().payload();
-      byte[] bytes = new byte[payload.limit()];
-      payload.get(bytes);
-      messages.add(bytes);
+    ConsumerRecords<byte[], byte[]> records = 
consumer.poll(Duration.ofSeconds(1));
 
 Review comment:
   Are we basing this off of a previous default from Kafka? I can't tell what 
that might have been from the removed code. If 1 second is indeed reasonable, 
can this value be made a constant?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to