private final AdderResults adderResults;
private final StateRepository stateRepository;
private final String id;
+ private final String topic;
+ private final Consumer consumer;
private final Set<Integer> partitions = new HashSet<>();
stateRepository
.findById(Integer.toString(partition))
.orElse(new StateDocument(partition));
+ log.info(
+ "{} - Offset of next unseen message for partition {}: {}",
+ id,
+ partition,
+ document.offset);
+ consumer.seek(tp, document.offset);
recordHandler.addPartition(partition, document.state);
for (String user : document.state.keySet())
{
log.info("{} - removing partition: {}", id, partition);
this.partitions.remove(partition);
Map<String, AdderResult> state = recordHandler.removePartition(partition);
+ Long offset = consumer.position(tp);
+ log.info(
+ "{} - offset of next unseen message for partition {} is {}",
+ id,
+ partition,
+ offset);
for (String user : state.keySet())
{
log.info(
state.get(user));
}
Map<String, List<AdderResult>> results = adderResults.removePartition(partition);
- stateRepository.save(new StateDocument(partition, state, results));
+ stateRepository.save(new StateDocument(partition, state, results, offset));
});
}
}
{
@Id
public String id;
+ public long offset = 0l;
public Map<String, AdderResult> state;
public Map<String, List<AdderResult>> results;
public StateDocument(
Integer partition,
Map<String, AdderResult> state,
- Map<String, List<AdderResult>> results)
+ Map<String, List<AdderResult>> results,
+ long offset)
{
this.id = Integer.toString(partition);
this.state = state;
this.results = results;
+ this.offset = offset;
}
}