use of org.apache.ratis.proto.RaftProtos.StartLeaderElectionReplyProto in project incubator-ratis by apache.
the class LeaderStateImpl method sendStartLeaderElectionToHigherPriorityPeer.
private synchronized void sendStartLeaderElectionToHigherPriorityPeer(RaftPeerId follower, TermIndex lastEntry) {
ServerState state = server.getState();
TermIndex currLastEntry = state.getLastEntry();
if (ServerState.compareLog(currLastEntry, lastEntry) != 0) {
LOG.warn("{} can not send StartLeaderElectionRequest to follower:{} because currLastEntry:{} " + "did not match lastEntry:{}", this, follower, currLastEntry, lastEntry);
return;
}
final StartLeaderElectionRequestProto r = ServerProtoUtils.toStartLeaderElectionRequestProto(server.getMemberId(), follower, lastEntry);
CompletableFuture.supplyAsync(() -> {
server.getLeaderElectionMetrics().onTransferLeadership();
try {
StartLeaderElectionReplyProto replyProto = server.getServerRpc().startLeaderElection(r);
LOG.info("{} received {} reply of StartLeaderElectionRequest from follower:{}", this, replyProto.getServerReply().getSuccess() ? "success" : "fail", follower);
} catch (IOException e) {
LOG.warn("{} send StartLeaderElectionRequest throw exception", this, e);
}
return null;
});
}
Aggregations