1 package de.juplo.kafka;
3 import lombok.ToString;
4 import org.apache.kafka.common.TopicPartition;
5 import org.springframework.data.annotation.Id;
6 import org.springframework.data.mongodb.core.mapping.Document;
8 import java.util.HashMap;
12 @Document(collection = "statistics")
14 public class StatisticsDocument
19 public Integer partition;
21 public Map<String, Long> statistics;
23 public StatisticsDocument()
27 public StatisticsDocument(TopicPartition tp)
29 this.topic = tp.topic();
30 this.partition = tp.partition();
34 public StatisticsDocument(String topic, Integer partition, Map<String, Long> statistics)
36 this.partition = partition;
37 this.statistics = statistics;
40 public StatisticsDocument(PartitionStatistics statistics, long offset)
42 this.topic = statistics.getPartition().topic();
43 this.id = statistics.toString();
44 this.partition = statistics.getPartition().partition();
46 this.statistics = new HashMap<>();
47 statistics.getStatistics().forEach(counter -> this.statistics.put(counter.getKey(), counter.getResult()));