for (CamusRequest request : finalRequests) {
if (moveLatest.contains(request.getTopic())
|| moveLatest.contains("all")) {
log.info("Moving to latest for topic: " + request.getTopic());
//TODO: factor out kafka specific request functionality
EtlKey oldKey = offsetKeys.get(request);
EtlKey newKey = new EtlKey(request.getTopic(), ((EtlRequest)request).getLeaderId(),
request.getPartition(), 0, request
.getLastOffset());
if (oldKey != null)
newKey.setMessageSize(oldKey.getMessageSize());
offsetKeys.put(request, newKey);
}
EtlKey key = offsetKeys.get(request);
if (key != null) {
request.setOffset(key.getOffset());
request.setAvgMsgSize(key.getMessageSize());
}
if (request.getEarliestOffset() > request.getOffset()
|| request.getOffset() > request.getLastOffset()) {
if(request.getEarliestOffset() > request.getOffset())
{
log.error("The earliest offset was found to be more than the current offset: " + request);
log.error("Moving to the earliest offset available");
}
else
{
log.error("The current offset was found to be more than the latest offset: " + request);
log.error("Moving to the earliest offset available");
}
request.setOffset(request.getEarliestOffset());
offsetKeys.put(
request,
//TODO: factor out kafka specific request functionality
new EtlKey(request.getTopic(), ((EtlRequest)request).getLeaderId(),
request.getPartition(), 0, request
.getOffset()));
}
log.info(request);
}