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;
{
@Id
public String id;
- public String topic;
- public Integer partition;
- public long offset;
+ public long offset = -1l;
public Map<String, Long> 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<String, Long> statistics)
+ public StatisticsDocument(Integer partition, Map<String, Long> 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()));
}
}