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: deserialization-synchroner-test~15 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=262d13bfa0274005b050c7b271f867acd9809f8b;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 1525f5a..93580ee 100644 --- a/src/main/java/de/juplo/kafka/DriverController.java +++ b/src/main/java/de/juplo/kafka/DriverController.java @@ -32,7 +32,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 c2d4447..bc3d357 100644 --- a/src/main/java/de/juplo/kafka/EndlessConsumer.java +++ b/src/main/java/de/juplo/kafka/EndlessConsumer.java @@ -37,7 +37,7 @@ public class EndlessConsumer implements Runnable private KafkaConsumer consumer = null; - private final Map> seen = new HashMap<>(); + private final Map> seen = new HashMap<>(); public EndlessConsumer( @@ -81,7 +81,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( @@ -127,12 +127,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); } @@ -176,7 +176,7 @@ public class EndlessConsumer implements Runnable } } - public Map> getSeen() + public Map> getSeen() { return seen; }