public override Task <VoteResult> Vote(VoteRequest request) { if (!GrantVotes) { return(Task.FromResult(new VoteResult(Term, false))); } return(base.Vote(request)); }
public override Task<VoteResult> Vote(VoteRequest request) { if (!GrantVotes) { return Task.FromResult(new VoteResult(Term, false)); } return base.Vote(request); }
public async Task <VoteResult> Vote(VoteRequest request) { if (request.Term < node.Term) { return(new VoteResult(node.Term, false)); } //this needs some sort of lock around it. although it would be very rare in a deployed system, the nodes in unit tests have hit //this block at the exact same time, resulting in both nodes getting the vote. //using a lock for now. should be replaced at some point with interlocked for perf lock (node.grantVoteLocker) { if (request.Term > node.Term) { node.StepDown(node.Term, request.Id); } return(new VoteResult(node.Term, false)); } }
public async Task<VoteResult> Vote(VoteRequest request) { if (request.Term < node.Term) { return new VoteResult(node.Term, false); } //this needs some sort of lock around it. although it would be very rare in a deployed system, the nodes in unit tests have hit //this block at the exact same time, resulting in both nodes getting the vote. //using a lock for now. should be replaced at some point with interlocked for perf lock (node.grantVoteLocker) { if (request.Term > node.Term) { node.StepDown(node.Term, request.Id); } return new VoteResult(node.Term, false); } }
public async Task <VoteResult> Vote(VoteRequest request) { if (request.Term < node.Term) { return(new VoteResult(node.Term, false)); } //this needs some sort of lock around it. although it would be very rare in a deployed system, the nodes in unit tests have hit //this block at the exact same time, resulting in both nodes getting the vote. //using a lock for now. should be replaced at some point with interlocked for perf lock (node.grantVoteLocker) { if (node.CurrentLeader == null || node.CurrentLeader == request.Id) { Debug.WriteLine("{0}: Voting for {1} for term {2}", node.NodeInfo(), request.Id, request.Term); node.requestHandler = new Follower(node); node.CurrentLeader = request.Id; node.Term = request.Term; node.lastHeartBeat = node.settings.Scheduler.Now; return(new VoteResult(node.Term, true)); } return(new VoteResult(node.Term, false)); } }
public async Task<VoteResult> Vote(VoteRequest request) { if (request.Term < node.Term) { return new VoteResult(node.Term, false); } //this needs some sort of lock around it. although it would be very rare in a deployed system, the nodes in unit tests have hit //this block at the exact same time, resulting in both nodes getting the vote. //using a lock for now. should be replaced at some point with interlocked for perf lock (node.grantVoteLocker) { if (node.CurrentLeader == null || node.CurrentLeader == request.Id) { Debug.WriteLine("{0}: Voting for {1} for term {2}", node.NodeInfo(), request.Id, request.Term); node.requestHandler = new Follower(node); node.CurrentLeader = request.Id; node.Term = request.Term; node.lastHeartBeat = node.settings.Scheduler.Now; return new VoteResult(node.Term, true); } return new VoteResult(node.Term, false); } }
public async Task <VoteResult> RequestVote(VoteRequest request) { return(await requestVote(request)); }
public virtual async Task <VoteResult> Vote(VoteRequest request) { return(await requestHandler.Vote(request)); }
public async Task<VoteResult> RequestVote(VoteRequest request) { var voteResult = await requestVote(request); return voteResult; }
public async Task <VoteResult> RequestVote(VoteRequest request) { var voteResult = await requestVote(request); return(voteResult); }
public virtual async Task<VoteResult> Vote(VoteRequest request) { return await requestHandler.Vote(request); }