in ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderDefault.java [60:97]
private AppendEntriesReplyProto sendAppendEntriesWithRetries(AtomicLong requestFirstIndex)
throws InterruptedException, InterruptedIOException, RaftLogIOException {
for(int retry = 0; isRunning(); retry++) {
final ReferenceCountedObject<AppendEntriesRequestProto> request = nextAppendEntriesRequest(
CallId.getAndIncrement(), false);
if (request == null) {
LOG.trace("{} no entries to send now, wait ...", this);
return null;
}
try {
if (!isRunning()) {
LOG.info("{} is stopped. Skip appendEntries.", this);
return null;
}
final AppendEntriesRequestProto proto = request.get();
final AppendEntriesReplyProto reply = sendAppendEntries(proto);
final long first = proto.getEntriesCount() > 0 ? proto.getEntries(0).getIndex() : RaftLog.INVALID_LOG_INDEX;
requestFirstIndex.set(first);
return reply;
} catch (InterruptedIOException | RaftLogIOException e) {
throw e;
} catch (IOException ioe) {
// TODO should have more detailed retry policy here.
if (retry % 10 == 0) { // to reduce the number of messages
LOG.warn("{}: Failed to appendEntries (retry={})", this, retry, ioe);
}
handleException(ioe);
} finally {
request.release();
}
if (isRunning()) {
getServer().properties().rpcSleepTime().sleep();
}
}
return null;
}