use of com.hazelcast.cp.internal.raft.impl.dto.PreVoteRequest in project hazelcast by hazelcast.
the class PreVoteTask method innerRun.
@Override
protected void innerRun() {
RaftState state = raftNode.state();
if (state.leader() != null) {
logger.fine("No new pre-vote phase, we already have a LEADER: " + state.leader());
return;
} else if (state.term() != term) {
logger.fine("No new pre-vote phase for term= " + term + " because of new term: " + state.term());
return;
}
Collection<RaftEndpoint> remoteMembers = state.remoteMembers();
if (remoteMembers.isEmpty()) {
logger.fine("Remote members is empty. No need for pre-voting.");
return;
}
state.initPreCandidateState();
int nextTerm = state.term() + 1;
RaftLog log = state.log();
PreVoteRequest request = new PreVoteRequest(localMember(), nextTerm, log.lastLogOrSnapshotTerm(), log.lastLogOrSnapshotIndex());
logger.info("Pre-vote started for next term: " + request.nextTerm() + ", last log index: " + request.lastLogIndex() + ", last log term: " + request.lastLogTerm());
raftNode.printMemberState();
for (RaftEndpoint endpoint : remoteMembers) {
raftNode.send(request, endpoint);
}
schedulePreVoteTimeout();
}
Aggregations