Search in sources :

Example 1 with StaleReadException

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);
}
Also used : StaleReadException(org.apache.ratis.protocol.exceptions.StaleReadException) StateMachineException(org.apache.ratis.protocol.exceptions.StateMachineException)

Aggregations

StaleReadException (org.apache.ratis.protocol.exceptions.StaleReadException)1 StateMachineException (org.apache.ratis.protocol.exceptions.StateMachineException)1