From: Kai Moritz Date: Sat, 9 Apr 2022 16:00:48 +0000 (+0200) Subject: Gesehene Schlüssel sollten als long gezählt werden X-Git-Tag: offset-endpoint~2 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=c6c3d6879d0fcf0a8937733f23ff1c487fb4426c;p=demos%2Fkafka%2Ftraining Gesehene Schlüssel sollten als long gezählt werden --- diff --git a/src/main/java/de/juplo/kafka/DriverController.java b/src/main/java/de/juplo/kafka/DriverController.java index a504842..93e2856 100644 --- a/src/main/java/de/juplo/kafka/DriverController.java +++ b/src/main/java/de/juplo/kafka/DriverController.java @@ -30,7 +30,7 @@ public class DriverController @GetMapping("seen") - public Map> seen() + public Map> seen() { return consumer.getSeen(); } diff --git a/src/main/java/de/juplo/kafka/EndlessConsumer.java b/src/main/java/de/juplo/kafka/EndlessConsumer.java index 14a875b..2e79009 100644 --- a/src/main/java/de/juplo/kafka/EndlessConsumer.java +++ b/src/main/java/de/juplo/kafka/EndlessConsumer.java @@ -33,7 +33,7 @@ public class EndlessConsumer implements Runnable private KafkaConsumer consumer = null; private Future future = null; - private final Map> seen = new HashMap<>(); + private final Map> seen = new HashMap<>(); public EndlessConsumer( @@ -77,7 +77,7 @@ public class EndlessConsumer implements Runnable partitions.forEach(tp -> { log.info("{} - removing partition: {}", id, tp); - Map removed = seen.remove(tp.partition()); + Map removed = seen.remove(tp.partition()); for (String key : removed.keySet()) { log.info( @@ -123,12 +123,12 @@ public class EndlessConsumer implements Runnable Integer partition = record.partition(); String key = record.key() == null ? "NULL" : record.key(); - Map byKey = seen.get(partition); + Map byKey = seen.get(partition); if (!byKey.containsKey(key)) - byKey.put(key, 0); + byKey.put(key, 0l); - int seenByKey = byKey.get(key); + long seenByKey = byKey.get(key); seenByKey++; byKey.put(key, seenByKey); } @@ -151,7 +151,7 @@ public class EndlessConsumer implements Runnable } } - public Map> getSeen() + public Map> getSeen() { return seen; }