X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fkafka%2FStatisticsDocument.java;h=96ebfb1c070dbaf17eb7f6c6681fd7786b678f6a;hb=620191782035383e0083dc348e4941c9cec0d994;hp=e8c2e9b1125533c50f8e1b67fd1de0f3ee63af42;hpb=3c1d3fa68df685146bdef7cc2e396e55fa0933dc;p=demos%2Fkafka%2Ftraining diff --git a/src/main/java/de/juplo/kafka/StatisticsDocument.java b/src/main/java/de/juplo/kafka/StatisticsDocument.java index e8c2e9b..96ebfb1 100644 --- a/src/main/java/de/juplo/kafka/StatisticsDocument.java +++ b/src/main/java/de/juplo/kafka/StatisticsDocument.java @@ -1,7 +1,6 @@ package de.juplo.kafka; import lombok.ToString; -import org.apache.kafka.common.TopicPartition; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; @@ -15,35 +14,23 @@ public class StatisticsDocument { @Id public String id; - public String topic; - public Integer partition; public long offset; - public Map statistics; + public Map statistics; public StatisticsDocument() { } - public StatisticsDocument(TopicPartition tp) + public StatisticsDocument(Integer partition) { - this.topic = tp.topic(); - this.partition = tp.partition(); - this.offset = 0; + this.id = Integer.toString(partition); + this.statistics = new HashMap<>(); } - public StatisticsDocument(String topic, Integer partition, Map statistics) + public StatisticsDocument(Integer partition, Map statistics, long offset) { - this.partition = partition; + this.id = Integer.toString(partition); this.statistics = statistics; - } - - public StatisticsDocument(PartitionStatistics statistics, long offset) - { - this.topic = statistics.getPartition().topic(); - this.id = statistics.toString(); - this.partition = statistics.getPartition().partition(); this.offset = offset; - this.statistics = new HashMap<>(); - statistics.getStatistics().forEach(counter -> this.statistics.put(counter.getKey(), counter.getResult())); } }