1 package de.juplo.kafka;
3 import lombok.EqualsAndHashCode;
5 import lombok.RequiredArgsConstructor;
6 import org.apache.kafka.common.TopicPartition;
8 import java.util.Collection;
9 import java.util.HashMap;
13 @RequiredArgsConstructor
15 @EqualsAndHashCode(of = { "partition" })
16 public class PartitionStatistics
18 private final TopicPartition partition;
19 private final Map<String, KeyCounter> statistics = new HashMap<>();
22 public KeyCounter addKey(String key)
24 KeyCounter counter = new KeyCounter(key);
27 statistics.put(key, counter);
33 public long increment(String key)
35 KeyCounter counter = statistics.get(key);
39 counter = new KeyCounter(key);
40 statistics.put(key, counter);
43 return counter.increment();
46 public Collection<KeyCounter> getStatistics()
48 return statistics.values();
52 public String toString()
54 return partition.toString();