in src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/ForwardedIndexChangeHandler.java [74:121]
private void doIndex(String id, Optional<IndexEvent> indexEvent, int retryCount)
throws IOException {
try {
ChangeChecker checker = changeCheckerFactory.create(id);
Optional<ChangeNotes> changeNotes;
try {
changeNotes = checker.getChangeNotes();
} catch (StorageException e) {
log.atWarning().withCause(e).log("Change %s: cannot load change notes", id);
changeNotes = Optional.empty();
}
if (changeNotes.isPresent()) {
ChangeNotes notes = changeNotes.get();
reindex(notes);
if (checker.isChangeUpToDate(indexEvent)) {
if (retryCount > 0) {
log.atWarning().log(
"Change %s has been eventually indexed after %d attempt(s)", id, retryCount);
} else {
log.atFine().log("Change %s successfully indexed", id);
}
} else {
log.atWarning().log(
"Change %s seems too old compared to the event timestamp (event-Ts=%s >> change-Ts=%s)",
id, indexEvent, checker);
rescheduleIndex(id, indexEvent, retryCount + 1);
}
} else {
log.atWarning().log(
"Change %s not present yet in local Git repository (event=%s) after %d attempt(s)",
id, indexEvent, retryCount);
if (!rescheduleIndex(id, indexEvent, retryCount + 1)) {
log.atSevere().log(
"Change %s could not be found in the local Git repository (event=%s)",
id, indexEvent);
}
}
} catch (Exception e) {
if (isCausedByNoSuchChangeException(e)) {
indexer.delete(parseChangeId(id));
log.atWarning().withCause(e).log("Error trying to index Change %s. Deleted from index", id);
return;
}
throw e;
}
}