use of org.apache.ratis.protocol.exceptions.StaleReadException in project incubator-ratis by apache.
the class RaftServerImpl method staleReadAsync.
private CompletableFuture<RaftClientReply> staleReadAsync(RaftClientRequest request) {
final long minIndex = request.getType().getStaleRead().getMinIndex();
final long commitIndex = state.getLog().getLastCommittedIndex();
LOG.debug("{}: minIndex={}, commitIndex={}", getMemberId(), minIndex, commitIndex);
if (commitIndex < minIndex) {
final StaleReadException e = new StaleReadException("Unable to serve stale-read due to server commit index = " + commitIndex + " < min = " + minIndex);
return CompletableFuture.completedFuture(newExceptionReply(request, new StateMachineException(getMemberId(), e)));
}
return processQueryFuture(stateMachine.queryStale(request.getMessage(), minIndex), request);
}
Aggregations