Skip to content

Commit

Permalink
fix issue#3, which offered by yuhongye
Browse files Browse the repository at this point in the history
  • Loading branch information
wenweihu86 committed Oct 26, 2017
1 parent 7e6d26b commit a1c43d4
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,24 +250,27 @@ private void requestVote(Peer peer) {
lock.unlock();
}

RaftMessage.VoteRequest request = requestBuilder.build();
peer.getRpcClient().asyncCall(
"RaftConsensusService.requestVote", requestBuilder.build(),
new VoteResponseCallback(peer));
"RaftConsensusService.requestVote", request,
new VoteResponseCallback(peer, request));
}

private class VoteResponseCallback implements RPCCallback<RaftMessage.VoteResponse> {
private Peer peer;
private RaftMessage.VoteRequest request;

public VoteResponseCallback(Peer peer) {
public VoteResponseCallback(Peer peer, RaftMessage.VoteRequest request) {
this.peer = peer;
this.request = request;
}

@Override
public void success(RaftMessage.VoteResponse response) {
lock.lock();
try {
peer.setVoteGranted(response.getGranted());
if (currentTerm != response.getTerm() || state != NodeState.STATE_CANDIDATE) {
if (currentTerm != request.getTerm() || state != NodeState.STATE_CANDIDATE) {
LOG.info("ignore requestVote RPC result");
return;
}
Expand Down

0 comments on commit a1c43d4

Please sign in to comment.